Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
JMuonBundleCategory.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JMUONBUNDLECATEGORY__
2 #define __JAANET__JMUONBUNDLECATEGORY__
3 
4 #include <iostream>
5 
7 
10 
11 #include "JLang/JClonable.hh"
12 
13 #include "JTools/JRange.hh"
14 
15 #include "JGeometry3D/JVector3D.hh"
18 #include "JGeometry3D/JTrack3E.hh"
19 
20 #include "JMath/JMathToolkit.hh"
21 
22 #include "JAAnet/JHead.hh"
23 #include "JAAnet/JHeadToolkit.hh"
24 #include "JAAnet/JEvtCategory.hh"
25 #include "JAAnet/JAAnetToolkit.hh"
26 
27 
28 /**
29  * \file
30  *
31  * Classes and methods for defining muon bundle categories.
32  * \author bjung
33  */
34 namespace JAANET {}
35 namespace JPP { using namespace JAANET; }
36 
37 namespace JAANET {
38 
39  using JLANG::JClonable;
40 
41  using JTOOLS::JRange;
42 
43 
44  static const JRange<double> DEFAULT_BUNDLE_ENERGY_RANGE = JRange<double>(0, 1e11); //!< Default bundle energy range [GeV]
45  static const JRange<double> DEFAULT_BUNDLE_COSINE_ZENITH_ANGLE_RANGE = JRange<double>(0.0, 1.0); //!< Default bundle cosine zenith angle range [-]
46  static const JRange<int> DEFAULT_BUNDLE_MULTIPLICITY_RANGE = JRange<int> (0, 1000); //!< Default bundle multiplicity range [-]
47  static const double DEFAULT_BUNDLE_RADIAL_EXTENT = 1e5; //!< Default bundle radial extent [m]
48 
49 
50  /**
51  * Auxiliary function to check if given PDG code corresponds to a valid muon bundle primary type.
52  *
53  * \param type PDG type
54  * \return true if given PDG type corresponds to a valid muon bundle primary type; else false
55  */
56  inline bool is_muon_bundle_primary(const int type)
57  {
58  using namespace std;
59 
60  const int absType = abs(type);
61  const string typeStr = to_string(absType);
62 
63  return ( (absType == PDG_MUONBUNDLE || // MUPAGE
64  absType == TRACK_TYPE_MUON) ||
65  (typeStr.size() == 10 && typeStr.substr(0,2) == "10") || // CORSIKA nuclei
66  (absType != TRACK_TYPE_PHOTON && // CORSIKA single baryon primaries (e.g. proton or neutron)
67  absType != TRACK_TYPE_ELECTRON &&
68  absType != TRACK_TYPE_MUON &&
69  absType != TRACK_TYPE_TAU &&
70  absType != TRACK_TYPE_NUE &&
71  absType != TRACK_TYPE_NUMU &&
72  absType != TRACK_TYPE_NUTAU &&
73  ((int)(absType / 1000)) % 10 != 0) );
74  }
75 
76 
77  /**
78  * Class for muon bundle categories.
79  */
80  struct JMuonBundleCategory final :
81  public JClonable<JEvtCategory, JMuonBundleCategory>
82  {
83  /**
84  * Default constructor.
85  */
91  {}
92 
93 
94  /**
95  * Constructor.
96  *
97  * \param primaryType cosmic-ray primary PDG identifier
98  */
99  JMuonBundleCategory(const int primaryType) :
104  {
105  this->primaryType = primaryType;
106 
107  check_validity();
108  }
109 
110 
111  /**
112  * Constructor.
113  *
114  * \param primaryType cosmic-ray primary PDG identifier
115  * \param Erange energy range
116  * \param coszRange cosine zenith-angle range
117  * \param Mrange multiplicity range
118  * \param Rmax maximum radial extent
119  */
120  JMuonBundleCategory(const int primaryType,
121  const JRange<double>& Erange,
122  const JRange<double>& coszRange,
123  const JRange<int>& Mrange,
124  const double Rmax) :
125  Erange (Erange),
127  Mrange (Mrange),
128  Rmax (Rmax)
129  {
130  this->primaryType = primaryType;
131 
132  check_validity();
133  }
134 
135 
136  /**
137  * Constructor.
138  *
139  * \param header MC header
140  */
141  JMuonBundleCategory(const JHead& header) :
143  {
144  using namespace std;
145  using namespace JPP;
146 
147  if (is_mupage(header)) {
148  this->primaryType = PDG_MUONBUNDLE;
149  this->Erange = header.cut_in.E;
150  this->coszRange = header.cut_in.cosT;
151  } else if (is_corsika(header)) {
152  this->primaryType = header.primary.type;
153  this->Erange = header.cut_primary.E;
154  this->coszRange = header.cut_primary.cosT;
155  }
156 
157  check_validity();
158  }
159 
160 
161  /**
162  * Check if muon bundle category is valid.
163  *
164  * \return true if muon bundle category is valid; else false
165  */
166  inline bool is_valid() const override final
167  {
168  return (is_muon_bundle_primary(this->primaryType) &&
169  Erange .is_valid() &&
170  coszRange.is_valid() &&
171  Mrange.getLowerLimit() >= 0 &&
172  Mrange .is_valid() &&
173  Rmax > 0);
174  }
175 
176 
177  /**
178  * Check whether this event category matches with the given MC header.
179  *
180  * \param header header
181  * \return true if matching; else false
182  */
183  bool match(const JHead& header) const override final
184  {
185  if (is_mupage(header) || is_corsika(header)) {
186 
187  const JMuonBundleCategory cat(header);
188 
189  return (this->primaryType == cat.getPrimaryType() &&
190  this->Erange .overlap (cat.Erange) &&
191  this->coszRange.overlap (cat.coszRange));
192 
193  } else {
194 
195  return false;
196  }
197  }
198 
199 
200  /**
201  * Check whether given event matches with this event category.
202  *
203  * \param event event
204  * \return true if matching; else false
205  */
206  bool match(const Evt& event) const override final
207  {
208  using namespace std;
209  using namespace JPP;
210 
211  const Trk& primary = get_primary(event);
212 
213  if (!(is_muonbundle(primary) || is_muon(primary)) ||
214  !Erange ( primary.E) ||
215  !coszRange(-primary.dir.z)) { return false; }
216 
218  Rmax == DEFAULT_BUNDLE_RADIAL_EXTENT) { return true; }
219 
220  const JTrack3E& tp = getTrack(primary);
221  const JDirection3D& dp = tp.getDirection();
222  const JPosition3D& pp = tp.getPosition();
223 
224  int multiplicity = 0;
225  double maxR = 0.0;
226 
227  for (vector<Trk>::const_iterator i = event.mc_trks.cbegin(); i != event.mc_trks.cend(); ++i) {
228  if (is_finalstate(*i) && is_muon(*i)) {
229 
230  const JTrack3E& ti = getTrack(*i);
231  const JPosition3D& pi = ti.getPosition();
232 
233  const double R = getCross<JVector3D>(dp, pi - pp).getLength();
234 
235  if (R > maxR) { maxR = R; }
236 
237  ++multiplicity;
238  }
239  }
240 
241  return (Mrange(multiplicity) && maxR < Rmax);
242  }
243 
244 
245  /**
246  * Less-than method.
247  *
248  * Note: The energy, cosine zenith-angle and multiplicity ranges are compared based on the lower limit first.\n
249  * If the lower limits are equal, the upper limits are compared.
250  *
251  * \param category event category
252  * \return true if first this event category less than given event category; else false
253  */
254  inline bool less(const JEvtCategory& category) const override final
255  {
256 #define RETURN_IF_DIFFERENT_RANGE(A, B) \
257  if (A != B) { return (A.getLowerLimit() == B.getLowerLimit() ? \
258  A.getUpperLimit() < B.getUpperLimit() : \
259  A.getLowerLimit() < B.getLowerLimit() ); }
260 
261  if (this->primaryType != category.getPrimaryType()) {
262  return this->primaryType < category.getPrimaryType();
263  }
264 
265  const JMuonBundleCategory* p = dynamic_cast<const JMuonBundleCategory*>(&category);
266 
267  if (p == NULL) { return false; }
268 
272 
273  return this->Rmax < p->Rmax;
274 
275 #undef RETURN_IF_DIFFERENT_RANGE
276  }
277 
278 
279  /**
280  * Get properties of this class.
281  *
282  * \param equation equation parameters
283  */
285  {
286  return JMuonBundleCategoryHelper(*this, equation);
287  }
288 
289 
290  /**
291  * Get properties of this class.
292  *
293  * \param equation equation parameters
294  */
296  {
297  return JMuonBundleCategoryHelper(*this, equation);
298  }
299 
300 
301  private:
302 
303  JRange<double> Erange; //!< energy range [GeV]
304  JRange<double> coszRange; //!< cosine zenith-angle range [-]
305  JRange<int> Mrange; //!< multiplicity range [-]
306  double Rmax; //!< maximum radial extent [m]
307 
308 
309  /**
310  * Auxiliary class for I/O of muon bundle category.
311  */
313  public JProperties
314  {
315  /**
316  * Constructor.
317  *
318  * \param cat muon bundle category
319  * \param equation equation parameters
320  */
321  template<class JMuonBundleCategory_t>
322  JMuonBundleCategoryHelper(JMuonBundleCategory_t& cat,
323  const JEquationParameters& equation) :
324  JProperties(equation, 1)
325  {
326  this->insert(gmake_property(cat.primaryType));
327  this->insert(gmake_property(cat.Erange));
328  this->insert(gmake_property(cat.coszRange));
329  this->insert(gmake_property(cat.Mrange));
330  this->insert(gmake_property(cat.Rmax));
331  }
332  };
333  };
334 }
335 
336 #endif
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Auxiliary methods for geometrical methods.
#define RETURN_IF_DIFFERENT_RANGE(A, B)
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class to define a range between two values.
Monte Carlo run header.
Definition: JHead.hh:1236
JAANET::cut_in cut_in
Definition: JHead.hh:1595
JAANET::primary primary
Definition: JHead.hh:1611
JAANET::cut_primary cut_primary
Definition: JHead.hh:1593
Utility class to parse parameter values.
Definition: JProperties.hh:501
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:35
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JTrack3D.hh:147
3D track with energy.
Definition: JTrack3E.hh:32
double getLength() const
Get length.
Definition: JVector3D.hh:246
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Range of values.
Definition: JRange.hh:42
bool is_valid() const
Check validity of range.
Definition: JRange.hh:311
bool overlap(const range_type &range) const
Test overlap with given range.
Definition: JRange.hh:382
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
Extensions to Evt data format.
const Trk & get_primary(const Evt &evt)
Get primary.
static const JRange< int > DEFAULT_BUNDLE_MULTIPLICITY_RANGE
Default bundle multiplicity range [-].
JTrack3E getTrack(const Trk &track)
Get track.
bool is_corsika(const JHead &header)
Check for generator.
static const JRange< double > DEFAULT_BUNDLE_ENERGY_RANGE
Default bundle energy range [GeV].
static const JRange< double > DEFAULT_BUNDLE_COSINE_ZENITH_ANGLE_RANGE
Default bundle cosine zenith angle range [-].
bool is_muonbundle(const Trk &track)
Test whether given track is a (anti-)muon.
static const double DEFAULT_BUNDLE_RADIAL_EXTENT
Default bundle radial extent [m].
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
bool is_mupage(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:85
@ TRACK_TYPE_NUTAU
@ TRACK_TYPE_NUE
@ TRACK_TYPE_ELECTRON
@ TRACK_TYPE_PHOTON
@ TRACK_TYPE_MUON
@ TRACK_TYPE_NUMU
bool is_muon_bundle_primary(const int type)
Auxiliary function to check if given PDG code corresponds to a valid muon bundle primary type.
std::string to_string(const T &value)
Convert value to string.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
Low-level interface for event categories.
Definition: JEvtCategory.hh:38
static JEquationParameters & getEquationParameters()
Get equation parameters.
Auxiliary class for I/O of muon bundle category.
JMuonBundleCategoryHelper(JMuonBundleCategory_t &cat, const JEquationParameters &equation)
Constructor.
Class for muon bundle categories.
bool match(const JHead &header) const override final
Check whether this event category matches with the given MC header.
bool match(const Evt &event) const override final
Check whether given event matches with this event category.
JMuonBundleCategory(const int primaryType, const JRange< double > &Erange, const JRange< double > &coszRange, const JRange< int > &Mrange, const double Rmax)
Constructor.
JMuonBundleCategory(const JHead &header)
Constructor.
JRange< double > Erange
energy range [GeV]
JMuonBundleCategory(const int primaryType)
Constructor.
bool is_valid() const override final
Check if muon bundle category is valid.
JProperties getProperties(const JEquationParameters &equation=JEvtCategory::getEquationParameters()) override final
Get properties of this class.
JProperties getProperties(const JEquationParameters &equation=JEvtCategory::getEquationParameters()) const override final
Get properties of this class.
JRange< double > coszRange
cosine zenith-angle range [-]
JMuonBundleCategory()
Default constructor.
double Rmax
maximum radial extent [m]
JRange< int > Mrange
multiplicity range [-]
bool less(const JEvtCategory &category) const override final
Less-than method.
JRange_t cosT
Cosine zenith angle range
Definition: JHead.hh:420
JRange_t E
Energy range [GeV].
Definition: JHead.hh:419
Primary particle.
Definition: JHead.hh:1174
int type
Particle type.
Definition: JHead.hh:1204
Template class for object cloning.
Definition: JClonable.hh:59
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:15
static const int PDG_MUONBUNDLE
muon bundle reached the can level (mupage)
Definition: trkmembers.hh:38