Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 
0003 #include <vector>
0004 
0005 #include <TRef.h>
0006 
0007 #include "CherenkovRadiator.h"
0008 #include "RadiatorHistory.h"
0009 #include "TransientParticle.h"
0010 #include "CherenkovPID.h"
0011 #include "DigitizedHit.h"
0012 
0013 namespace IRT2 {
0014 
0015 class ChargedParticle: public TransientParticle {
0016  public:
0017  ChargedParticle(int pdg = 0, bool primary = true): 
0018   TransientParticle(pdg, primary), m_StopTracing(false), 
0019   m_HadronicInteractionOccured(false), m_GoodForReconstruction(true), m_EICreconParticleID(0) {};
0020   ~ChargedParticle() {  
0021     for(auto radiator: m_RadiatorHistory)
0022       delete radiator.second;
0023 
0024     // Typically will be empty anyway;
0025     if (m_OrphanPhotons.size()) {
0026       for(auto photon: m_OrphanPhotons)
0027     delete photon;
0028       m_OrphanPhotons.clear(); 
0029     } //if
0030      
0031     m_RadiatorHistory.clear();
0032   };
0033 
0034   bool IsCharged( void ) const { return true; };
0035   
0036   // FIXME: TRef does not allow one to use std::map -> resort to a vector; then 
0037   // have to do a stupid search; a couple of elements, so more intelligent schemes
0038   // are not really needed;
0039   inline RadiatorHistory *FindRadiatorHistory(CherenkovRadiator *radiator) const {
0040     for(auto rpair: m_RadiatorHistory)
0041       if (rpair.first == radiator)
0042     return rpair.second;
0043       
0044     return 0;
0045   };
0046 
0047   inline void AddOrphanPhoton(OpticalPhoton *photon) { m_OrphanPhotons.push_back(photon); };
0048   inline void StopTracing( void ) { m_StopTracing = true; };
0049   inline bool TracingIsStopped( void ) const { return m_StopTracing; };
0050   inline void StartRadiatorHistory(const std::pair<CherenkovRadiator*, RadiatorHistory*> &history) {
0051     m_RadiatorHistory.push_back(history);
0052   };
0053   inline /*const*/ std::vector<std::pair<TRef, RadiatorHistory*> > &GetRadiatorHistory( void ) /*const*/ {
0054     return m_RadiatorHistory;
0055   };
0056 
0057   // FIXME: this interface should be improved; 
0058   CherenkovRadiator *GetRadiator(const std::pair<TRef, RadiatorHistory*> &entry) {
0059     return dynamic_cast<CherenkovRadiator*>(entry.first.GetObject());
0060   };
0061   // FIXME: one of the dd4hep interface hacks;
0062   void SetRadiator(std::pair<TRef, RadiatorHistory*> &entry, CherenkovRadiator *radiator) {
0063     entry.first = radiator;
0064   };
0065   RadiatorHistory *GetHistory(/*const*/ std::pair<TRef, RadiatorHistory*> &entry) {
0066     return entry.second;
0067   };
0068 
0069   void SetRecoPdgCode(int pdg)                    { m_RecoPdgCode = pdg; };
0070   int GetRecoPdgCode( void )                const { return m_RecoPdgCode; };
0071   unsigned GetRecoCherenkovHitCount( void ) const { return m_Hits.size(); };
0072   DigitizedHit *GetRecoCherenkovHit(unsigned id) const { 
0073     return (id < m_Hits.size() ? m_Hits[id] : 0); 
0074   };
0075   double GetRecoCherenkovPhotonTheta(unsigned id);
0076   double GetRecoCherenkovPhotonPhi(unsigned id);
0077   double GetRecoCherenkovAverageTheta(CherenkovRadiator *radiator = 0);
0078   double GetMocaCherenkovAverageTheta(CherenkovRadiator *radiator = 0);
0079   unsigned GetRecoCherenkovPhotonCount(CherenkovRadiator *radiator = 0);
0080   
0081   void AddHit(DigitizedHit *hit) { m_Hits.push_back(hit); };
0082   
0083  private:
0084   // Optical photons produced elsewhere;
0085   std::vector<OpticalPhoton*> m_OrphanPhotons; 
0086 
0087   // Group steps by radiator of course; in the easiest case an entry and exit points;
0088   std::vector<std::pair<TRef, RadiatorHistory*> > m_RadiatorHistory;
0089 
0090   bool m_StopTracing;                //!
0091 
0092   int m_RecoPdgCode;                 //!
0093   std::vector<DigitizedHit*> m_Hits; //!
0094 
0095  public:
0096   bool m_HadronicInteractionOccured;
0097 
0098   bool IsGoodForReconstruction( void ) { return m_GoodForReconstruction; };
0099   bool m_GoodForReconstruction;      //!
0100 
0101   // Interface to ePIC tracking; 
0102   void SetEICreconParticleID(unsigned id) { m_EICreconParticleID = id;};
0103   unsigned m_EICreconParticleID;     //!
0104 
0105 #ifndef DISABLE_ROOT_IO
0106   ClassDef(ChargedParticle, 6);
0107 #endif
0108 };
0109 
0110 } // namespace IRT2