//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class PndTpcDetector // see PndTpcDetector.hh for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // // //----------------------------------------------------------- // Panda Headers ---------------------- // This Class' Header ------------------ #include "PndTpcDetector.h" // C/C++ Headers ---------------------- // Collaborating Class Headers -------- #include "TClonesArray.h" #include "CbmRootManager.h" #include "PndTpcPoint.h" #include "TVirtualMC.h" #include "TLorentzVector.h" #include "PndTpcGeo.h" #include "CbmGeoLoader.h" #include "CbmGeoInterface.h" #include "TList.h" #include "CbmRun.h" #include "CbmRuntimeDb.h" #include "PndTpcGeoPar.h" #include "TObjArray.h" #include "CbmGeoNode.h" #include "CbmGeoVolume.h" #include "CbmVolume.h" #include "TParticle.h" #include "CbmStack.h" #include "TVirtualMC.h" // Class Member definitions ----------- PndTpcDetector::PndTpcDetector(const char * Name, Bool_t Active) : CbmDetector(Name, Active) { fPndTpcPointCollection= new TClonesArray("PndTpcPoint"); } PndTpcDetector::PndTpcDetector() { fPndTpcPointCollection= new TClonesArray("PndTpcPoint"); } PndTpcDetector::~PndTpcDetector() { if (fPndTpcPointCollection) { fPndTpcPointCollection->Delete(); delete fPndTpcPointCollection; } } void PndTpcDetector::EndOfEvent() { //fPndTpcPointCollection->Clear(); } void PndTpcDetector::Register() { /** This will create a branch in the output tree called PndTpcDetectorPoint, setting the last parameter to kFALSE means: this collection will not be written to the file, it will exist only during the simulation. */ CbmRootManager::Instance()->Register("PndTpcPoint", "PndTpc", fPndTpcPointCollection, kTRUE); } Bool_t PndTpcDetector::ProcessHits( CbmVolume *v) { Double_t q= gMC->TrackCharge(); if(q==0)return kTRUE; // create Hit for every MC step where energy is deposited Double_t eLoss = gMC->Edep(); if(eLoss<=0)return kTRUE; Double_t time = gMC->TrackTime() * 1.0e09; Double_t length = gMC->TrackStep(); TLorentzVector pos; gMC->TrackPosition(pos); //pos.Print(); TLorentzVector mom; gMC->TrackMomentum(mom); //mom.Print(); Int_t trackID = gMC->GetStack()->GetCurrentTrackNumber(); Int_t volumeID = v->getMCid(); //std::cout<<"CurrentID="<GetStack()->GetCurrentTrack(); while(!mother->IsPrimary()){ trackID=mother->GetFirstMother(); mother=dynamic_cast(gMC->GetStack())->GetParticle(trackID); //std::cout<<"Fetching mother id="<Print(""); return kTRUE; } TClonesArray* PndTpcDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fPndTpcPointCollection; else return NULL; } PndTpcPoint* PndTpcDetector::AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss) { TClonesArray& clref = *fPndTpcPointCollection; Int_t size = clref.GetEntriesFast(); return new(clref[size]) PndTpcPoint(trackID, detID, pos, mom, time, length, eLoss); } void PndTpcDetector::BeginEvent() { //std::cout<<"PndTpcDetector::BeginEvent()"<Delete(); } void PndTpcDetector::Reset() { //std::cout<<"PndTpcDetector::Reset()"<Delete(); //ResetParameters(); } void PndTpcDetector::ConstructGeometry() { /** If you are using the standard ASCII input for the geometry just copy this and use it for your detector, otherwise you can implement here you own way of constructing the geometry. */ std::cout<<" --- Building TPC Geometry ---"<getGeoInterface(); PndTpcGeo* Geo = new PndTpcGeo(); Geo->setGeomFile(GetGeometryFileName()); geoFace->addGeoModule(Geo); Bool_t rc = geoFace->readSet(Geo); if (rc) Geo->create(geoLoad->getGeoBuilder()); else std::cerr<<"PndTpcDetector:: geometry could not be read!"<getListOfVolumes(); // store geo parameter CbmRun *fRun = CbmRun::Instance(); CbmRuntimeDb *rtdb= CbmRun::Instance()->GetRuntimeDb(); PndTpcGeoPar* par=(PndTpcGeoPar*)(rtdb->getContainer("PndTpcGeoPar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); TObjArray *fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); CbmGeoNode* node = NULL; CbmGeoVolume *aVol=NULL; while( (node = (CbmGeoNode*)iter.Next()) ) { aVol = dynamic_cast ( node ); if ( node->isSensitive() ) { fSensNodes->AddLast( aVol ); }else{ fPassNodes->AddLast( aVol ); } } par->setChanged(); par->setInputVersion(fRun->GetRunId(),1); ProcessNodes ( volList ); } ClassImp(PndTpcDetector)