ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1ZDC
src
TrigT1Run2ZDC.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 "
TrigT1Run2ZDC.h
"
6
#include "
AthContainers/ConstAccessor.h
"
7
#include <fstream>
8
#include <bitset>
9
#include <vector>
10
#include <iomanip>
11
12
13
using
json
= nlohmann::json;
14
15
namespace
LVL1
{
16
17
//--------------------------------
18
// Constructors and destructors
19
//--------------------------------
20
21
TrigT1Run2ZDC::TrigT1Run2ZDC
(
const
std::string&
name
, ISvcLocator* pSvcLocator)
22
:
AthReentrantAlgorithm
(
name
, pSvcLocator ) {}
23
24
//---------------------------------
25
// initialise()
26
//---------------------------------
27
28
StatusCode
TrigT1Run2ZDC::initialize
()
29
{
30
ATH_CHECK
(
m_zdcCTPLocation
.initialize());
31
ATH_CHECK
(
m_zdcModuleKey
.initialize());
32
ATH_CHECK
(
m_zdcModuleCalibEnergyKey
.initialize());
33
// Find the full path to filename:
34
std::string
file
=
PathResolverFindCalibFile
(
m_lutFile
);
35
ATH_MSG_INFO
(
"Reading file "
<<
file
);
36
std::ifstream fin(
file
.c_str());
37
if
(!fin){
38
ATH_MSG_ERROR
(
"Can not read file: "
<<
file
);
39
return
StatusCode::FAILURE;
40
}
41
json
data = json::parse(fin);
42
43
// Conversion factor from Run2 Energies (GeV) to dynamic range of LUT (4096 entries)
44
std::vector<float> convfact;
45
// if EnergyToADCScaleFactor is 0, using Run3 Data
46
// this means we make trigger decisions based on real trigger amplitudes
47
convfact.push_back((
m_energyToADCScaleFactor
) ?
static_cast<
float
>
(
m_energyToADCScaleFactor
) :
static_cast<
float
>
(1.0));
48
49
// Will eventually obtain LUTs from COOL, for now obtain them from calibration area
50
// A data member to hold the side A LUT values
51
//coverity[STACK_USE]
52
std::array<unsigned int, 4096> sideALUT = data[
"LucrodHighGain"
][
"LUTs"
][
"sideA"
];
53
// A data member to hold the side C LUT values
54
//coverity[STACK_USE]
55
std::array<unsigned int, 4096> sideCLUT = data[
"LucrodHighGain"
][
"LUTs"
][
"sideC"
];
56
// A data member to hold the Combined LUT values
57
std::array<unsigned int, 256> combLUT = data[
"LucrodHighGain"
][
"LUTs"
][
"comb"
];
58
59
// Construct Simulation Objects
60
m_modInputs_p
= std::make_shared<ZDCTriggerSim::ModuleAmplInputsFloat>(
ZDCTriggerSim::ModuleAmplInputsFloat
(convfact));
61
m_simTrig
= std::make_shared<ZDCTriggerSimModuleAmpls>(std::move(sideALUT), std::move(sideCLUT), std::move(combLUT));
62
63
ATH_MSG_DEBUG
(
"TrigT1Run2ZDC initilized"
);
64
return
StatusCode::SUCCESS;
65
}
66
67
//----------------------------------------------
68
// execute() method called once per event
69
//----------------------------------------------
70
71
StatusCode
TrigT1Run2ZDC::execute
(
const
EventContext &ctx)
const
72
{
73
// access ZDC modules
74
SG::ReadHandle<xAOD::ZdcModuleContainer>
zdcModules(
m_zdcModuleKey
, ctx);
75
// access ZDC aux data
76
SG::ReadDecorHandle<xAOD::ZdcModuleContainer, float>
zdcModuleCalibEnergyHandle(
m_zdcModuleCalibEnergyKey
, ctx);
77
// create vector to store module CalibEnergy
78
std::vector<float> moduleEnergy = {0., 0., 0., 0., 0., 0., 0., 0.};
79
80
// Read Single Modules
81
if
(zdcModules.
isValid
())
82
{
83
for
(
const
auto
zdcModule : *zdcModules)
84
{
85
if
(zdcModule->zdcType() == 0)
86
{
// type = 0 are big modules, type = 1 the pixels
87
88
ATH_MSG_DEBUG
(
"ZDC Side "
<< zdcModule->zdcSide() <<
", Module: "
<< zdcModule->zdcModule() <<
" and Energy: "
<< zdcModuleCalibEnergyHandle(*zdcModule));
89
// Side A
90
static
const
SG::ConstAccessor<uint16_t>
lucrodTriggerAmpAcc(
"LucrodTriggerAmp"
);
91
if
(zdcModule->zdcSide() > 0)
92
{
93
moduleEnergy.at(zdcModule->zdcModule()) = (!
m_energyToADCScaleFactor
&& lucrodTriggerAmpAcc.
isAvailable
(*zdcModule)) ?
static_cast<
float
>
(lucrodTriggerAmpAcc(*zdcModule)) : zdcModuleCalibEnergyHandle(*zdcModule);
94
}
95
96
// Side C
97
if
(zdcModule->zdcSide() < 0)
98
{
99
moduleEnergy.at(zdcModule->zdcModule() + 4) = (!
m_energyToADCScaleFactor
&& lucrodTriggerAmpAcc.
isAvailable
(*zdcModule)) ?
static_cast<
float
>
(lucrodTriggerAmpAcc(*zdcModule)) : zdcModuleCalibEnergyHandle(*zdcModule);
100
}
101
}
102
}
103
}
104
105
// Get Output as an integer (0-7)
106
m_modInputs_p
->setData(moduleEnergy);
107
108
// call ZDCTriggerSim to actually get ZDC Bits
109
unsigned
int
wordOut =
m_simTrig
->simLevel1Trig(
ZDCTriggerSim::SimDataCPtr
(
m_modInputs_p
));
110
111
// convert int to bitset
112
std::bitset<3>
bin
(wordOut);
113
114
// load output into trigger word on correct bits
115
unsigned
int
word0 = 0;
116
word0 += (
bin
[0] << 25);
117
word0 += (
bin
[1] << 26);
118
word0 += (
bin
[2] << 27);
119
120
// form CTP obejct
121
SG::WriteHandle<ZdcCTP>
zdcCTP =
SG::makeHandle
(
m_zdcCTPLocation
, ctx);
122
123
//record CTP object
124
ATH_CHECK
(zdcCTP.
record
(std::make_unique<ZdcCTP>(word0)));
125
ATH_MSG_DEBUG
(
"Stored ZDC CTP object with words "
<< std::hex << (zdcCTP->cableWord0()) <<
" from LUTOutput "
<< std::dec << wordOut);
126
return
StatusCode::SUCCESS;
127
}
128
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
json
nlohmann::json json
Definition
HistogramDef.cxx:9
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.cxx:325
TrigT1Run2ZDC.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
LVL1::TrigT1Run2ZDC::m_zdcCTPLocation
SG::WriteHandleKey< ZdcCTP > m_zdcCTPLocation
Definition
TrigT1Run2ZDC.h:61
LVL1::TrigT1Run2ZDC::TrigT1Run2ZDC
TrigT1Run2ZDC(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TrigT1Run2ZDC.cxx:21
LVL1::TrigT1Run2ZDC::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TrigT1Run2ZDC.cxx:71
LVL1::TrigT1Run2ZDC::initialize
virtual StatusCode initialize() override
Definition
TrigT1Run2ZDC.cxx:28
LVL1::TrigT1Run2ZDC::m_energyToADCScaleFactor
Gaudi::Property< float > m_energyToADCScaleFactor
Definition
TrigT1Run2ZDC.h:67
LVL1::TrigT1Run2ZDC::m_lutFile
Gaudi::Property< std::string > m_lutFile
Definition
TrigT1Run2ZDC.h:66
LVL1::TrigT1Run2ZDC::m_zdcModuleCalibEnergyKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibEnergyKey
Definition
TrigT1Run2ZDC.h:58
LVL1::TrigT1Run2ZDC::m_simTrig
std::shared_ptr< ZDCTriggerSimModuleAmpls > m_simTrig
A data member to hold the ZDCTrigger Object that computes the LUT logic: shared ptr to ensure cleanup...
Definition
TrigT1Run2ZDC.h:73
LVL1::TrigT1Run2ZDC::m_modInputs_p
std::shared_ptr< ZDCTriggerSim::ModuleAmplInputsFloat > m_modInputs_p
A data member to hold the ZDCTrigger Object that stores input floats: shared ptr to ensure cleanup.
Definition
TrigT1Run2ZDC.h:70
LVL1::TrigT1Run2ZDC::m_zdcModuleKey
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleKey
Definition
TrigT1Run2ZDC.h:53
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
bin
Definition
BinsDiffFromStripMedian.h:43
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition
IZdcDataAccess.h:13
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
ZDCTriggerSim::ModuleAmplInputsFloat
ZDCTriggerSimData< float, 8, 12, TModAmplsInput > ModuleAmplInputsFloat
Definition
ZDCTriggerSim.h:146
ZDCTriggerSim::SimDataCPtr
std::shared_ptr< const ZDCTriggerSimDataBase > SimDataCPtr
Definition
ZDCTriggerSim.h:170
TrigConf::name
Definition
HLTChainList.h:35
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0