diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude_1mm.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude_1mm.py index 07d0d7bce2c573c758960d70bb08166531f01cfe..bd8ff71d42b580ed72355f873d6d2673fa840a0a 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude_1mm.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude_1mm.py @@ -1,5 +1,9 @@ from AthenaCommon.CfgGetter import getPublicTool stepInfoSDTool = getPublicTool("SensitiveDetectorMasterTool").SensitiveDetectors['FCS_StepInfoSensitiveDetector'] -stepInfoSDTool.shift_lar_subhit=True +stepInfoSDTool.shift_lar_subhit=True #default stepInfoSDTool.shorten_lar_step=True -stepInfoSDTool.maxRadiusLAr=1 +stepInfoSDTool.maxRadiusFine=1. #default (for EMB1 and EME1) +stepInfoSDTool.maxRadius=25. #default +stepInfoSDTool.maxRadiusTile=25. #default +stepInfoSDTool.maxTime=25. #default +stepInfoSDTool.maxTimeTile=100. #default diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSD.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSD.h index 1a4c3410976fc92b0ea63abb5afeec716db9e01d..ee742efedf1447cde24ad14d664d911157a0a840 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSD.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSD.h @@ -45,6 +45,7 @@ namespace FCS_Param { // Merging properties double m_maxRadius=25.; //!< property, see @link LArG4GenShowerLib::LArG4GenShowerLib @endlink + double m_maxRadiusFine=1.; //!< property, see @link LArG4GenShowerLib::LArG4GenShowerLib @endlink double m_maxRadiusLAr=25.; //!< property, see @link LArG4GenShowerLib::LArG4GenShowerLib @endlink double m_maxRadiusHEC=100.; //!< property, see @link LArG4GenShowerLib::LArG4GenShowerLib @endlink double m_maxRadiusFCAL=100.; //!< property, see @link LArG4GenShowerLib::LArG4GenShowerLib @endlink diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSDTool.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSDTool.cxx index 0068ce2db88ba7a9278f0f84cb0b1700916521cf..0426231ce438c151460149aee4c5fedf5be1f537 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSDTool.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/FCS_StepInfoSDTool.cxx @@ -92,6 +92,7 @@ namespace FCS_Param declareProperty("shorten_lar_step",m_config.shorten_lar_step, ""); declareProperty("maxRadius",m_config.m_maxRadius, ""); + declareProperty("maxRadiusFine",m_config.m_maxRadiusFine, ""); declareProperty("maxRadiusLAr",m_config.m_maxRadiusLAr, ""); declareProperty("maxRadiusHEC",m_config.m_maxRadiusHEC, ""); declareProperty("maxRadiusFCAL",m_config.m_maxRadiusFCAL, ""); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx index 4213a4db1312ccc49ff67f3b569191f29c233707..8ea078a67f5edd96ef11c4b02797ed839eb19217 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.cxx @@ -213,6 +213,50 @@ G4bool LArFCS_StepInfoSD::ProcessHits(G4Step* a_step,G4TouchableHistory*) return result; } +void LArFCS_StepInfoSD::update_map(const CLHEP::Hep3Vector & l_vec, const Identifier & l_cell, double l_energy, double l_time, bool l_valid, int l_detector) +{ + // Drop any hits that don't have a good identifier attached + if (!m_calo_dd_man->get_element(l_cell)) { + if(m_config.verboseLevel > 4) { + G4cout<<this->GetName()<<" DEBUG update_map: bad identifier: "<<l_cell.getString()<<" skipping this hit."<<G4endl; + } + return; + } + + auto map_item = m_hit_map.find( l_cell ); + if (map_item==m_hit_map.end()) { + m_hit_map[l_cell] = new std::vector< ISF_FCS_Parametrization::FCS_StepInfo* >; + m_hit_map[l_cell]->reserve(200); + m_hit_map[l_cell]->push_back( new ISF_FCS_Parametrization::FCS_StepInfo( l_vec , l_cell , l_energy , l_time , l_valid , l_detector ) ); + } + else { + // Get the appropriate merging limits + const CaloCell_ID::CaloSample& layer = m_calo_dd_man->get_element(l_cell)->getSampling(); + const double tsame(m_config.m_maxTime); + const double maxRadius((layer == CaloCell_ID::EMB1 || layer == CaloCell_ID::EME1) ? m_config.m_maxRadiusFine : m_config.m_maxRadius); //Default 1mm merging in layers 1 & 5, 5mm merging elsewhere + bool match = false; + for (auto map_it : * map_item->second) { + // Time check + const double delta_t = std::fabs(map_it->time()-l_time); + if ( delta_t >= tsame ) { continue; } + // Distance check + const CLHEP::Hep3Vector & currentPosition = map_it->position(); + const double hit_diff2 = currentPosition.diff2( l_vec ); + if ( hit_diff2 >= maxRadius ) { continue; } + + // Found a match. Make a temporary that will be deleted! + const ISF_FCS_Parametrization::FCS_StepInfo my_info( l_vec , l_cell , l_energy , l_time , l_valid , l_detector ); + *map_it += my_info; + match = true; + break; + } // End of search for match in time and space + if (!match) { + map_item->second->push_back( new ISF_FCS_Parametrization::FCS_StepInfo( l_vec , l_cell , l_energy , l_time , l_valid , l_detector ) ); + } // Didn't match + } // ID already in the map + return; +} // That's it for updating the map! + Identifier LArFCS_StepInfoSD::ConvertID(const LArG4Identifier& a_ident) const { Identifier id; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.h index e5756d43a11aecd4e249103047392535d9ba3bcb..f450ae96bad837443280b5124748a025304b7598 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimSD/src/LArFCS_StepInfoSD.h @@ -41,6 +41,11 @@ public: G4bool ProcessHits(G4Step* a_step, G4TouchableHistory*) override; private: + /// Keep a map instead of trying to keep the full vector. + /// At the end of the event we'll push the map back into the + /// FCS_StepInfoCollection in StoreGate. + virtual void update_map(const CLHEP::Hep3Vector & l_vec, const Identifier & l_cell, double l_energy, double l_time, bool l_valid, int l_detector) override final; + /// Helper function for making "real" identifiers from LArG4Identifiers Identifier ConvertID(const LArG4Identifier& a_ident) const;