//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcDetector // see TpcDetector.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 "TpcDetector.h" // C/C++ Headers ---------------------- // Collaborating Class Headers -------- #include "TClonesArray.h" #include "CbmRootManager.h" #include "TpcPoint.h" #include "TVirtualMC.h" #include "TLorentzVector.h" #include "TpcGeo.h" #include "CbmGeoLoader.h" #include "CbmGeoInterface.h" #include "TList.h" #include "CbmRun.h" #include "CbmRuntimeDb.h" #include "TpcGeoPar.h" #include "TObjArray.h" #include "CbmGeoNode.h" #include "CbmGeoVolume.h" // Class Member definitions ----------- TpcDetector::TpcDetector(const char * Name, Bool_t Active) : CbmDetector(Name, Active) { fTpcPointCollection= new TClonesArray("TpcPoint"); } TpcDetector::TpcDetector() { fTpcPointCollection= new TClonesArray("TpcPoint"); } TpcDetector::~TpcDetector() { if (fTpcPointCollection) { fTpcPointCollection->Delete(); delete fTpcPointCollection; } } void TpcDetector::EndOfEvent() { fTpcPointCollection->Clear(); } void TpcDetector::Register() { /** This will create a branch in the output tree called TpcDetectorPoint, 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("TpcPoint", "Tpc", fTpcPointCollection, kTRUE); } Bool_t TpcDetector::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(); TpcPoint* p=AddHit(trackID, volumeID, pos.Vect(), mom.Vect(), time, length, eLoss); //p->Print(""); return kTRUE; } TClonesArray* TpcDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fTpcPointCollection; else return NULL; } TpcPoint* TpcDetector::AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss) { TClonesArray& clref = *fTpcPointCollection; Int_t size = clref.GetEntriesFast(); return new(clref[size]) TpcPoint(trackID, detID, pos, mom, time, length, eLoss); } void TpcDetector::Reset() { fTpcPointCollection->Clear(); //ResetParameters(); } void TpcDetector::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(); TpcGeo* Geo = new TpcGeo(); Geo->setGeomFile(GetGeometryFileName()); geoFace->addGeoModule(Geo); Bool_t rc = geoFace->readSet(Geo); if (rc) Geo->create(geoLoad->getGeoBuilder()); else std::cerr<<"TpcDetector:: geometry could not be read!"<getListOfVolumes(); // store geo parameter CbmRun *fRun = CbmRun::Instance(); CbmRuntimeDb *rtdb= CbmRun::Instance()->GetRuntimeDb(); TpcGeoPar* par=(TpcGeoPar*)(rtdb->getContainer("TpcGeoPar")); 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(TpcDetector)