ATLAS Offline Software
VP1TriggerHandleL2.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 : VP1TriggerHandleL2
8  *
9  * @brief : L2 Trigger Data Handle
10  *
11  * @author : Manuel Proissl <mproissl@cern.ch> - University of Edinburgh
12  * @author : Edward Moyse <edward.moyse@cern.ch>
13  ***********************************************************************************/
14 
15 //Local includes
17 
18 //L2 includes
32 
33 //Other includes
34 #include <QString>
35 
36 //DEFs
37 const float ZERO_LIMIT = 0.00001;
38 
39 
40 //Processing L2 data handle item
41 //_____________________________________________________________________________________________
43 {
44  //Vectors Data Structure Init ------------------------------>
45  std::vector<QString> headerID(3), barrelID, endcapID, generalID,
46  barrelData, endcapData, generalData;
47 
48  //Define Header IDs (thus pre-define vector data structure)
49  headerID[0]=QString("Barrel");
50  headerID[1]=QString("Endcap");
51  headerID[2]=QString("General");
52 
53  //Clear Export Vector
54  m_trigData.clear();
55  //----------------------------------------------------------<
56 
57  //Muon feature iterator
58  std::vector<const MuonFeatureDetails*>::const_iterator itMfd;
59  //bool off_match = false; never used, code commented out below
60  for(itMfd=m_containerL2.begin(); itMfd!=m_containerL2.end(); ++itMfd) {
61  //Check ID
62  int id = (*itMfd)->id();
63  if(id!=1) continue; //muFast_Muon
64 
65  //RoI System
66  int systemID = (*itMfd)->roi_system(); //0:barrel, 1:endcap, 2:forward
67 
68  //Flow
69  bool isL1hitThere = false;
70  bool isL1emuOkForTriggerPlane = false;
71 
72  int nRPC = (*itMfd)->pad_hit_onlineId().size();
73 
74  int nTGCMidRho = (*itMfd)->tgc_Mid_rho_N();
75  int nTGCMidPhi = (*itMfd)->tgc_Mid_phi_N();
76 
77  float TGCMidRhoChi2 = (*itMfd)->tgc_Mid_rho_chi2();
78  float TGCMidPhiChi2 = (*itMfd)->tgc_Mid_phi_chi2();
79 
80  //Process systems
81  if(systemID==0) { //RPC
82  float rpc1_z = (*itMfd)->rpc1_z();
83  float rpc2_z = (*itMfd)->rpc2_z();
84  const float NO_VALUE = 99999;
85  if(nRPC!=0) isL1hitThere = true;
86  if(fabs(rpc1_z-NO_VALUE) > ZERO_LIMIT && fabs(rpc1_z) > ZERO_LIMIT && fabs(rpc2_z-NO_VALUE) > ZERO_LIMIT && fabs(rpc2_z) > ZERO_LIMIT) {
87  isL1emuOkForTriggerPlane = true;
88  }
89 
90  //Dump to vectors
91  barrelID.push_back("RPC-1: Z");
92  barrelData.push_back(QString::number(rpc1_z));
93 
94  barrelID.push_back("RPC-2: Z");
95  barrelData.push_back(QString::number(rpc2_z));
96 
97  barrelID.push_back("RPC: nHits");
98  barrelData.push_back(QString::number(nRPC));
99  } else { //TGC
100  const float NO_VALUE = -99999;
101  if(nTGCMidRho!=0 && nTGCMidPhi!=0) isL1hitThere = true;
102  if(fabs(TGCMidRhoChi2 - NO_VALUE) > ZERO_LIMIT && fabs(TGCMidPhiChi2 - NO_VALUE) > ZERO_LIMIT) isL1emuOkForTriggerPlane = true;
103 
104  //Dump to vectors
105  endcapID.push_back("TGC Mid nHits: Rho");
106  endcapData.push_back(QString::number(nTGCMidRho));
107 
108  endcapID.push_back("TGC Mid nHits: Phi");
109  endcapData.push_back(QString::number(nTGCMidPhi));
110 
111  endcapID.push_back("TGC Mid Chi2: Rho");
112  endcapData.push_back(QString::number(TGCMidRhoChi2));
113 
114  endcapID.push_back("TGC Mid Chi2: Phi");
115  endcapData.push_back(QString::number(TGCMidPhiChi2));
116  }
117 
118  //Loop over each MDT tube
119  std::vector<float> mdt_tube_residual = (*itMfd)->mdt_tube_residual();
120  std::vector<float> mdt_tube_r = (*itMfd)->mdt_tube_r();
121  std::vector<float> mdt_tube_z = (*itMfd)->mdt_tube_z();
122 
123  //INIT counters
124  int n_mdt_hits_inner = 0;
125  int n_mdt_hits_middle = 0;
126  int n_mdt_hits_outer = 0;
127 
128  //Process systems
129  if(systemID==0) { //Barrel
130  for(int i_tube=0; i_tube<(int)mdt_tube_residual.size(); i_tube++) {
131  QString tube;
132  float res = mdt_tube_residual[i_tube];
133  float r = mdt_tube_r[i_tube];
134  int imr = 2;
135 
136  //Flags
137  if (r<650) { imr=0; }
138  else if(r<850) { imr=1; }
139 
140  //Dump to vectors
141  if(imr==0) {
142  n_mdt_hits_inner++;
143  tube = (QString::number(i_tube));
144  barrelID.push_back(QString("muFast_MDT_Inn_residual_barrel Tube No-")+tube);
145  barrelData.push_back(QString::number(res));
146 
152  }
153  else if(imr==1) {
154  n_mdt_hits_middle++;
155  tube = (QString::number(i_tube));
156  barrelID.push_back(QString("muFast_MDT_Mid_residual_barrel Tube No-")+tube);
157  barrelData.push_back(QString::number(res));
158 
164  }
165  else if(imr==2) {
166  n_mdt_hits_outer++;
167  tube = (QString::number(i_tube));
168  barrelID.push_back(QString("muFast_MDT_Out_residual_barrel tube No-")+tube);
169  barrelData.push_back(QString::number(res));
170 
176  }
177  }
178  }//END: systemID=0
179  else{ //Endcap
180  for(int i_tube=0; i_tube<(int)mdt_tube_residual.size(); i_tube++) {
181  QString tube;
182  float z = mdt_tube_z[i_tube];
183  int imr = 2;
184 
185  if ( fabs(z) < 10000 ) { imr=0; }
186  else if( fabs(z) < 15000 ) { imr=1; }
187 
188  //Dump to vectors
189  if(imr == 0) {
190  n_mdt_hits_inner++;
191  tube = (QString::number(i_tube));
192  endcapID.push_back(QString("muFast_MDT_Inn_residual_endcap Tube No-")+tube);
193  endcapData.push_back(QString::number(TGCMidRhoChi2));
194 
200  }
201  else if(imr == 1) {
202  n_mdt_hits_middle++;
203  tube = (QString::number(i_tube));
204  endcapID.push_back(QString("muFast_MDT_Mid_residual_endcap Tube No-")+tube);
205  endcapData.push_back(QString::number(TGCMidRhoChi2));
206 
212  } else if(imr == 2) {
213  n_mdt_hits_outer++;
214  tube = (QString::number(i_tube));
215  endcapID.push_back(QString("muFast_MDT_Out_residual_endcap Tube No-" )+tube);
216  endcapData.push_back(QString::number(TGCMidRhoChi2));
217 
223  }
224  }
225  }//END: Endcap
226 
227  //MDT flow
228  bool isMDThitThereForTriggerPlane = false;
229  bool isMDTFitOkForTriggerPlane = false;
230  bool isMDTFitOkFor2Plane = false;
231 
232  int nMDT = (*itMfd)->mdt_onlineId().size();
233 
234  float MDTInnChi2 = (*itMfd)->mdt_Inner_fit_chi();
235  float MDTMidChi2 = (*itMfd)->mdt_Middle_fit_chi();
236  float MDTOutChi2 = (*itMfd)->mdt_Outer_fit_chi();
237 
238  const float MDT_CHI2_NO_VALUE = -99999;
239 
240  if(n_mdt_hits_middle != 0) isMDThitThereForTriggerPlane = true;
241  if(fabs(MDTMidChi2-MDT_CHI2_NO_VALUE) > ZERO_LIMIT) isMDTFitOkForTriggerPlane = true;
242  if(isMDTFitOkForTriggerPlane && (fabs(MDTInnChi2 - MDT_CHI2_NO_VALUE) > ZERO_LIMIT || fabs(MDTOutChi2 - MDT_CHI2_NO_VALUE) > ZERO_LIMIT) ) {
243  isMDTFitOkFor2Plane = true;
244  }
245 
246  //DEFs
247  int isL1hitTheret, isL1emuOkForTriggerPlanet, isMDThitTheret, isMDTFitOkForTriggerPlanet, isMDTFitOkFor2Planet;
248 
249  if(isL1hitThere==true) isL1hitTheret=1;
250  else isL1hitTheret=0;
251 
252  if(isL1emuOkForTriggerPlane==true) isL1emuOkForTriggerPlanet=1;
253  else isL1emuOkForTriggerPlanet=0;
254 
255  if(isMDThitThereForTriggerPlane==true) isMDThitTheret=1;
256  else isMDThitTheret=0;
257 
258  if(isMDTFitOkForTriggerPlane==true) isMDTFitOkForTriggerPlanet=1;
259  else isMDTFitOkForTriggerPlanet=0;
260 
261  if(isMDTFitOkFor2Plane==true) isMDTFitOkFor2Planet=1;
262  else isMDTFitOkFor2Planet=0;
263 
264  //Dump to vectors
265  generalID.push_back("isL1hitThere");
266  generalData.push_back(QString::number(isL1hitTheret));
267 
268  generalID.push_back("L1emuOkForTriggerPlane");
269  generalData.push_back(QString::number(isL1emuOkForTriggerPlanet));
270 
271  generalID.push_back("isMDThitThere");
272  generalData.push_back(QString::number(isMDThitTheret));
273 
274  generalID.push_back("FitOkForTriggerPlane");
275  generalData.push_back(QString::number(isMDTFitOkForTriggerPlanet));
276 
277  generalID.push_back("FitOkFor2Plane");
278  generalData.push_back(QString::number(isMDTFitOkFor2Planet));
279 
280  //Dump to vectors
281  if(systemID==0) { //Barrel
282  barrelID.push_back("muFast_RPC_Pad_N" );
283  barrelData.push_back(QString::number(nRPC));
284 
285  barrelID.push_back("muFast_MDT_Inn_fit_chi2_barrel");
286  barrelData.push_back(QString::number(MDTInnChi2));
287 
288  barrelID.push_back("muFast_MDT_Mid_fit_chi2_barrel");
289  barrelData.push_back(QString::number(MDTMidChi2));
290 
291  barrelID.push_back("muFast_MDT_Out_fit_chi2_barrel");
292  barrelData.push_back(QString::number(MDTOutChi2));
293 
294  } else{ //Endcap
295  endcapID.push_back("muFast_TGC_Mid_rho_chi2");
296  endcapData.push_back(QString::number(TGCMidRhoChi2));
297 
298  endcapID.push_back("muFast_TGC_Mid_phi_chi2" );
299  endcapData.push_back(QString::number(TGCMidPhiChi2));
300 
301  endcapID.push_back("muFast_MDT_Inn_fit_chi2_endcap");
302  endcapData.push_back(QString::number(MDTInnChi2));
303 
304  endcapID.push_back("FitOkFor2Plane");
305  endcapData.push_back(QString::number(MDTMidChi2));
306 
307  endcapID.push_back("muFast_MDT_Out_fit_chi2_endcap");
308  endcapData.push_back(QString::number(MDTOutChi2));
309 
310  endcapID.push_back("muFast_MDT_N_endcap");
311  endcapData.push_back(QString::number(nMDT));
312  }
313  }
314  //END: Looping MuonFeatureDetails
315 
316  //Export Trigger Data according to pre-def. structure ------>
317  if(int(headerID.size())==3) {
318  if(int(barrelID.size())==int(barrelData.size()) && int(endcapID.size())==int(endcapData.size()) && int(generalID.size())==int(generalData.size())) {
319  if(int(barrelData.size())!=0 || int(endcapData.size())!=0 || int(generalData.size())) {
320  m_trigData.push_back(headerID); //[0]
321 
322  m_trigData.push_back(barrelID); //[1]
323  m_trigData.push_back(endcapID); //[2]
324  m_trigData.push_back(generalID); //[3]
325 
326  m_trigData.push_back(barrelData); //[4]
327  m_trigData.push_back(endcapData); //[5]
328  m_trigData.push_back(generalData); //[6]
329 
330  return true;
331  }//one or more non-empty vectors
332  else
333  log_warning("processitem(): No Barrel, Endcap or General data found.");
334  }//ID-Data size match
335  else
336  log_error("processitem(): ID-Data size matching failed!");
337  }//header size
338  else
339  log_error("processitem(): incorrect headerID size!");
340  return false;
341  //----------------------------------------------------------<
342 }//END: processitem
343 
344 
345 //Processes L2 data item with storage in QTreeWidgetItem and returns processing success/failure
346 //_____________________________________________________________________________________________
348 {
349  //Process Handle item
350  bool status = processitem();
351 
352  if(status) {
353  //VARs
354  m_qtrigData = new QTreeWidgetItem(0);
355  QTreeWidgetItem* dataL2item;
356  int x_id=0, x_data=0, diff=0, avail=0;
357 
358  //DEFs
359  QString sep = " = ";
360 
361  if(int(m_trigData.size())>1 && int(m_trigData[0].size())!=0 && int(m_trigData.size())==(int(m_trigData[0].size())*2)+1) {
362 
363  diff=int(m_trigData[0].size());
364  for(int x=1; x<=int(m_trigData[0].size()); ++x) {
365  x_id=x;
366  x_data=x_id+diff;
367  if((x_data<int(m_trigData.size())) && (int(m_trigData[x_id].size())==int(m_trigData[x_data].size())) && (int(m_trigData[x_data].size())>0)) {
368  //New Item
369  dataL2item = new QTreeWidgetItem(m_qtrigData);
370 
371  //Set ID
372  dataL2item->setText(0, m_trigData[0][x-1]);
373 
374  //Load Data
375  QList<QTreeWidgetItem *> dataList;
376  for(int i=0; i<int(m_trigData[x_id].size()); ++i)
377  dataList.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(m_trigData[x_id][i]+sep+m_trigData[x_data][i])));
378  dataL2item->insertChildren(0, dataList);
379  //y loop
380  ++avail;
381  }//avail. range
382  }//x loop
383 
384  //Data available
385  if(avail>0) m_qtrigstatus=true;
386  else m_qtrigstatus=false;
387  }//vector check
388  else {
389  log_error("processQTrigItem(): L2 data not available!");
390  m_qtrigstatus=false;
391  }
392  }
393  else
394  m_qtrigstatus=false;
395 
396  return m_qtrigstatus;
397 }//END: processQTrigItem
398 
399 
400 //Processes L2 data item with storage in Vector and returns processing success/failure
401 //_____________________________________________________________________________________________
403 {
404  //Process Handle item
405  bool status = processitem();
406 
407  if(status)
408  m_vtrigstatus=true;
409  else
410  m_vtrigstatus=false;
411 
412  return m_vtrigstatus;
413 }//END: processVTrigItem
414 
415 /*
416 std::vector<QString>::iterator x_trigData;
417 std::vector<std::vector<QString> >::iterator y_trigData;
418 
419 for(y_trigData=m_trigData.begin(); y_trigData!=m_trigData.end(); ++y_trigData) {
420  for(x_trigData=y_trigData->begin(); x_trigData!=y_trigData->end(); ++x_trigData) {
421  std::cout << (*x_trigData).toStdString() << " ";
422  }
423  std::cout << std::endl;
424  }
425 */
beamspotman.r
def r
Definition: beamspotman.py:676
TileTrackMuFeatureContainer.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigMuonEFIsolationContainer.h
TrigMuonEFInfoContainer.h
TrigMuonEFCbTrack.h
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
TrigMuonEFTrack.h
VP1Trig::VP1TriggerHandleL2::processVTrigItem
bool processVTrigItem()
Definition: VP1TriggerHandleL2.cxx:402
MuonFeatureDetailsContainer.h
x
#define x
TrigMuonEFInfoTrack.h
MuonFeature.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
VP1TriggerHandleL2.h
CombinedMuonFeatureContainer.h
VP1Trig::VP1TriggerHandleL2::processQTrigItem
bool processQTrigItem()
Definition: VP1TriggerHandleL2.cxx:347
TrigMuonEFInfo.h
VP1Trig::Logger::log_warning
void log_warning(const QString &msg)
Definition: graphics/VP1/VP1Systems/VP1TriggerSystems/src/Logger.cxx:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
TileMuFeatureContainer.h
VP1Trig::Logger::log_error
void log_error(const QString &msg)
Definition: graphics/VP1/VP1Systems/VP1TriggerSystems/src/Logger.cxx:46
ZERO_LIMIT
const float ZERO_LIMIT
Definition: VP1TriggerHandleL2.cxx:37
grepfile.sep
sep
Definition: grepfile.py:38
python.selection.number
number
Definition: selection.py:20
VP1Trig::VP1TriggerHandleL2::processitem
bool processitem()
Definition: VP1TriggerHandleL2.cxx:42
TrigMuonEFInfoTrackContainer.h
VP1Trig::VP1TriggerHandleL2::m_containerL2
std::vector< const MuonFeatureDetails * > m_containerL2
Definition: VP1TriggerHandleL2.h:45
merge.status
status
Definition: merge.py:17
VP1Trig::VP1TriggerHandleL2::m_trigData
std::vector< std::vector< QString > > m_trigData
Definition: VP1TriggerHandleL2.h:60
TrigMuonEFContainer.h
calibdata.tube
tube
Definition: calibdata.py:31