/* * CbmClusteringGeometry.cxx * * Created on: Feb 22, 2012 * Author: kozlov */ #include "CbmClusteringGeometry.h" #include "CbmStsHit.h" #include "CbmStsPoint.h" #include "CbmMuchPixelHit.h" #include "CbmMuchPoint.h" #include "CbmMCTrack.h" #include "CbmMuchGeoScheme.h" #include "CbmMuchLayerSide.h" #include "CbmMuchModuleGem.h" #include "CbmMuchModuleGemRadial.h" #include "CbmMuchPad.h" #include "CbmMuchPadRadial.h" #include "CbmMuchDigi.h" #include "CbmMuchStation.h" #include "CbmMuchLayer.h" #include "CbmMuchLayerSide.h" #include "CbmMuchSectorRectangular.h" #include "CbmMuchSectorRadial.h" #include "CbmMuchPadRectangular.h" #include "FairRootManager.h" #include "TClonesArray.h" #include #include using std::cout; using std::endl; CbmClusteringGeometry::CbmClusteringGeometry(): fDetId(), fPadList() { fNofPads = 0; //fStation = 0; //fLayer = 0; //fSide = 0; //fModule = 0; fNofActivePads = 0; } CbmClusteringGeometry::CbmClusteringGeometry(Int_t nStation, Int_t nLayer, Bool_t nSide, Int_t nModule, CbmMuchGeoScheme* scheme, Int_t geoVersion) { switch(geoVersion){ case 1: { SetMuchModuleGeometry(nStation, nLayer, nSide, nModule, scheme); break; } case 2: { SetMuchModuleGeometryRadial(nStation, nLayer, nSide, nModule, scheme); break; } default: { std::cout<<"Error. Wrong detector geometry.\n"; break; } } // SetMuchModuleGeometry(nStation, nLayer, nSide, nModule, scheme); // SetMuchModuleGeometryRadial(nStation, nLayer, nSide, nModule, scheme); } CbmClusteringGeometry::CbmClusteringGeometry(CbmClusteringGeometry* geo, Int_t nofPads) { fNofPads = nofPads; fNofActivePads = fNofPads; fDetId = geo->GetDetId(); fPadList = new PadInformation[fNofPads]; for(Int_t iPad = 0; iPad < fNofPads; iPad++) { fPadList[iPad].fDigiNum = 0; fPadList[iPad].fCharge = 0; fPadList[iPad].fX = 0; fPadList[iPad].fY = 0; fPadList[iPad].fDx = 0; fPadList[iPad].fDy = 0; fPadList[iPad].fPhi1 = 0; fPadList[iPad].fPhi2 = 0; fPadList[iPad].fR1 = 0; fPadList[iPad].fR2 = 0; fPadList[iPad].fNofNeighbors = 0; fPadList[iPad].fNofGoodNeighbors = 0; fPadList[iPad].fNeighbors.clear(); fPadList[iPad].channelID = 0; } } void CbmClusteringGeometry::CbmClusteringSetPad(Int_t nPad, Float_t x, Float_t y, Float_t dx, Float_t dy, Double_t phi1, Double_t phi2, Float_t r1, Float_t r2, Int_t digiNum, UInt_t charge, /*Int_t nofNeighbors, Int_t nofGoodNeighbors, vector neighbors, */Long64_t chID) { fPadList[nPad].fDigiNum = digiNum; std::cout<<"-----TakeDigi: "<n"<Getenv("VMCWORKDIR")) + TString("/parameters"); //--TString muchDigiFile = "/home/kozlov/cbm/cbmroot_new/cbmroot/parameters/much/much_v11a.digi.root"; //--scheme->Init(muchDigiFile); CbmMuchModuleGem* module = (CbmMuchModuleGem*) scheme->GetModule(nStation, nLayer, nSide, nModule); fNofPads = module->GetNPads(); fDetId = module->GetDetectorId(); fPadList = new PadInformation[fNofPads]; fNofActivePads = 0; Int_t nofSectors = module->GetNSectors(); Int_t padIterator = 0; for(Int_t iSector = 0; iSector < nofSectors; iSector++) { CbmMuchSectorRectangular* sector = (CbmMuchSectorRectangular*) module->GetSector(iSector); //??? Int_t nofPadsInSector = sector->GetNChannels();//(sector->GetNCols())*(sector->GetNRows()); //Double_t padsDx_2 = (sector->GetPadDx())/2; //Double_t padsDy_2 = (sector->GetPadDy())/2; //std::cout<<"DX: "<GetPadNx(); Int_t padNy = sector->GetPadNy(); //for(Int_t iPad = 0; iPad < nofPadsInSector; iPad++) /*for(Int_t i = 0; i < padNx; i++) { for(Int_t j = 0; j < padNy; j++) {*/ for(Int_t iPad = 0; iPad < nofPadsInSector; iPad++) { CbmMuchPadRectangular* pad = (CbmMuchPadRectangular*) sector->GetPadByChannelIndex(iPad); //!!! fPadList[padIterator].fDigiNum = 0; fPadList[padIterator].fCharge = 0; fPadList[padIterator].fX = pad->GetX(); fPadList[padIterator].fY = pad->GetY(); fPadList[padIterator].fDx = sector->GetPadDx(); fPadList[padIterator].fDy = sector->GetPadDy(); fPadList[padIterator].fNeighbors.clear(); //fPadList[padIterator].x1 = fPadList[padIterator].xc - padsDx_2; //fPadList[padIterator].x2 = fPadList[padIterator].xc + padsDx_2; //fPadList[padIterator].y1 = fPadList[padIterator].yc - padsDy_2; //fPadList[padIterator].y2 = fPadList[padIterator].yc + padsDy_2; fPadList[padIterator].channelID = pad->GetChannelId(); fPadByChannelId[pad->GetChannelId()] = padIterator; /*std::cout<<"Pad: "<GetChannelId()<<"\n"; std::cout<<"Xc = "<= (GetMin(yDown_1, yUp_1) - dY)) && ((GetMin(yDown_2, yUp_2) - dY) <= (GetMax(yDown_1, yUp_1) + dY)))) || ((SubEqual(yDown_1, yUp_2, dY) || SubEqual(yUp_1, yDown_2, dY)) && (((GetMax(xLeft_2, xRight_2) + dX) >= (GetMin(xLeft_1, xRight_1) - dX)) && ((GetMin(xLeft_2, xRight_2) - dX) <= (GetMax(xLeft_1, xRight_1) + dX))))) && (iPadMain != iPadNeighbor)) { fSingleLayerGeo[iPadMain].allNeighbors[padIterator] = iPadNeighbor; fSingleLayerGeo[iPadMain].nofNeighbors++; padIterator++; //std::cout<<"Neighbours: P1 = "< (GetMin(yDown_1, yUp_1) + dY)) && ((GetMin(yDown_2, yUp_2) + dY) < (GetMax(yDown_1, yUp_1) - dY)))) || ((SubEqual(yDown_1, yUp_2, dY) || SubEqual(yUp_1, yDown_2, dY)) && (((GetMax(xLeft_2, xRight_2) - dX) > (GetMin(xLeft_1, xRight_1) + dX)) && ((GetMin(xLeft_2, xRight_2) + dX) < (GetMax(xLeft_1, xRight_1) - dX))))) && (iPadMain != iPadNeighbor)) { fPadList[iPadMain].fNeighbors.push_back(iPadNeighbor); //fSingleLayerGeo[iPadMain].goodNeighbors[padIterator2] = iPadNeighbor; fPadList[iPadMain].fNofGoodNeighbors++; //padIterator2++; } }} } //fStation = nStation; //fLayer = nLayer; //fSide = nSide; //fModule = nModule; //std::cout<<" Geometry created:\nStation "<GetModule(nStation, nLayer, nSide, nModule); fNofPads = module->GetNPads(); fDetId = module->GetDetectorId(); fPadList = new PadInformation[fNofPads]; fNofActivePads = 0; Int_t nofSectors = module->GetNSectors(); Int_t padIterator = 0; for(Int_t iSector = 0; iSector < nofSectors; iSector++) { CbmMuchSectorRadial* sector = (CbmMuchSectorRadial*) module->GetSector(iSector); Int_t nofPadsInSector = sector->GetNChannels(); // Int_t padNx = sector->GetPadNx(); // Int_t padNy = sector->GetPadNy(); for(Int_t iPad = 0; iPad < nofPadsInSector; iPad++) { CbmMuchPadRadial* pad = (CbmMuchPadRadial*) sector->GetPadByChannelIndex(iPad); /*if(padIterator < 5000){ std::cout<<"RadialTest: "<GetChannelId()<<"\n"; std::cout<<"->Phi1 = "<GetPhi1()<<"; Phi2 = "<GetPhi2()<<"; R1 = "<GetR1()<<"; R2 = "<GetR2()<<"\n";}*/ fPadList[padIterator].fDigiNum = 0; fPadList[padIterator].fCharge = 0; fPadList[padIterator].fPhi1 = pad->GetPhi1(); fPadList[padIterator].fPhi2 = pad->GetPhi2(); fPadList[padIterator].fR1 = pad->GetR1(); fPadList[padIterator].fR2 = pad->GetR2(); Float_t r = (fPadList[padIterator].fR1 + fPadList[padIterator].fR2) / 2; Double_t phi = (fPadList[padIterator].fPhi1 + fPadList[padIterator].fPhi2) / 2; fPadList[padIterator].fX = r * cos(phi); fPadList[padIterator].fY = r * sin(phi); // fPadList[padIterator].fX = pad->GetX(); // fPadList[padIterator].fY = pad->GetY(); // fPadList[padIterator].fDx = sector->GetPadDx(); // fPadList[padIterator].fDy = sector->GetPadDy(); fPadList[padIterator].fNeighbors.clear(); fPadList[padIterator].channelID = pad->GetChannelId(); fPadByChannelId[pad->GetChannelId()] = padIterator; /*if(padIterator < 100){ std::cout<<"RadialTest: "<Phi1 = "< Down_2)) { //std::cout<<"--->lR: "<P1: "<P2: "< (Left_2 + lPhi))) if(((Left_1 - lPhi) < Right_2) && ((Right_1 + lPhi) > Left_2)) { //std::cout<<"lR: "< (GetMin(yDown_1, yUp_1) + dY)) && ((GetMin(yDown_2, yUp_2) + dY) < (GetMax(yDown_1, yUp_1) - dY)))) || ((SubEqual(yDown_1, yUp_2, dY) || SubEqual(yUp_1, yDown_2, dY)) && (((GetMax(xLeft_2, xRight_2) - dX) > (GetMin(xLeft_1, xRight_1) + dX)) && ((GetMin(xLeft_2, xRight_2) + dX) < (GetMax(xLeft_1, xRight_1) - dX))))) && (iPadMain != iPadNeighbor)) { fPadList[iPadMain].fNeighbors.push_back(iPadNeighbor); //fSingleLayerGeo[iPadMain].goodNeighbors[padIterator2] = iPadNeighbor; fPadList[iPadMain].fNofGoodNeighbors++; //padIterator2++; } }*/ } } } Float_t CbmClusteringGeometry::GetX0(Int_t iPad) { return fPadList[iPad].fX; } Float_t CbmClusteringGeometry::GetDx(Int_t iPad) { return fPadList[iPad].fDx; } Float_t CbmClusteringGeometry::GetDy(Int_t iPad) { return fPadList[iPad].fDy; } Float_t CbmClusteringGeometry::GetY0(Int_t iPad) { return fPadList[iPad].fY; } /*Float_t CbmMuchGeoCl::GetY1(Int_t iPad) { return fSingleLayerGeo[iPad].y1; } Float_t CbmMuchGeoCl::GetY2(Int_t iPad) { return fSingleLayerGeo[iPad].y2; }*/ Int_t CbmClusteringGeometry::GetDigiNum(Int_t iPad) { return fPadList[iPad].fDigiNum; } void CbmClusteringGeometry::SetDigiNum(Int_t iPad, Int_t iDigi) { fPadList[iPad].fDigiNum = iDigi; } Int_t CbmClusteringGeometry::GetNeighborsNum(Int_t iPad) { return fPadList[iPad].fNofNeighbors; } Int_t CbmClusteringGeometry::GetGoodNeighborsNum(Int_t iPad) { return fPadList[iPad].fNofGoodNeighbors; } Int_t CbmClusteringGeometry::GetNeighbor(Int_t iPad, Int_t iNeighbor) { //return fSingleLayerGeo[iPad].allNeighbors[iNeighbor]; return fPadList[iPad].fNeighbors[iNeighbor]; } /*Int_t CbmMuchGeoCl::GetGoodNeighbor(Int_t iPad, Int_t iNeighbor) { return fSingleLayerGeo[iPad].goodNeighbors[iNeighbor]; }*/ Long64_t CbmClusteringGeometry::GetPadID(Int_t iPad) { return fPadList[iPad].channelID; } UInt_t CbmClusteringGeometry::GetPadCharge(Int_t iPad) { return fPadList[iPad].fCharge; } void CbmClusteringGeometry::SetPadCharge(Int_t iPad, UInt_t iCharge) { fPadList[iPad].fCharge = iCharge; } void CbmClusteringGeometry::SetAPadsNom(Int_t nPads) { fNofActivePads = nPads; } void CbmClusteringGeometry::SetAPadsPlusOne() { fNofActivePads++; } template T1 CbmClusteringGeometry::GetMin(T1& a, T1& b) { if(a > b) { return b; } else { return a; } } template T2 CbmClusteringGeometry::GetMax(T2& a, T2& b) { if(a < b) { return b; } else { return a; } } Bool_t CbmClusteringGeometry::SubEqual(Double_t x1, Double_t x2, Double_t l) { //l = l * 0.1; if((x1 < (x2 + l)) && (x1 > (x2 - l))) { return 1; } else { return 0; } } Int_t CbmClusteringGeometry::GetPadByChannelId(Long64_t chId) { return fPadByChannelId[chId]; } Double_t CbmClusteringGeometry::GetPhi1(Int_t iPad) { return fPadList[iPad].fPhi1; } Double_t CbmClusteringGeometry::GetPhi2(Int_t iPad) { return fPadList[iPad].fPhi2; } Float_t CbmClusteringGeometry::GetR1(Int_t iPad) { return fPadList[iPad].fR1; } Float_t CbmClusteringGeometry::GetR2(Int_t iPad) { return fPadList[iPad].fR2; } vector CbmClusteringGeometry::GetNeighbors(Int_t iPad) { return fPadList[iPad].fNeighbors; } Long64_t CbmClusteringGeometry::GetChannelID(Int_t iPad) { return fPadList[iPad].channelID; }