Pixie16 Analysis Software Suite
Analysis code for processing of .ldf files
Globals.hpp
Go to the documentation of this file.
1 
5 #ifndef __GLOBALS_HPP_
6 #define __GLOBALS_HPP_
7 
8 #include <algorithm>
9 #include <sstream>
10 #include <string>
11 #include <utility>
12 #include <vector>
13 
14 #include <cstdlib>
15 #include <stdint.h>
16 
17 #include "pugixml.hpp"
18 
19 #include "pixie16app_defs.h"
20 
21 #include "Exceptions.hpp"
22 #include "Messenger.hpp"
23 
30 namespace pixie {
31  typedef uint32_t word_t;
32  typedef uint16_t halfword_t;
33  typedef uint32_t bufword_t;
34 
40 
45  const unsigned int TOTALREAD = 1000000;
46 
48  const pixie::word_t clockVsn = 1000;
50  const size_t numberOfChannels = 16;
51 };
52 
54 namespace readbuff {
55  const int STATS = -10;
56  const int ERROR = -100;
57 }
58 
60 namespace TimingDefs {
62  typedef std::pair<unsigned int, std::string> TimingIdentifier;
63 }
64 
66 namespace strings {
70  inline double to_double (std::string s) {
71  std::istringstream iss(s);
72  double value;
73  if (!(iss >> value)) {
74  std::stringstream ss;
75  ss << "strings::to_double: Could not convert string '"
76  << s << "' to double" << std::endl;
77  throw ConversionException(ss.str());
78  }
79  return value;
80  }
81 
85  inline int to_int (std::string s) {
86  std::istringstream iss(s);
87  int value;
88  if (!(iss >> value)) {
89  std::stringstream ss;
90  ss << "strings::to_int: Could not convert string '"
91  << s << "' to int" << std::endl;
92  throw ConversionException(ss.str());
93  }
94  return value;
95  }
96 
103  inline bool to_bool (std::string s) {
104  std::transform(s.begin(), s.end(), s.begin(), ::tolower);
105  if (s == "true" || s == "1")
106  return true;
107  else if (s == "false" || s == "0")
108  return false;
109  else {
110  std::stringstream ss;
111  ss << "strings::to_bool: Could not convert string '"
112  << s << "' to bool" << std::endl;
113  throw ConversionException(ss.str());
114  }
115  }
116 
122  inline std::vector<std::string> tokenize(std::string str,
123  std::string delimiter) {
124  std::string temp;
125  std::vector<std::string> tokenized;
126  while (str.find(delimiter) != std::string::npos) {
127  size_t pos = str.find(delimiter);
128  temp = str.substr(0, pos);
129  str.erase(0, pos + 1);
130  tokenized.push_back(temp);
131  }
132  tokenized.push_back(str);
133  return tokenized;
134  }
135 };
136 
138 class Globals {
139 public:
141  static Globals* get();
142  ~Globals();
143 
145  bool hasReject() const { return hasReject_; }
146 
148  double adcClockInSeconds() const {return adcClockInSeconds_;}
150  double clockInSeconds() const {return(clockInSeconds_);}
152  double eventInSeconds() const {return eventInSeconds_; }
154  double energyContraction() const { return energyContraction_; }
156  double filterClockInSeconds() const { return filterClockInSeconds_; }
158  double bigLength() const {return(bigLength_);}
160  double bigLengthTime() const {return(bigLength_/speedOfLightBig_);}
162  double mediumLength() const {return(mediumLength_);}
166  double neutronMass() const {return(neutronMass_);}
168  double smallLength() const {return(smallLength_);}
172  double speedOfLight() const {return(speedOfLight_);}
174  double speedOfLightBig() const {return(speedOfLightBig_);}
176  double speedOfLightMedium() const {return(speedOfLightMedium_);}
178  double speedOfLightSmall() const {return(speedOfLightSmall_);}
180  double discriminationStart() const {return(discriminationStart_);}
182  double qdcCompression() const {return (qdcCompression_);}
184  double sigmaBaselineThresh() const {return(sigmaBaselineThresh_);}
188  double traceDelay() const {return(traceDelay_);}
190  double traceLength() const {return(traceLength_);}
192  double trapezoidalWalk() const {return(trapezoidalWalk_);}
194  int eventWidth() const { return eventWidth_; }
196  std::pair<unsigned int, unsigned int> waveformRange() const {return(waveformRange_);}
198  std::pair<unsigned int, unsigned int> siPmtWaveformRange() const {return(siPmtWaveformRange_);}
200  std::pair<double,double> smallVandlePars() {return(smallVandlePars_);}
202  std::pair<double,double> mediumVandlePars() {return(mediumVandlePars_);}
204  std::pair<double,double> bigVandlePars() {return(bigVandlePars_);}
206  std::pair<double,double> singleBetaPars() {return(singleBetaPars_);}
208  std::pair<double,double> doubleBetaPars() {return(doubleBetaPars_);}
210  std::pair<double,double> pulserPars() {return(pulserPars_);}
212  std::pair<double,double> tvandlePars() {return(tvandlePars_);}
214  std::pair<double,double> liquidScintPars() {return(liquidScintPars_);}
219  std::string configPath(std::string fileName) {
220  std::stringstream ss;
221  ss << configPath_ << fileName;
222  return ss.str();
223  }
225  std::string revision() const { return revision_; }
227  unsigned int maxWords() const { return maxWords_; }
230  unsigned short numTraces() const { return numTraces_; }
234  std::vector< std::pair<int, int> > rejectRegions() const {return reject_; };
235 private:
237  Globals();
238  Globals(Globals const&);
239  void operator=(Globals const&);
240  static Globals* instance;
241 
243  void SanityCheck();
247  void WarnOfUnknownParameter(Messenger &m, pugi::xml_node_iterator &it);
248 
255  double bigLength_;
257  double neutronMass_;
258  double smallLength_;
267  double traceDelay_;
268  double traceLength_;
271  std::pair<unsigned int, unsigned int> waveformRange_;
272  std::pair<unsigned int, unsigned int> siPmtWaveformRange_;
273  std::pair<double,double> smallVandlePars_;
274  std::pair<double,double> mediumVandlePars_;
275  std::pair<double,double> bigVandlePars_;
276  std::pair<double,double> singleBetaPars_;
277  std::pair<double,double> doubleBetaPars_;
278  std::pair<double,double> pulserPars_;
279  std::pair<double,double> tvandlePars_;
280  std::pair<double,double> liquidScintPars_;
281  std::string configPath_;
282  std::string revision_;
283  unsigned int maxWords_;
284  unsigned short numTraces_;
285  std::vector< std::pair<int, int> > reject_;
286 };
287 #endif
std::string revision_
the pixie revision
Definition: Globals.hpp:282
double sigmaBaselineThresh_
threshold on fitting for Std dev. of the baseline
Definition: Globals.hpp:265
double traceDelay_
the trace delay in ns
Definition: Globals.hpp:267
uint16_t halfword_t
a half pixie word
Definition: Globals.hpp:32
int to_int(std::string s)
Definition: Globals.hpp:85
double clockInSeconds_
the ACQ clock in seconds
Definition: Globals.hpp:251
static Globals * instance
Create the static instance of the class.
Definition: Globals.hpp:240
std::pair< unsigned int, unsigned int > siPmtWaveformRange() const
Definition: Globals.hpp:198
double qdcCompression() const
Definition: Globals.hpp:182
double bigLength() const
Definition: Globals.hpp:158
std::vector< std::pair< int, int > > reject_
rejection range in time
Definition: Globals.hpp:285
double energyContraction() const
Definition: Globals.hpp:154
double energyContraction_
energy contraction
Definition: Globals.hpp:252
double discriminationStart_
starting sample for the n-gamma discrimination
Definition: Globals.hpp:263
std::string revision() const
Definition: Globals.hpp:225
bool to_bool(std::string s)
Definition: Globals.hpp:103
uint32_t bufword_t
word in a pixie buffer
Definition: Globals.hpp:33
Pixie module related things that should not change between revisions.
Definition: Globals.hpp:30
int eventWidth() const
Definition: Globals.hpp:194
const pixie::word_t clockVsn
Definition: Globals.hpp:48
double smallLength() const
Definition: Globals.hpp:168
Some common string conversion operations.
Definition: Globals.hpp:66
Namespace defining some buffer related constants.
Definition: Globals.hpp:54
unsigned int maxWords_
maximum words in the
Definition: Globals.hpp:283
int eventWidth_
the size of the events
Definition: Globals.hpp:270
const unsigned int TOTALREAD
Definition: Globals.hpp:45
const int STATS
a stats buffer
Definition: Globals.hpp:55
std::vector< std::pair< int, int > > rejectRegions() const
Definition: Globals.hpp:234
Class to handle errors occurring during the execution of the code.
double traceDelay() const
Definition: Globals.hpp:188
double speedOfLightMedium() const
Definition: Globals.hpp:176
void WarnOfUnknownParameter(Messenger &m, pugi::xml_node_iterator &it)
Singleton class holding global parameters.
Definition: Globals.hpp:138
double traceLength() const
Definition: Globals.hpp:190
std::pair< double, double > smallVandlePars_
small VANDLE parameters for fitting
Definition: Globals.hpp:273
double siPmtSigmaBaselineThresh() const
Definition: Globals.hpp:186
double adcClockInSeconds_
adc clock in second
Definition: Globals.hpp:250
std::pair< double, double > smallVandlePars()
Definition: Globals.hpp:200
double speedOfLightBig_
speed of light in big VANDLE bars in cm/ns
Definition: Globals.hpp:260
std::pair< unsigned int, unsigned int > siPmtWaveformRange_
Range for the waveform of a Fast SiPmt.
Definition: Globals.hpp:272
bool hasReject() const
Definition: Globals.hpp:145
double to_double(std::string s)
Definition: Globals.hpp:70
unsigned short numTraces() const
Definition: Globals.hpp:230
double speedOfLight_
speed of light in cm/ns
Definition: Globals.hpp:259
std::pair< double, double > singleBetaPars_
Single Beta parameters for fitting.
Definition: Globals.hpp:276
std::pair< double, double > doubleBetaPars_
Double Beta parameters for fitting.
Definition: Globals.hpp:277
std::pair< double, double > tvandlePars_
Teeny-VANDEL parameters for fitting.
Definition: Globals.hpp:279
double neutronMass() const
Definition: Globals.hpp:166
double traceLength_
the trace length in ns
Definition: Globals.hpp:268
std::vector< std::string > tokenize(std::string str, std::string delimiter)
Definition: Globals.hpp:122
const size_t numberOfChannels
Definition: Globals.hpp:50
! Namespace defining some information for Timing related stuff
Definition: Globals.hpp:60
unsigned short numTraces_
number of traces to plot
Definition: Globals.hpp:284
unsigned int maxWords() const
Definition: Globals.hpp:227
std::pair< double, double > bigVandlePars_
big VANDLE parameters for fitting
Definition: Globals.hpp:275
double speedOfLightSmall_
speed of light in small VANDLE bars in cm/ns
Definition: Globals.hpp:262
const int ERROR
Defines an error buffer.
Definition: Globals.hpp:56
double bigLength_
length of big VANDLE bars in cm
Definition: Globals.hpp:255
double eventInSeconds() const
Definition: Globals.hpp:152
void SanityCheck()
A class to handle messages and output them prettily.
double sigmaBaselineThresh() const
Definition: Globals.hpp:184
std::pair< double, double > singleBetaPars()
Definition: Globals.hpp:206
double speedOfLightSmall() const
Definition: Globals.hpp:178
double mediumLength_
length of medium VANDLE bars in cm
Definition: Globals.hpp:256
std::pair< double, double > liquidScintPars_
liquid scint pars for fitting
Definition: Globals.hpp:280
std::pair< double, double > liquidScintPars()
Definition: Globals.hpp:214
double filterClockInSeconds_
filter clock in seconds
Definition: Globals.hpp:254
double speedOfLightBig() const
Definition: Globals.hpp:174
double trapezoidalWalk() const
Definition: Globals.hpp:192
double speedOfLightMedium_
speed of light in medium VANDLE bars in cm/ns
Definition: Globals.hpp:261
std::pair< double, double > mediumVandlePars()
Definition: Globals.hpp:202
std::pair< double, double > pulserPars()
Definition: Globals.hpp:210
double bigLengthTime() const
Definition: Globals.hpp:160
double smallLengthTime() const
Definition: Globals.hpp:170
double adcClockInSeconds() const
Definition: Globals.hpp:148
std::pair< unsigned int, std::string > TimingIdentifier
Definition: Globals.hpp:62
const pixie::word_t U_DELIMITER
Definition: Globals.hpp:39
double filterClockInSeconds() const
Definition: Globals.hpp:156
This class outputs nicely formatted messages during configuration loading.
Definition: Messenger.hpp:19
double trapezoidalWalk_
the approximate walk in ns of the trap filter
Definition: Globals.hpp:269
double qdcCompression_
QDC compression factor for VANDLE related plots.
Definition: Globals.hpp:264
double clockInSeconds() const
Definition: Globals.hpp:150
bool hasReject_
Has a rejected.
Definition: Globals.hpp:249
std::pair< double, double > pulserPars_
Pulser parameters for fitting.
Definition: Globals.hpp:278
double speedOfLight() const
Definition: Globals.hpp:172
Error in conversion of string to numerical or boolean value.
Definition: Exceptions.hpp:87
std::string configPath_
configuration path
Definition: Globals.hpp:281
uint32_t word_t
a pixie word
Definition: Globals.hpp:31
void operator=(Globals const &)
copy constructor
double eventInSeconds_
event width in seconds
Definition: Globals.hpp:253
std::pair< double, double > mediumVandlePars_
medium VANDLE parameters for fitting
Definition: Globals.hpp:274
std::pair< double, double > bigVandlePars()
Definition: Globals.hpp:204
double mediumLength() const
Definition: Globals.hpp:162
std::pair< double, double > doubleBetaPars()
Definition: Globals.hpp:208
std::string configPath(std::string fileName)
Definition: Globals.hpp:219
double smallLength_
length of small VANDLE bars in cm
Definition: Globals.hpp:258
double mediumLengthTime() const
Definition: Globals.hpp:164
double neutronMass_
mass of neutrons in MeV/c/c
Definition: Globals.hpp:257
std::pair< unsigned int, unsigned int > waveformRange() const
Definition: Globals.hpp:196
std::pair< unsigned int, unsigned int > waveformRange_
Range for the waveform.
Definition: Globals.hpp:271
double siPmtSigmaBaselineThresh_
threshold on fitting for Std dev. of the baseline for SiPMTs
Definition: Globals.hpp:266
double discriminationStart() const
Definition: Globals.hpp:180
std::pair< double, double > tvandlePars()
Definition: Globals.hpp:212