Skip to content
Snippets Groups Projects
Commit 737ea913 authored by FU Chengdong's avatar FU Chengdong
Browse files

Merge branch 'master' of github.com:cepc/CEPCSW

parents 8e2c730a 1a58348e
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ public:
typedef G4THitsCollection<CalorimeterHit> CaloHitCollection;
public:
CaloSensitiveDetector(const std::string& name, dd4hep::Detector& description, bool unmerge=true);
CaloSensitiveDetector(const std::string& name, dd4hep::Detector& description, bool m_isMergeEnabled=true);
public:
// Geant4 interface
......@@ -31,7 +31,7 @@ protected:
HitCollection* m_hc;
std::map<unsigned long, CalorimeterHit*> m_hitMap;
bool m_unmerge;
bool m_isMergeEnabled;
};
......
......@@ -4,10 +4,10 @@
#include <algorithm>
CaloSensitiveDetector::CaloSensitiveDetector(const std::string& name, dd4hep::Detector& description, bool unmerge)
CaloSensitiveDetector::CaloSensitiveDetector(const std::string& name, dd4hep::Detector& description, bool is_merge_enabled)
: DDG4SensitiveDetector(name, description),
m_hc(nullptr),
m_unmerge(unmerge){
m_isMergeEnabled(is_merge_enabled){
const std::string& coll_name = m_sensitive.hitsCollection();
collectionName.insert(coll_name);
}
......@@ -37,19 +37,21 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step);
const std::string& name = GetName();
unsigned long id = getCellID( step );
//std::cout << name << " " << id << std::endl;
CalorimeterHit* hit=nullptr;
if(m_unmerge) hit=find(m_hc,dd4hep::sim::HitPositionCompare<CalorimeterHit>(pos));
else{
if(m_isMergeEnabled){
std::map<unsigned long, CalorimeterHit*>::iterator it = m_hitMap.find(id);
if(it!=m_hitMap.end()) hit = it->second;
}
else{
//Commented by fucd: hit position almost different, only very few hits found sucessfully, so discard to find since this option is disable merge
//hit=find(m_hc,dd4hep::sim::HitPositionCompare<CalorimeterHit>(pos));
}
// G4cout << "----------- Geant4GenericSD<Calorimeter>::buildHits : position : " << pos << G4endl;
if ( !hit ) {
hit = new CalorimeterHit(pos);
hit->cellID = id; //getCellID( step );
m_hc->insert(hit);
if(!m_unmerge) m_hitMap[id] = hit;
if(m_isMergeEnabled) m_hitMap[id] = hit;
}
hit->truth.push_back(contrib);
hit->energyDeposit += contrib.deposit;
......
......@@ -35,15 +35,15 @@ CalorimeterSensDetTool::createSD(const std::string& name) {
dd4hep::Detector* dd4hep_geo = m_geosvc->lcdd();
bool flagUnmerge = false;
for(auto cal_name : m_unmergeCals){
bool is_merge_enabled = true;
for(auto cal_name : m_listCalsMergeDisable){
if(cal_name==name){
flagUnmerge = true;
is_merge_enabled = false;
break;
}
}
G4VSensitiveDetector* sd = new CaloSensitiveDetector(name, *dd4hep_geo, flagUnmerge);
debug() << name << " set to merge true/false = " << !flagUnmerge << endmsg;
G4VSensitiveDetector* sd = new CaloSensitiveDetector(name, *dd4hep_geo, is_merge_enabled);
debug() << name << " set to merge true/false = " << is_merge_enabled << endmsg;
return sd;
}
......
......@@ -29,7 +29,7 @@ private:
// in order to initialize SD, we need to get the lcdd()
SmartIF<IGeomSvc> m_geosvc;
Gaudi::Property<std::vector<std::string> > m_unmergeCals{this, "UnmergedCalNames", {}};
Gaudi::Property<std::vector<std::string> > m_listCalsMergeDisable{this, "CalNamesMergeDisable", {}};
};
#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