///////////////////////////////////////////////////////////// // //----------------------------------------------------------------------- // File and Version Information: // $Id:$ // // Description: // EMC Mapper class. Map crystal index (fDetectorId) to two coordinate index. // // This class uses the singleton pattern design // Author List: // Dima Melnychuk // 27/04/2007 Stefano Spataro (encoding for the Fwd Endcup) // /////////////////////////////////////////////////////////////// #include "PndEmcMapper.h" #include "PndEmcTwoCoordIndex.h" #include "TGeoManager.h" #include "TGeoVolume.h" #include "TROOT.h" #include #include using namespace std; PndEmcMapper* PndEmcMapper::_instance = 0; PndEmcMapper* PndEmcMapper::Instance (Int_t MapVersion) { if (_instance == 0) { if (MapVersion==0){ cout<<"Map version 0 does not exist"<::const_iterator tciIter; for(tciIter=fIntTwoCoordMap.begin();tciIter!=fIntTwoCoordMap.end();++tciIter) { PndEmcTwoCoordIndex* _tci=tciIter->second; detId=tciIter->first; iTheta=_tci->itsXCoord(); iPhi=_tci->itsYCoord(); for (Int_t i=iTheta-1;i<=iTheta+1;i++) for (Int_t j=iPhi-1;j<=iPhi+1;j++) { if ((i!= 0)&&(i!= 73)&&(j!= 0)&&(j!=161)&& // Boundaries of module 1&2 (i!=210)&&(i!=291)&&(j!=210)&&(j!=291)&& // Boundaries of module 3 (i!=332)&&(i!=369)&&(j!=332)&&(j!=369)&& // Boundaries of module 4 (i!=465)&&(i!=436)&&(j!=458)&&(j!=443)&& // Boundaries of module 5 ((i!=iTheta)||(j!=iPhi))) { detId_tmp=PndEmcMapper::GetDetId(i,j); if (!IsValidIndex(detId_tmp)) continue; PndEmcTwoCoordIndex* tci_tmp=fIntTwoCoordMap[detId_tmp]; _tci->addToNeighbourList(tci_tmp); fIntTwoCoordMap[detId]=_tci; } else if ((i!=0)&&(i!=73)&&(j==0)) { detId_tmp=PndEmcMapper::GetDetId(i,160); if (!IsValidIndex(detId_tmp)) continue; PndEmcTwoCoordIndex* tci_tmp=fIntTwoCoordMap[detId_tmp]; _tci->addToNeighbourList(tci_tmp); fIntTwoCoordMap[detId]=_tci; } else if ((i!=0)&&(i!=73)&&(j==161)) { detId_tmp=PndEmcMapper::GetDetId(i,1); if (!IsValidIndex(detId_tmp)) continue; PndEmcTwoCoordIndex* tci_tmp=fIntTwoCoordMap[detId_tmp]; _tci->addToNeighbourList(tci_tmp); fIntTwoCoordMap[detId]=_tci; } } } } } PndEmcTwoCoordIndex* PndEmcMapper::GetTCI(Int_t DetectorId) { PndEmcTwoCoordIndex* tci= fIntTwoCoordMap[DetectorId]; return tci; }; // This function check is the volume with given detectorId is really exist in geometry bool PndEmcMapper::IsValidIndex(Int_t detectorId) { // Geometry loading TGeoManager *geom = (TGeoManager*) gROOT->FindObject("CBMGeom"); Short_t module =detectorId/100000000; Short_t row=(detectorId/1000000)%100; Short_t crystal=detectorId%10000; Text_t volname[30]; sprintf(volname,"emc0%dr%dc%d",module, row, crystal); TGeoVolume *vol = geom->FindVolumeFast(volname); if (!vol){ //std::cout<<"Volume "<& PndEmcMapper::GetTciMap() { return fIntTwoCoordMap; } Int_t PndEmcMapper::GetDetId(Int_t iTheta,Int_t iPhi) { Int_t module,row,copy,crystal,detId; if (iTheta<=29) { module=2; row=30-iTheta; copy=(iPhi-1)/10+1; crystal=(iPhi-1)%10+1; } else if ((iTheta>29)&&(iTheta<73)) { module=1; row=iTheta-29; copy=(iPhi-1)/10+1; crystal=(iPhi-1)%10+1; } if ((iTheta>200)&&(iTheta<300)) { module=3; if ((iTheta<=250)&& (iPhi>250)) { copy = 1; row = 1-(iTheta-250); crystal = iPhi-250; } if ((iTheta<=250)&& (iPhi<=250)) { copy = 2; row = 1-(iTheta-250); crystal = 1-(iPhi-250); } if ((iTheta>250)&& (iPhi<=250)) { copy = 3; row = (iTheta-250); crystal = 1-(iPhi-250); } if ((iTheta>250)&& (iPhi>250)) { copy = 4; row = iTheta-250; crystal = iPhi-250; } } if ((iTheta>300)&&(iTheta<400)) { module=4; if ((iTheta<=350)&& (iPhi>350)) { copy = 1; row = 1-(iTheta-350); crystal = iPhi-350; } if ((iTheta<=350)&& (iPhi<=350)) { copy = 2; row = 1-(iTheta-350); crystal = 1-(iPhi-350); } if ((iTheta>350)&& (iPhi<=350)) { copy = 3; row = (iTheta-350); crystal = 1-(iPhi-350); } if ((iTheta>350)&& (iPhi>350)) { copy = 4; row = (iTheta-350); crystal = iPhi-350; } } if ((iTheta>400)&&(iTheta<500)) { module=5; if ((iTheta<=450)&& (iPhi>450)) { copy = 1; row = 1-(iTheta-450); crystal = iPhi-450; } if ((iTheta<=450)&& (iPhi<=450)) { copy = 2; row = 1-(iTheta-450); crystal = 1-(iPhi-450); } if ((iTheta>450)&& (iPhi<=450)) { copy = 3; row = (iTheta-450); crystal = 1-(iPhi-450); } if ((iTheta>450)&& (iPhi>450)) { copy = 4; row = (iTheta-450); crystal = iPhi-450; } } detId = module*100000000 + row*1000000 + copy*10000 + crystal; return detId; } ClassImp(PndEmcMapper)