@@ -74,18 +74,22 @@ namespace {
7474class HitContributionAccumulator {
7575private:
7676 float m_energy{0 };
77+ float m_att_energy{0 };
7778 float m_avg_time{0 };
7879 float m_min_time{std::numeric_limits<float >::max ()};
7980 edm4hep::Vector3f m_avg_position{0 , 0 , 0 };
8081
8182public:
82- void add (const float energy, const float time, const edm4hep::Vector3f& pos) {
83+ void add (const float energy, const float attFactor, const float time,
84+ const edm4hep::Vector3f& pos) {
8385 m_energy += energy;
86+ m_att_energy += energy * attFactor;
8487 m_avg_time += energy * time;
8588 m_avg_position = m_avg_position + energy * pos;
8689 m_min_time = (time < m_min_time) ? time : m_min_time;
8790 }
8891 float getEnergy () const { return m_energy; }
92+ float getAttEnergy () const { return m_att_energy; }
8993 float getAvgTime () const { return m_energy > 0 ? m_avg_time / m_energy : 0 ; }
9094 float getMinTime () const { return m_min_time; }
9195 edm4hep::Vector3f getAvgPosition () const {
@@ -187,7 +191,7 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input
187191 const double totalTime = contrib.getTime () + propagationTime + m_cfg.fixedTimeDelay ;
188192 const int newhit_timeID = std::floor (totalTime / m_cfg.timeWindow );
189193 auto & hit_accum = hit_map[{primary, newhit_cellID, newhit_timeID}][newcontrib_cellID];
190- hit_accum.add (contrib.getEnergy () * attFactor, totalTime, ih.getPosition ());
194+ hit_accum.add (contrib.getEnergy (), attFactor, totalTime, ih.getPosition ());
191195 }
192196 }
193197
@@ -200,18 +204,21 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input
200204 const auto & [particle, cellID, timeID] = hit_idx;
201205 HitContributionAccumulator new_hit;
202206 for (const auto & [contrib_idx, contrib] : contribs) {
203- // Aggregate contributions to for the global hit
204- new_hit.add (contrib.getEnergy (), contrib.getMinTime (), contrib.getAvgPosition ());
207+ // Aggregate contributions to for the global hit; use effective "attenuation"
208+ new_hit.add (contrib.getEnergy (), contrib.getAttEnergy () / contrib.getEnergy (),
209+ contrib.getMinTime (), contrib.getAvgPosition ());
205210 // Now store the contribution itself
206211 auto out_hit_contrib = out_hit_contribs->create ();
212+ out_hit_contrib.setPDG (particle.getPDG ());
213+ out_hit_contrib.setEnergy (contrib.getEnergy ()); // UNattenuated energy
207214 out_hit_contrib.setTime (contrib.getMinTime ());
208- out_hit_contrib.setStepPosition (edm4hep::Vector3f{ 0 , 0 , contrib.getAvgPosition (). z } );
215+ out_hit_contrib.setStepPosition (contrib.getAvgPosition ());
209216 out_hit_contrib.setParticle (particle);
210217 out_hit.addToContributions (out_hit_contrib);
211218 }
212219 out_hit.setCellID (cellID);
213- out_hit.setEnergy (new_hit.getEnergy ());
214- out_hit.setPosition (edm4hep::Vector3f{ 0 , 0 , new_hit.getAvgPosition (). z } );
220+ out_hit.setEnergy (new_hit.getAttEnergy ()); // sum of attenuated energies
221+ out_hit.setPosition (new_hit.getAvgPosition ());
215222 }
216223}
217224
0 commit comments