NAIA  1.1.1
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 (std::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 = std::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 = std::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
NAIA::MCFileInfo::GetRMax
double GetRMax() const
Get the upper edge of the rigidity generation range.
Definition: FileInfo.cpp:54
FileInfo.h
FileInfo container class description.
NAIA::MCFileInfo::DatacardPID
int DatacardPID
Geant4 PID of the primary particle (from datacard)
Definition: FileInfo.h:105
NAIA::MCFileInfo::Charge
unsigned int Charge
Atomic number of the primary particle.
Definition: FileInfo.h:103
NAIA::MCFileInfo::Mass
float Mass
Mass of the primary particle in GeV/c^2.
Definition: FileInfo.h:104
NAIA::FileInfo::BadRunTag
int BadRunTag
If this is a bad run, the tag as returned by AMSSetupR::IsBadRun.
Definition: FileInfo.h:43
NAIA::MCFileInfo::SimFocus::NONE
@ NONE
NAIA::MCFileInfo::GetNGen
unsigned int GetNGen() const
Estimates of the total number of requested events at generation level.
Definition: FileInfo.cpp:28
NAIA::MCFileInfo::Focus
SimFocus Focus
Simulation focus.
Definition: FileInfo.h:112
NAIA::FileInfo::Run
unsigned int Run
Run number.
Definition: FileInfo.h:37
NAIA::MCFileInfo::SimFocus::L1
@ L1
particles shot towards Layer 1
NAIA
Definition: Event.h:13
NAIA::MCFileInfo::DatacardNGen
unsigned int DatacardNGen
Number of generated events from datacard.
Definition: FileInfo.h:106
NAIA::MCFileInfo::SimFocus::L19
@ L19
particles shot towards layer 1 and passing through layer 9
NAIA::MCFileInfo::GetRMin
double GetRMin() const
Get the lower edge of the rigidity generation range.
Definition: FileInfo.cpp:46
NAIA::FileInfo::Dump
void Dump() const
Dump on screen container content.
Definition: FileInfo.cpp:15
NAIA::MCFileInfo::MomentumRange
std::pair< float, float > MomentumRange
Momentum range as estimated from the events.
Definition: FileInfo.h:109
NAIA::MCFileInfo::DatacardMomentumRange
std::pair< float, float > DatacardMomentumRange
Momentum range as estimated from the datacard.
Definition: FileInfo.h:110
NAIA::MCFileInfo::EventNo
std::pair< unsigned int, unsigned int > EventNo
First / last event in the file.
Definition: FileInfo.h:108
NAIA::FileInfo::UTCTime
std::pair< unsigned int, unsigned int > UTCTime
First and last second of this run.
Definition: FileInfo.h:39
NAIA::FileInfo::EventNo
std::pair< unsigned int, unsigned int > EventNo
First and last event of this run.
Definition: FileInfo.h:40
NAIA::FileInfo::Clear
void Clear()
Clear container content.
Definition: FileInfo.cpp:6
NAIA::MCFileInfo::SimFocus::TB
@ TB
test beam simulation
NAIA::MCFileInfo::Dump
void Dump() const
Dump on screen container content.
Definition: FileInfo.cpp:73
NAIA::MCFileInfo::Clear
void Clear()
Clear container content.
Definition: FileInfo.cpp:62
NAIA::FileInfo::BadRunReason
std::string BadRunReason
If this is a bad run, the reason as returned by AMSSetupR::IsBadRun.
Definition: FileInfo.h:44
NAIA::FileInfo::FileName
std::string FileName
Name of the processed file.
Definition: FileInfo.h:41
NAIA::FileInfo::NEvents
unsigned int NEvents
Total number of processed events.
Definition: FileInfo.h:38