Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:06:28

0001 
0002 #include <vector>
0003 
0004 #include <TRef.h>
0005 
0006 #ifndef _CHARGED_PARTICLE_
0007 #define _CHARGED_PARTICLE_
0008 
0009 #include "CherenkovRadiator.h"
0010 #include "RadiatorHistory.h"
0011 #include "TransientParticle.h"
0012 #include "CherenkovPID.h"
0013 
0014 class ChargedParticle: public TransientParticle {
0015  public:
0016  ChargedParticle(int pdg = 0): TransientParticle(pdg), m_StopTracing(false) {};
0017   ~ChargedParticle() {  
0018     for(auto radiator: m_RadiatorHistory)
0019       delete radiator.second;
0020 
0021     // Typically will be empty anyway;
0022     if (m_OrphanPhotons.size()) {
0023       for(auto photon: m_OrphanPhotons)
0024     delete photon;
0025       m_OrphanPhotons.clear(); 
0026     } //if
0027      
0028     m_RadiatorHistory.clear();
0029   };
0030 
0031   bool IsCharged( void ) const { return true; };
0032   
0033   // FIXME: TRef does not allow one to use std::map -> resort to a vector; then 
0034   // have to do a stupid search; a couple of elements, so more intelligent schemes
0035   // are not really needed;
0036   inline RadiatorHistory *FindRadiatorHistory(CherenkovRadiator *radiator) const {
0037     for(auto rpair: m_RadiatorHistory)
0038       if (rpair.first == radiator)
0039     return rpair.second;
0040       
0041     return 0;
0042   };
0043 
0044   inline void AddOrphanPhoton(OpticalPhoton *photon) { m_OrphanPhotons.push_back(photon); };
0045   inline void StopTracing( void ) { m_StopTracing = true; };
0046   inline bool TracingIsStopped( void ) const { return m_StopTracing; };
0047   inline void StartRadiatorHistory(const std::pair<CherenkovRadiator*, RadiatorHistory*> &history) {
0048     m_RadiatorHistory.push_back(history);
0049   };
0050   inline /*const*/ std::vector<std::pair<TRef, RadiatorHistory*> > &GetRadiatorHistory( void ) /*const*/ {
0051     return m_RadiatorHistory;
0052   };
0053 
0054   // FIXME: this interface should be improved; 
0055   CherenkovRadiator *GetRadiator(const std::pair<TRef, RadiatorHistory*> &entry) {
0056     return dynamic_cast<CherenkovRadiator*>(entry.first.GetObject());
0057   };
0058   // FIXME: one of the dd4hep interface hacks;
0059   void SetRadiator(std::pair<TRef, RadiatorHistory*> &entry, CherenkovRadiator *radiator) {
0060     entry.first = radiator;
0061   };
0062   RadiatorHistory *GetHistory(/*const*/ std::pair<TRef, RadiatorHistory*> &entry) {
0063     return entry.second;
0064   };
0065 
0066   // Single particle case for now;
0067   void PIDReconstruction(CherenkovPID &pid);
0068 
0069  private:
0070   // Optical photons produced elsewhere;
0071   std::vector<OpticalPhoton*> m_OrphanPhotons; 
0072 
0073   // Group steps by radiator of course; in the easiest case an entry and exit points;
0074   std::vector<std::pair<TRef, RadiatorHistory*> > m_RadiatorHistory;
0075 
0076   bool m_StopTracing; //!
0077 
0078 #ifndef DISABLE_ROOT_IO
0079   ClassDef(ChargedParticle, 1);
0080 #endif
0081 };
0082 
0083 #endif