NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
RTIInfo.cpp
Go to the documentation of this file.
1 #include "Containers/RTIInfo.h"
2 
3 #include "TMath.h"
4 
5 #include "fmt/format.h"
6 
7 namespace NAIA {
8 
9 TGraph RTIInfo::m_saaEdge = TGraph();
10 
11 const std::array<float, RTIInfo::nrigbins + 1> RTIInfo::rigbins = {0., 0.5, 1.0, 1.33, 1.71, 2.15, 2.67,
12  3.29, 3.64, 4.43, 5.37, 6.47, 7.76, 9.26,
13  11.0, 13.0, 15.3, 18.0, 21.1, 24.7, 100000};
14 const std::array<float, RTIInfo::nbetabins + 1> RTIInfo::betabins = {0., 0.5, 0.6, 0.7, 0.8,
15  0.85, 0.9, 0.95, 0.99, 0.999};
16 
17 const std::map<unsigned int, std::pair<float, float>> RTIInfo::qbins = {
18  {1, {0.7, 1.3}}, {2, {1.7, 2.3}}, {3, {2.7, 5.3}}, {4, {5.55, 8.45}},
19  {5, {9.55, 14.5}}, {6, {14.5, 25.5}}, {7, {25.5, 26.5}}, {8, {26.5, 100}}};
20 
22  static unsigned long long lastSec = 0;
23 
24  if (lastSec != UTCTime) {
25  time_t time{UTCTime};
26  m_humanTime = *gmtime(&time);
27  lastSec = UTCTime;
28  }
29 }
30 
31 unsigned int RTIInfo::Year() {
32  UpdateTM();
33  return m_humanTime.tm_year + 1900;
34 }
35 
36 unsigned int RTIInfo::Month() {
37  UpdateTM();
38  return m_humanTime.tm_mon + 1;
39 }
40 
41 unsigned int RTIInfo::DayOfMonth() {
42  UpdateTM();
43  return m_humanTime.tm_mday;
44 }
45 
46 unsigned int RTIInfo::DayOfYear() {
47  UpdateTM();
48  return m_humanTime.tm_yday + 1;
49 }
50 
51 unsigned int RTIInfo::Hour() {
52  UpdateTM();
53  return m_humanTime.tm_hour;
54 }
55 
56 unsigned int RTIInfo::Minute() {
57  UpdateTM();
58  return m_humanTime.tm_min;
59 }
60 
61 unsigned int RTIInfo::Second() {
62  UpdateTM();
63  return m_humanTime.tm_sec;
64 }
65 
66 bool RTIInfo::IsInSAA() const {
67  if (m_saaEdge.GetN() == 0) {
68  m_saaEdge.SetPoint(0, -46.9020531516, 1.07065020944);
69  m_saaEdge.SetPoint(1, -42.4324570724, 0.278767621219);
70  m_saaEdge.SetPoint(2, -38.7963908651, -0.864383087583);
71  m_saaEdge.SetPoint(3, -32.3643804368, -7.86605177782);
72  m_saaEdge.SetPoint(4, -32.1564301222, -8.2925091686);
73  m_saaEdge.SetPoint(5, -30.4732034929, -10.2380772476);
74  m_saaEdge.SetPoint(6, -28.9780074759, -11.1541721933);
75  m_saaEdge.SetPoint(7, -24.9729186857, -13.9219707474);
76  m_saaEdge.SetPoint(8, -22.3514515118, -15.8035549547);
77  m_saaEdge.SetPoint(9, -17.864105537, -17.5329648531);
78  m_saaEdge.SetPoint(10, -13.7360395887, -18.4514556443);
79  m_saaEdge.SetPoint(11, -9.31195234438, -20.5579164624);
80  m_saaEdge.SetPoint(12, -7.18498632474, -21.1949557893);
81  m_saaEdge.SetPoint(13, -3.59895538649, -23.8036939586);
82  m_saaEdge.SetPoint(14, -2.34504587932, -24.8012082521);
83  m_saaEdge.SetPoint(15, -0.819716509312, -27.065064314);
84  m_saaEdge.SetPoint(16, -0.0558141297819, -29.4952077252);
85  m_saaEdge.SetPoint(17, -1.39465186809, -31.1867845581);
86  m_saaEdge.SetPoint(18, -4.48059829104, -33.3607272689);
87  m_saaEdge.SetPoint(19, -8.42183566883, -35.9587368092);
88  m_saaEdge.SetPoint(20, -9.27876931794, -36.2964186885);
89  m_saaEdge.SetPoint(21, -13.8165106415, -37.7311180334);
90  m_saaEdge.SetPoint(22, -17.4924677527, -39.0468547418);
91  m_saaEdge.SetPoint(23, -18.408230558, -39.407844502);
92  m_saaEdge.SetPoint(24, -19.3555119436, -39.7809321206);
93  m_saaEdge.SetPoint(25, -26.2402929635, -42.5628157663);
94  m_saaEdge.SetPoint(26, -29.3390198221, -43.7512422146);
95  m_saaEdge.SetPoint(27, -30.4468807826, -44.1487676525);
96  m_saaEdge.SetPoint(28, -36.2608202879, -44.9657315842);
97  m_saaEdge.SetPoint(29, -38.6471514882, -45.8362408379);
98  m_saaEdge.SetPoint(30, -39.884535768, -46.2670553531);
99  m_saaEdge.SetPoint(31, -41.1537099863, -46.7007904009);
100  m_saaEdge.SetPoint(32, -46.4231376314, -47.035405079);
101  m_saaEdge.SetPoint(33, -50.5517527888, -46.9389068642);
102  m_saaEdge.SetPoint(34, -56.1886816966, -45.9179669008);
103  m_saaEdge.SetPoint(35, -60.4620401598, -44.5064118787);
104  m_saaEdge.SetPoint(36, -65.9797837207, -40.9661101604);
105  m_saaEdge.SetPoint(37, -68.6756029734, -39.1105256272);
106  m_saaEdge.SetPoint(38, -69.9926612952, -38.1896928803);
107  m_saaEdge.SetPoint(39, -72.5874587403, -35.1855408369);
108  m_saaEdge.SetPoint(40, -74.9768865609, -32.1834974998);
109  m_saaEdge.SetPoint(41, -79.386936716, -24.8704780079);
110  m_saaEdge.SetPoint(42, -81.5015374707, -20.6638534546);
111  m_saaEdge.SetPoint(43, -83.3018473547, -16.5956399645);
112  m_saaEdge.SetPoint(44, -83.4855953538, -15.6706377827);
113  m_saaEdge.SetPoint(45, -83.4016563744, -13.3880324461);
114  m_saaEdge.SetPoint(46, -79.0157111546, -9.8025691601);
115  m_saaEdge.SetPoint(47, -76.0062621477, -8.49383318946);
116  m_saaEdge.SetPoint(48, -71.9675022979, -7.9008874195);
117  m_saaEdge.SetPoint(49, -69.1989836702, -6.34481990494);
118  m_saaEdge.SetPoint(50, -68.320940027, -6.15577355353);
119  m_saaEdge.SetPoint(51, -60.8270728968, -4.71604157559);
120  m_saaEdge.SetPoint(52, -57.4730300335, -3.41729725291);
121  m_saaEdge.SetPoint(53, -53.25104737, -1.64190214253);
122  m_saaEdge.SetPoint(54, -51.5811868613, -0.10182123818);
123  m_saaEdge.SetPoint(55, -49.9470795728, 1.16581717215);
124  m_saaEdge.SetPoint(56, -46.9020531516, 1.07065020944);
125  }
126 
127  float rtiLong = Phi * TMath::RadToDeg();
128  float rtiLat = Theta * TMath::RadToDeg();
129  while (rtiLong > 180.0f)
130  rtiLong -= 360.0f;
131 
132  return m_saaEdge.IsInside(rtiLong, rtiLat);
133 };
134 
136  Run = RunTag = FirstEvNo = LastEvNo = good = UTCTime = 0;
139 
141 
143 
144  nTRDTrack = nTRDHits = 0;
145  nEcalShower = nEcalHits = 0;
147  nTofClusterH = 0;
149  nTrk = nTrkInn = 0;
150  nACC = 0;
153  nRoomError = 0;
154 
155  // reset arrays
156  decltype(MaxStoermerCutoff){0}.swap(MaxStoermerCutoff);
157  decltype(MaxIGRFCutoff){0}.swap(MaxIGRFCutoff);
158  decltype(MinIGRFCutoff){0}.swap(MinIGRFCutoff);
159  decltype(nEventInnerL1L9){0}.swap(nEventInnerL1L9);
160  decltype(MeanAlignDiffExtLayer){0}.swap(MeanAlignDiffExtLayer);
161 
162  decltype(nTRDLayerHits){0}.swap(nTRDLayerHits);
163  decltype(nPartRate){0}.swap(nPartRate);
164  decltype(nPartInnRate){0}.swap(nPartInnRate);
165  decltype(nPartBetaRate){0}.swap(nPartBetaRate);
166  decltype(nPartAboveCutoff){0}.swap(nPartAboveCutoff);
167  decltype(nPartBelowCutoff){0}.swap(nPartBelowCutoff);
168  decltype(nTrkRate){0}.swap(nTrkRate);
169  decltype(nTrkInnRate){0}.swap(nTrkInnRate);
170  decltype(TrigPhysBPatt){0}.swap(TrigPhysBPatt);
171  decltype(TrigJMembPatt){0}.swap(TrigJMembPatt);
172  decltype(TrigRates){0}.swap(TrigRates);
173  decltype(TofFlags){0}.swap(TofFlags);
174 }
175 
176 void RTIInfo::Dump() const {
177  fmt::print("{:=^120} \n", " RTIInfo ");
178 
179  fmt::print("{:>15} {:>15} {:>15} {:>20} {:>15} {:>15} {:>15} {:>15} {:>15}\n", "Run", "RunTag", "UTCTime",
180  "LivetimeFraction", "Theta", "Phi", "Altitude", "nEvent", "nError");
181 
182  fmt::print("{:>15} {:>15x} {:>15} {:>20} {:>15} {:>15} {:>15} {:>15} {:>15}\n", Run, RunTag, UTCTime,
184  fmt::print("{:-^120}\n", "");
185 }
186 
187 } // namespace NAIA
unsigned int Month()
Get the current month [1-12].
Definition: RTIInfo.cpp:36
float nTrigger
Number of events with trigger in this second.
Definition: RTIInfo.h:83
float nPartTrkInn
Average number of ParticleR with InnerTracker track.
Definition: RTIInfo.h:120
float nTRDHitAvg
Average number of TRD raw hits for one event.
Definition: RTIInfo.h:89
void Clear()
Clear container content.
Definition: RTIInfo.cpp:135
bool DSPErrorJLV1
Has a DSP error occurred in JLV1 in this second?
Definition: RTIInfo.h:97
float nEventParticle
Number of events with tof+trd+tracker+ecal data.
Definition: RTIInfo.h:85
float Altitude
Altitude (gtod coordinate system) (cm)
Definition: RTIInfo.h:77
std::array< std::array< float, 2 >, 4 > MaxStoermerCutoff
Max Stoermer cutoff within a 25,30,35,40 degrees field of view (for both negative and positive partic...
Definition: RTIInfo.h:71
unsigned int LastEvNo
Last event no in this second.
Definition: RTIInfo.h:67
unsigned int FirstEvNo
First event nnumber in this second.
Definition: RTIInfo.h:66
unsigned int RunTag
Run tag.
Definition: RTIInfo.h:65
std::array< std::array< float, 2 >, 4 > MaxIGRFCutoff
Max IGRF cutoff within a 25,30,35,40 degrees field of view (for both negative and positive particles)...
Definition: RTIInfo.h:72
float nACC
Average number of ACC sectors.
Definition: RTIInfo.h:140
std::array< std::array< float, nbetabins+1 >, nqbins+1 > nPartBetaRate
Average number of ParticleR object divided by charge and beta.
Definition: RTIInfo.h:124
static const std::array< float, nbetabins+1 > betabins
Bin edges for beta-binned variables.
Definition: RTIInfo.h:160
std::array< float, 16 > TofFlags
Average value of TofFlags.
Definition: RTIInfo.h:141
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nTrkInnRate
Average number of TrTrackR object divided by charge and rigidity (inner tracker fit) ...
Definition: RTIInfo.h:134
std::array< float, nqbins+1 > nPartAboveCutoff
Average number of ParticleR objects above cutoff.
Definition: RTIInfo.h:127
float nTrClusterL1X
Average number of TrRawCluster on x side of L1.
Definition: RTIInfo.h:113
float nTrClusterY
Average number of TrRawCluster on y side.
Definition: RTIInfo.h:112
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nTrkRate
Average number of TrTrackR object divided by charge and rigidity.
Definition: RTIInfo.h:133
std::array< float, 8 > TrigPhysBPatt
Average fraction of each trigger pattern.
Definition: RTIInfo.h:137
std::array< float, 16 > TrigJMembPatt
Average fraction of each trigger pattern.
Definition: RTIInfo.h:138
float nHWError
Number of events with HW error (from JINJStatus)
Definition: RTIInfo.h:84
float nParticle
Average number of ParticleR objects.
Definition: RTIInfo.h:118
float nTrkInn
Average number of TrTrackR objects with inner fit.
Definition: RTIInfo.h:131
std::array< float, nqbins+1 > nPartBelowCutoff
Average number of ParticleR objects below cutoff.
Definition: RTIInfo.h:128
unsigned int Minute()
Get the current minute [0-59].
Definition: RTIInfo.cpp:56
float MagAltSphCoo
Magnetic coordinates altitude.
Definition: RTIInfo.h:101
float nTrClusterAvg
Average number of Tracker raw clusters for one event.
Definition: RTIInfo.h:90
float MostProbableHeRig
Most probable He rigidity for this second;.
Definition: RTIInfo.h:74
float LivetimeFraction
Livetime fraction during this second.
Definition: RTIInfo.h:68
float nTRDHits
Average number of total TrdRawHit.
Definition: RTIInfo.h:105
float nEcalShower
Average number of EcalShower objects.
Definition: RTIInfo.h:108
float Phi
Phi (gtod coordinate system) (rad)
Definition: RTIInfo.h:76
float nTrk
Average number of TrTrackR objects with default fit.
Definition: RTIInfo.h:130
void UpdateTM()
Definition: RTIInfo.cpp:21
float TofRaw_nsumh
High Threshold history.
Definition: RTIInfo.h:145
unsigned int UTCTime
JMDC unix time (seconds since 1 Jan 1970)
Definition: RTIInfo.h:92
float Theta
Theta (gtod coordinate system) (rad)
Definition: RTIInfo.h:75
bool DSPErrorJINF
Has a DSP error occurred in JINF in this second?
Definition: RTIInfo.h:96
float GalacticLong
Galactic longitude of AMS pointing direction (degrees)
Definition: RTIInfo.h:80
float Zenith
AMS zenith angle (degrees)
Definition: RTIInfo.h:78
std::array< std::array< float, 2 >, 2 > nEventInnerL1L9
Number of events with a track with layer 1 and layer 9 XY hit.
Definition: RTIInfo.h:86
static const std::map< unsigned int, std::pair< float, float > > qbins
Bin edges for charge-binned variables, depending on particle species.
Definition: RTIInfo.h:163
bool DSPError
Has a DSP error occurred in this second?
Definition: RTIInfo.h:94
float nEcalHits
Average number of EcalHit objects.
Definition: RTIInfo.h:109
float MagThetaSphCoo
Magnetic coordinates theta.
Definition: RTIInfo.h:99
float TofRaw_nftdc
Fast Trigger history.
Definition: RTIInfo.h:144
float nEvent
Total number of events in this second.
Definition: RTIInfo.h:81
unsigned int Second()
Get the current second [0-59].
Definition: RTIInfo.cpp:61
float MagPhiSphCoo
Magnetic coordinates phi.
Definition: RTIInfo.h:100
std::array< float, 19 > TrigRates
Average value of trigger rates.
Definition: RTIInfo.h:139
static TGraph m_saaEdge
Definition: RTIInfo.h:172
float nError
Number of missing events due to errors.
Definition: RTIInfo.h:82
float nPartTrk
Average number of ParticleR with Tracker track.
Definition: RTIInfo.h:121
unsigned int DayOfYear()
Get the current day of the year [1-366].
Definition: RTIInfo.cpp:46
std::array< float, 20 > nTRDLayerHits
Average number of TRD hits in each layer.
Definition: RTIInfo.h:106
unsigned int DayOfMonth()
Get the current day of the month [1-31].
Definition: RTIInfo.cpp:41
int good
0 if good (Thanks, Qi. Very descriptive)
Definition: RTIInfo.h:91
float nTrClusterX
Average number of TrRawCluster on x side.
Definition: RTIInfo.h:111
std::array< std::array< float, 3 >, 2 > MeanAlignDiffExtLayer
mean difference(um) bewteen PG ad CIEMAT alignment of L1 and L9(XYZ)
Definition: RTIInfo.h:87
bool IsInSAA() const
Check if the ISS is in the SAA for this second.
Definition: RTIInfo.cpp:66
tm m_humanTime
Definition: RTIInfo.h:169
void Dump() const
Dump on screen container content.
Definition: RTIInfo.cpp:176
float LShell
L shell.
Definition: RTIInfo.h:102
float AntiRaw_nftdc
Fast Trigger history.
Definition: RTIInfo.h:149
std::array< std::array< float, 2 >, 2 > MinIGRFCutoff
Min IGRF cutoff within a 25,40 degrees field of view (for both negative and positive particles) ...
Definition: RTIInfo.h:73
float nTofClusterH
Average number of TofClusterH objects.
Definition: RTIInfo.h:116
float nGoodParticle
Average number of &quot;good&quot; ParticleR objects.
Definition: RTIInfo.h:119
float TofRaw_nstdc
Low Threshold history.
Definition: RTIInfo.h:143
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nPartRate
Average number of ParticleR object divided by charge and rigidity.
Definition: RTIInfo.h:123
unsigned int Year()
Get the current year.
Definition: RTIInfo.cpp:31
float AntiRaw_ntdct
Low Threshold history.
Definition: RTIInfo.h:148
std::array< std::array< float, nrigbins+1 >, nqbins+1 > nPartInnRate
Average number of ParticleR object divided by charge and rigidity (inner tracker fit) ...
Definition: RTIInfo.h:125
unsigned int Hour()
Get the current hour [0-23].
Definition: RTIInfo.cpp:51
bool DSPErrorJINJ
Has a DSP error occurred in JINJ in this second?
Definition: RTIInfo.h:95
float nTRDTrack
Average number of TrdTrack objects.
Definition: RTIInfo.h:104
float TofRaw_nsumsh
Super-High Threshold history.
Definition: RTIInfo.h:146
float nTrClusterL1Y
Average number of TrRawCluster on y side of L1.
Definition: RTIInfo.h:114
float GalacticLat
Galactic latitude of AMS pointing direction (degrees)
Definition: RTIInfo.h:79
static const std::array< float, nrigbins+1 > rigbins
Bin edges for rigidity-binned variables.
Definition: RTIInfo.h:159
RTIInfo container class description.
float nRoomError
Average number of room errors.
Definition: RTIInfo.h:151
unsigned int Run
Run number.
Definition: RTIInfo.h:64