//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcShield // see TpcShield.h for details // // Environment: // Software developed for the FOPI GEM-TPC detector // // Author List: // Felix Boehmer TUM (original author) // // //----------------------------------------------------------- // Panda Headers ---------------------- // This Class' Header ------------------ #include "TpcShield.h" // C/C++ Headers ---------------------- #include // Collaborating Class Headers -------- #include "TClonesArray.h" #include "TGeoManager.h" #include "FairRootManager.h" #include "TpcShieldPoint.h" #include "TVirtualMC.h" #include "TLorentzVector.h" #include "TpcGeo.h" #include "FairGeoLoader.h" #include "FairGeoInterface.h" #include "FairRun.h" #include "FairRuntimeDb.h" #include "TpcGeoPar.h" #include "TObjArray.h" #include "FairGeoNode.h" #include "FairGeoVolume.h" #include "FairVolume.h" #include "TParticle.h" #include "PndStack.h" #include "FairGeoMedia.h" #include "TRandom.h" // Class Member definitions ----------- TpcShield::TpcShield(const char * Name, Bool_t Active) : FairDetector(Name, Active) { fTpcShieldPointCollection = new TClonesArray("TpcShieldPoint"); } TpcShield::TpcShield() { fTpcShieldPointCollection= new TClonesArray("TpcShieldPoint"); } TpcShield::~TpcShield() { if (fTpcShieldPointCollection) { fTpcShieldPointCollection->Delete(); delete fTpcShieldPointCollection; } } void TpcShield::EndOfEvent() { } void TpcShield::Register() { /* This will create a branch in the output tree called TpcShieldPoint, setting the last parameter to kFALSE means: this collection will not be written to the file, it will exist only during the simulation. */ FairRootManager::Instance()->Register("TpcShieldPoint", "TpcShield", fTpcShieldPointCollection, kTRUE); } void TpcShield::SetSpecialPhysicsCuts(){ FairRun* fRun = FairRun::Instance(); //check for GEANT3, else abort // if (strcmp(fRun->GetName(),"TGeant3") == 0) { int matIdVMC = gGeoManager->GetMedium("FOPIPassLead")->GetId(); //-- NO PHYSICS, JUST ENERGY LOSS ----------------------------- gMC->Gstpar(matIdVMC,"PAIR",0); gMC->Gstpar(matIdVMC,"COMP",0); gMC->Gstpar(matIdVMC,"PHOT",0); gMC->Gstpar(matIdVMC,"DRAY",0); gMC->Gstpar(matIdVMC,"ANNI",0); gMC->Gstpar(matIdVMC,"BREM",0); gMC->Gstpar(matIdVMC,"HADR",0); gMC->Gstpar(matIdVMC,"MUNU",0); gMC->Gstpar(matIdVMC,"DCAY",0); gMC->Gstpar(matIdVMC,"RAYL",0); gMC->Gstpar(matIdVMC,"STRA",0); gMC->Gstpar(matIdVMC,"ILOSS",2); // } } Bool_t TpcShield::ProcessHits( FairVolume *v) { Double_t q= gMC->TrackCharge(); // create Hit for every MC step where energy is deposited Double_t eLoss = gMC->Edep(); if(eLoss<=0) { //std::cout<<"\nTpcShield::ProcessHits: EXIT eLoss<=0"<TrackTime() * 1.0e09; Double_t length = gMC->TrackStep(); TLorentzVector pos; gMC->TrackPosition(pos); //pos.Print(); TLorentzVector mom; gMC->TrackMomentum(mom); Int_t trackID(gMC->GetStack()->GetCurrentTrackNumber()); Int_t secID(0); Int_t motherID(trackID); Int_t volumeID = v->getMCid(); TString volumeName = v->GetName(); TParticle* mother=gMC->GetStack()->GetCurrentTrack(); if(mother->IsPrimary()) secID = 0; else while(!mother->IsPrimary()){ motherID=mother->GetFirstMother(); mother=dynamic_cast(gMC->GetStack())->GetParticle(motherID); ++secID; } // trackID is now ID of track in MCTrackArray // secID is the "level" of the track (0: primary track, 1: secondary from primary track, 2: secondary from secondary from primary, ...) TpcShieldPoint* p=AddHit(trackID, secID, volumeID, pos.Vect(), mom.Vect(), time, length, eLoss); // Increment number of tpc points for TParticle PndStack* stack = (PndStack*) gMC->GetStack(); stack->AddPoint(kSTT); return kTRUE; } TClonesArray* TpcShield::GetCollection(Int_t iColl) const { if (iColl == 0) return fTpcShieldPointCollection; else return NULL; } TpcShieldPoint* TpcShield::AddHit(Int_t trackID, Int_t SecID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss) { TClonesArray& clref = *fTpcShieldPointCollection; Int_t size = clref.GetEntriesFast(); return new(clref[size]) TpcShieldPoint(trackID, detID, pos, mom, time, length, eLoss, SecID); } void TpcShield::BeginEvent() { //std::cout<<"TpcShield::BeginEvent()"<Delete(); } void TpcShield::Reset() { //std::cout<<"TpcShield::Reset()"<Delete(); //ResetParameters(); } void TpcShield::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. */ TString fileName = GetGeometryFileName(); if(fileName.EndsWith(".root")) { std::cout<<"TpcShield::ConstructGeometry() " <<" ...using ROOT 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<<"TpcShield:: geometry could not be read!"<getListOfVolumes(); // // store geo parameter // FairRun *fRun = FairRun::Instance(); // FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb(); // TpcGeoPar* par=(TpcGeoPar*)(rtdb->getContainer("TpcGeoPar")); // TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); // TObjArray *fPassNodes = par->GetGeoPassiveNodes(); // TListIter iter(volList); // FairGeoNode* node = NULL; // FairGeoVolume *aVol=NULL; // while( (node = (FairGeoNode*)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 ); // //if(fAliMC) // // AliTPCv3_InitDetector(); } bool TpcShield::CheckIfSensitive(std::string name) { TString test(name.c_str()); if(test.Contains("FOPISensAirV")) { std::cout<