Skip to content
Snippets Groups Projects
Unverified Commit 2f373cb4 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn Committed by GitHub
Browse files

Merge pull request #222 from fucd/birks

SIM: Birks option to apply energy correction for scintillator
parents fe22ec4e 730a9408
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,10 @@ detsimalg.AnaElems = [ ...@@ -88,6 +88,10 @@ detsimalg.AnaElems = [
] ]
detsimalg.RootDetElem = "WorldDetElemTool" detsimalg.RootDetElem = "WorldDetElemTool"
from Configurables import CalorimeterSensDetTool
cal_sensdettool = CalorimeterSensDetTool("CalorimeterSensDetTool")
cal_sensdettool.CalNamesApplyBirks = ["EcalBarrel"]
# output # output
from Configurables import PodioOutput from Configurables import PodioOutput
out = PodioOutput("outputalg") out = PodioOutput("outputalg")
......
...@@ -182,7 +182,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, ...@@ -182,7 +182,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
DetElement sd(ECAL, _toString(i,"trap%3d"), detid); DetElement sd(ECAL, _toString(i,"trap%3d"), detid);
sd.setPlacement(plv); sd.setPlacement(plv);
} }
sens.setType("calorimeter"); sens.setType("calorimeter");
ECAL.addExtension< LayeredCalorimeterData >( caloData ) ; ECAL.addExtension< LayeredCalorimeterData >( caloData ) ;
......
...@@ -23,6 +23,7 @@ public: ...@@ -23,6 +23,7 @@ public:
virtual void Initialize(G4HCofThisEvent* HCE); virtual void Initialize(G4HCofThisEvent* HCE);
virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history); virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history);
virtual void EndOfEvent(G4HCofThisEvent* HCE); virtual void EndOfEvent(G4HCofThisEvent* HCE);
void ApplyBirksLaw(){m_applyBirksLaw = true;};
protected: protected:
CalorimeterHit* find(const HitCollection*, const dd4hep::sim::HitCompare<CalorimeterHit>&); CalorimeterHit* find(const HitCollection*, const dd4hep::sim::HitCompare<CalorimeterHit>&);
...@@ -31,7 +32,8 @@ protected: ...@@ -31,7 +32,8 @@ protected:
HitCollection* m_hc; HitCollection* m_hc;
std::map<unsigned long, CalorimeterHit*> m_hitMap; std::map<unsigned long, CalorimeterHit*> m_hitMap;
bool m_isMergeEnabled; bool m_isMergeEnabled = false;
bool m_applyBirksLaw = false;
}; };
......
...@@ -33,6 +33,7 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) { ...@@ -33,6 +33,7 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
// std::cout << "CaloSensitiveDetector::ProcessHits" << std::endl; // std::cout << "CaloSensitiveDetector::ProcessHits" << std::endl;
dd4hep::sim::Geant4StepHandler h(step); dd4hep::sim::Geant4StepHandler h(step);
if(m_applyBirksLaw) h.doApplyBirksLaw();
dd4hep::Position pos = 0.5 * (h.prePos() + h.postPos()); dd4hep::Position pos = 0.5 * (h.prePos() + h.postPos());
HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step); HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step);
const std::string& name = GetName(); const std::string& name = GetName();
...@@ -62,9 +63,9 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) { ...@@ -62,9 +63,9 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
m_hc->insert(hit); m_hc->insert(hit);
} }
hit->truth.push_back(contrib); 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; return true;
} }
......
...@@ -42,9 +42,19 @@ CalorimeterSensDetTool::createSD(const std::string& name) { ...@@ -42,9 +42,19 @@ CalorimeterSensDetTool::createSD(const std::string& name) {
break; 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; 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; return sd;
} }
......
...@@ -30,6 +30,7 @@ private: ...@@ -30,6 +30,7 @@ private:
SmartIF<IGeomSvc> m_geosvc; SmartIF<IGeomSvc> m_geosvc;
Gaudi::Property<std::vector<std::string> > m_listCalsMergeDisable{this, "CalNamesMergeDisable", {}}; Gaudi::Property<std::vector<std::string> > m_listCalsMergeDisable{this, "CalNamesMergeDisable", {}};
Gaudi::Property<std::vector<std::string> > m_listCalsApplyBirks{this, "CalNamesApplyBirks", {}};
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment