Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JSirene.hh
Go to the documentation of this file.
1#ifndef __JSIRENE__JSIRENE__
2#define __JSIRENE__JSIRENE__
3
4#include <limits>
5#include <vector>
6#include <algorithm>
7
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JSIRENE {}
17namespace JPP { using namespace JSIRENE; }
18
19namespace JSIRENE {
20
21 /**
22 * Detector simulation parameters.
23 */
24 struct JParameters {
25 /**
26 * Default constructor.
27 */
29 {
30 Ecut_GeV = 0.1;
31 Emin_GeV = 1.0;
32 Dmin_m = 0.1;
33 Emax_GeV = 250.0;
34 Dmax_m = 10.0;
35 Tmax_ns = 0.1;
36 Nmax_NPE = 25.0;
37 Nmax_PMT = std::numeric_limits<size_t>::max();
38 Tmin_GeV = 0.2;
39 }
40
41 double Ecut_GeV; //!< minimal energy for generation of light from shower [GeV]
42 double Emin_GeV; //!< minimal energy of muon for shower generation [GeV]
43 double Dmin_m; //!< minimal distance for positioning [m]
44 double Emax_GeV; //!< maximal energy of muon below which step size is limited [GeV]
45 double Dmax_m; //!< maximal step size when limited [m]
46 double Tmax_ns; //!< maximal time between hits on same PMT to be merged
47 double Nmax_NPE; //!< maximal number of photo-electrons of low probability regime
48 size_t Nmax_PMT; //!< maximal number of photo-electrons on PMT
49 double Tmin_GeV; //!< minimal kinetic energy of delta-rays for shower generation [GeV]
50 };
51
52
53 /**
54 * Auxiliary class to set-up Hit.
55 *
56 * This class is primarily used to limit the size of a Monte Carlo hit and
57 * thereby the memory usage of applications in case of large numbers of hits.
58 */
59 struct JHit_t
60 {
61 /**
62 * Constructor.
63 *
64 * \param id identifier
65 * \param pmt_id PMT identifier
66 * \param type type
67 * \param origin origin
68 * \param t time [ns]
69 * \param npe number of photo-electrons
70 */
71 JHit_t(const int id,
72 const int pmt_id,
73 const int type,
74 const int origin,
75 const double t,
76 const int npe)
77 {
78 this->id = id;
79 this->pmt_id = pmt_id;
80 this->type = type;
81 this->origin = origin;
82 this->t = t;
83 this->npe = npe;
84 }
85
86
87 /**
88 * Type conversion operator.
89 *
90 * \return hit
91 */
92 operator const Hit& () const
93 {
94 static Hit hit;
95
96 hit.id = this->id;
97 hit.pmt_id = this->pmt_id;
98 hit.type = this->type;
99 hit.origin = this->origin;
100 hit.t = this->t;
101 hit.a = this->npe;
102
103 return hit;
104 }
105
106
107 /**
108 * Less than operator for hits.
109 *
110 * First hit is defined as:
111 * -# smallest PMT identifier;
112 * -# earliest time if same PMT identifier;
113 *
114 * \param first first hit
115 * \param second second hit
116 * \return true if first hit earlier than second hit; else false
117 */
118 friend inline bool operator<(const JHit_t& first, const JHit_t& second)
119 {
120 if (first.pmt_id == second.pmt_id)
121 return first.t < second.t;
122 else
123 return first.pmt_id < second.pmt_id;
124 }
125
126
127 int id;
129 int type;
131 double t;
132 int npe;
133 };
134
135
136 /**
137 * Auxiliary data structure for list of hits with hit merging capability.
138 */
139 struct JHits_t :
140 public std::vector<JHit_t>
141 {
142 /**
143 * Merge hits on same PMT that are within given time window.
144 *
145 * The earliest hit has the sum of the number of photo-electrons of all following hits within given time window.\n
146 * The hit identifiers are subsequently set in ascending order, starting at one.
147 *
148 * \param Tmax_ns maximal time difference [ns]
149 */
150 void merge(const double Tmax_ns)
151 {
152 using namespace std;
153
154 if (!this->empty()) {
155
156 sort(this->begin(), this->end());
157
158 iterator in = this->begin();
159 iterator out = this->begin();
160
161 out->id = 1; // set first hit identifier
162
163 while (++in != this->end()) {
164
165 if (out->pmt_id == in->pmt_id && in->t - out->t <= Tmax_ns) {
166
167 out->npe += in->npe; // accumulate number of photo-electrons
168
169 } else {
170
171 int id = out->id;
172
173 ++out; // increment desitination address
174
175 *out = *in; // copy first new hit
176
177 out->id = ++id; // set hit identifier
178 }
179 }
180
181 this->erase(++out, this->end()); // remove hits
182 }
183 }
184 };
185
186
187 /**
188 * Auxiliary class to set-up Trk.
189 */
190 struct JTrk_t :
191 public Trk
192 {
193 /**
194 * Constructor.
195 *
196 * \param id identifier
197 * \param type type
198 * \param mother_id mother identifier
199 * \param pos position
200 * \param dir direction
201 * \param t time [ns]
202 * \param E energy [GeV]
203 */
204 JTrk_t(const int id,
205 const int type,
206 const int mother_id,
207 const Vec& pos,
208 const Vec& dir,
209 const double t,
210 const double E)
211 {
212 this->id = id;
213 this->type = type;
214 this->mother_id = mother_id;
215 this->pos = pos;
216 this->dir = dir;
217 this->t = t;
218 this->E = E;
219 }
220 };
221}
222
223#endif
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition Hit.hh:10
int pmt_id
global PMT identifier as found in evt files
Definition Hit.hh:20
int origin
track id of the track that created this hit (mc only)
Definition Hit.hh:29
double a
hit amplitude (in p.e.)
Definition Hit.hh:24
int id
Definition Hit.hh:11
int type
particle type or parametrisation used for hit (mc only)
Definition Hit.hh:28
double t
hit time (from tdc+calibration or MC truth)
Definition Hit.hh:23
Auxiliary class to set-up Hit.
Definition JSirene.hh:60
friend bool operator<(const JHit_t &first, const JHit_t &second)
Less than operator for hits.
Definition JSirene.hh:118
JHit_t(const int id, const int pmt_id, const int type, const int origin, const double t, const int npe)
Constructor.
Definition JSirene.hh:71
Auxiliary data structure for list of hits with hit merging capability.
Definition JSirene.hh:141
void merge(const double Tmax_ns)
Merge hits on same PMT that are within given time window.
Definition JSirene.hh:150
Detector simulation parameters.
Definition JSirene.hh:24
size_t Nmax_PMT
maximal number of photo-electrons on PMT
Definition JSirene.hh:48
double Tmin_GeV
minimal kinetic energy of delta-rays for shower generation [GeV]
Definition JSirene.hh:49
double Dmin_m
minimal distance for positioning [m]
Definition JSirene.hh:43
JParameters()
Default constructor.
Definition JSirene.hh:28
double Dmax_m
maximal step size when limited [m]
Definition JSirene.hh:45
double Nmax_NPE
maximal number of photo-electrons of low probability regime
Definition JSirene.hh:47
double Emax_GeV
maximal energy of muon below which step size is limited [GeV]
Definition JSirene.hh:44
double Emin_GeV
minimal energy of muon for shower generation [GeV]
Definition JSirene.hh:42
double Tmax_ns
maximal time between hits on same PMT to be merged
Definition JSirene.hh:46
double Ecut_GeV
minimal energy for generation of light from shower [GeV]
Definition JSirene.hh:41
Auxiliary class to set-up Trk.
Definition JSirene.hh:192
JTrk_t(const int id, const int type, const int mother_id, const Vec &pos, const Vec &dir, const double t, const double E)
Constructor.
Definition JSirene.hh:204
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int type
MC: particle type in PDG encoding.
Definition Trk.hh:24
int id
track identifier
Definition Trk.hh:16
Vec dir
track direction
Definition Trk.hh:18
double E
Energy [GeV] (either MC truth or reconstructed)
Definition Trk.hh:20
double t
track time [ns] (when the particle is at pos )
Definition Trk.hh:19
int mother_id
id of the parent MC particle or of the reconstructed track at the previous stage
Definition Trk.hh:29
Vec pos
postion [m] of the track at time t
Definition Trk.hh:17
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition Vec.hh:13