Jpp - 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 "JLang/JException.hh"
8 #include "Jeep/JeepToolkit.hh"
9 
10 /**
11  * \file
12  *
13  * Numbering scheme for PDF types.
14  * \author mdejong
15  */
16 namespace JPHYSICS {}
17 namespace JPP { using namespace JPHYSICS; }
18 
19 namespace JPHYSICS {
20 
21  using JLANG::JException;
22 
23 
24  /**
25  * PDF types
26  */
27  enum JPDFType_t {
28 
29  DIRECT_LIGHT_FROM_MUON = 1, //!< direct light from muon
30  SCATTERED_LIGHT_FROM_MUON = 2, //!< scattered light from muon
31 
32  DIRECT_LIGHT_FROM_EMSHOWERS = 3, //!< direct light from EM showers
33  SCATTERED_LIGHT_FROM_EMSHOWERS = 4, //!< scattered light from EM showers
34 
35  DIRECT_LIGHT_FROM_DELTARAYS = 5, //!< direct light from delta-rays
36  SCATTERED_LIGHT_FROM_DELTARAYS = 6, //!< scattered light from delta-rays
37 
38  SCATTERED_LIGHT_FROM_MUON_5D = 12, //!< scattered light from muon
39 
40  DIRECT_LIGHT_FROM_EMSHOWER = 13, //!< direct light from EM shower
41  SCATTERED_LIGHT_FROM_EMSHOWER = 14, //!< scattered light from EM shower
42 
43  //DIRECT_LIGHT_FROM_SHOWER = 15, //!< direct + scattered light from HADRONIC shower
44 
45  DIRECT_LIGHT_FROM_BRIGHT_POINT = 23, //!< direct light from bright point
46  SCATTERED_LIGHT_FROM_BRIGHT_POINT = 24, //!< scattered light from bright point
47 
48  LIGHT_FROM_MUON = 1001, //!< direct and scattered light from muon
49  LIGHT_FROM_EMSHOWERS = 1003, //!< direct and scattered light from EM showers
50  LIGHT_FROM_DELTARAYS = 1005, //!< direct and scattered light from delta-rays
51  LIGHT_FROM_EMSHOWER = 1013, //!< direct and scattered light from EM shower
52  LIGHT_FROM_BRIGTH_POINT = 1023 //!< direct and scattered light from brigth point
53  };
54 
55 
56  static const char WILD_CARD = '%'; //!< wild card character for file name substitution
57 
58 
59  /**
60  * Get PDF label.
61  *
62  * \param pdf PDF type
63  * \return PDF label
64  */
65  inline std::string getLabel(const JPDFType_t pdf)
66  {
67  std::ostringstream os;
68 
69  os << pdf;
70 
71  return os.str();
72  }
73 
74 
75  /**
76  * Get PDF type.
77  *
78  * \param file_name file name
79  * \return PDF type (-1 in case of error)
80  */
81  inline int getPDFType(const std::string& file_name)
82  {
83  using namespace std;
84 
85  static const char* digits = "0123456789";
86 
87  int type = -1;
88 
89  string buffer = JEEP::getFilename(file_name);
90 
91  string::size_type pos = buffer.find_first_of(digits);
92 
93  if (pos != string::npos) {
94 
95  string::size_type len = buffer.substr(pos).find_first_not_of(digits);
96 
97  istringstream(buffer.substr(pos, len)) >> type;
98  }
99 
100  return type;
101  }
102 
103 
104  /**
105  * Check wild card.
106  *
107  * \param file_name file name
108  * \return true if wild card present; else false
109  */
110  inline bool hasWildCard(const std::string& file_name)
111  {
112  return (file_name.find(WILD_CARD) != std::string::npos);
113  }
114 
115 
116  /**
117  * Get PDF file name.
118  *
119  * The input file name should contain the wild card character WILD_CARD
120  * which will be replaced by the label corresponding to the given PDF type.
121  *
122  * \param file_name input file name
123  * \param pdf PDF type
124  * \return output file name
125  */
126  inline std::string getFilename(const std::string& file_name,
127  const JPDFType_t pdf)
128  {
129  using namespace std;
130 
131  string buffer = file_name;
132 
133  string::size_type pos = buffer.find(WILD_CARD);
134 
135  if (pos == string::npos) {
136  throw JException(string("Method getFilename(): Missing wild card character \'") + WILD_CARD + "\'.");
137  }
138 
139  return buffer.replace(pos, 1, getLabel(pdf));
140  }
141 
142 
143  /**
144  * Test if given PDF type corresponds to Cherenkov light from muon.
145  *
146  * \param pdf PDF type
147  * \return true if PDF corresponds to muon; else false
148  */
149  inline bool is_muon(const int pdf)
150  {
151  return (pdf == DIRECT_LIGHT_FROM_MUON ||
152  pdf == SCATTERED_LIGHT_FROM_MUON ||
153  pdf == LIGHT_FROM_MUON);
154  }
155 
156 
157  /**
158  * Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
159  *
160  * \param pdf PDF type
161  * \return true if PDF corresponds to Bremsstrahlung; else false
162  */
163  inline bool is_bremsstrahlung(const int pdf)
164  {
165  return (pdf == DIRECT_LIGHT_FROM_EMSHOWERS ||
167  pdf == LIGHT_FROM_EMSHOWERS);
168  }
169 
170 
171  /**
172  * Test if given PDF type corresponds to Cherenkov light from delta-rays.
173  *
174  * \param pdf PDF type
175  * \return true if PDF corresponds to delta-rays; else false
176  */
177  inline bool is_deltarays(const int pdf)
178  {
179  return (pdf == DIRECT_LIGHT_FROM_DELTARAYS ||
181  pdf == LIGHT_FROM_DELTARAYS);
182  }
183 
184 
185  /**
186  * Test if given PDF type corresponds to scattered light.
187  *
188  * \param pdf PDF type
189  * \return true if PDF corresponds to scattered light; else false
190  */
191  inline bool is_scattered(const int pdf)
192  {
193  return (pdf == SCATTERED_LIGHT_FROM_MUON ||
198  }
199 }
200 
201 #endif
direct and scattered light from brigth point
Definition: JPDFTypes.hh:52
General exception.
Definition: JException.hh:23
Exceptions.
direct and scattered light from EM shower
Definition: JPDFTypes.hh:51
direct and scattered light from muon
Definition: JPDFTypes.hh:48
scattered light from muon
Definition: JPDFTypes.hh:38
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:41
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
direct light from EM showers
Definition: JPDFTypes.hh:32
direct light from bright point
Definition: JPDFTypes.hh:45
direct light from muon
Definition: JPDFTypes.hh:29
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:163
scattered light from muon
Definition: JPDFTypes.hh:30
Auxiliary methods for handling file names, type names and environment.
scattered light from delta-rays
Definition: JPDFTypes.hh:36
direct light from EM shower
Definition: JPDFTypes.hh:40
scattered light from EM showers
Definition: JPDFTypes.hh:33
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:27
scattered light from bright point
Definition: JPDFTypes.hh:46
direct light from delta-rays
Definition: JPDFTypes.hh:35
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:81
direct and scattered light from delta-rays
Definition: JPDFTypes.hh:50
bool is_scattered(const int pdf)
Test if given PDF type corresponds to scattered light.
Definition: JPDFTypes.hh:191
static const char WILD_CARD
Definition: JDAQTags.hh:34
direct and scattered light from EM showers
Definition: JPDFTypes.hh:49
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:177
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:88
bool hasWildCard(const std::string &file_name)
Check wild card.
Definition: JPDFTypes.hh:110