//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of TpcLaserGrid // // // Environment: // Software developed for the GEM-TPC detector // // Author List: // Felix Boehmer TUM (original author) // //----------------------------------------------------------- #include "TpcLaserGrid.h" #include "TpcDigiPar.h" #include "TpcDigiMapper.h" #include "RKTrackRep.h" #include #include #include #include #include "TVector3.h" TpcLaserGrid* TpcLaserGrid::fInstance = NULL; std::string trim(std::string &str, const std::string &trimChars = " ") { std::string result = str.erase(str.find_last_not_of(trimChars) + 1); return result.erase(0, result.find_first_not_of(trimChars)); } std::string trimComment(std::string &str, const std::string &trimChars = " ") { int pos = str.find_first_of(trimChars); if(pos>=0) str.erase(pos); return str; } TpcLaserGrid::TpcLaserGrid() : fInit(false) {;} TpcLaserGrid::~TpcLaserGrid() { std::map::iterator it; for(it=fLaserMap.begin(); it!=fLaserMap.end(); it++) delete it->second; } TpcLaserGrid* TpcLaserGrid::Instance() { if(fInstance == NULL) fInstance = new TpcLaserGrid(); return fInstance; } void TpcLaserGrid::Destruct() { if(fInstance != NULL) delete fInstance; fInstance = NULL; //fInit = false; } void TpcLaserGrid::ReadFile(const TString& filename) { if(!fInit) { std::cerr<<"ERROR: TpcLaserGrid::ReadFile(): Geometry was not initialized! Call Init() first!" <<"\nAbrorting ..."<>dirSwitch>>id>>startX>>startY>>startZ>>dirX>>dirY>>dirZ>>iondens>>width>>time; std::string dirStr(1,dirSwitch); //decide which sort of vector we have bool isEnd = true; bool ok = false; if(dirStr==dir) { ok = true; isEnd = false; } if(dirStr==end) ok = true; if(!ok) { std::cout<<"ERROR: TpcLaserGrid::ReadFile(): Invalid direction/end specifier in line: \n" <<" "<getDir(); lDir.SetMag(1.); TVector3 lStart = (fLaserMap[id])->getStart(); double mom = 100.; //100 GeV/c, but should not matter for what we need here fTrackMap[id] = new RKTrackRep(lStart, mom*lDir, lStart*0.001, mom*lDir*0.001,211); //211: pi+ //TAKE CARE THAT YOU USE ZERO MAGNETIC FIELD IN THE MC SIM! } std::cout<<"TpcLaserGrid::ReadFile(): Created "<windowMin(); fZMax = par->windowMax(); fRMin = par->getRMin(); fRMax = par->getRMax(); fInit = true; } void TpcLaserGrid::Init(double rMin, double rMax, double zMin, double zMax) { if(fInit) std::cout<<"WARNING: TpcLaserGrid::Init(): ReInitialization of geometry information!" <<" Be careful what you do ..."<* TpcLaserGrid::GetLasers() const { if(!fInit) std::cerr<<"ERROR: TpcLaserGrid::GetLasers(): TpcLaserGrid was not initialized yet! " <<"\nReturning empty list ..."<* TpcLaserGrid::GetTracks() const { if(!fInit) std::cerr<<"ERROR: TpcLaserGrid::GetTracks(): TpcLaserGrid was not initialized yet! " <<"\nReturning empty list ..."<