ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1ResultRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8
11namespace JiveXML {
12
13
17 LVL1ResultRetriever::LVL1ResultRetriever(const std::string& type, const std::string& name, const IInterface* parent):
18 AthAlgTool(type, name, parent)
19 {
20 declareInterface<IDataRetriever>(this);
21 }
22
29
30 //be verbose
31 ATH_MSG_VERBOSE("initialize()");
32
33 //Try to retrieve the trig decision tool
34 if ( !m_trigDecTool.retrieve() ) {
35 ATH_MSG_FATAL("Could not retrieve TrigDecisionTool!");
36 return StatusCode::FAILURE;
37 }
38
39 // We define the chain groups relying on the name convention (i.e. all L1
40 // items start their name from "L1_", etc) In principle we would not have to do
41 // so as the TrigDecisionTool jobOptions defines these as public chain
42 // groups. This way, we are independant of jobOptions
43 m_all = m_trigDecTool->getChainGroup(".*");
44 m_allL1 = m_trigDecTool->getChainGroup("L1_.*");
45 m_allL2 = m_trigDecTool->getChainGroup("L2_.*");
46 m_allEF = m_trigDecTool->getChainGroup("EF_.*");
47 m_allHLT = m_trigDecTool->getChainGroup("HLT_.*");
48
49 return StatusCode::SUCCESS;
50 }
51
57 std::string& itemList, std::string& prescaleList) {
58
59 std::string sig_name;
60
61 //Get a list of L1 items
62 std::vector<std::string> chainList = chains->getListOfTriggers();
63 ATH_MSG_DEBUG("Number of items in chain is " << chainList.size());
64
65 for (auto &trigName : chainList){
66 // Make sure the item is not empty
67 // (can this actually happen ?!?
68 if ( trigName.empty() ) continue;
69
70 auto trigChain = m_trigDecTool->getChainGroup(trigName);
71 // getPrescale() returns 0.0 for the first event: trigger decision tool needs
72 // to internally cache the values prior to the event, but running from RAW the
73 // conditions algorithm only runs during the event. Hence the "live" loading of
74 // prescales are 1 event late - No trigger decisions for the first event
75 if ( std::abs(trigChain->getPrescale()-1.0) > 1e-5 ) continue;
76
77 //Output debug info
78 std::string myItem = trigName;
79 ATH_MSG_VERBOSE(" * item : name=" << myItem
80 << "; result = " << (trigChain->isPassed() ? "passed" : "failed")
81 << "; prescale = " << trigChain->getPrescale());
82
83 // replace HLT with EF (as AtlantisJava doesn't know 'HLT'):
84 if ( myItem.find("HLT",0) != std::string::npos){
85 myItem.replace(0,4,"EF_");
86 ATH_MSG_VERBOSE(trigName << " renamed into: " << myItem);
87 }
88
89 // prescale: see TWiki page TrigDecisionTool15
90
91 //Only add passed items
92 if ( trigChain->isPassed() ) {
93
94 //Add item to list
95 itemList += "-" + myItem;
96
97 // prescale factor
98 prescaleList += "-" + DataType( trigChain->getPrescale() ).toString();
99 }
100 }
101
102
103 //Mark empty item lists
104 if ( itemList.empty() ){ itemList = "empty"; }
105 if ( prescaleList.empty() ){ prescaleList = "empty"; }
106
107 //print debug information
108 ATH_MSG_DEBUG(" itemList: " << itemList);
109 ATH_MSG_DEBUG(" prescaleList: " << prescaleList);
110
111 return StatusCode::SUCCESS;
112 }
113
120 StatusCode LVL1ResultRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
121
122 //be verbose
123 ATH_MSG_VERBOSE("retrieve()");
124
125 //Get the item and prescale lists for all levels
126 std::string itemListL1="";
127 std::string prescaleListL1="";
128 std::string itemListL2="";
129 std::string prescaleListL2="";
130 std::string itemListEF="";
131 std::string prescaleListEF="";
132 std::string itemListHLT="";
133 std::string prescaleListHLT="";
134
135 //Get L1
136 getItemLists( m_allL1, itemListL1, prescaleListL1 ).ignore();
137 //Summarize L1 result
138 int flagL1Passed = m_allL1->isPassed();
139 ATH_MSG_DEBUG("Decision : Level-1 " << ((flagL1Passed)? "passed":"failed"));
140
141 //Get L2
142 getItemLists( m_allL2, itemListL2, prescaleListL2 ).ignore();
143 //Summarize L2 result
144 int flagL2Passed = m_allL2->isPassed();
145 ATH_MSG_DEBUG("Decision : Level-2 " << ((flagL2Passed)? "passed":"failed"));
146
147 //Get EF
148 getItemLists( m_allEF, itemListEF, prescaleListEF ).ignore();
149 //Summarize EF result
150 int flagEFPassed = m_allEF->isPassed();
151 ATH_MSG_DEBUG("Decision : EventFilter " << ((flagEFPassed)? "passed":"failed"));
152
153 //Get HLT
154 getItemLists( m_allHLT, itemListHLT, prescaleListHLT ).ignore();
155 //Summarize HLT result
156 int flagHLTPassed = m_allHLT->isPassed();
157 ATH_MSG_DEBUG("Decision : HLT " << ((flagHLTPassed)? "passed":"failed"));
158
159 //Do not write trigger info if we failed to obtain any of it
160 if ((itemListL1=="empty") && (itemListL2=="empty") && (itemListEF=="empty") && (itemListHLT=="empty") ){
161 ATH_MSG_INFO("All item lists empty, will not write out any data");
162 return StatusCode::SUCCESS;
163 }
164
165 //Store results in data list
166 DataVect itemListL1Vec; itemListL1Vec.push_back( DataType( itemListL1 ));
167 DataVect prescaleListL1Vec; prescaleListL1Vec.push_back( DataType( prescaleListL1 ));
168 DataVect itemListL2Vec; itemListL2Vec.push_back( DataType( itemListL2 ));
169 DataVect prescaleListL2Vec; prescaleListL2Vec.push_back( DataType( prescaleListL2 ));
170 DataVect itemListEFVec; itemListEFVec.push_back( DataType( itemListEF ));
171 DataVect prescaleListEFVec; prescaleListEFVec.push_back( DataType( prescaleListEF ));
172 DataVect itemListHLTVec; itemListHLTVec.push_back( DataType( itemListHLT ));
173 DataVect prescaleListHLTVec; prescaleListHLTVec.push_back( DataType( prescaleListHLT ));
174 DataVect passedTrigger; passedTrigger.push_back(DataType( flagHLTPassed )); //this is just a duplicate
175 DataVect passedL1; passedL1.push_back(DataType( flagL1Passed ));
176 DataVect passedL2; passedL2.push_back(DataType( flagL2Passed ));
177 DataVect passedEF; passedEF.push_back(DataType( flagHLTPassed )); // temporary.
178 DataVect passedHLT; passedHLT.push_back(DataType( flagHLTPassed ));
179 // placeholders only ! For backwards compatibility.
180 // Trigger energies moved to TriggerInfoRetriever
181 DataVect energySumEt; energySumEt.push_back(DataType( -1. ) );
182 DataVect energyEx; energyEx.push_back(DataType( -1. ) );
183 DataVect energyEy; energyEy.push_back(DataType( -1. ) );
184 DataVect energyEtMiss; energyEtMiss.push_back(DataType( -1. ) );
185
186 //Finally create data map and write out results
187 DataMap dataMap;
188 const std::size_t n = itemListL1Vec.size();
189 dataMap["ctpItemList"] = std::move(itemListL1Vec);
190 dataMap["prescaleListL1"] = std::move(prescaleListL1Vec);
191 dataMap["itemListL2"] = std::move(itemListL2Vec);
192 dataMap["prescaleListL2"] = std::move(prescaleListL2Vec);
193 dataMap["itemListEF"] = std::move(itemListHLTVec); // temporary. AtlantisJava doesn't know 'HLT' yet. jpt 23Jun15
194 dataMap["prescaleListEF"] = std::move(prescaleListHLTVec);
195 dataMap["passedTrigger"] = std::move(passedTrigger);
196 dataMap["passedL1"] = std::move(passedL1);
197 dataMap["passedL2"] = passedHLT; // temporary. AtlantisJava doesn't know 'HLT' yet. jpt 23Jun15
198 dataMap["passedEF"] = std::move(passedHLT); // temporary. AtlantisJava doesn't know 'HLT' yet. jpt 23Jun15
199 dataMap["energySumEt"] = std::move(energySumEt);
200 dataMap["energyEx"] = std::move(energyEx);
201 dataMap["energyEy"] = std::move(energyEy);
202 dataMap["energyEtMiss"] = std::move(energyEtMiss);
203
204 ATH_MSG_DEBUG(dataTypeName() << ": "<< n);
205 //forward data to formating tool
206 return FormatTool->AddToEvent(dataTypeName(), "TrigDecision", &dataMap);
207 }
208}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const Trig::ChainGroup * m_allL1
const Trig::ChainGroup * m_allEF
const Trig::ChainGroup * m_all
the trigger chains
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
A handle to the TrigDecisionTool.
StatusCode initialize()
Initialize the tool.
const Trig::ChainGroup * m_allL2
LVL1ResultRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
const Trig::ChainGroup * m_allHLT
StatusCode getItemLists(const Trig::ChainGroup *chains, std::string &listName, std::string &prescaleName)
Subroutine for constructing the item list string.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual std::string dataTypeName() const
Return the name of the data type.
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58