ATLAS Offline Software
xAODTriggerTowerRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 #include "CLHEP/Units/SystemOfUnits.h"
9 
11 
12 namespace JiveXML {
13 
14  //--------------------------------------------------------------------------
15 
16  xAODTriggerTowerRetriever::xAODTriggerTowerRetriever(const std::string& type, const std::string& name, const IInterface* parent):
17  AthAlgTool(type, name, parent), m_typeName("LVL1TriggerTower")
18  {
19  declareInterface<IDataRetriever>(this);
20  declareProperty("StoreGateKey", m_sgKey = "xAODTriggerTowers", "Storegate key for Level-1 TriggerTowers");
21  }
22 
23  //--------------------------------------------------------------------------
24 
25  StatusCode xAODTriggerTowerRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
26 
27  //Retrieve trigger towers
28  const DataVector<xAOD::TriggerTower>* TTVector;
29 
30  if ( evtStore()->retrieve(TTVector,m_sgKey).isFailure() ) {
31  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No Level-1 Trigger Towers found in SG at "
32  << m_sgKey << endmsg;
33  return StatusCode::SUCCESS;
34  }
35 
36  //Get number of trigger towers
37  int numTrigTowers = TTVector->size();
38  int count = 0;
39  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Retrieving xAOD Level-1 Trigger Towers with size " << numTrigTowers << endmsg;
40 
41  DataVect phi; phi.reserve(numTrigTowers);
42  DataVect eta; eta.reserve(numTrigTowers);
43  DataVect emEnergyVec; emEnergyVec.reserve(numTrigTowers);
44  DataVect hadEnergyVec; hadEnergyVec.reserve(numTrigTowers);
45 
46  DataVect sumEnergyVec; sumEnergyVec.reserve(numTrigTowers);
47  DataVect numADCVec; numADCVec.reserve(numTrigTowers);
48  DataVect emBCIDVec; emBCIDVec.reserve(numTrigTowers);
49  DataVect hadBCIDVec; hadBCIDVec.reserve(numTrigTowers);
50  DataVect isEMSaturated; isEMSaturated.reserve(numTrigTowers);
51  DataVect isHadSaturated; isHadSaturated.reserve(numTrigTowers);
52  DataVect emADCVec; emADCVec.reserve(numTrigTowers);
53  DataVect hadADCVec; hadADCVec.reserve(numTrigTowers);
54 
55  // Loop over all trigger towers and fill vectors
56  DataVector<xAOD::TriggerTower>::const_iterator trigTowerIter = TTVector->begin();
57  for ( trigTowerIter = TTVector->begin(); trigTowerIter < TTVector->end(); ++trigTowerIter ){
58 
59  // skip TTs with no energy
60  if ( (*trigTowerIter)->cpET() == 0 ) continue;
61 
62  int sumEnergy = 0;
63  int emEnergy = 0;
64  int hadEnergy = 0;
65 
66  // from Sasha Mazurov (L1Calo):
67  // references: energies: Trigger/TrigT1/TrigT1CaloMonitoring/PPrMon.cxx#L728
68  // adc: Trigger/TrigT1/TrigT1CaloMonitoring/trunk/src/PPrMon.cxx#L796
69  // "We have separated elecromagnetic and hadronic towers, so instead of
70  // one trigger tower we have two trigger towers where :
71  // triggerTower->layer() == 0 => Electromagnetic layer (= emEnergy for old objects)
72  // triggerTower->layer() == 1 => Hadronic layer (= hadEnergy for old objects)
73  // triggerTower->cpET() and triggerTower->jepET() energies from LUT
74  // triggerTower->adc()[triggerTower->adcPeak()] - peak energy in FADC"
75 
76  const int layer = (*trigTowerIter)->layer();
77  const int cpET = (*trigTowerIter)->cpET();
78  const int peakEnergy = (*trigTowerIter)->adc()[(*trigTowerIter)->adcPeak()];
79  const int jepET = (*trigTowerIter)->jepET(); // currently not in output. JetElements ?
80 
81  if ( layer == 0 ){
82  // emEnergy = emEnergy+cpET;
83  emEnergy = peakEnergy;
84  }else{
85  // hadEnergy = hadEnergy+cpET;
86  hadEnergy = peakEnergy;
87  }
88 
89  if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) <<" L1 TT No " << count++
90  << " at layer: " << layer << ", with"
91  << " eta:"<<(*trigTowerIter)->eta() << ", phi:"<<(*trigTowerIter)->phi()
92  << ", em energy:"<< emEnergy <<", had energy:"<< hadEnergy
93  << ", cpET:" << cpET <<", jepET:"<< jepET << endmsg;
94 
95  //Store eta and phi
96  eta.push_back(DataType( (*trigTowerIter)->eta() ));
97  phi.push_back(DataType( (*trigTowerIter)->phi() ));
98 
99  sumEnergy = emEnergy+hadEnergy; // probably too simple ? Saturation !
100 
101  emEnergyVec.push_back( emEnergy );
102  hadEnergyVec.push_back( hadEnergy );
103  sumEnergyVec.push_back( sumEnergy );
104 
105  //Store saturation flag
106  isEMSaturated.push_back(DataType( ((*trigTowerIter)->isCpSaturated())? 1 : 0 ));
107  isHadSaturated.push_back(DataType( ((*trigTowerIter)->isJepSaturated())? 1 : 0 ));
108 
109  emADCVec.push_back( 0. ); // placeholders
110  hadADCVec.push_back( 0. );
111  numADCVec.push_back( 0. );
112  emBCIDVec.push_back( 0. );
113  hadBCIDVec.push_back( 0. );
114 
115  } // end of TT loop
116 
117  DataMap myDataMap;
118  int nEntries = phi.size();
119  myDataMap["phi"] = std::move(phi);
120  myDataMap["eta"] = std::move(eta);
121  myDataMap["emEnergy"] = std::move(emEnergyVec);
122  myDataMap["hadEnergy"] = std::move(hadEnergyVec);
123  myDataMap["sumEnergy"] = std::move(sumEnergyVec);
124 
125  myDataMap["emADC"] = std::move(emADCVec);
126  myDataMap["hadADC"] = std::move(hadADCVec);
127  myDataMap["numADC"] = std::move(numADCVec);
128  myDataMap["emBCID"] = std::move(emBCIDVec);
129  myDataMap["hadBCID"] = std::move(hadBCIDVec);
130  myDataMap["isEMSaturated"] = std::move(isEMSaturated);
131  myDataMap["isHadSaturated"] = std::move(isHadSaturated);
132 
133  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< nEntries
134  << " from: " << m_sgKey << endmsg;
135 
136  //forward data to formating tool
137  return FormatTool->AddToEvent(dataTypeName(), m_sgKey, &myDataMap);
138  }
139 }
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::xAODTriggerTowerRetriever::xAODTriggerTowerRetriever
xAODTriggerTowerRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: xAODTriggerTowerRetriever.cxx:16
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
TriggerTowerContainer.h
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
JiveXML::xAODTriggerTowerRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: xAODTriggerTowerRetriever.h:37
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
xAODTriggerTowerRetriever.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
JiveXML::xAODTriggerTowerRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: xAODTriggerTowerRetriever.cxx:25
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
JiveXML::xAODTriggerTowerRetriever::m_sgKey
std::string m_sgKey
Definition: xAODTriggerTowerRetriever.h:44
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
AthAlgTool
Definition: AthAlgTool.h:26
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.