diff --git a/Detector/DetCRD/scripts/Standalone-Sim-RotCrystal.py b/Detector/DetCRD/scripts/Standalone-Sim-RotCrystal.py index a424a1b3af88ed4b9929cf87ade65891277ce763..1386affd7623cda211e7d1d8f983fa749b26b9f3 100644 --- a/Detector/DetCRD/scripts/Standalone-Sim-RotCrystal.py +++ b/Detector/DetCRD/scripts/Standalone-Sim-RotCrystal.py @@ -88,6 +88,10 @@ detsimalg.AnaElems = [ ] detsimalg.RootDetElem = "WorldDetElemTool" +from Configurables import CalorimeterSensDetTool +cal_sensdettool = CalorimeterSensDetTool("CalorimeterSensDetTool") +cal_sensdettool.CalNamesApplyBirks = ["EcalBarrel"] + # output from Configurables import PodioOutput out = PodioOutput("outputalg") diff --git a/Detector/DetCRD/src/Calorimeter/CRDEcal_v01.cpp b/Detector/DetCRD/src/Calorimeter/CRDEcal_v01.cpp index f75648822cdf44352cd3cec502d292c1157b7d2c..4ba45b249f46c9bd815ac60b21f3a32f385a51cf 100644 --- a/Detector/DetCRD/src/Calorimeter/CRDEcal_v01.cpp +++ b/Detector/DetCRD/src/Calorimeter/CRDEcal_v01.cpp @@ -182,7 +182,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, DetElement sd(ECAL, _toString(i,"trap%3d"), detid); sd.setPlacement(plv); } - + sens.setType("calorimeter"); ECAL.addExtension< LayeredCalorimeterData >( caloData ) ; diff --git a/Simulation/DetSimSD/include/DetSimSD/CaloSensitiveDetector.h b/Simulation/DetSimSD/include/DetSimSD/CaloSensitiveDetector.h index db161be4269e9ba94c071a50f647b5a99b38ec19..4f2b6182c431cf3249591ae06f435bec7240b38d 100644 --- a/Simulation/DetSimSD/include/DetSimSD/CaloSensitiveDetector.h +++ b/Simulation/DetSimSD/include/DetSimSD/CaloSensitiveDetector.h @@ -23,6 +23,7 @@ public: virtual void Initialize(G4HCofThisEvent* HCE); virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history); virtual void EndOfEvent(G4HCofThisEvent* HCE); + void ApplyBirksLaw(){m_applyBirksLaw = true;}; protected: CalorimeterHit* find(const HitCollection*, const dd4hep::sim::HitCompare<CalorimeterHit>&); @@ -31,7 +32,8 @@ protected: HitCollection* m_hc; std::map<unsigned long, CalorimeterHit*> m_hitMap; - bool m_isMergeEnabled; + bool m_isMergeEnabled = false; + bool m_applyBirksLaw = false; }; diff --git a/Simulation/DetSimSD/src/CaloSensitiveDetector.cpp b/Simulation/DetSimSD/src/CaloSensitiveDetector.cpp index 11fb8cddabccf91713e068f0a4396772079ce2c1..950c4c45f91c1084f21fc95982fb533ae6b7a596 100644 --- a/Simulation/DetSimSD/src/CaloSensitiveDetector.cpp +++ b/Simulation/DetSimSD/src/CaloSensitiveDetector.cpp @@ -33,6 +33,7 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) { // std::cout << "CaloSensitiveDetector::ProcessHits" << std::endl; dd4hep::sim::Geant4StepHandler h(step); + if(m_applyBirksLaw) h.doApplyBirksLaw(); dd4hep::Position pos = 0.5 * (h.prePos() + h.postPos()); HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step); const std::string& name = GetName(); @@ -62,9 +63,9 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) { m_hc->insert(hit); } hit->truth.push_back(contrib); - hit->energyDeposit += contrib.deposit; - - + //hit->energyDeposit += contrib.deposit; + hit->energyDeposit += h.totalEnergy(); + //std::cout << "Apply Birk law: before = " << contrib.deposit << " after = " << h.totalEnergy() << std::endl; return true; } diff --git a/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp b/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp index f213a3b45282384f9cbdfdba788b7a8a2760046d..12a5f3f9586884efa9f5f3ee95f5aa9a82281362 100644 --- a/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp +++ b/Simulation/DetSimSD/src/CalorimeterSensDetTool.cpp @@ -42,9 +42,19 @@ CalorimeterSensDetTool::createSD(const std::string& name) { break; } } - G4VSensitiveDetector* sd = new CaloSensitiveDetector(name, *dd4hep_geo, is_merge_enabled); + + CaloSensitiveDetector* sd = new CaloSensitiveDetector(name, *dd4hep_geo, is_merge_enabled); warning() << name << " set to merge true/false = " << is_merge_enabled << endmsg; + for(auto cal_name : m_listCalsApplyBirks){ + if(cal_name==name){ + info() << name << " will apply Birks law" << endmsg; + sd->ApplyBirksLaw(); + break; + } + } + + return sd; } diff --git a/Simulation/DetSimSD/src/CalorimeterSensDetTool.h b/Simulation/DetSimSD/src/CalorimeterSensDetTool.h index 549de18d10ee548d6ba2daa3f2734d65f3b156ee..69bab1d4e5a5bde38b087ce14d54c8db1969dd96 100644 --- a/Simulation/DetSimSD/src/CalorimeterSensDetTool.h +++ b/Simulation/DetSimSD/src/CalorimeterSensDetTool.h @@ -30,6 +30,7 @@ private: SmartIF<IGeomSvc> m_geosvc; Gaudi::Property<std::vector<std::string> > m_listCalsMergeDisable{this, "CalNamesMergeDisable", {}}; + Gaudi::Property<std::vector<std::string> > m_listCalsApplyBirks{this, "CalNamesApplyBirks", {}}; }; #endif