diff --git a/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py b/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py index 42c09a09a0531ed9364cf10fcb3331ce035512d6..25a06a724c1853a97e0807d4f389b2c352b7bcb8 100644 --- a/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py +++ b/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py @@ -109,8 +109,6 @@ gearsvc = GearSvc("GearSvc") from Configurables import TrackSystemSvc tracksystemsvc = TrackSystemSvc("TrackSystemSvc") -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") from Configurables import TimeProjectionChamberSensDetTool tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") diff --git a/Examples/options/CEPCV4_simu_reco_Arbor.py b/Examples/options/CEPCV4_simu_reco_Arbor.py index 4dadbbd04c4551ebbbe2e76d9f8ac01ff9aa54ca..0c96f1af9dd999df6cb96b641db791a08433bd64 100644 --- a/Examples/options/CEPCV4_simu_reco_Arbor.py +++ b/Examples/options/CEPCV4_simu_reco_Arbor.py @@ -85,9 +85,6 @@ detsimalg.PhysicsList = "FTFP_BERT" detsimalg.AnaElems = ["Edm4hepWriterAnaElemTool"] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - ############################################################################## # Tracker diff --git a/Examples/options/detsim_tracker.py b/Examples/options/detsim_tracker.py index 4dbf71c8a11460bd01a751e2304e3d83330c8f08..cfe9c12add4ed474c28830d6f8c1658e6caf65bf 100644 --- a/Examples/options/detsim_tracker.py +++ b/Examples/options/detsim_tracker.py @@ -17,7 +17,6 @@ from Configurables import GenPrinter from Configurables import GtBeamBackgroundTool from Configurables import DetSimSvc from Configurables import DetSimAlg -from Configurables import AnExampleDetElemTool from Configurables import PodioOutput from Configurables import ApplicationMgr @@ -70,7 +69,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") # POD I/O diff --git a/Examples/options/sim-rec-trackerecal.py b/Examples/options/sim-rec-trackerecal.py index 8eb4691ac4e8b3504da9be9ccab2586e5781c582..c4fa7e16b1d8b94aad3f97f267d2e4dddae25018 100644 --- a/Examples/options/sim-rec-trackerecal.py +++ b/Examples/options/sim-rec-trackerecal.py @@ -72,9 +72,6 @@ detsimalg.PhysicsList = "FTFP_BERT" detsimalg.AnaElems = ["Edm4hepWriterAnaElemTool"] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import TimeProjectionChamberSensDetTool tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") tpc_sensdettool.TypeOption = 1 diff --git a/Examples/options/sim_beambkg.py b/Examples/options/sim_beambkg.py index cea73c11ff16dfbe60b45274322282c605a6a213..6e5bd3aaae9a2e738b8467fd9a2de9401d633c99 100755 --- a/Examples/options/sim_beambkg.py +++ b/Examples/options/sim_beambkg.py @@ -162,9 +162,6 @@ gearsvc = GearSvc("GearSvc") from Configurables import TrackSystemSvc tracksystemsvc = TrackSystemSvc("TrackSystemSvc") -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import TimeProjectionChamberSensDetTool tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") tpc_sensdettool.TypeOption = 1 diff --git a/Examples/options/tut_detrec_SDT.py b/Examples/options/tut_detrec_SDT.py index fe55a3c130f4aaae9cc03375abe4ee2ad03a810d..1c01d1de9506caa721dd91d431548e9c85829afc 100644 --- a/Examples/options/tut_detrec_SDT.py +++ b/Examples/options/tut_detrec_SDT.py @@ -91,9 +91,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - dedxoption = "BetheBlochEquationDedxSimTool" from Configurables import DriftChamberSensDetTool dc_sensdettool = DriftChamberSensDetTool("DriftChamberSensDetTool") diff --git a/Examples/options/tut_detsim.py b/Examples/options/tut_detsim.py index 6b82a5f3b1ed4369e58b6a0f7b4405730e7fa7bb..12acbf7924b239742d8c3cfb534f3e600560b557 100644 --- a/Examples/options/tut_detsim.py +++ b/Examples/options/tut_detsim.py @@ -115,9 +115,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - ############################################################################## # POD I/O diff --git a/Examples/options/tut_detsim_SDT.py b/Examples/options/tut_detsim_SDT.py index a5dc22a2276d5d390738f2e51a312b5ed1c821a4..5b13b7a49394ce3e6c382e71abbf9486fdcbe652 100644 --- a/Examples/options/tut_detsim_SDT.py +++ b/Examples/options/tut_detsim_SDT.py @@ -133,9 +133,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_SDT_Heed.py b/Examples/options/tut_detsim_SDT_Heed.py index 179ac68c6cb10717b1e0b6c9fc420bed43d5a408..646c2af7a562278954ebb2f6c8f9499df868a95a 100644 --- a/Examples/options/tut_detsim_SDT_Heed.py +++ b/Examples/options/tut_detsim_SDT_Heed.py @@ -137,9 +137,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_digi_SDT.py b/Examples/options/tut_detsim_digi_SDT.py index 5431461d29f50b28158c082f92b11c88f6a52489..bbb7fa6bd0d1673b95e843bbbddf9d51bdfe09ae 100644 --- a/Examples/options/tut_detsim_digi_SDT.py +++ b/Examples/options/tut_detsim_digi_SDT.py @@ -129,9 +129,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_digi_fit_DC.py b/Examples/options/tut_detsim_digi_fit_DC.py index efdfe66c9660d651bf63160a752cbe6c8167ae5b..610bfcf237c8de6c638857438c1b1e03f5136cd3 100644 --- a/Examples/options/tut_detsim_digi_fit_DC.py +++ b/Examples/options/tut_detsim_digi_fit_DC.py @@ -129,9 +129,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_digi_truthTracker_SDT.py b/Examples/options/tut_detsim_digi_truthTracker_SDT.py index 4ea9485fe36153fe4207e173cfa6f0b0fea5092f..7b786a08b0f4e43a2dcddac9c98bd5373bc0f15b 100644 --- a/Examples/options/tut_detsim_digi_truthTracker_SDT.py +++ b/Examples/options/tut_detsim_digi_truthTracker_SDT.py @@ -129,9 +129,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_digi_truthTracker_SDT_dedx.py b/Examples/options/tut_detsim_digi_truthTracker_SDT_dedx.py index 2743861e6cefc0081cd20edadfa5b4c8486d6d1b..45fcbab7880cce9f32daccfe7cad404229f5008e 100644 --- a/Examples/options/tut_detsim_digi_truthTracker_SDT_dedx.py +++ b/Examples/options/tut_detsim_digi_truthTracker_SDT_dedx.py @@ -132,9 +132,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - from Configurables import CalorimeterSensDetTool from Configurables import DriftChamberSensDetTool diff --git a/Examples/options/tut_detsim_pan_matrix.py b/Examples/options/tut_detsim_pan_matrix.py index 1d22d1f932e9f1c5f05ec09aeee572c14e8e838d..46934fa9ca4d55692981340b6ec2edc7cbdce7a2 100644 --- a/Examples/options/tut_detsim_pan_matrix.py +++ b/Examples/options/tut_detsim_pan_matrix.py @@ -102,8 +102,6 @@ detsimalg.AnaElems = [ "Edm4hepWriterAnaElemTool" ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") ############################################################################## # Detector digitization ############################################################################## diff --git a/Examples/options/tut_detsim_pandora.py b/Examples/options/tut_detsim_pandora.py index a6bd147dcad61dc53bff7c959365f7fba3b09d95..1d29ebf359cc9e1bc2f7a5d8237207ccb72cb7b0 100644 --- a/Examples/options/tut_detsim_pandora.py +++ b/Examples/options/tut_detsim_pandora.py @@ -107,9 +107,6 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" -from Configurables import AnExampleDetElemTool -example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") - ############################################################ from Configurables import SimHitMergeAlg simHitMerge = SimHitMergeAlg("SimHitMergeAlg") diff --git a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp b/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp deleted file mode 100644 index 2617d4c1e11d5cf9d7b897c8acea7f02e1b40bc6..0000000000000000000000000000000000000000 --- a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "ExampleAnaElemTool.h" - -#include "G4Event.hh" -#include "G4THitsCollection.hh" - -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DDG4/Geant4Converter.h" -#include "DDG4/Geant4Mapping.h" -#include "DDG4/Geant4HitCollection.h" -#include "DDG4/Geant4Data.h" -#include "DetSimSD/Geant4Hits.h" - -DECLARE_COMPONENT(ExampleAnaElemTool) - -void -ExampleAnaElemTool::BeginOfRunAction(const G4Run*) { - G4cout << "Begin Run of detector simultion..." << G4endl; -} - -void -ExampleAnaElemTool::EndOfRunAction(const G4Run*) { - G4cout << "End Run of detector simultion..." << G4endl; -} - -void -ExampleAnaElemTool::BeginOfEventAction(const G4Event* anEvent) { - msg() << "Event " << anEvent->GetEventID() << endmsg; -} - -void -ExampleAnaElemTool::EndOfEventAction(const G4Event* anEvent) { - auto mcCol = m_mcParCol.get(); - msg() << "mcCol size: " << mcCol->size() << endmsg; - // save all data - - // create collections. - auto trackercols = m_trackerCol.createAndPut(); - auto calorimetercols = m_calorimeterCol.createAndPut(); - auto calocontribcols = m_caloContribCol.createAndPut(); - - auto vxdcols = m_VXDCol.createAndPut(); - auto ftdcols = m_FTDCol.createAndPut(); - auto sitcols = m_SITCol.createAndPut(); - auto tpccols = m_TPCCol.createAndPut(); - auto setcols = m_SETCol.createAndPut(); - auto otkbarrelcols = m_OTKBarrelCol.createAndPut(); - auto otkendcapcols = m_OTKEndcapCol.createAndPut(); - - // readout defined in DD4hep - auto lcdd = &(dd4hep::Detector::getInstance()); - auto allReadouts = lcdd->readouts(); - - for (auto& readout : allReadouts) { - info() << "Readout " << readout.first << endmsg; - } - - // retrieve the hit collections - G4HCofThisEvent* collections = anEvent->GetHCofThisEvent(); - if (!collections) { - warning() << "No collections found. " << endmsg; - return; - } - int Ncol = collections->GetNumberOfCollections(); - for (int icol = 0; icol < Ncol; ++icol) { - G4VHitsCollection* collect = collections->GetHC(icol); - if (!collect) { - warning() << "Collection iCol " << icol << " is missing" << endmsg; - continue; - } - size_t nhits = collect->GetSize(); - info() << "Collection " << collect->GetName() - << " #" << icol - << " has " << nhits << " hits." - << endmsg; - if (nhits==0) { - // just skip this collection. - continue; - } - - plcio::SimTrackerHitCollection* tracker_col_ptr = nullptr; - plcio::SimCalorimeterHitCollection* calo_col_ptr = nullptr; - - // the mapping between hit collection and the data handler - if (collect->GetName() == "VXDCollection") { - tracker_col_ptr = vxdcols; - } else if (collect->GetName() == "FTDCollection") { - tracker_col_ptr = ftdcols; - } else if (collect->GetName() == "SITCollection") { - tracker_col_ptr = sitcols; - } else if (collect->GetName() == "TPCCollection") { - tracker_col_ptr = tpccols; - } else if (collect->GetName() == "SETCollection") { - tracker_col_ptr = setcols; - } else if (collect->GetName() == "SETCollection") { - tracker_col_ptr = setcols; - } else if (collect->GetName() == "OTKBarrelCollection") { - tracker_col_ptr = otkbarrelcols; - } else if (collect->GetName() == "OTKEndcapCollection") { - tracker_col_ptr = otkendcapcols; - } else if (collect->GetName() == "CaloHitsCollection") { - calo_col_ptr = calorimetercols; - } else { - warning() << "Unknown collection name: " << collect->GetName() - << ". The SimTrackerCol will be used. " << endmsg; - tracker_col_ptr = trackercols; - } - - - - // There are different types (new and old) - - dd4hep::sim::Geant4HitCollection* coll = dynamic_cast<dd4hep::sim::Geant4HitCollection*>(collect); - if (coll) { - info() << " cast to dd4hep::sim::Geant4HitCollection. " << endmsg; - for(size_t i=0; i<nhits; ++i) { - - dd4hep::sim::Geant4HitData* h = coll->hit(i); - - dd4hep::sim::Geant4Tracker::Hit* trk_hit = dynamic_cast<dd4hep::sim::Geant4Tracker::Hit*>(h); - if ( 0 != trk_hit ) { - dd4hep::sim::Geant4HitData::Contribution& t = trk_hit->truth; - int trackID = t.trackID; - // t.trackID = m_truth->particleID(trackID); - } - // Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); - // if ( 0 != cal_hit ) { - // Geant4HitData::Contributions& c = cal_hit->truth; - // for(Geant4HitData::Contributions::iterator j=c.begin(); j!=c.end(); ++j) { - // Geant4HitData::Contribution& t = *j; - // int trackID = t.trackID; - // // t.trackID = m_truth->particleID(trackID); - // } - // } - } - continue; - } - - typedef G4THitsCollection<dd4hep::sim::Geant4Hit> HitCollection; - HitCollection* coll2 = dynamic_cast<HitCollection*>(collect); - - if (coll2) { - info() << " cast to G4THitsCollection<dd4hep::sim::Geant4Hit>. " << endmsg; - - int n_trk_hit = 0; - int n_cal_hit = 0; - - for(size_t i=0; i<nhits; ++i) { - dd4hep::sim::Geant4Hit* h = dynamic_cast<dd4hep::sim::Geant4Hit*>(coll2->GetHit(i)); - if (!h) { - warning() << "Failed to cast to dd4hep::sim::Geant4Hit. " << endmsg; - continue; - } - - dd4hep::sim::Geant4TrackerHit* trk_hit = dynamic_cast<dd4hep::sim::Geant4TrackerHit*>(h); - if (trk_hit) { - ++n_trk_hit; - // auto edm_trk_hit = trackercols->create(); - auto edm_trk_hit = tracker_col_ptr->create(); - - // Refer to: ./DDG4/lcio/LCIOConversions.cpp - edm_trk_hit->setCellID0((trk_hit->cellID >> 0 ) & 0xFFFFFFFF); - edm_trk_hit->setCellID1((trk_hit->cellID >> sizeof(int)*8) & 0xFFFFFFFF); - edm_trk_hit->setEDep(trk_hit->energyDeposit/CLHEP::GeV); - edm_trk_hit->setTime(trk_hit->truth.time/CLHEP::ns); - edm_trk_hit->setPathLength(trk_hit->length/CLHEP::mm); - // lc_hit->setMCParticle(lc_mcp); - double pos[3] = {trk_hit->position.x()/CLHEP::mm, - trk_hit->position.y()/CLHEP::mm, - trk_hit->position.z()/CLHEP::mm}; - edm_trk_hit->setPosition(plcio::DoubleThree(pos)); - - float mom[3] = {trk_hit->momentum.x()/CLHEP::GeV, - trk_hit->momentum.y()/CLHEP::GeV, - trk_hit->momentum.z()/CLHEP::GeV}; - edm_trk_hit->setMomentum(plcio::FloatThree(mom)); - } - - dd4hep::sim::Geant4CalorimeterHit* cal_hit = dynamic_cast<dd4hep::sim::Geant4CalorimeterHit*>(h); - if (cal_hit) { - ++n_cal_hit; - auto edm_calo_hit = calo_col_ptr->create(); - edm_calo_hit->setCellID0((cal_hit->cellID >> 0 ) & 0xFFFFFFFF); - edm_calo_hit->setCellID1((cal_hit->cellID >> sizeof(int)*8) & 0xFFFFFFFF); - edm_calo_hit->setEnergy(cal_hit->energyDeposit); - float pos[3] = {cal_hit->position.x()/CLHEP::mm, - cal_hit->position.y()/CLHEP::mm, - cal_hit->position.z()/CLHEP::mm}; - edm_calo_hit->setPosition(plcio::FloatThree(pos)); - - // contribution - typedef dd4hep::sim::Geant4CalorimeterHit::Contributions Contributions; - typedef dd4hep::sim::Geant4CalorimeterHit::Contribution Contribution; - for (Contributions::const_iterator j = cal_hit->truth.begin(); - j != cal_hit->truth.end(); ++j) { - const Contribution& c = *j; - // The legacy Hit object does not contains positions of contributions. - // float contrib_pos[] = {float(c.x/mm), float(c.y/mm), float(c.z/mm)}; - auto edm_calo_contrib = calocontribcols->create(); - edm_calo_contrib.setPDG(c.pdgID); - edm_calo_contrib.setEnergy(c.deposit/CLHEP::GeV); - edm_calo_contrib.setTime(c.time/CLHEP::ns); - edm_calo_contrib.setStepPosition(plcio::FloatThree(pos)); - edm_calo_contrib.setParticle(mcCol->at(0)); - edm_calo_hit->addContribution(edm_calo_contrib); - } - } - - } - - info() << n_trk_hit << " hits cast to dd4hep::sim::Geant4TrackerHit. " << endmsg; - info() << n_cal_hit << " hits cast to dd4hep::sim::Geant4CalorimeterHit. " << endmsg; - - - continue; - } - - warning() << "Failed to convert to collection " - << collect->GetName() - << endmsg; - - } -} - -void -ExampleAnaElemTool::PreUserTrackingAction(const G4Track*) { - -} - -void -ExampleAnaElemTool::PostUserTrackingAction(const G4Track*) { - -} - -void -ExampleAnaElemTool::UserSteppingAction(const G4Step*) { - -} - -StatusCode -ExampleAnaElemTool::initialize() { - StatusCode sc; - - return sc; -} - -StatusCode -ExampleAnaElemTool::finalize() { - StatusCode sc; - - return sc; -} - - diff --git a/Simulation/DetSimAna/src/ExampleAnaElemTool.h b/Simulation/DetSimAna/src/ExampleAnaElemTool.h deleted file mode 100644 index 1a1ce0af087e5ed85b31ae3a34766be30f0dcbd6..0000000000000000000000000000000000000000 --- a/Simulation/DetSimAna/src/ExampleAnaElemTool.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef ExampleAnaElemTool_h -#define ExampleAnaElemTool_h - -#include "GaudiKernel/AlgTool.h" -#include "k4FWCore/DataHandle.h" -#include "DetSimInterface/IAnaElemTool.h" - -#include "plcio/MCParticleCollection.h" -#include "plcio/SimTrackerHitCollection.h" -#include "plcio/SimCalorimeterHitCollection.h" -#include "plcio/CaloHitContributionCollection.h" - -class ExampleAnaElemTool: public extends<AlgTool, IAnaElemTool> { - -public: - - using extends::extends; - - /// IAnaElemTool interface - // Run - virtual void BeginOfRunAction(const G4Run*) override; - virtual void EndOfRunAction(const G4Run*) override; - - // Event - virtual void BeginOfEventAction(const G4Event*) override; - virtual void EndOfEventAction(const G4Event*) override; - - // Tracking - virtual void PreUserTrackingAction(const G4Track*) override; - virtual void PostUserTrackingAction(const G4Track*) override; - - // Stepping - virtual void UserSteppingAction(const G4Step*) override; - - - /// Overriding initialize and finalize - StatusCode initialize() override; - StatusCode finalize() override; - -private: - // In order to associate MCParticle with contribution, we need to access MC Particle. - DataHandle<plcio::MCParticleCollection> m_mcParCol{"MCParticle", - Gaudi::DataHandle::Writer, this}; - - // Generic collections for Tracker and Calorimeter - DataHandle<plcio::SimTrackerHitCollection> m_trackerCol{"SimTrackerCol", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimCalorimeterHitCollection> m_calorimeterCol{"SimCalorimeterCol", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::CaloHitContributionCollection> m_caloContribCol{"SimCaloContributionCol", - Gaudi::DataHandle::Writer, this}; - - // Dedicated collections for CEPC - DataHandle<plcio::SimTrackerHitCollection> m_VXDCol{"VXDCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimTrackerHitCollection> m_FTDCol{"FTDCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimTrackerHitCollection> m_SITCol{"SITCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimTrackerHitCollection> m_TPCCol{"TPCCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimTrackerHitCollection> m_SETCol{"SETCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<plcio::SimTrackerHitCollection> m_OTKBarrelCol{"OTKBarrelCollection", - Gaudi::DataHandle::Writer, this}; - DataHandle<edm4hep::SimTrackerHitCollection> m_OTKEndcapCol{"OTKEndcapCollection", - Gaudi::DataHandle::Writer, this}; - -}; - -#endif diff --git a/Simulation/DetSimGeom/CMakeLists.txt b/Simulation/DetSimGeom/CMakeLists.txt index 62caab085fc23161676656af218ea2968d96b6eb..987129f484e1d585cee0bcf57d072175bf0b4ffb 100644 --- a/Simulation/DetSimGeom/CMakeLists.txt +++ b/Simulation/DetSimGeom/CMakeLists.txt @@ -1,7 +1,7 @@ gaudi_add_module(DetSimGeom SOURCES src/WorldDetElemTool.cpp - src/AnExampleDetElemTool.cpp + src/DDG4DetElemTool.cpp LINK DetSimInterface DetInterface ${DD4hep_COMPONENT_LIBRARIES} diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/DDG4DetElemTool.cpp similarity index 79% rename from Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp rename to Simulation/DetSimGeom/src/DDG4DetElemTool.cpp index bfcf35c54186a15d50cac039ec572516e7c2f98c..8f898c90dce60572e7b353f33f7bc9a3d132f9cd 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/DDG4DetElemTool.cpp @@ -1,4 +1,4 @@ -#include "AnExampleDetElemTool.h" +#include "DDG4DetElemTool.h" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" @@ -30,10 +30,10 @@ #include "DDG4/Geant4Mapping.h" #include "DDG4/Geant4Field.h" -DECLARE_COMPONENT(AnExampleDetElemTool) +DECLARE_COMPONENT(DDG4DetElemTool) G4LogicalVolume* -AnExampleDetElemTool::getLV() { +DDG4DetElemTool::getLV() { // G4Material* Galactic = G4Material::GetMaterial("Galactic"); @@ -75,7 +75,7 @@ AnExampleDetElemTool::getLV() { } void -AnExampleDetElemTool::ConstructSDandField() { +DDG4DetElemTool::ConstructSDandField() { // DEBUG ONLY: turn off all the SD. if (not m_SD_enabled) { @@ -127,43 +127,39 @@ AnExampleDetElemTool::ConstructSDandField() { } else { warning() << "DriftChamberSensDetTool is not found. " << endmsg; } + } else if (nam == "TPC") { + m_tpc_sdtool = ToolHandle<ISensDetTool>("TimeProjectionChamberSensDetTool"); + if (m_tpc_sdtool) { + info() << "Find the TimeProjectionChamberSensDetTool" << endmsg; + g4sd = m_tpc_sdtool->createSD(nam); + } + else { + warning() << "TimeProjectionChamberSensDetTool is not found, and default tracker SD will be used" << endmsg; + } + } else { + m_tracker_sdtool = ToolHandle<ISensDetTool>("GenericTrackerSensDetTool"); + if (m_tracker_sdtool) { + info() << "Find the GenericTrackerSensDetTool" << endmsg; + g4sd = m_tracker_sdtool->createSD(nam); + } + else { + warning() << "GenericTrackerSensDetTool is not found. " << endmsg; + } + } + } else if (typ=="muonbarrel") { + m_muonbarrel_sdtool = ToolHandle<ISensDetTool>("MuonBarrelSensDetTool"); + if (m_muonbarrel_sdtool) { + info() << "Find the MuonBarrelSensDetTool." << endmsg; + g4sd = m_muonbarrel_sdtool->createSD(nam); + info() << "create g4SD: " << g4sd << endmsg; + } + } else if (typ=="muonendcap") { + m_muonendcap_sdtool = ToolHandle<ISensDetTool>("MuonEndcapSensDetTool"); + if (m_muonendcap_sdtool) { + info() << "Find the MuonEndcapSensDetTool." << endmsg; + g4sd = m_muonendcap_sdtool->createSD(nam); + info() << "create g4SD: " << g4sd << endmsg; } - else if (nam == "TPC") { - m_tpc_sdtool = ToolHandle<ISensDetTool>("TimeProjectionChamberSensDetTool"); - if (m_tpc_sdtool) { - info() << "Find the TimeProjectionChamberSensDetTool" << endmsg; - g4sd = m_tpc_sdtool->createSD(nam); - } - else { - warning() << "TimeProjectionChamberSensDetTool is not found, and default tracker SD will be used" << endmsg; - } - } - else { - m_tracker_sdtool = ToolHandle<ISensDetTool>("GenericTrackerSensDetTool"); - if (m_tracker_sdtool) { - info() << "Find the GenericTrackerSensDetTool" << endmsg; - g4sd = m_tracker_sdtool->createSD(nam); - } - else { - warning() << "GenericTrackerSensDetTool is not found. " << endmsg; - } - } - } - if (typ=="muonbarrel") { - m_muonbarrel_sdtool = ToolHandle<ISensDetTool>("MuonBarrelSensDetTool"); - if (m_muonbarrel_sdtool) { - info() << "Find the MuonBarrelSensDetTool." << endmsg; - g4sd = m_muonbarrel_sdtool->createSD(nam); - info() << "create g4SD: " << g4sd << endmsg; - } - } - if (typ=="muonendcap") { - m_muonendcap_sdtool = ToolHandle<ISensDetTool>("MuonEndcapSensDetTool"); - if (m_muonendcap_sdtool) { - info() << "Find the MuonEndcapSensDetTool." << endmsg; - g4sd = m_muonendcap_sdtool->createSD(nam); - info() << "create g4SD: " << g4sd << endmsg; - } } } @@ -233,7 +229,7 @@ AnExampleDetElemTool::ConstructSDandField() { } StatusCode -AnExampleDetElemTool::initialize() { +DDG4DetElemTool::initialize() { StatusCode sc; m_geosvc = service<IGeomSvc>("GeomSvc"); @@ -252,7 +248,7 @@ AnExampleDetElemTool::initialize() { } StatusCode -AnExampleDetElemTool::finalize() { +DDG4DetElemTool::finalize() { StatusCode sc; return sc; } diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.h b/Simulation/DetSimGeom/src/DDG4DetElemTool.h similarity index 89% rename from Simulation/DetSimGeom/src/AnExampleDetElemTool.h rename to Simulation/DetSimGeom/src/DDG4DetElemTool.h index 74442d777db44de4c7d8b2a0a9063034f09eee5d..ccd73537aeafe265538dea447d209b53ec395c56 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.h +++ b/Simulation/DetSimGeom/src/DDG4DetElemTool.h @@ -1,5 +1,5 @@ -#ifndef AnExampleDetElemTool_h -#define AnExampleDetElemTool_h +#ifndef DDG4DetElemTool_h +#define DDG4DetElemTool_h #include "GaudiKernel/AlgTool.h" #include <Gaudi/Property.h> @@ -13,7 +13,7 @@ #include "DetSimInterface/ISensDetTool.h" -class AnExampleDetElemTool: public extends<AlgTool, IDetElemTool> { +class DDG4DetElemTool: public extends<AlgTool, IDetElemTool> { public: using extends::extends; diff --git a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp index ccef28d7f00deb6252079fe3b6d039505331c0bf..1006fb942660e496ab67cd4cffda63395eba55e2 100644 --- a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp @@ -33,7 +33,7 @@ WorldDetElemTool::getLV() { // G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); // An example, get a detelem first, then place the detector components inside world. - ToolHandle<IDetElemTool> inner_detelem_tool("AnExampleDetElemTool"); + ToolHandle<IDetElemTool> inner_detelem_tool("DDG4DetElemTool"); G4LogicalVolume* inner_lv = inner_detelem_tool->getLV(); if (inner_lv) { @@ -55,7 +55,7 @@ void WorldDetElemTool::ConstructSDandField() { // After the whole detector volumes are constructed, // now start the construction of SD. - ToolHandle<IDetElemTool> inner_detelem_tool("AnExampleDetElemTool"); + ToolHandle<IDetElemTool> inner_detelem_tool("DDG4DetElemTool"); inner_detelem_tool->ConstructSDandField(); }