Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
16 namespace JSIRENE {}
17 namespace JPP { using namespace JSIRENE; }
18 
19 namespace 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 = std::numeric_limits<int>::max();
37  }
38 
39  double Ecut_GeV; //!< minimal energy for generation of light from shower [GeV]
40  double Emin_GeV; //!< minimal energy of muon for shower generation [GeV]
41  double Dmin_m; //!< minimal distance for positioning [m]
42  double Emax_GeV; //!< maximal energy of muon below which step size is limited [GeV]
43  double Dmax_m; //!< maximal step size when limited [m]
44  double Tmax_ns; //!< maximal time between hits on same PMT to be merged
45  int Nmax_npe; //!< maximal number of photo-electrons
46  };
47 
48 
49  /**
50  * Auxiliary class to set-up Hit.
51  *
52  * This class is primarily used to limit the size of a Monte Carlo hit and
53  * thereby the memory usage of applications in case of large numbers of hits.
54  */
55  struct JHit_t
56  {
57  /**
58  * Constructor.
59  *
60  * \param id identifier
61  * \param pmt_id PMT identifier
62  * \param type type
63  * \param origin origin
64  * \param t time [ns]
65  * \param npe number of photo-electrons
66  */
67  JHit_t(const int id,
68  const int pmt_id,
69  const int type,
70  const int origin,
71  const double t,
72  const int npe)
73  {
74  this->id = id;
75  this->pmt_id = pmt_id;
76  this->type = type;
77  this->origin = origin;
78  this->t = t;
79  this->npe = npe;
80  }
81 
82 
83  /**
84  * Type conversion operator.
85  *
86  * \return hit
87  */
88  operator const Hit& () const
89  {
90  static Hit hit;
91 
92  hit.id = this->id;
93  hit.pmt_id = this->pmt_id;
94  hit.type = this->type;
95  hit.origin = this->origin;
96  hit.t = this->t;
97  hit.a = this->npe;
98 
99  return hit;
100  }
101 
102 
103  /**
104  * Less than operator for hits.
105  *
106  * First hit is defined as:
107  * -# smallest PMT identifier;
108  * -# earliest time if same PMT identifier;
109  *
110  * \param first first hit
111  * \param second second hit
112  * \return true if first hit earlier than second hit; else false
113  */
114  friend inline bool operator<(const JHit_t& first, const JHit_t& second)
115  {
116  if (first.pmt_id == second.pmt_id)
117  return first.t < second.t;
118  else
119  return first.pmt_id < second.pmt_id;
120  }
121 
122 
123  int id;
124  int pmt_id;
125  int type;
126  int origin;
127  double t;
128  int npe;
129  };
130 
131 
132  /**
133  * Auxiliary data structure for list of hits with hit merging capability.
134  */
135  struct JHits_t :
136  public std::vector<JHit_t>
137  {
138  /**
139  * Merge hits on same PMT that are within given time window.
140  *
141  * The earliest hit has the sum of the number of photo-electrons of all following hits within given time window.\n
142  * The hit identifiers are subsequently set in ascending order, starting at one.
143  *
144  * \param Tmax_ns maximal time difference [ns]
145  */
146  void merge(const double Tmax_ns)
147  {
148  using namespace std;
149 
150  if (!this->empty()) {
151 
152  sort(this->begin(), this->end());
153 
154  iterator in = this->begin();
155  iterator out = this->begin();
156 
157  out->id = 1; // set first hit identifier
158 
159  while (++in != this->end()) {
160 
161  if (out->pmt_id == in->pmt_id && in->t - out->t <= Tmax_ns) {
162 
163  out->npe += in->npe; // accumulate number of photo-electrons
164 
165  } else {
166 
167  int id = out->id;
168 
169  ++out; // increment desitination address
170 
171  *out = *in; // copy first new hit
172 
173  out->id = ++id; // set hit identifier
174  }
175  }
176 
177  this->erase(++out, this->end()); // remove hits
178  }
179  }
180  };
181 
182 
183  /**
184  * Auxiliary class to set-up Trk.
185  */
186  struct JTrk_t :
187  public Trk
188  {
189  /**
190  * Constructor.
191  *
192  * \param id identifier
193  * \param type type
194  * \param mother_id mother identifier
195  * \param pos position
196  * \param dir direction
197  * \param t time [ns]
198  * \param E energy [GeV]
199  */
200  JTrk_t(const int id,
201  const int type,
202  const int mother_id,
203  const Vec& pos,
204  const Vec& dir,
205  const double t,
206  const double E)
207  {
208  this->id = id;
209  this->type = type;
210  this->mother_id = mother_id;
211  this->pos = pos;
212  this->dir = dir;
213  this->t = t;
214  this->E = E;
215  }
216  };
217 }
218 
219 #endif
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:67
double Emax_GeV
maximal energy of muon below which step size is limited [GeV]
Definition: JSirene.hh:42
Detector simulation parameters.
Definition: JSirene.hh:24
then usage E
Definition: JMuonPostfit.sh:35
void merge(const double Tmax_ns)
Merge hits on same PMT that are within given time window.
Definition: JSirene.hh:146
Auxiliary class to set-up Trk.
Definition: JSirene.hh:186
JParameters()
Default constructor.
Definition: JSirene.hh:28
int pmt_id
global PMT identifier as found in evt files
Definition: Hit.hh:20
double Dmax_m
maximal step size when limited [m]
Definition: JSirene.hh:43
int origin
track id of the track that created this hit
Definition: Hit.hh:29
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Auxiliary data structure for list of hits with hit merging capability.
Definition: JSirene.hh:135
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:200
double a
hit amplitude (in p.e.)
Definition: Hit.hh:24
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
friend bool operator<(const JHit_t &first, const JHit_t &second)
Less than operator for hits.
Definition: JSirene.hh:114
double Dmin_m
minimal distance for positioning [m]
Definition: JSirene.hh:41
int id
Definition: Hit.hh:11
int Nmax_npe
maximal number of photo-electrons
Definition: JSirene.hh:45
double Tmax_ns
maximal time between hits on same PMT to be merged
Definition: JSirene.hh:44
double Ecut_GeV
minimal energy for generation of light from shower [GeV]
Definition: JSirene.hh:39
Definition: Hit.hh:8
double t
hit time (from tdc+calibration or MC truth)
Definition: Hit.hh:23
Auxiliary class to set-up Hit.
Definition: JSirene.hh:55
double Emin_GeV
minimal energy of muon for shower generation [GeV]
Definition: JSirene.hh:40
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
int type
particle type or parametrisation used for hit (mc only)
Definition: Hit.hh:28