SND@LHC Software
Loading...
Searching...
No Matches
SNDLHCEventHeader.cxx
Go to the documentation of this file.
1#include "SNDLHCEventHeader.h"
3#include "FairRootManager.h"
4
5#include <ctime>
6#include <iostream>
7#include <map>
8#include <string>
9#include <vector>
10
11using namespace std;
12
13// Helper function to get the left shift corresponding to a mask
14constexpr int maskToShift(uint64_t mask) {
15 int c = 64; // c will be the number of zero bits on the right
16 mask &= -mask;
17 if (mask) c--;
18 if (mask & 0x00000000FFFFFFFF) c -= 32;
19 if (mask & 0x0000FFFF0000FFFF) c -= 16;
20 if (mask & 0x00FF00FF00FF00FF) c -= 8;
21 if (mask & 0x0F0F0F0F0F0F0F0F) c -= 4;
22 if (mask & 0x3333333333333333) c -= 2;
23 if (mask & 0x5555555555555555) c -= 1;
24
25 return c;
26}
27
28// ----- Default constructor -------------------------------------------
30 : TNamed()
31 , fRunId(0)
32 , fEventTime(-1)
33 , fInputFileId(-1)
34 , fEventNumber(-1)
35 , fFlags(0)
36 , fFillNumber(0)
37 , fAccMode(0)
38 , fBeamMode(0)
39 , fBunchType(-1)
40{}
41// -------------------------------------------------------------------------
42
43// ----- Standard constructor ------------------------------------------
44SNDLHCEventHeader::SNDLHCEventHeader(Int_t runN, uint64_t evtNumber, int64_t timestamp, uint64_t flags, int16_t bunchType)
45{
46 SetRunId(runN);
47 SetEventTime(timestamp);
48 SetEventNumber(evtNumber);
49 SetFlags(flags);
50 SetBunchType(bunchType);
51}
52
53// -------------------------------------------------------------------------
54
55// ----- Destructor ----------------------------------------------------
57// -------------------------------------------------------------------------
58
59//----- Setters --------------------------------------------------------
60void SNDLHCEventHeader::SetFlags(uint64_t flags)
61{
62 fFlags = flags;
63 fFillNumber = (fFlags & FILL_NUMBER_MASK);
64 fAccMode = (fFlags & ACCELERATOR_MODE_MASK) >> maskToShift(ACCELERATOR_MODE_MASK);
65 fBeamMode = (fFlags & BEAM_MODE_MASK) >> maskToShift(BEAM_MODE_MASK);
66}
67//----- Getters ----------------------------------------------------
69{
70 time_t time = fUTCtimestamp;
71 struct tm *GMTtime;
72 GMTtime = gmtime(&time);
73
74 return asctime(GMTtime);
75}
76
78{
79 map<string, bool> FastNoiseFilters{};
80
81 auto base = (fFlags & FAST_FILTER_MASK) >> maskToShift(FAST_FILTER_MASK);
82 FastNoiseFilters["SciFi"] = base & FAST_FILTER_SCIFI;
83 FastNoiseFilters["SciFi_Total"] = base & FAST_FILTER_SCIFI_TOTAL;
84 FastNoiseFilters["US"] = base & FAST_FILTER_US;
85 FastNoiseFilters["US_Total"] = base & FAST_FILTER_US_TOTAL;
86 FastNoiseFilters["DS"] = base & FAST_FILTER_DS;
87 FastNoiseFilters["DS_Total"] = base & FAST_FILTER_DS_TOTAL;
88 FastNoiseFilters["Veto_Total"] = base & FAST_FILTER_VETO_TOTAL;
89
90 return FastNoiseFilters;
91}
92
94{
95 map<string, bool> AdvNoiseFilters{};
96
97 auto base = (fFlags & ADVANCED_FILTER_MASK) >> maskToShift(ADVANCED_FILTER_MASK);
98 AdvNoiseFilters["SciFi_Planes"] = base & ADVANCED_FILTER_SCIFI_PLANES;
99 AdvNoiseFilters["SciFi_Hits"] = base & ADVANCED_FILTER_SCIFI_HITS;
100 AdvNoiseFilters["US_Planes"] = base & ADVANCED_FILTER_US_PLANES;
101 AdvNoiseFilters["US_Hits"] = base & ADVANCED_FILTER_US_HITS;
102 AdvNoiseFilters["DSH_Planes"] = base & ADVANCED_FILTER_DSH_PLANES;
103 AdvNoiseFilters["DSH_Hits"] = base & ADVANCED_FILTER_DSH_HITS;
104 AdvNoiseFilters["DSV_Planes"] = base & ADVANCED_FILTER_DSV_PLANES;
105 AdvNoiseFilters["DSV_Hits"] = base & ADVANCED_FILTER_DSV_HITS;
106 AdvNoiseFilters["DS_Planes"] = base & ADVANCED_FILTER_DS_PLANES;
107 AdvNoiseFilters["VETO_Planes"] = base & ADVANCED_FILTER_VETO_PLANES;
108 AdvNoiseFilters["VETO_Hits"] = base & ADVANCED_FILTER_VETO_HITS;
109 AdvNoiseFilters["GLOBAL_Planes"] = base & ADVANCED_FILTER_GLOBAL_PLANES;
110
111 return AdvNoiseFilters;
112}
113
115{
116 map<string, bool> FastNoiseFilters = GetFastNoiseFilters();
117 vector<string> passed;
118 for ( auto it : FastNoiseFilters )
119 if ( it.second == true ) passed.push_back(it.first);
120
121 return passed;
122}
123
125{
126 map<string, bool> AdvNoiseFilters = GetAdvNoiseFilters();
127 vector<string> passed;
128 for ( auto it : AdvNoiseFilters )
129 if ( it.second == true ) passed.push_back(it.first);
130
131 return passed;
132}
133
135{
136 return (fBunchType/1000)%10==1;
137}
138
140{
141 return (fBunchType/100)%10==1;
142}
143
145{
146 return (fBunchType/10)%10==1;
147}
148
150{
151 return fBunchType%10==1;
152}
153
155{
156 /* b1 and not IP1 and not b2 */
157 return isB1() && !isIP1() && !isB2();
158}
159
161{
162 /* b2 and not b1 */
163 return isB2() && !isB1();
164}
165
167{
168 /* not b1 and not b2
169 Also, its return must be False in case
170 no filling scheme data is available (fBunchType=-1) */
171 return fBunchType%10==0 && (fBunchType/10)%10==0;
172}
173
175{
176 /* no filling scheme data available (fBunchType=-1) */
177 return fBunchType%10==-1;
178}
179// ----- Public method Print -------------------------------------------
180void SNDLHCEventHeader::Print(const Option_t* opt) const
181{
182
183 cout << "-I- SNDLHCEventHeader: run number " << fRunId
184 << " event number " << fEventNumber
185 << " timestamp " << fEventTime << endl
186 << " LHC fill number " << fFillNumber
187 << " LHC beam mode " << fBeamMode << endl;
188
189}
190// -------------------------------------------------------------------------
191
193
constexpr int maskToShift(uint64_t mask)
virtual void Print(const Option_t *opt) const
void SetBunchType(int16_t bunchType)
std::map< std::string, bool > GetFastNoiseFilters()
void SetEventTime(int64_t time)
void SetRunId(uint64_t runid)
void SetFlags(uint64_t flags)
std::map< std::string, bool > GetAdvNoiseFilters()
std::vector< std::string > GetPassedFastNFCriteria()
std::string GetTimeAsString()
std::vector< std::string > GetPassedAdvNFCriteria()
void SetEventNumber(int id)
ClassImp(ecalContFact) ecalContFact