ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcLEDNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
20StatusCode ZdcLEDNtuple ::initialize()
21{
22
23 ANA_MSG_DEBUG("Howdy from Initialize!");
24
26 ANA_CHECK(m_zdcSumContainerName.initialize());
27
29 {
30
31 ANA_CHECK(book(TTree("zdcLEDTree", "ZDC LED Tree")));
32 m_outputTree = tree("zdcLEDTree");
33
34 m_outputTree->Branch("bcid", &t_bcid, "bcid/i");
35 m_outputTree->Branch("runNumber", &t_runNumber, "runNumber/i");
36 m_outputTree->Branch("eventNumber", &t_eventNumber, "eventNumber/i");
37 m_outputTree->Branch("lumiBlock", &t_lumiBlock, "lumiBlock/i");
38 m_outputTree->Branch("bunchGroup", &t_bunchGroup, "bunchGroup/b");
39 m_outputTree->Branch("extendedLevel1ID", &t_extendedLevel1ID, "extendedLevel1ID/i");
40 m_outputTree->Branch("timeStamp", &t_timeStamp, "timeStamp/i");
41 m_outputTree->Branch("timeStampNSOffset", &t_timeStampNSOffset, "timeStampNSOffset/i");
42
43 m_outputTree->Branch("avgIntPerCrossing", &t_avgIntPerCrossing, "avgIntPerCrossing/F");
44 m_outputTree->Branch("actIntPerCrossing", &t_actIntPerCrossing, "actIntPerCrossing/F");
45
46 m_outputTree->Branch("LEDType", &t_LEDType, "LEDType/i");
47
48 m_outputTree->Branch("ZdcModulePresample", &t_ZdcModulePresample, Form("ZdcModulePresample[%d][%d]/F", nSides, nZDC));
49 m_outputTree->Branch("ZdcModuleADCSum", &t_ZdcModuleADCSum, Form("ZdcModuleADCSum[%d][%d]/I", nSides, nZDC));
50 m_outputTree->Branch("ZdcModuleMaxADC", &t_ZdcModuleMaxADC, Form("ZdcModuleMaxADC[%d][%d]/I", nSides, nZDC));
51 m_outputTree->Branch("ZdcModuleMaxSample", &t_ZdcModuleMaxSample, Form("ZdcModuleMaxSample[%d][%d]/i", nSides, nZDC));
52 m_outputTree->Branch("ZdcModuleAvgTime", &t_ZdcModuleAvgTime, Form("ZdcModuleAvgTime[%d][%d]/F", nSides, nZDC));
53 m_outputTree->Branch("ZdcModuleRawsLowGain", &t_ZdcModuleg0data, Form("ZdcModuleRawsLowGain[%d][%d][%d]/s", nSides, nZDC, nSamples));
54 m_outputTree->Branch("ZdcModuleRawsHighGain", &t_ZdcModuleg1data, Form("ZdcModuleRawsHighGain[%d][%d][%d]/s", nSides, nZDC, nSamples));
55 m_outputTree->Branch("RPDModuleRaws", &t_RPDModuleRawdata, Form("RPDModuleRaws[%d][%d][%d]/s", nSides, nRPD, nSamples));
56 m_outputTree->Branch("RPDModulePresample", &t_RPDModulePresample, Form("RPDModulePresample[%d][%d]/F", nSides, nRPD));
57 m_outputTree->Branch("RPDModuleADCSum", &t_RPDModuleADCSum, Form("RPDModuleADCSum[%d][%d]/I", nSides, nRPD));
58 m_outputTree->Branch("RPDModuleMaxADC", &t_RPDModuleMaxADC, Form("RPDModuleMaxADC[%d][%d]/I", nSides, nRPD));
59 m_outputTree->Branch("RPDModuleMaxSample", &t_RPDModuleMaxSample, Form("RPDModuleMaxSample[%d][%d]/i", nSides, nRPD));
60 m_outputTree->Branch("RPDModuleAvgTime", &t_RPDModuleAvgTime, Form("RPDModuleAvgTime[%d][%d]/F", nSides, nRPD));
61 }
62
63 return StatusCode::SUCCESS;
64}
65
66StatusCode ZdcLEDNtuple ::execute()
67{
68 if (!evtStore())
69 {
70 ANA_MSG_INFO("*** No event found! ***");
71 return StatusCode::SUCCESS;
72 }
73
74 ANA_CHECK(evtStore()->retrieve(m_eventInfo, "EventInfo"));
77
79 {
80 if (t_LEDType == 0 || t_LEDType == 1 || t_LEDType == 2 )
81 {
82 tree("zdcLEDTree")->Fill();
83 }
84 }
85
86 return StatusCode::SUCCESS;
87}
88
90{
91 // iside 0 is side C, iside 1 is side A
94
95 ANA_MSG_DEBUG("copying already processed info!");
96
97 for (size_t iside = 0; iside < nSides; iside++)
98 {
99 for (int imod = 0; imod < nZDC; imod++)
100 {
101 t_ZdcModulePresample[iside][imod] = 0;
102 t_ZdcModuleADCSum[iside][imod] = 0;
103 t_ZdcModuleMaxADC[iside][imod] = 0;
104 t_ZdcModuleMaxSample[iside][imod] = 0;
105 t_ZdcModuleAvgTime[iside][imod] = 0;
106
107 for (int isam = 0; isam < nSamples; isam++)
108 {
109 t_ZdcModuleg0data[iside][imod][isam] = 0;
110 t_ZdcModuleg1data[iside][imod][isam] = 0;
111 }
112 }
113 for (int imod = 0; imod < nRPD; imod++)
114 {
115 t_RPDModulePresample[iside][imod] = 0;
116 t_RPDModuleADCSum[iside][imod] = 0;
117 t_RPDModuleMaxADC[iside][imod] = 0;
118 t_RPDModuleMaxSample[iside][imod] = 0;
119 t_RPDModuleAvgTime[iside][imod] = 0;
120 }
121 }
122
123 ANA_MSG_DEBUG("accessing ZdcModules");
124
125 SG::ConstAccessor<int> ADCSumAcc("ADCSum" + auxSuffix.value());
126 SG::ConstAccessor<unsigned int> LEDTypeAcc("LEDType" + auxSuffix.value());
127 SG::ConstAccessor<float> PresampleAcc("Presample"+auxSuffix.value());
128 SG::ConstAccessor<int> MaxADCAcc("MaxADC" + auxSuffix.value());
129 SG::ConstAccessor<unsigned int> MaxSampleAcc("MaxSample" + auxSuffix.value());
130 SG::ConstAccessor<float> AvgTimeAcc("AvgTime" + auxSuffix.value());
131 SG::ConstAccessor<std::vector<uint16_t> > g0dataAcc("g0data" + auxSuffix.value());
132 SG::ConstAccessor<std::vector<uint16_t> > g1dataAcc("g1data" + auxSuffix.value());
133
134 if (zdcModules.ptr())
135 {
136
137 for (const auto zdcMod : *zdcModules)
138 {
139 if (ADCSumAcc.isAvailable(*zdcMod))
140 {
141 if (zdcSums.ptr())
142 {
143 for (const auto zdcSum : *zdcSums)
144 {
145 if (zdcSum->zdcSide() == infoSumInd)
146 {
147 if (LEDTypeAcc.isAvailable(*zdcSum))
148 {
149 t_LEDType = LEDTypeAcc(*zdcSum);
150 break;
151 }
152 }
153 }
154 }
155 }
156 else
157 {
158 t_LEDType = 999;
159 break;
160 }
161 if (zdcMod->zdcSide() != 0)
162 { // side 0 is info
163 int iside = 0;
164 if (zdcMod->zdcSide() > 0)
165 iside = 1;
166
167 ANA_MSG_VERBOSE("Module " << zdcMod->zdcSide() << " " << zdcMod->zdcModule());
168 if (zdcMod->zdcType() == ZdcTypeInd)
169 {
170 int imod = zdcMod->zdcModule();
171 if (!PresampleAcc.isAvailable(*zdcMod))
172 {
173 ANA_MSG_WARNING("Missing ZDC aux data");
174 continue;
175 }
176 t_ZdcModulePresample[iside][imod] = PresampleAcc(*zdcMod);
177 t_ZdcModuleADCSum[iside][imod] = ADCSumAcc(*zdcMod);
178 t_ZdcModuleMaxADC[iside][imod] = MaxADCAcc(*zdcMod);
179 t_ZdcModuleMaxSample[iside][imod] = MaxSampleAcc(*zdcMod);
180 t_ZdcModuleAvgTime[iside][imod] = AvgTimeAcc(*zdcMod);
181
182 g0dataVec = g0dataAcc(*zdcMod);
183 g1dataVec = g1dataAcc(*zdcMod);
184
185 for (int isam = 0; isam < nSamples; isam++)
186 {
187 t_ZdcModuleg0data[iside][imod][isam] = g0dataVec.at(isam);
188 t_ZdcModuleg1data[iside][imod][isam] = g1dataVec.at(isam);
189 }
190 }
191 if ((zdcMod->zdcType() == RPDTypeInd) && (zdcMod->zdcModule() == RPDModuleInd))
192 {
193 int imod = zdcMod->zdcChannel();
194 if (!PresampleAcc.isAvailable(*zdcMod))
195 {
196 ANA_MSG_WARNING("Missing RPD aux data");
197 continue;
198 }
199 t_RPDModulePresample[iside][imod] = PresampleAcc(*zdcMod);
200 t_RPDModuleADCSum[iside][imod] = ADCSumAcc(*zdcMod);
201 t_RPDModuleMaxADC[iside][imod] = MaxADCAcc(*zdcMod);
202 t_RPDModuleMaxSample[iside][imod] = MaxSampleAcc(*zdcMod);
203 t_RPDModuleAvgTime[iside][imod] = AvgTimeAcc(*zdcMod);
204
205 g0dataVec = g0dataAcc(*zdcMod);
206
207 for (int isam = 0; isam < nSamples; isam++)
208 {
209 t_RPDModuleRawdata[iside][imod][isam] = g0dataVec.at(isam);
210 }
211 }
212 }
213 }
214 }
215}
216
218{
219 ANA_MSG_DEBUG("processing event info");
220
221 t_bcid = m_eventInfo->bcid();
222 t_runNumber = m_eventInfo->runNumber();
223 t_eventNumber = m_eventInfo->eventNumber();
224 t_lumiBlock = m_eventInfo->lumiBlock();
225 t_bunchGroup = -1;
226 t_extendedLevel1ID = m_eventInfo->extendedLevel1ID();
227 t_timeStamp = m_eventInfo->timeStamp();
228 t_timeStampNSOffset = m_eventInfo->timeStampNSOffset();
229 t_avgIntPerCrossing = m_eventInfo->averageInteractionsPerCrossing();
230 t_actIntPerCrossing = m_eventInfo->actualInteractionsPerCrossing();
231
232 if (!(m_eventCounter++ % 1000))
233 {
234 ANA_MSG_INFO("Event# " << m_eventCounter << "Run " << m_eventInfo->runNumber() << " Event " << m_eventInfo->eventNumber() << " LB " << m_eventInfo->lumiBlock());
235 }
236}
237
238StatusCode ZdcLEDNtuple ::finalize()
239{
240 return StatusCode::SUCCESS;
241}
Helper class to provide constant type-safe access to aux data.
#define ANA_MSG_DEBUG(xmsg,...)
Macro printing debug messages.
#define ANA_MSG_VERBOSE(xmsg,...)
Macro printing verbose messages.
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_MSG_WARNING(xmsg,...)
Macro printing warning messages.
ServiceHandle< StoreGateSvc > & evtStore()
StatusCode book(const TH1 &hist, std::string_view tDir="", std::string_view 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]
float t_RPDModulePresample[nSides][nRPD]
unsigned int t_ZdcModuleMaxSample[nSides][nZDC]
float t_RPDModuleAvgTime[nSides][nRPD]
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
Gaudi::Property< std::string > auxSuffix
Gaudi::Property< bool > enableOutputTree
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