 |
ATLAS Offline Software
|
Go to the documentation of this file.
28 #ifndef XAOD_STANDALONE
29 declareInterface<IZdcAnalysisTool>(
this);
55 return StatusCode::FAILURE;
62 return StatusCode::FAILURE;
77 std::ostringstream BCIDList;
78 BCIDList <<
"LED BCIDs:";
132 return StatusCode::SUCCESS;
172 return StatusCode::FAILURE;
175 if (moduleContainer.
size()==0)
return StatusCode::SUCCESS;
178 if (!eventInfo.
isValid())
return StatusCode::FAILURE;
184 ATH_MSG_WARNING(
"ZDC or RPD decoding error found - abandoning ZdcLEDAnalysisTool!");
185 return StatusCode::SUCCESS;
188 unsigned int thisRunNumber = eventInfo->
runNumber();
190 ATH_MSG_INFO(
"ZDC LED analysis tool will be configured for run " << thisRunNumber <<
" m_doFADCCorr = " <<
m_doFADCCorr);
193 unsigned int calibRunNumber = thisRunNumber;
195 ATH_MSG_INFO(
"FADC corrections will be configured for run " << calibRunNumber);
205 bool haveZdcEventInfo =
false;
207 unsigned int bcid = eventInfo->
bcid();
212 for (
auto modSum : moduleSumContainer) {
216 if (modSum->zdcSide() == 0) {
221 eventType = eventTypeHandle(*modSum);
222 DAQMode = DAQModeHandle(*modSum);
223 haveZdcEventInfo =
true;
224 moduleSumEventInfo_ptr = modSum;
227 if (!haveZdcEventInfo) {
228 ATH_MSG_ERROR(
"Zdc event data not available (moduleSum with side = 0)");
229 return StatusCode::FAILURE;
241 if (!robBCIDHandle.isValid())
return StatusCode::FAILURE;
243 const std::vector<uint16_t>& robBCIDvec = robBCIDHandle(*moduleSumEventInfo_ptr);
244 if (robBCIDHandle->size() == 0)
return StatusCode::FAILURE;
246 unsigned int checkBCID = robBCIDvec[0];
247 for (
unsigned int bcid : robBCIDvec) {
248 if (
bcid != checkBCID) {
249 ATH_MSG_ERROR(
"Inconsistent BCIDs in rob header, cannot continue in standalone mode");
250 return StatusCode::FAILURE;
283 return StatusCode::SUCCESS;
302 for (
const auto zdcModule : moduleContainer)
305 if (zdcModule->zdcType() == 0) {
308 else if (zdcModule->zdcType() == 1 && zdcModule->zdcModule() == 4) {
312 ATH_MSG_DEBUG(
"Writing aux decors to module with side, module, channel = " << zdcModule->zdcSide() <<
", " << zdcModule->zdcModule()
313 <<
", " << zdcModule->zdcChannel());
315 moduleLEDPresampleADCHandle(*zdcModule) = std::floor(
results.getPresampleADC() + 1.0e-6);
316 moduleLEDADCSumHandle(*zdcModule) =
results.getADCSum();
317 moduleLEDMaxADCHandle(*zdcModule) =
results.getMaxADC();
318 moduleLEDMaxSampleHandle(*zdcModule) =
results.getMaxSample();
319 moduleLEDAvgTimeHandle(*zdcModule) =
results.getAvgTime();
324 LEDTypeHandle(*moduleSumEventInfo_ptr) = evtLEDType;
329 return StatusCode::SUCCESS;
336 return StatusCode::FAILURE;
347 return StatusCode::SUCCESS;
357 std::vector<uint16_t> HGSamples = g1dataAcc (
module);
358 std::vector<uint16_t> LGSamples = g0dataAcc (
module);
360 std::vector<uint16_t>::const_iterator maxIter = std::max_element(HGSamples.begin(), HGSamples.end());
361 if (maxIter != HGSamples.end()) {
381 unsigned int startSample,
unsigned int endSample,
float gainScale)
385 int maxADCsub = -999;
386 unsigned int maxSample = 0;
388 bool highgain = (gainScale<1.1);
391 ATH_MSG_ERROR(
"Start or end sample number greater than number of samples");
408 if (FADCsub > maxADCsub) {
413 avgTime += time*FADCsub;
421 return ZDCLEDModuleResults(preFADC, ADCSum*gainScale, maxADCsub*gainScale, maxSample, avgTime);
428 double amplCorrFactor = 1;
430 double fadcCorr = highGain ?
m_FADCCorrHG[iside][imod]->Interpolate(fitAmp) :
m_FADCCorrLG[iside][imod]->Interpolate(fitAmp);
431 amplCorrFactor *= fadcCorr;
433 return amplCorrFactor;
439 std::string runString;
442 else runString = (
"ZdcFADCCorr_Run"+TString::Itoa(
runNumber,10)+
".root").Data();
448 ATH_MSG_INFO(
"No FADC corrections file - disabling correction");
454 std::unique_ptr<TFile> fFADCCorr(TFile::Open(
filename.c_str(),
"READ"));
456 if (!fFADCCorr->IsOpen()) {
457 ATH_MSG_INFO (
"setFADCCorrections: failed to open file: " <<
filename <<
". Disabling correction.");
465 bool readSuccess =
true;
466 std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsHG;
467 std::array<std::array<std::unique_ptr<const TH1>, 4>, 2> histogramsLG;
469 for (
size_t side : {0, 1}) {
470 for (
int module : {0, 1, 2, 3}) {
474 ATH_MSG_DEBUG(
"setFADCCorrections: Searching for histograms HG and LG: " << histNameHG <<
", " << histNameLG);
476 TH1* histHG_ptr =
static_cast<TH1*
>(fFADCCorr->GetObjectChecked(histNameHG.c_str(),
"TH1"));
477 TH1* histLG_ptr =
static_cast<TH1*
>(fFADCCorr->GetObjectChecked(histNameLG.c_str(),
"TH1"));
479 if (!histHG_ptr || !histLG_ptr) {
480 std::string errMsg =
"setFADCCorrections: unable to read FADC correction histogram(s) ";
481 if (!histHG_ptr) errMsg += histNameHG +
" ";
482 if (!histLG_ptr) errMsg += histNameLG;
493 if ( std::abs(histHG_ptr->GetXaxis()->GetXmin()+0.5) > 1
e-3 || std::abs(histHG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1
e-3) {
494 ATH_MSG_ERROR(
"setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameHG);
498 if (std::abs(histLG_ptr->GetXaxis()->GetXmin()+0.5) > 1
e-3 || std::abs(histLG_ptr->GetXaxis()->GetXmax() - 4095.5) > 1
e-3) {
499 ATH_MSG_ERROR(
"setFADCCorrections: invalid axis range for HG FADC corrections in histogram with name " << histNameLG);
514 ATH_MSG_INFO(
"Successfully configured FADC correction");
518 ATH_MSG_ERROR(
"setFADCCorrections: due to at least one error, FADC corrections are not implemented");
def retrieve(aClass, aKey=None)
char data[hepevt_bytes_allocation_ATLAS]
Class containing ZDC Module information.
Helper class to provide constant type-safe access to aux data.
uint32_t runNumber() const
The current event's run number.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Handle class for reading a decoration on an object.
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Handle class for adding a decoration to an object.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
@ ForwardDet
The forward detectors.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string to_string(const DetectorType &type)
setEventNumber setTimeStamp bcid
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define ATH_MSG_WARNING(x)
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Helper class to provide constant type-safe access to aux data.
uint32_t bcid() const
The bunch crossing ID of the event.
size_type size() const noexcept
Returns the number of elements in the collection.
Define enumerations for event-level ZDC data.