ATLAS Offline Software
VP1TriggerProcessor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***********************************************************************************
6  * @Package : VP1TriggerSystems
7  * @Class : VP1TriggerProcessor
8  *
9  * @brief : Trigger Processor - trigger data processing methods;
10  * - VP1TriggerTool interface to VP1TriggerSystem
11  *
12  * @author : Manuel Proissl <mproissl@cern.ch> - University of Edinburgh
13  ***********************************************************************************/
14 
15 //Local includes
18 
19 //Other includes
20 #include <iostream>
21 #include <string>
22 #include <vector>
23 #include <map>
24 #include <stdio.h>
25 #include <QTreeWidget>
26 #include <QTreeWidgetItem>
27 
28 //Global VARs ------------------------->
29 int muonsInEvt=-1;
30 //-------------------------------------<
31 
32 
33 //Trigger Processor Constructor
34 //_____________________________________________________________________________________________
36  : Logger("VP1TriggerProcessor"),
37  m_triggersystem(nullptr),
38  m_initStatus(false),
39  m_daqStatus(false),
40  m_trigLvl("all"),
41  m_dataFormat('v'),
42  m_L1_QData{}, m_L2_QData{}, m_EF_QData{} {
43  log_verbose("constructor");
44  }
45 
46 
47 //Trigger Processor Destructor
48 //_____________________________________________________________________________________________
50 {
51  log_verbose("destructor");
52  delete m_triggersystem;
53 }
54 
55 
56 //Initialize Trigger System
57 //_____________________________________________________________________________________________
59 {
60  log_info("Initializing VP1Trig::VP1TriggerSystem");
61  m_triggersystem = new VP1TriggerSystem();
62  m_initStatus=true;
63 }
64 
65 
66 //Load Trigger Data
67 //_____________________________________________________________________________________________
69 {
70  QString method="loadData(): ";
71  log_info("Loading trigger data via VP1TriggerSystem");
72 
73  //--- Note: Filling trigger handle (L1, L2, EF) objects via the VP1TriggerSystem. ---
74  if(m_initStatus) {
75  m_daqStatus = m_triggersystem->loadTriggerHandles(storeGate, m_trigLvl);
76  if(m_daqStatus)
77  processData();
78  else
79  log_fatal(method+"system initialized but retrieving data failed!");
80  }
81  else
82  log_error(method+"trigger system not initialized!");
83 }
84 
85 
86 //Process Trigger Data
87 //_____________________________________________________________________________________________
89 {
90  QString method="processData(): ";
91  log_info("Processing trigger data: start");
92 
93  //Status flags
94  bool l1status=false,l2status=false,efstatus=false;
95 
96  //L2 and EF triggers from L1 handle processor ------------->
97  QTreeWidgetItem * L1_triggers, * L2_triggers, * EF_triggers;
98  L1_triggers = new QTreeWidgetItem(0);
99  L2_triggers = new QTreeWidgetItem(0);
100  EF_triggers = new QTreeWidgetItem(0);
101  L1_triggers->setText(0, QString("Triggers"));
102  L2_triggers->setText(0, QString("Triggers"));
103  EF_triggers->setText(0, QString("Triggers"));
104  //---------------------------------------------------------<
105 
106  //--- Note: Handles for L1, L2, EF contain trigger data previously stored in each ---
107  //--- object's containers by the VP1TriggerSystem via loadData() and are ---
108  //--- being modified in each "Fill" section below by calling each handles' ---
109  //--- processing methods, which fill m_trigData with processed data. ---
110 
111  //L1 PROCESSING ------------------------------------------------------------------------------>
112  if(m_trigLvl.compare("ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare("L1", Qt::CaseInsensitive)==0) {
113  std::vector<VP1Trig::VP1TriggerHandleL1> handleL1 = m_triggersystem->getHandleL1();
115 
116  if(handleL1.size()>0) {
117  log_info(pfx1()+"processing L1 data: start");
118 
119  if(m_dataFormat=='q') {
120  log_verbose("processing sector for QTree format");
121  //************************* INIT *************************//
122  m_L1_QData = new QTreeWidgetItem(0);
123  m_L1_QData->setText(0, QString("L1 Data"));
124 
125  //************************* FILL *************************//
126  for(l1it=handleL1.begin(); l1it!=handleL1.end(); ++l1it) {
127  if(l1it->processQTrigItem()) {
128  QString trigID = l1it->m_trigID;
129  if(trigID.contains("L2_"))
130  L2_triggers->addChild(l1it->m_qtrigitem);
131  else if(trigID.contains("EF_"))
132  EF_triggers->addChild(l1it->m_qtrigitem);
133  else
134  L1_triggers->addChild(l1it->m_qtrigitem);
135  }
136  }
137  m_L1_QData->addChild(L1_triggers);
138 
139  //************************* DIST *************************//
140  m_trigLvlDataSet << m_L1_QData;
141 
142  //General processing status update
143  if(int(m_L1_QData->childCount())>0)
144  l1status=true;
145  else
146  log_warning("L1 QTree has no children");
147 
148  }//END: [q] processing
149  else if(m_dataFormat=='v') {
150  log_verbose("processing sector for vector format");
151  //************************* INIT *************************//
152  int p_success=0, p_failed=0;
153 
154  //************************* FILL *************************//
155  for(l1it=handleL1.begin(); l1it!=handleL1.end(); ++l1it) {
156  if(l1it->processVTrigItem())
157  ++p_success;
158  else
159  ++p_failed;
160  }
161 
162  //General processing status update
163  if(p_success>0)
164  l1status=true;
165  if(p_failed>0)
166  log_warning("L1 data item(s) failed processing: "+VP1String::str(p_failed));
167  }//END: [v] processing
168  else
169  log_error(method+"data container format invalid!");
170  log_info(pfx1()+"processing L1 data: complete");
171  }//END: size>0
172  else
173  log_warning(method+"L1 data requested but not available");
174  }//END: L1
175  //--------------------------------------------------------------------------------------------<
176 
177 
178  //L2 PROCESSING ------------------------------------------------------------------------------>
179  if(m_trigLvl.compare("ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare("L2", Qt::CaseInsensitive)==0) {
180  std::vector<VP1Trig::VP1TriggerHandleL2> handleL2 = m_triggersystem->getHandleL2();
182 
183  if(handleL2.size()>0) {
184  log_info(pfx1()+"processing L2 data: start");
185  if(m_dataFormat=='q') {
186  log_verbose("processing sector for QTree format");
187  //************************* FILL *************************//
188  if(l2it->processQTrigItem())
189  m_L2_QData = l2it->m_qtrigData;
190  else
191  m_L2_QData = new QTreeWidgetItem(0);
192  m_L2_QData->setText(0, QString("L2 Data"));
193 
194  if(int(L2_triggers->childCount())>0)
195  m_L2_QData->insertChild(0,L2_triggers); //from L1 processor
196 
197  //************************* DIST *************************//
198  m_trigLvlDataSet << m_L2_QData;
199 
200  //General processing status update
201  if(int(m_L2_QData->childCount())>0)
202  l2status=true;
203  else
204  log_warning("L2 QTree has no children");
205  }//END: [q] processing
206  else if(m_dataFormat=='v') {
207  log_verbose("processing sector for vector format");
208  //************************* FILL *************************//
209  l2it->processVTrigItem();
210 
211  //General processing status update
212  l2status=true;
213  }//END: [v] processing
214  else
215  log_error(method+"data container format invalid!");
216  log_info(pfx1()+"processing L2 data: complete");
217  }//END: size>0
218  else
219  log_warning(method+"L2 data requested but not available");
220  }//END: L2
221  //--------------------------------------------------------------------------------------------<
222 
223 
224  //EF PROCESSING ------------------------------------------------------------------------------>
225  if(m_trigLvl.compare("ALL", Qt::CaseInsensitive)==0 || m_trigLvl.compare("EF", Qt::CaseInsensitive)==0) {
226  std::vector<VP1Trig::VP1TriggerHandleEF> handleEF = m_triggersystem->getHandleEF();
228 
229  //Muons in event
230  muonsInEvt = int(handleEF.size());
231 
232  if(handleEF.size()>0) {
233  log_info(pfx1()+"processing EF data: start");
234  if(m_dataFormat=='q') {
235  log_verbose("processing sector for QTree format");
236  //************************* INIT *************************//
237  m_EF_QData = new QTreeWidgetItem(0);
238  m_EF_QData->setText(0, QString("EF Data"));
239 
240  //************************* FILL *************************//
241  if(int(EF_triggers->childCount())>0)
242  m_EF_QData->addChild(EF_triggers); //from L1 processor
243  for(efit=handleEF.begin(); efit!=handleEF.end(); ++efit) {
244  if(efit->processQTrigItem())
245  m_EF_QData->addChild(efit->m_qtrigData);
246  }
247 
248  //************************* DIST *************************//
249  m_trigLvlDataSet << m_EF_QData;
250 
251  //General processing status update
252  if(int(m_EF_QData->childCount())>0)
253  efstatus=true;
254  else
255  log_warning("EF QTree has no children");
256  }//END: [q] processing
257  else if(m_dataFormat=='v') {
258  log_verbose("processing sector for vector format");
259  //************************* INIT *************************//
260  int p_success=0, p_failed=0;
261 
262  //************************* FILL *************************//
263  for(efit=handleEF.begin(); efit!=handleEF.end(); ++efit) {
264  if(efit->processVTrigItem())
265  ++p_success;
266  else
267  ++p_failed;
268  }
269 
270  //General processing status update
271  if(p_success>0)
272  efstatus=true;
273  if(p_failed>0)
274  log_warning("EF data item(s) failed processing: "+VP1String::str(p_failed));
275  }//END: [v] processing
276  else
277  log_error(method+"data container format invalid!");
278  log_info(pfx1()+"processing EF data: complete");
279  }//END: size>0
280  else
281  log_warning(method+"EF data requested but not available");
282  }//END: EF
283  //--------------------------------------------------------------------------------------------<
284 
285  //Update DAQ Status flag ~~~~~~~~~~~~~~~
286  if(m_daqStatus) {
287  if(l1status || l2status || efstatus)
288  m_daqStatus=true;
289  else
290  m_daqStatus=false;
291  }//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292 
293  log_info("Processing trigger data: complete");
294 }//END: processData
295 
296 
297 //Clear System (at erase)
298 //_____________________________________________________________________________________________
300 {
301  log_info("clearSystem()");
302 
303  m_triggersystem->clearTriggerHandles();
304 
305  m_trigLvlDataSet.clear();
306 
307  m_L1_QData->takeChildren();
308  m_L2_QData->takeChildren();
309  m_EF_QData->takeChildren();
310 }//END: clearSystem
311 
312 
313 //#############################################################################################
314 // PUBLIC USER ACCESS METHODS [GETTER]
315 //#############################################################################################
316 
317 
318 //Return Status of Initalization
319 //_____________________________________________________________________________________________
321 {
322  log_verbose("User request: return status of initalization");
323  return m_initStatus;
324 }
325 
326 
327 //Return DAQ Status
328 //_____________________________________________________________________________________________
330 {
331  log_verbose("User request: return daq status");
332  return m_daqStatus;
333 }
334 
335 
336 //Return Data Container Export Format
337 //_____________________________________________________________________________________________
339 {
340  log_verbose("User request: return data container export type");
341  return m_dataFormat;
342 }
343 
344 
345 //Return Trigger Level flag to Process
346 //_____________________________________________________________________________________________
348 {
349  log_verbose("User request: return trigger level flag to process");
350  return m_trigLvl;
351 }
352 
353 
354 //Return Number of Muons in Event (requires EF trigLvl)
355 //_____________________________________________________________________________________________
357 {
358  log_verbose("User request: return number of muons in event");
359  return muonsInEvt;
360 }
361 
362 
363 //Return collected Trigger Data in QTree container format
364 //_____________________________________________________________________________________________
365 QList<QTreeWidgetItem *> VP1Trig::VP1TriggerProcessor::getQTrigData(QString triglvl)
366 {
367  log_verbose("User request: return collected trigger data in QTree container format");
368  QList<QTreeWidgetItem *> customDataSet;
369 
370  if(m_daqStatus) {
371  if(triglvl.compare("ALL", Qt::CaseInsensitive)==0 || triglvl.compare("L1", Qt::CaseInsensitive)==0 || triglvl.compare("L2", Qt::CaseInsensitive)==0 || triglvl.compare("EF", Qt::CaseInsensitive)==0) {
372  if(m_trigLvl.compare(triglvl, Qt::CaseInsensitive)==0)
373  return m_trigLvlDataSet;
374  else if(m_trigLvl.compare("ALL", Qt::CaseInsensitive)==0) {
375  if(triglvl.compare("ALL", Qt::CaseInsensitive)==0)
376  return m_trigLvlDataSet;
377  else if(triglvl.compare("L1", Qt::CaseInsensitive)==0) {
378  customDataSet << m_L1_QData;
379  return customDataSet;
380  }
381  else if(triglvl.compare("L2", Qt::CaseInsensitive)==0) {
382  customDataSet << m_L2_QData;
383  return customDataSet;
384  }
385  else if(triglvl.compare("EF", Qt::CaseInsensitive)==0) {
386  customDataSet << m_EF_QData;
387  return customDataSet;
388  }
389  }//all available
390  }//available trigger levels
391  }//daq status ok
392  else {
393  log_fatal("User data request: DAQ not available!");
394  return customDataSet;
395  }
396 
397  log_error("User requested ["+triglvl+"] trigger data which is not available! Only ["+m_trigLvl+"] available.");
398  return m_trigLvlDataSet;
399 }
400 
401 
402 //#############################################################################################
403 // PUBLIC USER ACCESS METHODS [SETTER]
404 //#############################################################################################
405 
406 
407 //Set Trigger Level flag to Process
408 //_____________________________________________________________________________________________
410 {
411  if(triglvl.compare("L1", Qt::CaseInsensitive)==0 || triglvl.compare("L2", Qt::CaseInsensitive)==0 || triglvl.compare("EF", Qt::CaseInsensitive)==0 || triglvl.compare("ALL", Qt::CaseInsensitive)==0) {
412  log_verbose("User request: set trigger level flag to "+triglvl);
413  m_trigLvl = triglvl;
414  }
415  else
416  log_error("setTrigLvl(): ["+triglvl+"] as trigger level flag not available!");
417 }
418 
419 
420 //Set Data Container Format (> dataFormat)
421 //_____________________________________________________________________________________________
423 {
424  if(ctnid=='v' || ctnid=='q' || ctnid=='a') { //[v]ector, [q]tree, [a]ll available
425  log_verbose("User request: set data container format to "+qstr(ctnid));
426  m_dataFormat = ctnid;
427  }
428  else
429  log_error("setDataFormat(): ["+qstr(ctnid)+"] as data container format not available!");
430 }
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VP1Trig::VP1TriggerProcessor::VP1TriggerProcessor
VP1TriggerProcessor()
Definition: VP1TriggerProcessor.cxx:35
VP1Trig::Logger
Definition: graphics/VP1/VP1Systems/VP1TriggerSystems/VP1TriggerSystems/Logger.h:32
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
VP1Trig::VP1TriggerProcessor::processData
void processData()
Definition: VP1TriggerProcessor.cxx:88
VP1Trig::VP1TriggerProcessor::loadData
void loadData(StoreGateSvc *m_storeGate)
Definition: VP1TriggerProcessor.cxx:68
VP1Trig::VP1TriggerProcessor::initialize
void initialize()
Definition: VP1TriggerProcessor.cxx:58
VP1Trig::VP1TriggerProcessor::getDaqStatus
bool getDaqStatus()
Definition: VP1TriggerProcessor.cxx:329
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1Trig::VP1TriggerProcessor::clearSystem
void clearSystem()
Definition: VP1TriggerProcessor.cxx:299
muonsInEvt
int muonsInEvt
Definition: VP1TriggerProcessor.cxx:29
VP1Trig::VP1TriggerProcessor::getInitStatus
bool getInitStatus()
Definition: VP1TriggerProcessor.cxx:320
VP1Trig::VP1TriggerProcessor::setTrigLvl
void setTrigLvl(QString triglvl)
Definition: VP1TriggerProcessor.cxx:409
VP1Trig::VP1TriggerSystem
Definition: VP1TriggerSystem.h:56
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
VP1TriggerSystem.h
VP1Trig::VP1TriggerProcessor::getDataFormat
char getDataFormat()
Definition: VP1TriggerProcessor.cxx:338
VP1Trig::VP1TriggerProcessor::setDataFormat
void setDataFormat(char ctnid)
Definition: VP1TriggerProcessor.cxx:422
VP1Trig::VP1TriggerProcessor::getQTrigData
QList< QTreeWidgetItem * > getQTrigData(QString)
Definition: VP1TriggerProcessor.cxx:365
VP1TriggerProcessor.h
VP1Trig::VP1TriggerProcessor::~VP1TriggerProcessor
virtual ~VP1TriggerProcessor()
Definition: VP1TriggerProcessor.cxx:49
VP1Trig::VP1TriggerProcessor::getTrigLvl
QString getTrigLvl()
Definition: VP1TriggerProcessor.cxx:347
VP1Trig::VP1TriggerProcessor::getMuonsInEvt
int getMuonsInEvt()
Definition: VP1TriggerProcessor.cxx:356
python.PyKernel.storeGate
storeGate
Definition: PyKernel.py:40