//====================================================================== // File and Version Information: // $Id: $ // // Description: // Class PndDchStructure // //====================================================================== //----------------------- // This Class's Header -- //----------------------- #include "PndDchStructure.h" #include "TGeoMatrix.h" #include "TGeoManager.h" #include "TVector3.h" #include "TRotation.h" #include "TMath.h" #include "TString.h" #include "PndDchPoint.h" //--------------- // C++ Headers -- //--------------- #include "stdlib.h" #include using std::cout; using std::endl; //------------------------------- // Collaborating Class Headers -- //------------------------------- PndDchStructure* PndDchStructure::fInstance = 0; PndDchStructure::~PndDchStructure(){} PndDchStructure* PndDchStructure::Instance (TGeoManager *geoMan) { if (fInstance == 0) { if (geoMan==0){ cout<<"Empty geometry passed to PndDchStructure"<GetTopVolume()); TGeoNode *node; while ((node=next())) { next.GetPath(nodePath); bool isDchSplane=nodePath.Contains("dchSplane"); if (!isDchSplane) continue; detID = GetDetectorID(nodePath); planeMatrix = new TGeoCombiTrans(*next.GetCurrentMatrix()); cellSize= node->GetVolume()->GetShape()->GetAxisRange(3,xlo,xup); fPlaneGeoTransMap[detID] = planeMatrix; fCellSizeMap[detID] = cellSize; } if(!SetWireOrientation()) cout<<"PndDchStructure::PndDchStructure(...): \n \t Failed in SetWireOrientation()\n"; } Double_t PndDchStructure::GetCellSize(Int_t detID) const { // returns cell size for a sensitive plane with detectorID = detID std::map::const_iterator it; if((it = fCellSizeMap.find(detID)) == fCellSizeMap.end()) return 0; else return it->second; } const TGeoCombiTrans* PndDchStructure::GetTransMatrix(Int_t detID) const { // returns transformation matrix for a sensitive plane with detectorID = detID std::map::const_iterator it; if((it = fPlaneGeoTransMap.find(detID)) == fPlaneGeoTransMap.end()) return 0; else return it->second; } Int_t PndDchStructure::GetDetectorID(TString nodePath) { // The following code extract information about detID from the path name TString tmp = ""; Int_t ch, pl; ch = pl = 0; tmp = nodePath(nodePath.Sizeof()-2,1); pl = tmp.Atoi(); tmp = nodePath(nodePath.Sizeof()-4,1); ch = tmp.Atoi(); Int_t detID = PndDchMapper::CalculateDetectorID(ch, pl); return detID; } Bool_t PndDchStructure::SetWireOrientation(void){ // adds rotation of wires w.r.t. the y-axis to // each transformation in fPlaneGeoTransMap Bool_t result = kTRUE; std::map::const_iterator iterator; Int_t detID, plane, chamber; Double_t wireangle; for (iterator = fPlaneGeoTransMap.begin(); iterator != fPlaneGeoTransMap.end();iterator++ ){ detID = plane = chamber = 0; wireangle = 0.; TGeoCombiTrans *trans = iterator->second; detID = iterator->first; plane = PndDchMapper::CalculatePlane(detID); chamber = PndDchMapper::CalculateChamber(detID); if (chamber>2){ if(plane==1 || plane==2) wireangle = 0.; else if(plane==3 || plane==4) wireangle = 30.; else if(plane==5 || plane==6) wireangle = -30.; else {result=kFALSE;} } else if (chamber==2){ if(plane==1 || plane==2) wireangle = 0.; else if(plane==3 || plane==4) wireangle = -45.; else if(plane==5 || plane==6) wireangle = 45.; else if(plane==7 || plane==8) wireangle = 90.; else {result=kFALSE;} } else if (chamber==1){ if(plane==1) wireangle = 0.; else if(plane==2) wireangle = 90.; else {result=kFALSE;} } else {result=kFALSE;} trans->RotateZ(wireangle); } return result; } // ----- Public method Print ------------------------------------------- void PndDchStructure::Print(const Option_t*) const { cout << "-I- PndDchStructure: " << endl; std::map::const_iterator it2 = fCellSizeMap.begin(); while (it2 != fCellSizeMap.end()) { cout << "DetID "<<(*it2).first<<" CellSize " << (*it2).second << endl; it2++; } std::map::const_iterator it3; for (it3 = fPlaneGeoTransMap.begin(); it3 != fPlaneGeoTransMap.end();it3++ ){ TGeoCombiTrans *trans = it3->second; cout << "DetID "<<(*it3).first<<" PlaneGeoTrans "<Print(); } } // ------------------------------------------------------------------------- ClassImp(PndDchStructure)