Structs.h
Go to the documentation of this file.
1 //
2 // Structs.h
3 //
4 // Created by Brian Rebel on 4/11/16.
5 //
6 
7 #ifndef COVARIANCEMATRIXFIT_DATAPRODUCTS_Structs_h
8 #define COVARIANCEMATRIXFIT_DATAPRODUCTS_Structs_h
9 
10 #include <sstream>
11 #include <string>
12 
13 #include "NovaDAQConventions/DAQConventions.h"
16 
17 namespace cmf {
18 
19  long StringToKey(std::string const& str);
20 
22  {
23 
26  , ComponentKeyI(-1)
27  , OffsetI(-1)
28  , PositionI(-1)
29  , NumBinsI(-1)
30  , ComponentKeyJ(-1)
31  , OffsetJ(-1)
32  , PositionJ(-1)
33  , NumBinsJ(-1)
34  {}
35 
36  SubMatrixData(int const& cpn,
37  int const& cki,
38  int const& oi,
39  int const& pi,
40  int const& nbi,
41  int const& ckj,
42  int const& oj,
43  int const& pj,
44  int const& nbj)
45  : CantorPairingNumber(cpn)
46  , ComponentKeyI(cki)
47  , OffsetI(oi)
48  , PositionI(pi)
49  , NumBinsI(nbi)
50  , ComponentKeyJ(ckj)
51  , OffsetJ(oj)
52  , PositionJ(pj)
53  , NumBinsJ(nbj)
54  {}
55 
57  int ComponentKeyI = -1;
58  int OffsetI = -1;
59  int PositionI = -1;
60  int NumBinsI = -1;
61  int ComponentKeyJ = -1;
62  int OffsetJ = -1;
63  int PositionJ = -1;
64  int NumBinsJ = -1;
65  };
66 
67  struct MetaDataLite
68  {
69  MetaDataLite();
70 
72  cmf::SelectionType_t const& st,
73  std::string const& ep);
74 
76  cmf::SelectionType_t const& st,
77  long const& ep)
78  : detector(det)
79  , selectionType(st)
80  , period(ep)
81  {}
82 
85  long period;
86 
87  long Period() const { return period; }
88  std::string PeriodString() const;
89  std::string ToString() const;
90 
91  bool operator==(const MetaDataLite& other) const;
92  bool operator<(const MetaDataLite& other) const;
93  };
94 
95  struct MetaData
96  {
97  MetaData();
98 
99  MetaData(bool const& mc,
100  cmf::DetType_t const& det,
101  cmf::FileType_t const& ft,
102  cmf::SelectionType_t const& st,
103  cmf::InteractionType_t const& it,
104  std::string const& ep);
105 
106  MetaData(bool const& mc,
107  cmf::DetType_t const& det,
108  cmf::FileType_t const& ft,
109  cmf::SelectionType_t const& st,
110  cmf::InteractionType_t const& it,
111  int const& ep);
112 
113  bool isMC;
118  long period;
119 
120  long MCKey() const { return ((isMC) ? 1 : -1); }
121  long DetectorKey() const { return cmf::DetectorTypeKey(detector); }
122  long PeriodKey() const { return cmf::PeriodKey(period); }
123  long FileKey() const { return cmf::FileTypeKey(fileType); }
124  long SelectionKey() const { return cmf::SelectionTypeKey(selectionType); }
125  long InteractionKey() const { return cmf::InteractionTypeKey(interactionType); }
126  long BeamTypeKey() const { return cmf::BeamTypeKey(this->BeamType()); }
127  long DetectorBeamSelectionKey() const;
128  long Period() const { return period; }
129  long Key() const;
130  std::string PeriodString() const;
131  std::string DetectorString() const;
132  std::string ToString() const;
133  std::string ToStringLatex() const;
134  std::string DetectorFilePeriodString() const;
135  bool IsNuMuSelected() const;
136  bool IsNuMuQuantiles() const;
137  bool IsNuESelected() const;
138  bool IsNCSelected() const;
139  bool IsCosmicMuon() const { return fileType == cmf::kCosmicBackgroundFile; }
140  bool IsRockMuon() const { return (fileType == cmf::kRockFluxSwap || fileType == cmf::kRockNonSwap); }
141 
142  cmf::BeamType_t BeamType() const;
143 
144  cmf::MetaDataLite LiteMD() const;
145 
146  bool operator==(MetaData const& other) const;
147  bool operator<(MetaData const& other) const;
148  };
149 
150  //---------------------------------------------------------------------------
152  {
153  // for backwards compatibility with previously made files we will
154  // strip the "Det" off the name returned by the novadaq function
156  auto pos = name.find("Det");
157 
158  return (pos != std::string::npos) ? name.erase(pos, 3) : name;
159  }
160 
161  //---------------------------------------------------------------------------
163  {
164  return ("Period" + std::to_string(period));
165  }
166 
167  //---------------------------------------------------------------------------
169  {
170  return (this->DetectorString() +
172  this->PeriodString());
173  }
174 
175  //---------------------------------------------------------------------------
177  {
178  SpillSummary();
179  SpillSummary(double const& totPOT,
180  double const& gPOT,
181  double const& lt,
182  unsigned long int const& totSpill,
183  unsigned long int const& goodSpill);
184 
185  double totalPOT;
186  double goodPOT;
187  double liveTime;
188  unsigned long int totalNumSpills;
189  unsigned long int numGoodSpills;
190 
191  void clear();
192  void operator+=(SpillSummary const& o);
193  void operator*=(float f);
194 
195  friend std::ostream& operator<< (std::ostream & o, SpillSummary const& ss);
196  };
197 
198  //----------------------------------------------------------------------------
199  inline std::ostream& operator<< (std::ostream & o, SpillSummary const& ss)
200  {
201  o << "good POT: "
202  << ss.goodPOT
203  << " total POT: "
204  << ss.totalPOT
205  << " live time: "
206  << ss.liveTime
207  << " good spills: "
208  << ss.numGoodSpills
209  << " total spills: "
210  << ss.totalNumSpills;
211 
212  return o;
213  }
214 
215  typedef std::map<cmf::MetaData, cmf::SpillSummary> ExposureMap;
216 
217 } // namespace cmf
218 
219 #endif /* COVARIANCEMATRIXFIT_DATAPRODUCTS_Structs_h */
long StringToKey(std::string const &str)
Definition: Structs.cxx:15
const XML_Char * name
Definition: expat.h:151
std::map< cmf::MetaData, cmf::SpillSummary > ExposureMap
Definition: Structs.h:215
MetaDataLite(cmf::DetType_t const &det, cmf::SelectionType_t const &st, long const &ep)
Definition: Structs.h:75
SubMatrixData(int const &cpn, int const &cki, int const &oi, int const &pi, int const &nbi, int const &ckj, int const &oj, int const &pj, int const &nbj)
Definition: Structs.h:36
enum cmf::interaction_type InteractionType_t
long DetectorKey() const
Definition: Structs.h:121
TDC::value_type operator+=(TDC lhs, TDC rhs)
Definition: BaseProducts.h:53
double lt
static long SelectionTypeKey(cmf::SelectionType_t const &st)
Definition: StaticFuncs.h:19
set< int >::iterator it
long Period() const
Definition: Structs.h:128
cmf::DetType_t detector
Definition: Structs.h:114
static long DetectorTypeKey(cmf::DetType_t const &det)
Definition: StaticFuncs.h:15
unsigned long int totalNumSpills
Definition: Structs.h:188
double liveTime
Definition: Structs.h:187
vector< vector< double > > clear
Float_t ss
Definition: plot.C:24
long PeriodKey() const
Definition: Structs.h:122
enum cmf::det_type DetType_t
std::string PeriodString() const
Definition: Structs.h:162
long SelectionKey() const
Definition: Structs.h:124
cmf::SelectionType_t selectionType
Definition: Structs.h:84
enum cmf::sel_type SelectionType_t
long MCKey() const
Definition: Structs.h:120
std::ostream & operator<<(std::ostream &o, cmf::Event const &event)
Definition: Event.cxx:27
static bool IsNuESelected(cmf::SelectionType_t const &sel)
Definition: StaticFuncs.h:372
static bool IsNuMuQuantiles(cmf::SelectionType_t const &sel)
Definition: StaticFuncs.h:365
fileType
Definition: mkDefs.py:112
std::string DetectorString() const
Definition: Structs.h:151
static bool IsNuMuSelected(cmf::SelectionType_t const &sel)
Definition: StaticFuncs.h:358
const std::string cFileTypeStrings[10]
Definition: Constants.h:176
long FileKey() const
Definition: Structs.h:123
cmf::SelectionType_t selectionType
Definition: Structs.h:116
BeamType
Beam type. BOONE or NuMI.
bool IsRockMuon() const
Definition: Structs.h:140
std::string ToString(double value)
static long PeriodKey(long const &ep)
Definition: StaticFuncs.h:16
bool operator<(StanConfig::Verbosity a, StanConfig::Verbosity b)
Allow for comparing them, since kQuiet is definitely "less" verbose than kVerbose.
Definition: StanConfig.h:95
unsigned long int numGoodSpills
Definition: Structs.h:189
cmf::DetType_t detector
Definition: Structs.h:83
bool operator==(FC &A, FC &B)
static long InteractionTypeKey(cmf::InteractionType_t const &it)
Definition: StaticFuncs.h:20
Module to combine a set of results into a single file currently only does one data product type at a ...
Definition: Event.cxx:24
std::string DetectorFilePeriodString() const
Definition: Structs.h:168
cmf::FileType_t fileType
Definition: Structs.h:115
double goodPOT
Definition: Structs.h:186
int CantorPairingNumber
Definition: Structs.h:56
long InteractionKey() const
Definition: Structs.h:125
long BeamTypeKey() const
Definition: Structs.h:126
static long FileTypeKey(cmf::FileType_t const &ft)
Definition: StaticFuncs.h:17
enum cmf::beam_type BeamType_t
long Period() const
Definition: Structs.h:87
long period
Definition: Structs.h:118
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
cmf::InteractionType_t interactionType
Definition: Structs.h:117
const std::string cDetType_Strings[5]
Definition: Constants.h:29
double totalPOT
Definition: Structs.h:185
bool IsCosmicMuon() const
Definition: Structs.h:139
static long BeamTypeKey(cmf::BeamType_t const &bt)
Definition: StaticFuncs.h:18
enum cmf::file_type FileType_t
enum BeamMode string