#include "PndSsdDetector.h" #include "FairGeoInterface.h" #include "FairGeoLoader.h" #include "FairGeoNode.h" #include "FairGeoRootBuilder.h" #include "FairRootManager.h" #include "FairRuntimeDb.h" #include "FairRun.h" #include "FairGeoMedia.h" #include "FairGeoVolume.h" #include "FairRunSim.h" #include "FairVolume.h" #include "TClonesArray.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "TObjArray.h" #include "TList.h" #include "TKey.h" #include "TGeoManager.h" #include "TGeoVoxelFinder.h" #include "TGeoMatrix.h" #include "PndStack.h" #include "PndMvdMCPoint.h" #include "PndSsdGeo.h" #include "PndSsdGeoPar.h" #include "PndSsdGeoHandling.h" #include #include #include class FairVolume; // ----- Default constructor ------------------------------------------- PndSsdDetector::PndSsdDetector() : fUseRadDamOption(false) { fPndSsdCollection = new TClonesArray("PndMvdMCPoint"); /* fPosIndex = 0; fListOfSensitives.push_back("Disk-Sensor");//Root_Test.root fListOfSensitives.push_back("Barrel-Sensor");//Root_Test.root fListOfSensitives.push_back("PixelActive");//Root_Test.root fListOfSensitives.push_back("StripSensor");//MVD14.root fListOfSensitives.push_back("SensorActiveArea");//MVD14.root fListOfSensitives.push_back("StripActive");//MVD_v1.0.root fListOfSensitives.push_back("PixelActive");//MVD_v1.0.root fListOfSensitives.push_back("LumActive");//MATZE_LUMI.root //if (fVerboseLevel>0) { std::cout<<"-I- PndSsdDetector: fListOfSensitives contains:"; for(Int_t k=0;k0) { std::cout<<"- I - PndSsdDetector: fListOfSensitives contains:"; for(Int_t k=0;kDelete(); delete fPndSsdCollection; } delete fGeoH; } // ----- Public method ProcessHits -------------------------------------- Bool_t PndSsdDetector::ProcessHits(FairVolume* vol) { // std::cout<<"-I- PndSsdDetector::ProcessHits() : called. Please remove this line soon."<IsTrackEntering() ) { // Set parameters at entrance of volume. Reset ELoss. fELoss = 0.; fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); gMC->TrackPosition(fPosIn); gMC->TrackMomentum(fMomIn); } // Sum energy loss for all steps in the active volume fELoss += gMC->Edep(); // Create PndMvdMCPoint at exit of active volume if ( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) { fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); if(0==fGeoH) { std::cout<<" -E- No PndSsdGeoHandling loaded."< 1){ std::cout << "******* Info from gMC *************" << std::endl; std::cout << "Hit in " << gMC->CurrentVolPath() << " with MCiD: " << vol->getMCid() << " PixelDetectorID: " << fVolumeID << std::endl; std::cout<<"VolumeID: "<GetID(gMC->CurrentVolPath())<TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); if (fUseRadDamOption == false){ if (fELoss == 0.) return kFALSE; } TString detPath = gMC->CurrentVolPath(); AddHit(fTrackID, kMVDPoint, fGeoH->GetID(detPath), TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()), TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, fLength, fELoss); // Increment number of PndMvd points for TParticle PndStack* stack = (PndStack*) gMC->GetStack(); stack->AddPoint(kMVD); ResetParameters(); } return kTRUE; } // ------------------------------------------------------------------------- // ----- Public method EndOfEvent -------------------------------------- void PndSsdDetector::EndOfEvent() { if (fVerboseLevel) Print(); fPndSsdCollection->Clear(); fPosIndex = 0; } // ------------------------------------------------------------------------- void PndSsdDetector::FinishRun() { } // ----- Public method Register ---------------------------------------- void PndSsdDetector::Register() { FairRootManager::Instance()->Register("SSDPoint", "PndMvd", fPndSsdCollection, kTRUE); } // ------------------------------------------------------------------------- // ----- Public method GetCollection ----------------------------------- TClonesArray* PndSsdDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fPndSsdCollection; else return NULL; } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- void PndSsdDetector::Print() const { Int_t nHits = fPndSsdCollection->GetEntriesFast(); std::cout << "-I- PndSsdDetector: " << nHits << " points registered in this event." << std::endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ------------------------------------------------------------------------- // ----- Public method Reset ------------------------------------------- void PndSsdDetector::Reset() { fPndSsdCollection->Clear(); ResetParameters(); } // ------------------------------------------------------------------------- // ----- Public method CopyClones -------------------------------------- void PndSsdDetector::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) { Int_t nEntries = cl1->GetEntriesFast(); std::cout << "-I- PndSsdDetector: " << nEntries << " entries to add." << std::endl; TClonesArray& clref = *cl2; PndMvdMCPoint *oldpoint = NULL; for (Int_t i=0; iAt(i); Int_t index = oldpoint->GetTrackID() + offset; oldpoint->SetTrackID(index); new (clref[fPosIndex]) PndMvdMCPoint(*oldpoint); fPosIndex++; } std::cout << "-I- PndSsdDetector: " << cl2->GetEntriesFast() << " merged entries." << std::endl; } // ------------------------------------------------------------------------- void PndSsdDetector::ConstructGeometry() { TString fileName=GetGeometryFileName(); if(fileName.EndsWith(".geo")){ ConstructASCIIGeometry(); }else if(fileName.EndsWith(".root")){ ConstructRootGeometry(); }else{ std::cout<< "Geometry format not supported " <getGeoInterface(); PndSsdGeo *thePndSsdGeo = new PndSsdGeo(); thePndSsdGeo->setGeomFile(GetGeometryFileName()); geoFace->addGeoModule(thePndSsdGeo); Bool_t rc = geoFace->readSet(thePndSsdGeo); if (rc) thePndSsdGeo->create(geoLoad->getGeoBuilder()); TList* volList = thePndSsdGeo->getListOfVolumes(); // store geo parameter FairRun *fRun = FairRun::Instance(); FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb(); PndSsdGeoPar *par= (PndSsdGeoPar*)(rtdb->getContainer("PndSsdGeoPar")); 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 ); } // ------------------------------------------------------------------------- // ----- Public method SetExclusiveSensorType ------------------------------- void PndSsdDetector::SetExclusiveSensorType(const TString sens) { //Set one exclusive sensor type for testing purposes fListOfSensitives.clear(); fListOfSensitives.push_back(sens.Data()); std::cout<<"-I- PndSsdDetector: Only active sensor type is set to \""<= 2) std::cout << "-I- PndSsdDetector: Adding Point at (" << posIn.X() << ", " << posIn.Y() << ", " << posIn.Z() << ") cm, (" << posOut.X() << ", " << posOut.Y() << ", " << posOut.Z() << ") cm, detector " << detName << " " << detID << ", track " << trackID << ", energy loss " << eLoss*1e06 << " keV" << std::endl; return new(clref[size]) PndMvdMCPoint(trackID, detID, detName, posIn, posOut, momIn, momOut, time, length, eLoss); } // ------------------------------------------------------------------------- ClassImp(PndSsdDetector);