NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
FileInfo.cpp
Go to the documentation of this file.
1 #include "Containers/FileInfo.h"
2 
3 #include "fmt/format.h"
4 
5 namespace NAIA {
7  FileName = "";
8  Run = NEvents = 0;
9  UTCTime = EventNo = {0, 0};
10 
11  BadRunReason = "";
12  BadRunTag = 0;
13 }
14 
15 void FileInfo::Dump() const {
16  fmt::print("{:=^120} \n", " FileInfo ");
17 
18  fmt::print("File: {}\n", FileName);
19 
20  fmt::print("{:>15} {:>15} {:^24} {:^24}\n", "Run", "NEvents", "UTCTime", "EventNo");
21 
22  fmt::print("{:>15} {:>15} [{:>10}, {:>10}] [{:>10}, {:>10}]\n", Run, NEvents, UTCTime.first, UTCTime.second,
23  EventNo.first, EventNo.second);
24 
25  fmt::print("{:-^120}\n", "");
26 }
27 
28 unsigned int MCFileInfo::GetNGen() const {
29  int ngen1 = EventNo.second;
30  if (EventNo.first > 1000)
31  ngen1 -= EventNo.first;
32  int ngen2 = DatacardNGen;
33  int ngen = 0;
34  // if file and datacard agree at percent, use datacard
35  if (fabs(ngen2 - ngen1) < 0.01 * ngen2)
36  ngen = ngen2;
37  // otherwise use last-first
38  else
39  ngen = ngen1;
40  // if number of generated is too low return 0
41  if (ngen < 1000)
42  return 0;
43  return ngen;
44 }
45 
46 double MCFileInfo::GetRMin() const {
47  if (Charge == 0)
48  return 0;
49  // by default take it from datacard
50  double rmin = fabs(DatacardMomentumRange.first / Charge);
51  return rmin;
52 }
53 
54 double MCFileInfo::GetRMax() const {
55  if (Charge == 0)
56  return 0;
57  // by default take it from datacard
58  double rmin = fabs(DatacardMomentumRange.second / Charge);
59  return rmin;
60 }
61 
63  Charge = DatacardNGen = 0;
64  Mass = 0;
65  DatacardPID = 0;
66 
67  EventNo = {0, 0};
69 
71 }
72 
73 void MCFileInfo::Dump() const {
74  fmt::print("{:=^120} \n", " MCFileInfo ");
75 
76  std::string focusName;
77  switch (Focus) {
78  case SimFocus::L1:
79  focusName = "L1";
80  break;
81  case SimFocus::L19:
82  focusName = "L19";
83  break;
84  case SimFocus::TB:
85  focusName = "TB";
86  break;
87  default:
88  break;
89  }
90 
91  fmt::print("Focus: {}\n", focusName);
92  fmt::print("Charge: {} Mass: {}\n", Charge, Mass);
93 
94  fmt::print("{:>15} {:^24} {:^24}\n", "DatacardPID", "MomentumRange", "DatacardMomentumRange");
95  fmt::print("{:>15} [{:>10}, {:>10}] [{:>10},{:>10}]\n", DatacardPID, MomentumRange.first, MomentumRange.second,
97 
98  fmt::print("{:-^120}\n", "");
99 }
100 
101 } // namespace NAIA
int DatacardPID
Geant4 PID of the primary particle (from datacard)
Definition: FileInfo.h:105
std::pair< float, float > MomentumRange
Momentum range as estimated from the events.
Definition: FileInfo.h:109
double GetRMin() const
Get the lower edge of the rigidity generation range.
Definition: FileInfo.cpp:46
std::string BadRunReason
If this is a bad run, the reason as returned by AMSSetupR::IsBadRun.
Definition: FileInfo.h:44
std::pair< unsigned int, unsigned int > EventNo
First / last event in the file.
Definition: FileInfo.h:108
unsigned int GetNGen() const
Estimates of the total number of requested events at generation level.
Definition: FileInfo.cpp:28
std::string FileName
Name of the processed file.
Definition: FileInfo.h:41
test beam simulation
std::pair< unsigned int, unsigned int > UTCTime
First and last second of this run.
Definition: FileInfo.h:39
std::pair< float, float > DatacardMomentumRange
Momentum range as estimated from the datacard.
Definition: FileInfo.h:110
void Dump() const
Dump on screen container content.
Definition: FileInfo.cpp:15
int BadRunTag
If this is a bad run, the tag as returned by AMSSetupR::IsBadRun.
Definition: FileInfo.h:43
unsigned int DatacardNGen
Number of generated events from datacard.
Definition: FileInfo.h:106
double GetRMax() const
Get the upper edge of the rigidity generation range.
Definition: FileInfo.cpp:54
FileInfo container class description.
unsigned int NEvents
Total number of processed events.
Definition: FileInfo.h:38
unsigned int Run
Run number.
Definition: FileInfo.h:37
void Clear()
Clear container content.
Definition: FileInfo.cpp:62
SimFocus Focus
Simulation focus.
Definition: FileInfo.h:112
particles shot towards Layer 1
void Dump() const
Dump on screen container content.
Definition: FileInfo.cpp:73
particles shot towards layer 1 and passing through layer 9
unsigned int Charge
Atomic number of the primary particle.
Definition: FileInfo.h:103
float Mass
Mass of the primary particle in GeV/c^2.
Definition: FileInfo.h:104
void Clear()
Clear container content.
Definition: FileInfo.cpp:6
std::pair< unsigned int, unsigned int > EventNo
First and last event of this run.
Definition: FileInfo.h:40