Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPDFTypes.hh
Go to the documentation of this file.
1 #ifndef __JPHYSICS__JPDFTYPES__
2 #define __JPHYSICS__JPDFTYPES__
3 
4 #include <string>
5 #include <sstream>
6 
7 #include "Jeep/JeepToolkit.hh"
8 
9 /**
10  * \file
11  *
12  * Numbering scheme for PDF types.
13  * \author mdejong
14  */
15 namespace JPHYSICS {}
16 namespace JPP { using namespace JPHYSICS; }
17 
18 namespace JPHYSICS {
19 
20 
21  /**
22  * PDF types
23  */
24  enum JPDFType_t {
25 
26  DIRECT_LIGHT_FROM_MUON = 1, //!< direct light from muon
27  SCATTERED_LIGHT_FROM_MUON = 2, //!< scattered light from muon
28 
29  DIRECT_LIGHT_FROM_EMSHOWERS = 3, //!< direct light from EM showers
30  SCATTERED_LIGHT_FROM_EMSHOWERS = 4, //!< scattered light from EM showers
31 
32  DIRECT_LIGHT_FROM_DELTARAYS = 5, //!< direct light from delta-rays
33  SCATTERED_LIGHT_FROM_DELTARAYS = 6, //!< scattered light from delta-rays
34 
35  SCATTERED_LIGHT_FROM_MUON_5D = 12, //!< scattered light from muon
36 
37  DIRECT_LIGHT_FROM_EMSHOWER = 13, //!< direct light from EM shower
38  SCATTERED_LIGHT_FROM_EMSHOWER = 14, //!< scattered light from EM shower
39 
40  //DIRECT_LIGHT_FROM_SHOWER = 15, //!< direct + scattered light from HADRONIC shower
41 
42  DIRECT_LIGHT_FROM_BRIGHT_POINT = 23, //!< direct light from bright point
43  SCATTERED_LIGHT_FROM_BRIGHT_POINT = 24, //!< scattered light from bright point
44 
45  LIGHT_FROM_ELONGATED_EMSHOWER = 113, //!< light from elongated EM shower
46 
47  LIGHT_FROM_MUON = 1001, //!< direct and scattered light from muon
48  LIGHT_FROM_EMSHOWERS = 1003, //!< direct and scattered light from EM showers
49  LIGHT_FROM_DELTARAYS = 1005, //!< direct and scattered light from delta-rays
50  LIGHT_FROM_EMSHOWER = 1013, //!< direct and scattered light from EM shower
51  LIGHT_FROM_BRIGTH_POINT = 1023 //!< direct and scattered light from brigth point
52  };
53 
54 
55  /**
56  * Get PDF label.
57  *
58  * \param pdf PDF type
59  * \return PDF label
60  */
61  inline std::string getLabel(const JPDFType_t pdf)
62  {
63  std::ostringstream os;
64 
65  os << pdf;
66 
67  return os.str();
68  }
69 
70 
71  /**
72  * Get PDF type.
73  *
74  * \param file_name file name
75  * \return PDF type (-1 in case of error)
76  */
77  inline int getPDFType(const std::string& file_name)
78  {
79  using namespace std;
80 
81  static const char* digits = "0123456789";
82 
83  int type = -1;
84 
85  string buffer = JEEP::getFilename(file_name);
86 
87  string::size_type pos = buffer.find_first_of(digits);
88 
89  if (pos != string::npos) {
90 
91  string::size_type len = buffer.substr(pos).find_first_not_of(digits);
92 
93  istringstream(buffer.substr(pos, len)) >> type;
94  }
95 
96  return type;
97  }
98 
99 
100  /**
101  * Get PDF file name.
102  *
103  * The input file name should contain the wild card character JEEP::FILENAME_WILDCARD
104  * which will be replaced by the label corresponding to the given PDF type.
105  *
106  * \param file_name input file name
107  * \param pdf PDF type
108  * \return output file name
109  */
110  inline std::string getFilename(const std::string& file_name,
111  const JPDFType_t pdf)
112  {
113  return JEEP::setWildCard(file_name, getLabel(pdf));
114  }
115 
116 
117  /**
118  * Test if given PDF type corresponds to Cherenkov light from muon.
119  *
120  * \param pdf PDF type
121  * \return true if PDF corresponds to muon; else false
122  */
123  inline bool is_muon(const int pdf)
124  {
125  return (pdf == DIRECT_LIGHT_FROM_MUON ||
126  pdf == SCATTERED_LIGHT_FROM_MUON ||
127  pdf == LIGHT_FROM_MUON);
128  }
129 
130 
131  /**
132  * Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
133  *
134  * \param pdf PDF type
135  * \return true if PDF corresponds to Bremsstrahlung; else false
136  */
137  inline bool is_bremsstrahlung(const int pdf)
138  {
139  return (pdf == DIRECT_LIGHT_FROM_EMSHOWERS ||
141  pdf == LIGHT_FROM_EMSHOWERS);
142  }
143 
144 
145  /**
146  * Test if given PDF type corresponds to Cherenkov light from delta-rays.
147  *
148  * \param pdf PDF type
149  * \return true if PDF corresponds to delta-rays; else false
150  */
151  inline bool is_deltarays(const int pdf)
152  {
153  return (pdf == DIRECT_LIGHT_FROM_DELTARAYS ||
155  pdf == LIGHT_FROM_DELTARAYS);
156  }
157 
158 
159  /**
160  * Test if given PDF type corresponds to scattered light.
161  *
162  * \param pdf PDF type
163  * \return true if PDF corresponds to scattered light; else false
164  */
165  inline bool is_scattered(const int pdf)
166  {
167  return (pdf == SCATTERED_LIGHT_FROM_MUON ||
172  }
173 }
174 
175 #endif
direct and scattered light from brigth point
Definition: JPDFTypes.hh:51
direct and scattered light from EM shower
Definition: JPDFTypes.hh:50
direct and scattered light from muon
Definition: JPDFTypes.hh:47
scattered light from muon
Definition: JPDFTypes.hh:35
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
scattered light from EM shower
Definition: JPDFTypes.hh:38
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
direct light from EM showers
Definition: JPDFTypes.hh:29
direct light from bright point
Definition: JPDFTypes.hh:42
direct light from muon
Definition: JPDFTypes.hh:26
light from elongated EM shower
Definition: JPDFTypes.hh:45
then set_variable PMT_FILE set_variable DAQ_FILE set_variable OUTPUT_FILE set_variable DETECTOR else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:137
scattered light from muon
Definition: JPDFTypes.hh:27
Auxiliary methods for handling file names, type names and environment.
scattered light from delta-rays
Definition: JPDFTypes.hh:33
direct light from EM shower
Definition: JPDFTypes.hh:37
scattered light from EM showers
Definition: JPDFTypes.hh:30
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:24
scattered light from bright point
Definition: JPDFTypes.hh:43
direct light from delta-rays
Definition: JPDFTypes.hh:32
std::string setWildCard(const std::string &file_name, const std::string &value)
Get file name by setting wild card to given value.
Definition: JeepToolkit.hh:66
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:77
direct and scattered light from delta-rays
Definition: JPDFTypes.hh:49
bool is_scattered(const int pdf)
Test if given PDF type corresponds to scattered light.
Definition: JPDFTypes.hh:165
direct and scattered light from EM showers
Definition: JPDFTypes.hh:48
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:151
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128