ATLAS Offline Software
TriggerInfoRetriever.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 #include <string>
8 
9 #include "CLHEP/Units/SystemOfUnits.h"
10 
12 
13 #include "EventInfo/EventInfo.h"
14 #include "EventInfo/EventID.h"
15 #include "EventInfo/TriggerInfo.h"
16 #include <cmath> //std::sqrt
17 
18 namespace JiveXML {
19 
20  //--------------------------------------------------------------------------
21 
22  TriggerInfoRetriever::TriggerInfoRetriever(const std::string& type, const std::string& name, const IInterface* parent):
24  m_typeName("TriggerInfo")
25  {
26 
27  declareInterface<IDataRetriever>(this);
28  }
29 
30  //--------------------------------------------------------------------------
31 
32  StatusCode TriggerInfoRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
33 
34 // retrieve TriggerInfo
35  const EventInfo* eventInfo = nullptr;
36  const TriggerInfo* trigger_info = nullptr;
37 
38  if ( evtStore()->retrieve(eventInfo).isFailure() ) {
39  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No EventInfo found in SG" << endmsg;
40  return StatusCode::SUCCESS;
41  }
42  trigger_info = eventInfo->trigger_info();
43  if (trigger_info == 0){
44  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No TriggerInfo in EventInfo" << endmsg;
45  return StatusCode::SUCCESS;
46  }
47  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Retrieved EventInfo and TriggerInfo" << endmsg;
48 
49  std::string triggerInfoStrL1="0";
50  std::string triggerInfoStrL2="0";
51  std::string triggerInfoStrEF="0";
52  std::string triggerInfoStreamTag="0";
53 
54 // Level-1 Missing-ET from LVL1_ROI:
55  DataVect energySumEtVec;
56  DataVect energyExVec;
57  DataVect energyEyVec;
58  DataVect energyEtMissVec;
59 
60 // TriggerInfo from EventInfo:
61  DataVect trigInfoStatusVec;
62  DataVect trigInfoExtL1IDVec;
63  DataVect trigInfoLvl1TypeVec;
64  DataVect trigInfoL1Vec;
65  DataVect trigInfoL2Vec;
66  DataVect trigInfoEFVec;
67  DataVect trigInfoStreamTagVec;
68 
69 // from: AtlasTest/DatabaseTest/AthenaPoolTest/AthenaPoolTestDataReader
70 
71  trigInfoStatusVec.push_back(DataType( trigger_info->statusElement() ) );
72  trigInfoExtL1IDVec.push_back(DataType( trigger_info->extendedLevel1ID() ) );
73  trigInfoLvl1TypeVec.push_back(DataType( trigger_info->level1TriggerType() ) );
74  if ( trigger_info->level1TriggerInfo().size() > 0 ){
75  triggerInfoStrL1 = "-"; // item seperator
76  }
77  for (unsigned int i = 0; i < trigger_info->level1TriggerInfo().size(); ++i) {
78  triggerInfoStrL1 += DataType( trigger_info->level1TriggerInfo()[i]).toString() + "-";
79  }
80 
81  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " lvl2Info " << endmsg;
82  if ( trigger_info->level2TriggerInfo().size() > 0 ){
83  triggerInfoStrL2 = "-"; // item seperator
84  }
85  for (unsigned int i = 0; i < trigger_info->level2TriggerInfo().size(); ++i) {
86  triggerInfoStrL2 += DataType( trigger_info->level2TriggerInfo()[i] ).toString() + "-";
87  }
88 
89  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "EventFilterInfo " << endmsg;
90  if ( trigger_info->eventFilterInfo().size() > 0 ){
91  triggerInfoStrEF = "-"; // item seperator
92  }
93  for (unsigned int i = 0; i < trigger_info->eventFilterInfo().size(); ++i) {
94  triggerInfoStrEF += DataType( trigger_info->eventFilterInfo()[i]).toString() + "-";
95  }
96 
97  if ( trigger_info->streamTags().size() > 0 ){
98  triggerInfoStreamTag = "-"; // item seperator
99  }
100  for (unsigned int i = 0; i < trigger_info->streamTags().size(); ++i) {
101  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " i " << i << " name " << trigger_info->streamTags()[i].name()
102  << " type " << trigger_info->streamTags()[i].type()
103  << " ObeysLumi " << trigger_info->streamTags()[i].obeysLumiblock();
105  triggerInfoStreamTag += trigger_info->streamTags()[i].name() + "_" +
106  trigger_info->streamTags()[i].type() + "_";
107  if ( trigger_info->streamTags()[i].obeysLumiblock() ){ // is a boolean
108  triggerInfoStreamTag += "ObeysLumi";
109  }else{
110  triggerInfoStreamTag += "notObeysLumi";
111  }
112  if ( eventInfo->event_ID()->lumi_block() ){
113  triggerInfoStreamTag += "_lumiBlock";
114  triggerInfoStreamTag += DataType(eventInfo->event_ID()->lumi_block()).toString();
115  }else{
116  triggerInfoStreamTag += "_lumiBlockUnknown";
117  }
118  triggerInfoStreamTag += "-";
119  }
120 
121  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "trigInfoL1: " << triggerInfoStrL1 << endmsg;
122  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "trigInfoL2: " << triggerInfoStrL2 << endmsg;
123  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "trigInfoEF: " << triggerInfoStrEF << endmsg;
124  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "triggerInfoStreamTag: " << triggerInfoStreamTag << endmsg;
125 
126  trigInfoL1Vec.emplace_back(std::move(triggerInfoStrL1));
127  trigInfoL2Vec.emplace_back(std::move(triggerInfoStrL2 ));
128  trigInfoEFVec.emplace_back(std::move( triggerInfoStrEF ));
129  trigInfoStreamTagVec.emplace_back(std::move( triggerInfoStreamTag ));
130 
131  // Retrieve LVL1_ROI for trigger energies
132  // assume that eventInfo->triggerInfo _has_ to be present,
133  // but LVL1_ROI not present under all circumstances (ACR: muoncomm)
134  // Don't exit upon failed SG retrieval as usual.
135 
136  const LVL1_ROI * roi;
137  if ( evtStore()->retrieve(roi,"LVL1_ROI").isFailure() ) {
138  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No LVL1_ROI for Trigger-MissingET found in SG, setting placeholders." << endmsg;
139  // placeholders:
140  energySumEtVec.push_back(DataType( -1. ) ); // means n/a
141  energyExVec.push_back(DataType( -1. ) );
142  energyEyVec.push_back(DataType( -1. ) );
143  energyEtMissVec.push_back(DataType( -1. ) );
144  }else{
145  if ( (roi->getEnergySumROIs()).size() != 0 ){ // catch empty container
146  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TriggerInfo: LVL1_ROI for EnergySum retrieved" << endmsg;
147 
148  LVL1_ROI::energysums_type::const_iterator itES = (roi->getEnergySumROIs()).begin();
149  LVL1_ROI::energysums_type::const_iterator itESe = (roi->getEnergySumROIs()).end();
150  for (; itES != itESe; ++itES){
151  float Et = itES->getEnergyT()/CLHEP::GeV;
152  float Ex = itES->getEnergyX()/CLHEP::GeV;
153  float Ey = itES->getEnergyY()/CLHEP::GeV;
154  energySumEtVec.push_back(DataType( Et ) );
155  energyExVec.push_back(DataType( Ex ) );
156  energyEyVec.push_back(DataType( Ey ) );
157  float EtMiss = static_cast<long>(sqrt(static_cast<double>(Ex*Ex + Ey*Ey)));
158  energyEtMissVec.push_back(DataType( EtMiss ) );
159 
160  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "EnergySum from LVL1_ROI: X:" << Ex << ", Y:"
161  << Ey << ", T:" << Et << ", ETMiss:" << EtMiss << endmsg;
162  }
163  }else{ // empty container
164  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TriggerInfo: LVL1_ROI for EnergySum empty !" << endmsg;
165 
166  energySumEtVec.push_back(DataType( "-1" ) ); // means n/a
167  energyExVec.push_back(DataType( "-1" ) );
168  energyEyVec.push_back(DataType( "-1" ) );
169  energyEtMissVec.push_back(DataType( "-1" ) );
170  }
171  } // LVL1_ROI available ?
172 
173  DataMap myDataMap;
174  const int nEntries = trigInfoStatusVec.size();
175  myDataMap["energySumEt"] = std::move(energySumEtVec);
176  myDataMap["energyEx"] = std::move(energyExVec);
177  myDataMap["energyEy"] = std::move(energyEyVec);
178  myDataMap["energyEtMiss"] = std::move(energyEtMissVec);
179  myDataMap["trigInfoStatus"] = std::move(trigInfoStatusVec);
180  myDataMap["trigInfoExtL1ID"] = std::move(trigInfoExtL1IDVec);
181  myDataMap["trigInfoLvl1Type"] = std::move(trigInfoLvl1TypeVec);
182  myDataMap["trigInfoL1"] = std::move(trigInfoL1Vec);
183  myDataMap["trigInfoL2"] = std::move(trigInfoL2Vec);
184  myDataMap["trigInfoEF"] = std::move(trigInfoEFVec);
185  myDataMap["trigInfoStreamTag"] = std::move(trigInfoStreamTagVec);
186 
187  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< nEntries << endmsg;
188 
189  //forward data to formating tool
190  std::string emptyStr=""; // eventInfo has no SGKey
191  return FormatTool->AddToEvent(dataTypeName(), emptyStr, &myDataMap);
192  }
193 }
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
TriggerInfo::streamTags
const std::vector< StreamTag > & streamTags() const
get stream tags
Definition: TriggerInfo.cxx:158
JiveXML::TriggerInfoRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: TriggerInfoRetriever.h:28
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
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TriggerInfo.h
This class contains trigger related information.
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
JiveXML::TriggerInfoRetriever::TriggerInfoRetriever
TriggerInfoRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: TriggerInfoRetriever.cxx:22
TriggerInfo::level1TriggerInfo
const std::vector< number_type > & level1TriggerInfo() const
get level1 trigger info
Definition: TriggerInfo.cxx:143
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
lumiFormat.i
int i
Definition: lumiFormat.py:85
TriggerInfo::level2TriggerInfo
const std::vector< number_type > & level2TriggerInfo() const
get level2 trigger info
Definition: TriggerInfo.cxx:148
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
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:224
LVL1_ROI.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TriggerInfo::level1TriggerType
number_type level1TriggerType() const
get level1 trigger type
Definition: TriggerInfo.cxx:138
LVL1_ROI
Top level AOD object storing LVL1 RoIs.
Definition: LVL1_ROI.h:43
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
TriggerInfo
This class contains trigger related information.
Definition: TriggerInfo.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LVL1_ROI::getEnergySumROIs
const energysums_type & getEnergySumROIs() const
Get all the energy sum RoIs in the event.
Definition: LVL1_ROI.h:71
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
TriggerInfoRetriever.h
JiveXML::TriggerInfoRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: TriggerInfoRetriever.cxx:32
TriggerInfo::extendedLevel1ID
number_type extendedLevel1ID() const
get extended level1 ID
Definition: TriggerInfo.cxx:133
TriggerInfo::eventFilterInfo
const std::vector< number_type > & eventFilterInfo() const
get event filter trigger info
Definition: TriggerInfo.cxx:153
EventInfo::trigger_info
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
Definition: EventInfo/EventInfo/EventInfo.h:244
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
AthAlgTool
Definition: AthAlgTool.h:26
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
TriggerInfo::statusElement
number_type statusElement() const
get status element
Definition: TriggerInfo.cxx:128