ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcLEDNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <TSystem.h>
6#include <TFile.h>
12
14
15ZdcLEDNtuple ::ZdcLEDNtuple(const std::string &name, ISvcLocator *pSvcLocator)
16 : EL::AnaAlgorithm(name, pSvcLocator)
17{
18
19
20 declareProperty("enableOutputTree", enableOutputTree = true, "Enable output tree");
21 declareProperty("auxSuffix", auxSuffix = "", "comment");
22
24}
25
26StatusCode ZdcLEDNtuple ::initialize()
27{
28
29 ANA_MSG_DEBUG("Howdy from Initialize!");
30
32 ANA_CHECK(m_zdcSumContainerName.initialize());
33
35 {
36
37 ANA_CHECK(book(TTree("zdcLEDTree", "ZDC LED Tree")));
38 m_outputTree = tree("zdcLEDTree");
39
40 m_outputTree->Branch("bcid", &t_bcid, "bcid/i");
41 m_outputTree->Branch("runNumber", &t_runNumber, "runNumber/i");
42 m_outputTree->Branch("eventNumber", &t_eventNumber, "eventNumber/i");
43 m_outputTree->Branch("lumiBlock", &t_lumiBlock, "lumiBlock/i");
44 m_outputTree->Branch("bunchGroup", &t_bunchGroup, "bunchGroup/b");
45 m_outputTree->Branch("extendedLevel1ID", &t_extendedLevel1ID, "extendedLevel1ID/i");
46 m_outputTree->Branch("timeStamp", &t_timeStamp, "timeStamp/i");
47 m_outputTree->Branch("timeStampNSOffset", &t_timeStampNSOffset, "timeStampNSOffset/i");
48
49 m_outputTree->Branch("avgIntPerCrossing", &t_avgIntPerCrossing, "avgIntPerCrossing/F");
50 m_outputTree->Branch("actIntPerCrossing", &t_actIntPerCrossing, "actIntPerCrossing/F");
51
52 m_outputTree->Branch("LEDType", &t_LEDType, "LEDType/i");
53
54 m_outputTree->Branch("ZdcModulePresample", &t_ZdcModulePresample, Form("ZdcModulePresample[%d][%d]/F", nSides, nZDC));
55 m_outputTree->Branch("ZdcModuleADCSum", &t_ZdcModuleADCSum, Form("ZdcModuleADCSum[%d][%d]/I", nSides, nZDC));
56 m_outputTree->Branch("ZdcModuleMaxADC", &t_ZdcModuleMaxADC, Form("ZdcModuleMaxADC[%d][%d]/I", nSides, nZDC));
57 m_outputTree->Branch("ZdcModuleMaxSample", &t_ZdcModuleMaxSample, Form("ZdcModuleMaxSample[%d][%d]/i", nSides, nZDC));
58 m_outputTree->Branch("ZdcModuleAvgTime", &t_ZdcModuleAvgTime, Form("ZdcModuleAvgTime[%d][%d]/F", nSides, nZDC));
59 m_outputTree->Branch("ZdcModuleRawsLowGain", &t_ZdcModuleg0data, Form("ZdcModuleRawsLowGain[%d][%d][%d]/s", nSides, nZDC, nSamples));
60 m_outputTree->Branch("ZdcModuleRawsHighGain", &t_ZdcModuleg1data, Form("ZdcModuleRawsHighGain[%d][%d][%d]/s", nSides, nZDC, nSamples));
61 m_outputTree->Branch("RPDModuleRaws", &t_RPDModuleRawdata, Form("RPDModuleRaws[%d][%d][%d]/s", nSides, nRPD, nSamples));
62 m_outputTree->Branch("RPDModulePresample", &t_RPDModulePresample, Form("RPDModulePresample[%d][%d]/F", nSides, nRPD));
63 m_outputTree->Branch("RPDModuleADCSum", &t_RPDModuleADCSum, Form("RPDModuleADCSum[%d][%d]/I", nSides, nRPD));
64 m_outputTree->Branch("RPDModuleMaxADC", &t_RPDModuleMaxADC, Form("RPDModuleMaxADC[%d][%d]/I", nSides, nRPD));
65 m_outputTree->Branch("RPDModuleMaxSample", &t_RPDModuleMaxSample, Form("RPDModuleMaxSample[%d][%d]/i", nSides, nRPD));
66 m_outputTree->Branch("RPDModuleAvgTime", &t_RPDModuleAvgTime, Form("RPDModuleAvgTime[%d][%d]/F", nSides, nRPD));
67 }
68
69 return StatusCode::SUCCESS;
70}
71
72StatusCode ZdcLEDNtuple ::execute()
73{
74 if (!evtStore())
75 {
76 ANA_MSG_INFO("*** No event found! ***");
77 return StatusCode::SUCCESS;
78 }
79
80 ANA_CHECK(evtStore()->retrieve(m_eventInfo, "EventInfo"));
83
85 {
86 if (t_LEDType == 0 || t_LEDType == 1 || t_LEDType == 2 )
87 {
88 tree("zdcLEDTree")->Fill();
89 }
90 }
91
92 return StatusCode::SUCCESS;
93}
94
96{
97 // iside 0 is side C, iside 1 is side A
100
101 ANA_MSG_DEBUG("copying already processed info!");
102
103 for (size_t iside = 0; iside < nSides; iside++)
104 {
105 for (int imod = 0; imod < nZDC; imod++)
106 {
107 t_ZdcModulePresample[iside][imod] = 0;
108 t_ZdcModuleADCSum[iside][imod] = 0;
109 t_ZdcModuleMaxADC[iside][imod] = 0;
110 t_ZdcModuleMaxSample[iside][imod] = 0;
111 t_ZdcModuleAvgTime[iside][imod] = 0;
112
113 for (int isam = 0; isam < nSamples; isam++)
114 {
115 t_ZdcModuleg0data[iside][imod][isam] = 0;
116 t_ZdcModuleg1data[iside][imod][isam] = 0;
117 }
118 }
119 for (int imod = 0; imod < nRPD; imod++)
120 {
121 t_RPDModulePresample[iside][imod] = 0;
122 t_RPDModuleADCSum[iside][imod] = 0;
123 t_RPDModuleMaxADC[iside][imod] = 0;
124 t_RPDModuleMaxSample[iside][imod] = 0;
125 t_RPDModuleAvgTime[iside][imod] = 0;
126 }
127 }
128
129 ANA_MSG_DEBUG("accessing ZdcModules");
130
131 SG::ConstAccessor<int> ADCSumAcc("ADCSum" + auxSuffix);
132 SG::ConstAccessor<unsigned int> LEDTypeAcc("LEDType" + auxSuffix);
133 SG::ConstAccessor<float> PresampleAcc("Presample"+auxSuffix);
134 SG::ConstAccessor<int> MaxADCAcc("MaxADC" + auxSuffix);
135 SG::ConstAccessor<unsigned int> MaxSampleAcc("MaxSample" + auxSuffix);
136 SG::ConstAccessor<float> AvgTimeAcc("AvgTime" + auxSuffix);
139
140 if (zdcModules.ptr())
141 {
142
143 for (const auto zdcMod : *zdcModules)
144 {
145 if (ADCSumAcc.isAvailable(*zdcMod))
146 {
147 if (zdcSums.ptr())
148 {
149 for (const auto zdcSum : *zdcSums)
150 {
151 if (zdcSum->zdcSide() == infoSumInd)
152 {
153 if (LEDTypeAcc.isAvailable(*zdcSum))
154 {
155 t_LEDType = LEDTypeAcc(*zdcSum);
156 break;
157 }
158 }
159 }
160 }
161 }
162 else
163 {
164 t_LEDType = 999;
165 break;
166 }
167 if (zdcMod->zdcSide() != 0)
168 { // side 0 is info
169 int iside = 0;
170 if (zdcMod->zdcSide() > 0)
171 iside = 1;
172
173 ANA_MSG_VERBOSE("Module " << zdcMod->zdcSide() << " " << zdcMod->zdcModule());
174 if (zdcMod->zdcType() == ZdcTypeInd)
175 {
176 int imod = zdcMod->zdcModule();
177 if (!PresampleAcc.isAvailable(*zdcMod))
178 {
179 ANA_MSG_WARNING("Missing ZDC aux data");
180 continue;
181 }
182 t_ZdcModulePresample[iside][imod] = PresampleAcc(*zdcMod);
183 t_ZdcModuleADCSum[iside][imod] = ADCSumAcc(*zdcMod);
184 t_ZdcModuleMaxADC[iside][imod] = MaxADCAcc(*zdcMod);
185 t_ZdcModuleMaxSample[iside][imod] = MaxSampleAcc(*zdcMod);
186 t_ZdcModuleAvgTime[iside][imod] = AvgTimeAcc(*zdcMod);
187
188 g0dataVec = g0dataAcc(*zdcMod);
189 g1dataVec = g1dataAcc(*zdcMod);
190
191 for (int isam = 0; isam < nSamples; isam++)
192 {
193 t_ZdcModuleg0data[iside][imod][isam] = g0dataVec.at(isam);
194 t_ZdcModuleg1data[iside][imod][isam] = g1dataVec.at(isam);
195 }
196 }
197 if ((zdcMod->zdcType() == RPDTypeInd) && (zdcMod->zdcModule() == RPDModuleInd))
198 {
199 int imod = zdcMod->zdcChannel();
200 if (!PresampleAcc.isAvailable(*zdcMod))
201 {
202 ANA_MSG_WARNING("Missing RPD aux data");
203 continue;
204 }
205 t_RPDModulePresample[iside][imod] = PresampleAcc(*zdcMod);
206 t_RPDModuleADCSum[iside][imod] = ADCSumAcc(*zdcMod);
207 t_RPDModuleMaxADC[iside][imod] = MaxADCAcc(*zdcMod);
208 t_RPDModuleMaxSample[iside][imod] = MaxSampleAcc(*zdcMod);
209 t_RPDModuleAvgTime[iside][imod] = AvgTimeAcc(*zdcMod);
210
211 g0dataVec = g0dataAcc(*zdcMod);
212
213 for (int isam = 0; isam < nSamples; isam++)
214 {
215 t_RPDModuleRawdata[iside][imod][isam] = g0dataVec.at(isam);
216 }
217 }
218 }
219 }
220 }
221}
222
224{
225 ANA_MSG_DEBUG("processing event info");
226
227 t_bcid = m_eventInfo->bcid();
228 t_runNumber = m_eventInfo->runNumber();
229 t_eventNumber = m_eventInfo->eventNumber();
230 t_lumiBlock = m_eventInfo->lumiBlock();
231 t_bunchGroup = -1;
232 t_extendedLevel1ID = m_eventInfo->extendedLevel1ID();
233 t_timeStamp = m_eventInfo->timeStamp();
234 t_timeStampNSOffset = m_eventInfo->timeStampNSOffset();
235 t_avgIntPerCrossing = m_eventInfo->averageInteractionsPerCrossing();
236 t_actIntPerCrossing = m_eventInfo->actualInteractionsPerCrossing();
237
238 if (!(m_eventCounter++ % 1000))
239 {
240 ANA_MSG_INFO("Event# " << m_eventCounter << "Run " << m_eventInfo->runNumber() << " Event " << m_eventInfo->eventNumber() << " LB " << m_eventInfo->lumiBlock());
241 }
242}
243
244StatusCode ZdcLEDNtuple ::finalize()
245{
246 return StatusCode::SUCCESS;
247}
Helper class to provide constant type-safe access to aux data.
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
#define ANA_MSG_VERBOSE(xmsg)
Macro printing verbose messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const_pointer_type ptr()
Dereference the pointer.
unsigned int t_RPDModuleMaxSample[nSides][nRPD]
uint32_t t_timeStamp
uint16_t t_RPDModuleRawdata[nSides][nRPD][nSamples]
int t_ZdcModuleMaxADC[nSides][nZDC]
uint32_t t_extendedLevel1ID
void processZdcLEDNtupleFromModules()
TTree * m_outputTree
static constexpr int nSides
int t_RPDModuleMaxADC[nSides][nRPD]
bool enableOutputTree
float t_RPDModulePresample[nSides][nRPD]
unsigned int t_ZdcModuleMaxSample[nSides][nZDC]
float t_RPDModuleAvgTime[nSides][nRPD]
std::string auxSuffix
uint32_t t_eventNumber
uint32_t t_runNumber
float t_actIntPerCrossing
std::vector< uint16_t > g1dataVec
std::vector< uint16_t > g0dataVec
uint32_t t_timeStampNSOffset
unsigned int t_LEDType
float t_avgIntPerCrossing
uint32_t t_bcid
static constexpr int nSamples
static constexpr int ZdcTypeInd
static constexpr int RPDModuleInd
static constexpr int RPDTypeInd
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerName
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcSumContainerName
uint16_t t_ZdcModuleg0data[nSides][nZDC][nSamples]
int t_RPDModuleADCSum[nSides][nRPD]
static constexpr int nRPD
int t_ZdcModuleADCSum[nSides][nZDC]
uint8_t t_bunchGroup
static constexpr int nZDC
static constexpr int infoSumInd
uint32_t t_lumiBlock
float t_ZdcModulePresample[nSides][nZDC]
void processEventInfo()
uint16_t t_ZdcModuleg1data[nSides][nZDC][nSamples]
const xAOD::EventInfo * m_eventInfo
float t_ZdcModuleAvgTime[nSides][nZDC]
This module defines the arguments passed from the BATCH driver to the BATCH worker.
TChain * tree