Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:18:06

0001 #pragma once
0002 
0003 #include <map>
0004 #include <vector>
0005 
0006 #include <TObject.h>
0007 
0008 #include "OpticalPhoton.h"
0009 #include "ChargedParticleStep.h"
0010 
0011 namespace IRT2 {
0012 
0013 class RadiatorHistory: public TObject {
0014  public:
0015  RadiatorHistory(): m_EstimatedPath(0.0)/*, m_AverageTime(0.0)*/ {};
0016   ~RadiatorHistory() {
0017     for(auto photon: m_Photons)
0018       delete photon;
0019     m_Photons.clear(); 
0020 
0021     for(auto trace: m_Steps)
0022       delete trace;
0023     m_Steps.clear();
0024   };
0025 
0026   inline unsigned GetStepCount( void ) const { return m_Steps.size(); };
0027   inline void AddStep(ChargedParticleStep *step) { m_Steps.push_back(step); };
0028   inline void AddOpticalPhoton(OpticalPhoton *photon) { m_Photons.push_back(photon); };
0029 
0030   inline std::vector<OpticalPhoton*> &Photons( void )     { return m_Photons; };
0031   inline const ChargedParticleStep *GetStep(unsigned id) const { 
0032     return (id < m_Steps.size() ? m_Steps[id] : 0); 
0033   };
0034   inline unsigned StepCount( void ) { return m_Steps.size(); }; 
0035 
0036   void AddStepBufferPoint(double time, const TVector3 &x) {
0037     // Will be in ascending order of time;
0038     m_StepBuffer[time] = x;
0039   };
0040 
0041   void CalculateSteps(bool dirty = true) {
0042     // FIXME: memory leak;
0043     m_Steps.clear();
0044 
0045     // Add origin to the top of the buffer; FIXME: can times be negative 
0046     // as provided by GEANT?;
0047     if (m_StepBuffer.size() == 1) {
0048       if (!dirty) return;
0049 
0050       m_StepBuffer[0.0] = TVector3(0,0,0);
0051     } //if
0052 
0053     // FIXME: efficiency sucks here;
0054     std::vector<TVector3> buffer;
0055     for(auto entry: m_StepBuffer) 
0056       buffer.push_back(entry.second);
0057 
0058     for(unsigned iq=1; iq<buffer.size(); iq++) {
0059       m_Steps.push_back(new ChargedParticleStep(buffer[iq-1], 
0060                         (buffer[iq] - buffer[iq-1]).Unit()));
0061       // Well, would not hurt to add the last point in the same direction;
0062       if (iq == buffer.size()-1)
0063     m_Steps.push_back(new ChargedParticleStep(buffer[iq], 
0064                           (buffer[iq] - buffer[iq-1]).Unit()));
0065     } //for iq
0066   };
0067 
0068   // Average location, momentum and time of emission by this particle from this radiator
0069   // as evaluated by "calibration" photons which did not make it into the "detected" sample;
0070   TVector3 m_EstimatedVertex, m_AverageParentMomentum; //!
0071   double m_EstimatedPath;                              //!
0072   //double m_AverageTime;                              //!
0073 
0074   // Charged particle trajectory and optical photons generated in this radiator;
0075  private:
0076   std::vector<OpticalPhoton*> m_Photons;
0077   std::vector<ChargedParticleStep*> m_Steps;
0078 
0079   std::map<double, TVector3> m_StepBuffer;           //!
0080 
0081 #ifndef DISABLE_ROOT_IO
0082   ClassDef(RadiatorHistory, 1);
0083 #endif
0084 };
0085 
0086 } // namespace IRT2