File indexing completed on 2024-09-27 07:03:46
0001
0002 #include <map>
0003 #include <vector>
0004
0005 #include <TObject.h>
0006
0007 #ifndef _RADIATOR_HISTORY_
0008 #define _RADIATOR_HISTORY_
0009
0010 #include "OpticalPhoton.h"
0011 #include "ChargedParticleStep.h"
0012
0013 class RadiatorHistory: public TObject {
0014 public:
0015 RadiatorHistory() {};
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
0038 m_StepBuffer[time] = x;
0039 };
0040
0041 void CalculateSteps(bool dirty = true) {
0042
0043 m_Steps.clear();
0044
0045
0046
0047 if (m_StepBuffer.size() == 1) {
0048 if (!dirty) return;
0049
0050 m_StepBuffer[0.0] = TVector3(0,0,0);
0051 }
0052
0053
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
0062 if (iq == buffer.size()-1)
0063 m_Steps.push_back(new ChargedParticleStep(buffer[iq],
0064 (buffer[iq] - buffer[iq-1]).Unit()));
0065 }
0066 };
0067
0068
0069 private:
0070 std::vector<OpticalPhoton*> m_Photons;
0071 std::vector<ChargedParticleStep*> m_Steps;
0072
0073 std::map<double, TVector3> m_StepBuffer;
0074
0075 #ifndef DISABLE_ROOT_IO
0076 ClassDef(RadiatorHistory, 1);
0077 #endif
0078 };
0079
0080 #endif