ATLAS Offline Software
VP1TriggerHandleL1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***********************************************************************************
6  * @Package : VP1TriggerSystems
7  * @Class : VP1TriggerHandleL1
8  *
9  * @brief : L1 Trigger Data Handle
10  *
11  * @author : Manuel Proissl <mproissl@cern.ch> - University of Edinburgh
12  ***********************************************************************************/
13 
14 //Local includes
16 
17 //L1 includes
24 
25 //RoI Info: Names
26 QString roiInfoName[7] =
27  {
28  "z:", //ID: 0
29  "eta:", //ID: 1
30  "eta(z+)", //ID: 2
31  "eta(z-)", //ID: 3
32  "phi:", //ID: 4
33  "RoIid:", //ID: 5
34  "RoIword:" //ID: 6
35  };
36 
37 //RoI ID Vector
38 std::vector<QString> roi_id; //--- once complete -->|
39  //m_trigData <----- added to end <---|
40 
41 //Tokenize and Store Feature items
42 //_____________________________________________________________________________________________
43 bool VP1Trig::VP1TriggerHandleL1::processFeature(int processId, QString roiId, QString feature)
44 {
45  feature = feature.simplified();
46  QStringList featureSeg = feature.split(QRegExp("\\s+"));
47 
48  if(int(featureSeg.size())==22) { //default: 22 [current TrigDecisionTool]
49  std::vector<QString> fdata, fid;
50  QStringList fdataitem;
51  int idx=0, ri_idx=0;
52 
53  //**** COLLECT FEATURE ITEM DATA [3.DIM] ***********************************
54  for(int fs=0; fs<int(featureSeg.size()); ++fs) {
55  if(ri_idx<(int(sizeof roiInfoName/sizeof(QString))-1) && idx==1)
56  ++ri_idx;
57 
58  if(roiInfoName[ri_idx]==featureSeg[fs]) {
59  if(idx>1 && int(fdataitem.size())>0) {
60  fdata.push_back(fdataitem.join(" "));
61  fdataitem.clear();
62  idx=0;
63  }
64  ++idx;
65  continue;
66  }
67  else {
68  if(!featureSeg[fs].contains("[") && !featureSeg[fs].contains("]"))
69  fdataitem << featureSeg[fs];
70  ++idx;
71 
72  if(fs==(int(featureSeg.size())-1) && int(fdataitem.size())>0) {
73  fdata.push_back(fdataitem.join(" "));
74  fdataitem.clear();
75  }
76  }
77  }
78 
79  //**** COLLECT FEATURE ITEM DATA [2.DIM] ***********************************
80  //std::cout << "FULL: " << feature.toStdString() << std::endl;
81  if(int(sizeof roiInfoName/sizeof(QString))==int(fdata.size())) {
82  if(processId==0) {
83  for(int v=0; v<int(fdata.size()); ++v) {
84  //std::cout << "SEG: " << roiInfoName[v].toStdString() << " " << fdata[v].toStdString() << std::endl;
85  fid.push_back(roiInfoName[v]);
86  }
87  m_trigData.push_back(fid);
88  }
89  m_trigData.push_back(fdata);
90  roi_id.push_back(roiId);
91  return true;
92  }
93  else {
94  log_error("processFeature(): unexpected vector size: roiInfo["+VP1String::str(int(sizeof roiInfoName/sizeof(QString)))+"], fdata["+VP1String::str(int(featureSeg.size()))+"]!");
95  return false;
96  }
97  }//END: def_22
98  else {
99  //--- Note: This system depends on the return of the ATLAS TrigDecisionTool. In case ---
100  //--- this underlying package has been modified, there are various ways to ---
101  //--- deal with the return more dynamic or adaptive (TODO). In this version ---
102  //--- we however only throw an exception until stable adaptive methods tested. ---
103  log_error("processFeature(): TrigDecisionTool returned "+VP1String::str(int(featureSeg.size()))+" feature segment items!");
104  return false;
105  }
106 }//END: processFeature
107 
108 
109 //Processing L1 data handle item
110 //_____________________________________________________________________________________________
112 {
114  int combId=0, processId=0;
115  QString feature, roiId;
116 
117  //Clear ROI vectors
118  m_trigData.clear();
119  roi_id.clear();
120 
121  //--- Note: For single muon objects (use combinations only for 2 or more objects) ---
122  //e.g.: std::vector< Feature<TrigRoiDescriptor> > initRois = m_containerL1->get<TrigRoiDescriptor>("initialRoI");
123 
124  using namespace Trig;
125  for(cIt = m_containerL1.getCombinations().begin(); cIt != m_containerL1.getCombinations().end(); ++cIt) {
126 
127  //IMPORT: all possible features of TrigRoiDescriptor
128  std::vector< Feature<TrigRoiDescriptor> > forID = cIt->get<TrigRoiDescriptor>("forID");
129  std::vector< Feature<TrigRoiDescriptor> > forMS = cIt->get<TrigRoiDescriptor>("forMS");
130  std::vector< Feature<TrigRoiDescriptor> > initialRoI = cIt->get<TrigRoiDescriptor>("initialRoI");
131  std::vector< Feature<TrigRoiDescriptor> > secondaryRoI_L2 = cIt->get<TrigRoiDescriptor>("secondaryRoI_L2");
132  std::vector< Feature<TrigRoiDescriptor> > secondaryRoI_EF = cIt->get<TrigRoiDescriptor>("secondaryRoI_EF");
133  std::vector< Feature<TrigRoiDescriptor> > T2TauFinal = cIt->get<TrigRoiDescriptor>("T2TauFinal");
134  std::vector< Feature<TrigRoiDescriptor> > TrigT2CaloEgamma = cIt->get<TrigRoiDescriptor>("TrigT2CaloEgamma");
135  std::vector< Feature<TrigRoiDescriptor> > TrigT2CaloJet = cIt->get<TrigRoiDescriptor>("TrigT2CaloJet");
136  std::vector< Feature<TrigRoiDescriptor> > TrigT2CosmicJet = cIt->get<TrigRoiDescriptor>("TrigT2CosmicJet");
137  std::vector< Feature<TrigRoiDescriptor> > TrigT2CaloTau = cIt->get<TrigRoiDescriptor>("TrigT2CaloTau");
138 
139  //EXPORT: Feature vector contents >>
141  //********************
142  if( !forID.empty() ){
143  for(int dItr=0; dItr<int(forID.size()); ++dItr) {
144  d = forID[dItr];
145  feature = QString::fromStdString(::str(*d.cptr()));
146  roiId = QString("ROI_ID_")+QString::number(combId)+QString(":")+QString::number(dItr);
147  if(!feature.isEmpty()) {
148  bool fstatus = processFeature(processId, roiId, feature); ++processId;
149  if(!fstatus)
150  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
151  }
152  }//loop
153  }//END: forID
154 
155  //********************
156  if( !forMS.empty() ){
157  for(int dItr=0; dItr<int(forMS.size()); ++dItr) {
158  d = forMS[dItr];
159  feature = QString::fromStdString(::str(*d.cptr()));
160  roiId = QString("ROI_MS_")+QString::number(combId)+QString(":")+QString::number(dItr);
161  if(!feature.isEmpty()) {
162  bool fstatus = processFeature(processId, roiId, feature); ++processId;
163  if(!fstatus)
164  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
165  }
166  }//loop
167  }//END: forMS
168 
169  //********************
170  if( !initialRoI.empty() ){
171  for(int dItr=0; dItr<int(initialRoI.size()); ++dItr) {
172  d = initialRoI[dItr];
173  feature = QString::fromStdString(::str(*d.cptr()));
174  roiId = QString("ROI_Initial_")+QString::number(combId)+QString(":")+QString::number(dItr);
175  if(!feature.isEmpty()) {
176  bool fstatus = processFeature(processId, roiId, feature); ++processId;
177  if(!fstatus)
178  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
179  }
180  }//loop
181  }//END: initialRoI
182 
183  //********************
184  if( !secondaryRoI_L2.empty() ){
185  for(int dItr=0; dItr<int(secondaryRoI_L2.size()); ++dItr) {
186  d = secondaryRoI_L2[dItr];
187  feature = QString::fromStdString(::str(*d.cptr()));
188  roiId = QString("ROI_SecondaryL2_")+QString::number(combId)+QString(":")+QString::number(dItr);
189  if(!feature.isEmpty()) {
190  bool fstatus = processFeature(processId, roiId, feature); ++processId;
191  if(!fstatus)
192  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
193  }
194  }//loop
195  }//END: secondaryRoI_L2
196 
197  //********************
198  if( !secondaryRoI_EF.empty() ){
199  for(int dItr=0; dItr<int(secondaryRoI_EF.size()); ++dItr) {
200  d = secondaryRoI_EF[dItr];
201  feature = QString::fromStdString(::str(*d.cptr()));
202  roiId = QString("ROI_SecondaryEF_")+QString::number(combId)+QString(":")+QString::number(dItr);
203  if(!feature.isEmpty()) {
204  bool fstatus = processFeature(processId, roiId, feature); ++processId;
205  if(!fstatus)
206  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
207  }
208  }//loop
209  }//END: secondaryRoI_EF
210 
211  //********************
212  if( !T2TauFinal.empty() ){
213  for(int dItr=0; dItr<int(T2TauFinal.size()); ++dItr) {
214  d = T2TauFinal[dItr];
215  feature = QString::fromStdString(::str(*d.cptr()));
216  roiId = QString("ROI_T2TauFinal_")+QString::number(combId)+QString(":")+QString::number(dItr);
217  if(!feature.isEmpty()) {
218  bool fstatus = processFeature(processId, roiId, feature); ++processId;
219  if(!fstatus)
220  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
221  }
222  }//loop
223  }//END: T2TauFinal
224 
225  //********************
226  if( !TrigT2CaloEgamma.empty() ){
227  for(int dItr=0; dItr<int(TrigT2CaloEgamma.size()); ++dItr) {
228  d = TrigT2CaloEgamma[dItr];
229  feature = QString::fromStdString(::str(*d.cptr()));
230  roiId = QString("ROI_TrigT2CaloEgamma_")+QString::number(combId)+QString(":")+QString::number(dItr);
231  if(!feature.isEmpty()) {
232  bool fstatus = processFeature(processId, roiId, feature); ++processId;
233  if(!fstatus)
234  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
235  }
236  }//loop
237  }//END: TrigT2CaloEgamma
238 
239  //********************
240  if( !TrigT2CaloJet.empty() ){
241  for(int dItr=0; dItr<int(TrigT2CaloJet.size()); ++dItr) {
242  d = TrigT2CaloJet[dItr];
243  feature = QString::fromStdString(::str(*d.cptr()));
244  roiId = QString("ROI_TrigT2CaloJet_")+QString::number(combId)+QString(":")+QString::number(dItr);
245  if(!feature.isEmpty()) {
246  bool fstatus = processFeature(processId, roiId, feature); ++processId;
247  if(!fstatus)
248  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
249  }
250  }//loop
251  }//END: TrigT2CaloJet
252 
253  //********************
254  if( !TrigT2CosmicJet.empty() ){
255  for(int dItr=0; dItr<int(TrigT2CosmicJet.size()); ++dItr) {
256  d = TrigT2CosmicJet[dItr];
257  feature = QString::fromStdString(::str(*d.cptr()));
258  roiId = QString("ROI_TrigT2CosmicJet_")+QString::number(combId)+QString(":")+QString::number(dItr);
259  if(!feature.isEmpty()) {
260  bool fstatus = processFeature(processId, roiId, feature); ++processId;
261  if(!fstatus)
262  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
263  }
264  }//loop
265  }//END: TrigT2CosmicJet
266 
267  //********************
268  if( !TrigT2CaloTau.empty() ){
269  for(int dItr=0; dItr<int(TrigT2CaloTau.size()); ++dItr) {
270  d = TrigT2CaloTau[dItr];
271  feature = QString::fromStdString(::str(*d.cptr()));
272  roiId = QString("ROI_TrigT2CaloTau_")+QString::number(combId)+QString(":")+QString::number(dItr);
273  if(!feature.isEmpty()) {
274  bool fstatus = processFeature(processId, roiId, feature); ++processId;
275  if(!fstatus)
276  log_error("processitem(): feature processing failed for: "+roiId+" > "+qstr(::str(*d.cptr())));
277  }
278  }//loop
279  }//END: TrigT2CaloTau
280 
281  ++combId;
282  }//END: loop over chain group items
283 
284  //EXPORT TRIGGER DATA -------------------------------------------------------------------------------->
285  if(m_trigData.size()!=0 && m_trigData[0].size()!=0 && roi_id.size()!=0) {
286  //std::cout << "dataSize>" << int(m_trigData.size()) << " idSize>" << int(roi_id.size()) << std::endl;
287  if((int(m_trigData.size())-1)==int(roi_id.size())) {
288  m_trigData.push_back(roi_id); //Append ROI IDs to ROI data (incl. fid, fdata)
289  return true;
290  }
291  else {
292  log_error("processitem(): ROI data and ID entries do not match!");
293  return false;
294  }
295  }
296  else
297  log_error("processitem(): ROI vectors empty: cannot append IDs!");
298  return false;
299  //----------------------------------------------------------------------------------------------------<
300 }//END: processitem
301 
302 
303 //Processes L1 data item with storage in QTreeWidgetItem and returns processing success/failure
304 //_____________________________________________________________________________________________
306 {
307  //Process Handle item
308  bool status = processitem();
309  m_qtrigitem = new QTreeWidgetItem(0);
310 
311  if(status) {
312  //Safety Check: TrigID / content count match
313  if(!(int(m_trigData[int(m_trigData.size())-1].size()) == int(m_trigData.size())-2)) {
314  log_error("processQTrigItem(): mismatch in TrigID / data item count: TrigID size: "+VP1String::str(int(m_trigData[int(m_trigData.size())-1].size()))+" and TrigID data cout: "+VP1String::str(int(m_trigData.size())-2));
315  m_qtrigstatus=false;
316  }
317  else {
318  QTreeWidgetItem* trigId;
319  QString dataItem;
320 
321  m_qtrigitem->setText(0, QString("TE: ")+m_trigID);
322 
323  for(int x=1; x<int(m_trigData.size()-1); ++x) {
324  trigId = new QTreeWidgetItem(m_qtrigitem);
325  trigId->setText(0, m_trigData[int(m_trigData.size())-1][x-1]);
326 
327  QList<QTreeWidgetItem *> data;
328  for(int y=0; y<int(m_trigData[x].size()); ++y) {
329  if(int(m_trigData[0].size())==int(m_trigData[x].size())) {
330  dataItem = m_trigData[0][y]+QString(" ")+m_trigData[x][y];
331  data.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(dataItem)));
332  }
333  else
334  log_error("processQTrigItem(): mismatch in feature ID to data item count!");
335  }//y loop
336  trigId->insertChildren(0, data);
337  }//x loop
338  m_qtrigstatus=true;
339  }//count ok
340  }//status ok
341  else
342  m_qtrigstatus=false;
343 
344  return m_qtrigstatus;
345 }//END: processQTrigItem
346 
347 
348 //Processes L1 data item with storage in Vectors and returns processing success/failure
349 //_____________________________________________________________________________________________
351 {
352  //Process Handle item
353  bool status = processitem();
354 
355  if(status)
356  m_vtrigstatus=true;
357  else
358  m_vtrigstatus=false;
359 
360  return m_vtrigstatus;
361 }//END: processVTrigItem
VP1Trig::VP1TriggerHandleL1::m_trigData
std::vector< std::vector< QString > > m_trigData
Definition: VP1TriggerHandleL1.h:80
Trig::FeatureContainer::combination_const_iterator
std::vector< Combination >::const_iterator combination_const_iterator
Definition: FeatureContainer.h:69
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Trig::Feature
Definition: Feature.h:112
roiInfoName
QString roiInfoName[7]
Definition: VP1TriggerHandleL1.cxx:26
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
FeatureContainer.h
hist_file_dump.d
d
Definition: hist_file_dump.py:137
VP1Trig::VP1TriggerHandleL1::processitem
bool processitem()
Definition: VP1TriggerHandleL1.cxx:111
Feature.h
TrigDecisionTool.h
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
ChainGroup.h
roi_id
std::vector< QString > roi_id
Definition: VP1TriggerHandleL1.cxx:38
x
#define x
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
TDTUtilities.h
VP1TriggerHandleL1.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
VP1Trig::VP1TriggerHandleL1::processQTrigItem
bool processQTrigItem()
Definition: VP1TriggerHandleL1.cxx:305
xAOD::roiId
setTeId setLumiBlock roiId
Definition: L2StandAloneMuon_v1.cxx:331
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
VP1Trig::VP1TriggerHandleL1::processVTrigItem
bool processVTrigItem()
Definition: VP1TriggerHandleL1.cxx:350
VP1Trig::Logger::log_error
void log_error(const QString &msg)
Definition: graphics/VP1/VP1Systems/VP1TriggerSystems/src/Logger.cxx:46
python.selection.number
number
Definition: selection.py:20
python.PyAthena.v
v
Definition: PyAthena.py:154
y
#define y
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigRoiDescriptor.h
merge.status
status
Definition: merge.py:17
VP1Trig::VP1TriggerHandleL1::processFeature
bool processFeature(int processId, QString roiId, QString feature)
Definition: VP1TriggerHandleL1.cxx:43