Jpp  18.0.0-rc.2
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 = 25.0;
37  Nmax_PMT = std::numeric_limits<size_t>::max();
38  }
39 
40  double Ecut_GeV; //!< minimal energy for generation of light from shower [GeV]
41  double Emin_GeV; //!< minimal energy of muon for shower generation [GeV]
42  double Dmin_m; //!< minimal distance for positioning [m]
43  double Emax_GeV; //!< maximal energy of muon below which step size is limited [GeV]
44  double Dmax_m; //!< maximal step size when limited [m]
45  double Tmax_ns; //!< maximal time between hits on same PMT to be merged
46  double Nmax_NPE; //!< maximal number of photo-electrons of low probability regime
47  size_t Nmax_PMT; //!< maximal number of photo-electrons on PMT
48  };
49 
50 
51  /**
52  * Auxiliary class to set-up Hit.
53  *
54  * This class is primarily used to limit the size of a Monte Carlo hit and
55  * thereby the memory usage of applications in case of large numbers of hits.
56  */
57  struct JHit_t
58  {
59  /**
60  * Constructor.
61  *
62  * \param id identifier
63  * \param pmt_id PMT identifier
64  * \param type type
65  * \param origin origin
66  * \param t time [ns]
67  * \param npe number of photo-electrons
68  */
69  JHit_t(const int id,
70  const int pmt_id,
71  const int type,
72  const int origin,
73  const double t,
74  const int npe)
75  {
76  this->id = id;
77  this->pmt_id = pmt_id;
78  this->type = type;
79  this->origin = origin;
80  this->t = t;
81  this->npe = npe;
82  }
83 
84 
85  /**
86  * Type conversion operator.
87  *
88  * \return hit
89  */
90  operator const Hit& () const
91  {
92  static Hit hit;
93 
94  hit.id = this->id;
95  hit.pmt_id = this->pmt_id;
96  hit.type = this->type;
97  hit.origin = this->origin;
98  hit.t = this->t;
99  hit.a = this->npe;
100 
101  return hit;
102  }
103 
104 
105  /**
106  * Less than operator for hits.
107  *
108  * First hit is defined as:
109  * -# smallest PMT identifier;
110  * -# earliest time if same PMT identifier;
111  *
112  * \param first first hit
113  * \param second second hit
114  * \return true if first hit earlier than second hit; else false
115  */
116  friend inline bool operator<(const JHit_t& first, const JHit_t& second)
117  {
118  if (first.pmt_id == second.pmt_id)
119  return first.t < second.t;
120  else
121  return first.pmt_id < second.pmt_id;
122  }
123 
124 
125  int id;
126  int pmt_id;
127  int type;
128  int origin;
129  double t;
130  int npe;
131  };
132 
133 
134  /**
135  * Auxiliary data structure for list of hits with hit merging capability.
136  */
137  struct JHits_t :
138  public std::vector<JHit_t>
139  {
140  /**
141  * Merge hits on same PMT that are within given time window.
142  *
143  * The earliest hit has the sum of the number of photo-electrons of all following hits within given time window.\n
144  * The hit identifiers are subsequently set in ascending order, starting at one.
145  *
146  * \param Tmax_ns maximal time difference [ns]
147  */
148  void merge(const double Tmax_ns)
149  {
150  using namespace std;
151 
152  if (!this->empty()) {
153 
154  sort(this->begin(), this->end());
155 
156  iterator in = this->begin();
157  iterator out = this->begin();
158 
159  out->id = 1; // set first hit identifier
160 
161  while (++in != this->end()) {
162 
163  if (out->pmt_id == in->pmt_id && in->t - out->t <= Tmax_ns) {
164 
165  out->npe += in->npe; // accumulate number of photo-electrons
166 
167  } else {
168 
169  int id = out->id;
170 
171  ++out; // increment desitination address
172 
173  *out = *in; // copy first new hit
174 
175  out->id = ++id; // set hit identifier
176  }
177  }
178 
179  this->erase(++out, this->end()); // remove hits
180  }
181  }
182  };
183 
184 
185  /**
186  * Auxiliary class to set-up Trk.
187  */
188  struct JTrk_t :
189  public Trk
190  {
191  /**
192  * Constructor.
193  *
194  * \param id identifier
195  * \param type type
196  * \param mother_id mother identifier
197  * \param pos position
198  * \param dir direction
199  * \param t time [ns]
200  * \param E energy [GeV]
201  */
202  JTrk_t(const int id,
203  const int type,
204  const int mother_id,
205  const Vec& pos,
206  const Vec& dir,
207  const double t,
208  const double E)
209  {
210  this->id = id;
211  this->type = type;
212  this->mother_id = mother_id;
213  this->pos = pos;
214  this->dir = dir;
215  this->t = t;
216  this->E = E;
217  }
218  };
219 }
220 
221 #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:69
double Emax_GeV
maximal energy of muon below which step size is limited [GeV]
Definition: JSirene.hh:43
Detector simulation parameters.
Definition: JSirene.hh:24
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:36
void merge(const double Tmax_ns)
Merge hits on same PMT that are within given time window.
Definition: JSirene.hh:148
double Nmax_NPE
maximal number of photo-electrons of low probability regime
Definition: JSirene.hh:46
Auxiliary class to set-up Trk.
Definition: JSirene.hh:188
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:44
int origin
track id of the track that created this hit (mc only)
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:137
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:202
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:116
double Dmin_m
minimal distance for positioning [m]
Definition: JSirene.hh:42
int id
Definition: Hit.hh:11
double Tmax_ns
maximal time between hits on same PMT to be merged
Definition: JSirene.hh:45
double Ecut_GeV
minimal energy for generation of light from shower [GeV]
Definition: JSirene.hh:40
size_t Nmax_PMT
maximal number of photo-electrons on PMT
Definition: JSirene.hh:47
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:57
double Emin_GeV
minimal energy of muon for shower generation [GeV]
Definition: JSirene.hh:41
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