//---------------------------------------------------------- // //------------------ #include "TGeoMatrix.h" #include "TGeoManager.h" #include "FairRootManager.h" #include "PndDchMapper.h" #include "PndDchDrifter.h" #include "PndDchPoint.h" #include "PndDchStructure.h" #include #include //#include //#include #include "math.h" using std::cout; using std::endl; //using std::round; //using std::pow; //using std::sqrt; PndDchMapper* PndDchMapper::fgMapperInstance = 0; PndDchMapper* PndDchMapper::Instance() { if (0 == fgMapperInstance) fgMapperInstance = new PndDchMapper(); return fgMapperInstance; } PndDchMapper::PndDchMapper() { // Geometry loading FairRootManager* ioman = FairRootManager::Instance(); TFile *infile = ioman->GetInFile(); //TGeoManager *geoMan = (TGeoManager*) infile->Get("FAIRGeom"); fDchStructure = PndDchStructure::Instance(gGeoManager); } PndDchMapper::~PndDchMapper() {} Int_t PndDchMapper::WhichWire(Int_t detID, Double_t xLocal) const { Int_t plane = CalculatePlane(detID); Int_t numWire =(Int_t) round(xLocal/fDchStructure->GetCellSize(detID)); if(plane%2==1) numWire=(Int_t) round(xLocal/fDchStructure->GetCellSize(detID)+0.5); return numWire; } Double_t PndDchMapper::WirePosXlocal(Int_t wire, Int_t detID) const { Int_t plane = CalculatePlane(detID); Double_t cellSize = fDchStructure->GetCellSize(detID); Double_t xLocal = cellSize*wire; if( plane%2 == 1 ) xLocal -= 0.5*cellSize; return xLocal; } Bool_t PndDchMapper::TransformToLocal(Double_t* localPosition, Double_t* localMomentum, const PndDchPoint* point) const { Int_t detID = point->GetDetectorID(); Double_t globalPosition[3] = {point->GetX(),point->GetY(),point->GetZ()}; Double_t globalMomentum[3] = {point->GetPx(),point->GetPy(),point->GetPz()}; const TGeoCombiTrans* trans = fDchStructure->GetTransMatrix(detID); if(0 == trans) return kFALSE; trans->MasterToLocal(globalPosition, localPosition); trans->MasterToLocalVect(globalMomentum, localMomentum); // std::cout<<"ch = "<GetChamber()<<"\t pl= "<GetPlane()< 0.5*cellSize*sqrt(2.)){ //cout<< "PndDchMapper::GetFiredWires(...):\n\t Distance from wire too large!\n"; return 0; } } } return wireID.size(); } void PndDchMapper::Print(const Option_t*) const { // fDchPoInt_t->Print(); }