25#ifndef XAOD_STANDALONE
26 declareInterface<IZdcAnalysisTool>(
this);
36 std::ostringstream pedestalStr;
39 if (i > 0) pedestalStr <<
", ";
43 ATH_MSG_INFO(
"Initializing LISAnalysisTool with Pedestals: " << pedestalStr.str());
57 if (auxSuffix !=
"") auxSuffix =
"_" + auxSuffix;
100 return StatusCode::SUCCESS;
118 std::string filename;
119 std::string runString;
121 runString = (
"ZdcCalib_Run"+TString::Itoa(runNumber,10)+
".root").
Data();
125 if (filename.empty())
127 ATH_MSG_INFO(
"No LIS pedestals file found - using default pedestals");
128 return StatusCode::FAILURE;
131 ATH_MSG_INFO(
"Opening LIS pedestals file " << filename);
132 std::unique_ptr<TFile> fLISPed(TFile::Open(filename.c_str(),
"READ"));
134 if (!fLISPed->IsOpen()) {
135 ATH_MSG_INFO (
"SetPedestals: failed to open file: " << filename <<
". Using default pedestals.");
136 return StatusCode::FAILURE;
142 bool readSuccess =
true;
145 std::string histName =
"LIS_Pedestal_ch" + std::to_string(channel);
147 ATH_MSG_DEBUG(
"SetPedestals: Searching for histogram: " << histName);
149 TH1D* hist_ptr =
static_cast<TH1D*
>(fLISPed->GetObjectChecked(histName.c_str(),
"TH1D"));
152 ATH_MSG_ERROR(
"SetPedestals: unable to read pedestal histogram " << histName);
157 ATH_MSG_INFO(
"Successfully read pedestal histogram for channel " << channel);
159 hist_ptr->SetDirectory(0);
167 ATH_MSG_INFO(
"Successfully loaded LIS pedestals from file");
170 ATH_MSG_ERROR(
"SetPedestals: due to at least one error, LIS pedestals not loaded from file");
173 return readSuccess ? StatusCode::SUCCESS : StatusCode::FAILURE;
179 ATH_MSG_WARNING(
"GetPedestals: invalid channel " << channel <<
", returning 0");
192 ATH_MSG_DEBUG(
"GetPedestals: channel " << channel <<
", LB " << lumiBlock
193 <<
", lumiblock out of histogram range");
202 ATH_MSG_DEBUG(
"GetPedestals: channel " << channel <<
", LB " << lumiBlock
203 <<
", pedestal = " << pedestal <<
" (from histogram)");
207 ATH_MSG_DEBUG(
"GetPedestals: channel " << channel <<
", LB " << lumiBlock
208 <<
", no valid histogram entry");
213 ATH_MSG_DEBUG(
"GetPedestals: no histogram available for channel " << channel);
218 ATH_MSG_DEBUG(
"GetPedestals: channel " << channel <<
", LB " << lumiBlock
225 statusWord |= (1 << bitIndex);
229 int side,
int channel,
230 const std::vector<unsigned short>&
data,
231 unsigned int startSample,
unsigned int endSample,
232 unsigned int lumiBlock)
234 ATH_MSG_DEBUG(
"Processing LIS data for side " << side <<
", channel " << channel);
237 int maxADCsub = -999;
238 unsigned int maxSample = 0;
240 unsigned int moduleStatus = 0;
247 if (startSample >=
data.size() || endSample >=
data.size()) {
248 ATH_MSG_WARNING(
"Start or end sample number greater than number of samples");
253 float ModPedestal =
GetPedestal(channel, lumiBlock);
261 preFADC /= nBaseline;
264 for (
unsigned int sample = startSample; sample <= endSample; sample++) {
265 int FADCsub =
static_cast<int>(
data[sample]) -
static_cast<int>(std::round(ModPedestal));
270 if (FADCsub > maxADCsub) {
275 avgTime += time * FADCsub;
286 if(std::abs(preFADC - ModPedestal) > 15) {
301 bool hasBadStatus =
false;
315 ATH_MSG_DEBUG(
" Presample: " << preFADC <<
", ADCSum: " << ADCSum
316 <<
", MaxADC: " << maxADCsub <<
", MaxSample: " << maxSample
317 <<
", AvgTime: " << avgTime);
319 return LISModuleResults(preFADC, ADCSum, maxADCsub, maxSample, avgTime, moduleStatus);
323 ATH_MSG_DEBUG(
"Processing LIS module: side=" << module.zdcSide()
324 <<
", module=" << module.zdcModule()
325 <<
", channel=" << module.zdcChannel());
327 int LISModuleGain = 0;
329 if(module.zdcChannel() > 3){
349 const std::vector<uint16_t> &waveform = gainDataAccessor(module);
350 if (waveform.empty()) {
363 ATH_MSG_DEBUG(
"LISAnalysisTool::recoZdcModules processing event");
367 return StatusCode::FAILURE;
370 if (moduleContainer.
empty()) {
371 return StatusCode::SUCCESS;
377 return StatusCode::FAILURE;
382 ATH_MSG_WARNING(
"LIS decoding error found - abandoning LISAnalysisTool!");
383 return StatusCode::SUCCESS;
390 unsigned int lumiBlock = eventInfo->lumiBlock();
392 unsigned int thisRunNumber = eventInfo->runNumber();
394 ATH_MSG_INFO(
"LIS analysis tool will be configured for run " << thisRunNumber );
395 ATH_MSG_INFO(
"Pedestals will be configured for run " << thisRunNumber);
397 if (status != StatusCode::SUCCESS) {
398 ATH_MSG_ERROR(
"Failed to set pedestals from calibration file for run " << thisRunNumber <<
", using nominal pedestal values instead!");
406 bool haveZdcEventInfo =
false;
408 unsigned int bcid = 0;
412 for (
auto modSum : moduleSumContainer) {
416 if (modSum->zdcSide() == 0) {
421 eventType = eventTypeHandle(*modSum);
422 haveZdcEventInfo =
true;
423 moduleSumEventInfo_ptr = modSum;
427 if (!haveZdcEventInfo) {
428 ATH_MSG_ERROR(
"Zdc event data not available (moduleSum with side = 0)");
429 return StatusCode::FAILURE;
433 const std::vector<uint16_t>& rodBCID = rodBCIDHandle(*moduleSumEventInfo_ptr);
434 if (!rodBCID.empty()) {
439 bcid = eventInfo->bcid();
462 return StatusCode::SUCCESS;
465 ATH_MSG_DEBUG(
"Event with BCID = " << bcid <<
" has LED type " << evtLEDType);
480 for (
const auto* zdcModule : moduleContainer) {
484 ATH_MSG_DEBUG(
"Writing aux decors to LIS module: side=" << zdcModule->zdcSide()
485 <<
", channel=" << zdcModule->zdcChannel());
488 presampleHandle(*zdcModule) = results.getPresampleADC();
489 adcSumHandle(*zdcModule) = results.getADCSum();
490 maxADCHandle(*zdcModule) = results.getMaxADC();
491 maxSampleHandle(*zdcModule) = results.getMaxSample();
492 avgTimeHandle(*zdcModule) = results.getAvgTime();
493 moduleStatusHandle(*zdcModule) = results.getmoduleStatus();
500 LEDTypeHandle(*moduleSumEventInfo_ptr) = evtLEDType;
505 return StatusCode::SUCCESS;
511 return StatusCode::FAILURE;
524 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
char data[hepevt_bytes_allocation_ATLAS]
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
size_t size() const
Number of registered mappings.
Define enumerations for event-level ZDC data.
ServiceHandle< StoreGateSvc > & evtStore()
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
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.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
@ ForwardDet
The forward detectors.
ZdcModuleContainer_v1 ZdcModuleContainer