CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerEvent.cc
Go to the documentation of this file.
1 //
2 // $Id: TriggerEvent.cc,v 1.20 2013/06/11 13:24:50 vadler Exp $
3 //
4 
5 
7 
8 
9 using namespace pat;
10 
11 
12 // Constructors and Destructor
13 
14 
15 // Default constructor
17  nameL1Menu_(),
18  nameHltTable_(),
19  run_(),
20  accept_(),
21  error_(),
22  physDecl_(),
23  lhcFill_(),
24  beamMode_(),
25  beamMomentum_(),
26  intensityBeam1_(),
27  intensityBeam2_(),
28  bstMasterStatus_(),
29  turnCount_(),
30  bCurrentStart_(),
31  bCurrentStop_(),
32  bCurrentAvg_()
33 {
34  objectMatchResults_.clear();
35 }
36 
37 
38 // Constructor from values, HLT only
39 TriggerEvent::TriggerEvent( const std::string & nameHltTable, bool run, bool accept, bool error, bool physDecl ) :
40  nameL1Menu_(),
41  nameHltTable_( nameHltTable ),
42  run_( run ),
43  accept_( accept ),
44  error_( error ),
45  physDecl_( physDecl ) ,
46  lhcFill_(),
47  beamMode_(),
48  beamMomentum_(),
49  intensityBeam1_(),
50  intensityBeam2_(),
51  bstMasterStatus_(),
52  turnCount_(),
53  bCurrentStart_(),
54  bCurrentStop_(),
55  bCurrentAvg_()
56 {
57  objectMatchResults_.clear();
58 }
59 
60 
61 // Constructor from values, HLT and L1/GT
62 TriggerEvent::TriggerEvent( const std::string & nameL1Menu, const std::string & nameHltTable, bool run, bool accept, bool error, bool physDecl ) :
63  nameL1Menu_( nameL1Menu ),
64  nameHltTable_( nameHltTable ),
65  run_( run ),
66  accept_( accept ),
67  error_( error ),
68  physDecl_( physDecl ) ,
69  lhcFill_(),
70  beamMode_(),
71  beamMomentum_(),
72  intensityBeam1_(),
73  intensityBeam2_(),
74  bstMasterStatus_(),
75  turnCount_(),
76  bCurrentStart_(),
77  bCurrentStop_(),
78  bCurrentAvg_()
79 {
80  objectMatchResults_.clear();
81 }
82 
83 
84 // Methods
85 
86 
87 // Get a vector of references to all L1 algorithms
89 {
90  TriggerAlgorithmRefVector theAlgorithms;
91  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
92  const std::string nameAlgorithm( iAlgorithm->name() );
94  theAlgorithms.push_back( algorithmRef );
95  }
96  return theAlgorithms;
97 }
98 
99 
100 // Get a pointer to a certain L1 algorithm by name
101 const TriggerAlgorithm * TriggerEvent::algorithm( const std::string & nameAlgorithm ) const
102 {
103  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
104  if ( nameAlgorithm == iAlgorithm->name() ) return &*iAlgorithm;
105  }
106  return 0;
107 }
108 
109 
110 // Get a reference to a certain L1 algorithm by name
111 const TriggerAlgorithmRef TriggerEvent::algorithmRef( const std::string & nameAlgorithm ) const
112 {
113  for ( TriggerAlgorithmRefVector::const_iterator iAlgorithm = algorithmRefs().begin(); iAlgorithm != algorithmRefs().end(); ++iAlgorithm ) {
114  if ( nameAlgorithm == ( *iAlgorithm )->name() ) return *iAlgorithm;
115  }
116  return TriggerAlgorithmRef();
117 }
118 
119 
120 // Get the name of a certain L1 algorithm in the event collection by bit number physics or technical algorithms,
121 std::string TriggerEvent::nameAlgorithm( const unsigned bitAlgorithm, const bool techAlgorithm ) const
122 {
123  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
124  if ( bitAlgorithm == iAlgorithm->bit() && techAlgorithm == iAlgorithm->techTrigger() ) return iAlgorithm->name();
125  }
126  return std::string( "" );
127 }
128 
129 
130 // Get the index of a certain L1 algorithm in the event collection by name
131 unsigned TriggerEvent::indexAlgorithm( const std::string & nameAlgorithm ) const
132 {
133  unsigned iAlgorithm( 0 );
134  while ( iAlgorithm < algorithms()->size() && algorithms()->at( iAlgorithm ).name() != nameAlgorithm ) ++iAlgorithm;
135  return iAlgorithm;
136 }
137 
138 
139 // Get a vector of references to all succeeding L1 algorithms
141 {
142  TriggerAlgorithmRefVector theAcceptedAlgorithms;
143  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
144  if ( iAlgorithm->decision() ) {
145  const std::string nameAlgorithm( iAlgorithm->name() );
147  theAcceptedAlgorithms.push_back( algorithmRef );
148  }
149  }
150  return theAcceptedAlgorithms;
151 }
152 
153 
154 // Get a vector of references to all L1 algorithms succeeding on the GTL board
156 {
157  TriggerAlgorithmRefVector theAcceptedAlgorithms;
158  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
159  if ( iAlgorithm->gtlResult() ) {
160  const std::string nameAlgorithm( iAlgorithm->name() );
162  theAcceptedAlgorithms.push_back( algorithmRef );
163  }
164  }
165  return theAcceptedAlgorithms;
166 }
167 
168 
169 // Get a vector of references to all technical L1 algorithms
171 {
172  TriggerAlgorithmRefVector theTechAlgorithms;
173  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
174  if ( iAlgorithm->techTrigger() ) {
175  const std::string nameAlgorithm( iAlgorithm->name() );
177  theTechAlgorithms.push_back( algorithmRef );
178  }
179  }
180  return theTechAlgorithms;
181 }
182 
183 
184 // Get a vector of references to all succeeding technical L1 algorithms
186 {
187  TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
188  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
189  if ( iAlgorithm->techTrigger() && iAlgorithm->decision() ) {
190  const std::string nameAlgorithm( iAlgorithm->name() );
192  theAcceptedTechAlgorithms.push_back( algorithmRef );
193  }
194  }
195  return theAcceptedTechAlgorithms;
196 }
197 
198 
199 // Get a vector of references to all technical L1 algorithms succeeding on the GTL board
201 {
202  TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
203  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
204  if ( iAlgorithm->techTrigger() && iAlgorithm->gtlResult() ) {
205  const std::string nameAlgorithm( iAlgorithm->name() );
207  theAcceptedTechAlgorithms.push_back( algorithmRef );
208  }
209  }
210  return theAcceptedTechAlgorithms;
211 }
212 
213 
214 // Get a vector of references to all physics L1 algorithms
216 {
217  TriggerAlgorithmRefVector thePhysAlgorithms;
218  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
219  if ( ! iAlgorithm->techTrigger() ) {
220  const std::string nameAlgorithm( iAlgorithm->name() );
222  thePhysAlgorithms.push_back( algorithmRef );
223  }
224  }
225  return thePhysAlgorithms;
226 }
227 
228 
229 // Get a vector of references to all succeeding physics L1 algorithms
231 {
232  TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
233  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
234  if ( ! iAlgorithm->techTrigger() && iAlgorithm->decision() ) {
235  const std::string nameAlgorithm( iAlgorithm->name() );
237  theAcceptedPhysAlgorithms.push_back( algorithmRef );
238  }
239  }
240  return theAcceptedPhysAlgorithms;
241 }
242 
243 
244 // Get a vector of references to all physics L1 algorithms succeeding on the GTL board
246 {
247  TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
248  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
249  if ( ! iAlgorithm->techTrigger() && iAlgorithm->gtlResult() ) {
250  const std::string nameAlgorithm( iAlgorithm->name() );
252  theAcceptedPhysAlgorithms.push_back( algorithmRef );
253  }
254  }
255  return theAcceptedPhysAlgorithms;
256 }
257 
258 
259 // Get a vector of references to all L1 conditions
261 {
262  TriggerConditionRefVector theConditions;
263  for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
264  const std::string nameCondition( iCondition->name() );
265  const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
266  theConditions.push_back( conditionRef );
267  }
268  return theConditions;
269 }
270 
271 
272 // Get a pointer to a certain L1 condition by name
273 const TriggerCondition * TriggerEvent::condition( const std::string & nameCondition ) const
274 {
275  for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
276  if ( nameCondition == iCondition->name() ) return &*iCondition;
277  }
278  return 0;
279 }
280 
281 
282 // Get a reference to a certain L1 condition by name
283 const TriggerConditionRef TriggerEvent::conditionRef( const std::string & nameCondition ) const
284 {
285  for ( TriggerConditionRefVector::const_iterator iCondition = conditionRefs().begin(); iCondition != conditionRefs().end(); ++iCondition ) {
286  if ( nameCondition == ( *iCondition )->name() ) return *iCondition;
287  }
288  return TriggerConditionRef();
289 }
290 
291 
292 // Get the index of a certain L1 condition in the event collection by name
293 unsigned TriggerEvent::indexCondition( const std::string & nameCondition ) const
294 {
295  unsigned iCondition( 0 );
296  while ( iCondition < conditions()->size() && conditions()->at( iCondition ).name() != nameCondition ) ++iCondition;
297  return iCondition;
298 }
299 
300 
301 // Get a vector of references to all succeeding L1 conditions
303 {
304  TriggerConditionRefVector theAcceptedConditions;
305  for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
306  if ( iCondition->wasAccept() ) {
307  const std::string nameCondition( iCondition->name() );
308  const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
309  theAcceptedConditions.push_back( conditionRef );
310  }
311  }
312  return theAcceptedConditions;
313 }
314 
315 
316 // Get a vector of references to all HLT paths
318 {
319  TriggerPathRefVector thePaths;
320  for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
321  const std::string namePath( iPath->name() );
322  const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
323  thePaths.push_back( pathRef );
324  }
325  return thePaths;
326 }
327 
328 
329 // Get a pointer to a certain HLT path by name
330 const TriggerPath * TriggerEvent::path( const std::string & namePath ) const
331 {
332  for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
333  if ( namePath == iPath->name() ) return &*iPath;
334  }
335  return 0;
336 }
337 
338 
339 // Get a reference to a certain HLT path by name
340 const TriggerPathRef TriggerEvent::pathRef( const std::string & namePath ) const
341 {
342  for ( TriggerPathRefVector::const_iterator iPath = pathRefs().begin(); iPath != pathRefs().end(); ++iPath ) {
343  if ( namePath == ( *iPath )->name() ) return *iPath;
344  }
345  return TriggerPathRef();
346 }
347 
348 
349 // Get the index of a certain HLT path in the event collection by name
350 unsigned TriggerEvent::indexPath( const std::string & namePath ) const
351 {
352  unsigned iPath( 0 );
353  while ( iPath < paths()->size() && paths()->at( iPath ).name() != namePath ) ++iPath;
354  return iPath;
355 }
356 
357 
358 // Get a vector of references to all succeeding HLT paths
360 {
361  TriggerPathRefVector theAcceptedPaths;
362  for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
363  if ( iPath->wasAccept() ) {
364  const std::string namePath( iPath->name() );
365  const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
366  theAcceptedPaths.push_back( pathRef );
367  }
368  }
369  return theAcceptedPaths;
370 }
371 
372 
373 // Get a vector of references to all HLT filters
375 {
376  TriggerFilterRefVector theFilters;
377  for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
378  const std::string labelFilter( iFilter->label() );
379  const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
380  theFilters.push_back( filterRef );
381  }
382  return theFilters;
383 }
384 
385 
386 // Get a pointer to a certain HLT filter by label
387 const TriggerFilter * TriggerEvent::filter( const std::string & labelFilter ) const
388 {
389  for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
390  if ( labelFilter == iFilter->label() ) return &*iFilter;
391  }
392  return 0;
393 }
394 
395 
396 // Get a reference to a certain HLT filter by label
397 const TriggerFilterRef TriggerEvent::filterRef( const std::string & labelFilter ) const
398 {
399  for ( TriggerFilterRefVector::const_iterator iFilter = filterRefs().begin(); iFilter != filterRefs().end(); ++iFilter ) {
400  if ( labelFilter == ( *iFilter )->label() ) return *iFilter;
401  }
402  return TriggerFilterRef();
403 }
404 
405 
406 // Get the index of a certain HLT filter in the event collection by label
407 unsigned TriggerEvent::indexFilter( const std::string & labelFilter ) const
408 {
409  unsigned iFilter( 0 );
410  while ( iFilter < filters()->size() && filters()->at( iFilter ).label() != labelFilter ) ++iFilter;
411  return iFilter;
412 }
413 
414 
415 // Get a vector of references to all succeeding HLT filters
417 {
418  TriggerFilterRefVector theAcceptedFilters;
419  for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
420  if ( iFilter->status() == 1 ) {
421  const std::string labelFilter( iFilter->label() );
422  const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
423  theAcceptedFilters.push_back( filterRef );
424  }
425  }
426  return theAcceptedFilters;
427 }
428 
429 
430 // Get a vector of references to all trigger objects
432 {
433  TriggerObjectRefVector theObjects;
434  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
435  const TriggerObjectRef objectRef( objects_, iObject );
436  theObjects.push_back( objectRef );
437  }
438  return theObjects;
439 }
440 
441 
442 // Get a vector of references to all trigger objects by trigger object type
444 {
445  TriggerObjectRefVector theObjects;
446  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
447  if ( objects()->at( iObject ).hasTriggerObjectType( triggerObjectType ) ) {
448  const TriggerObjectRef objectRef( objects_, iObject );
449  theObjects.push_back( objectRef );
450  }
451  }
452  return theObjects;
453 }
454 
455 
456 // Get a vector of references to all conditions assigned to a certain algorithm given by name
457 TriggerConditionRefVector TriggerEvent::algorithmConditions( const std::string & nameAlgorithm ) const
458 {
459  TriggerConditionRefVector theAlgorithmConditions;
460  if ( const TriggerAlgorithm * algorithmPtr = algorithm( nameAlgorithm ) ) {
461  for ( unsigned iC = 0; iC < algorithmPtr->conditionKeys().size(); ++iC ) {
462  const TriggerConditionRef conditionRef( conditions_, algorithmPtr->conditionKeys().at( iC ) );
463  theAlgorithmConditions.push_back( conditionRef );
464  }
465  }
466  return theAlgorithmConditions;
467 }
468 
469 
470 // Checks, if a condition is assigned to a certain algorithm given by name
471 bool TriggerEvent::conditionInAlgorithm( const TriggerConditionRef & conditionRef, const std::string & nameAlgorithm ) const
472 {
473  TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
474  for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
475  if ( conditionRef == *iCondition ) return true;
476  }
477  return false;
478 }
479 
480 
481 // Get a vector of references to all algorithms, which have a certain condition assigned
483 {
484  TriggerAlgorithmRefVector theConditionAlgorithms;
485  size_t cAlgorithms( 0 );
486  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
487  const std::string nameAlgorithm( iAlgorithm->name() );
488  if ( conditionInAlgorithm( conditionRef, nameAlgorithm ) ) {
489  const TriggerAlgorithmRef algorithmRef( algorithms_, cAlgorithms );
490  theConditionAlgorithms.push_back( algorithmRef );
491  }
492  ++cAlgorithms;
493  }
494  return theConditionAlgorithms;
495 }
496 
497 
498 // Get a list of all trigger object collections used in a certain condition given by name
499 std::vector< std::string > TriggerEvent::conditionCollections( const std::string & nameCondition ) const
500 {
501  std::vector< std::string > theConditionCollections;
502  if ( const TriggerCondition * conditionPtr = condition( nameCondition ) ) {
503  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
504  if ( conditionPtr->hasObjectKey( iObject ) ) {
505  bool found( false );
506  std::string objectCollection( objects()->at( iObject ).collection() );
507  for ( std::vector< std::string >::const_iterator iC = theConditionCollections.begin(); iC != theConditionCollections.end(); ++iC ) {
508  if ( *iC == objectCollection ) {
509  found = true;
510  break;
511  }
512  }
513  if ( ! found ) {
514  theConditionCollections.push_back( objectCollection );
515  }
516  }
517  }
518  }
519  return theConditionCollections;
520 }
521 
522 
523 // Get a vector of references to all objects, which were used in a certain condition given by name
524 TriggerObjectRefVector TriggerEvent::conditionObjects( const std::string & nameCondition ) const
525 {
526  TriggerObjectRefVector theConditionObjects;
527  if ( const TriggerCondition * conditionPtr = condition( nameCondition ) ) {
528  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
529  if ( conditionPtr->hasObjectKey( iObject ) ) {
530  const TriggerObjectRef objectRef( objects_, iObject );
531  theConditionObjects.push_back( objectRef );
532  }
533  }
534  }
535  return theConditionObjects;
536 }
537 
538 
539 // Checks, if an object was used in a certain condition given by name
540 bool TriggerEvent::objectInCondition( const TriggerObjectRef & objectRef, const std::string & nameCondition ) const {
541  if ( const TriggerCondition * conditionPtr = condition( nameCondition ) ) return conditionPtr->hasObjectKey( objectRef.key() );
542  return false;
543 }
544 
545 
546 // Get a vector of references to all conditions, which have a certain object assigned
548 {
549  TriggerConditionRefVector theObjectConditions;
550  for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
551  const std::string nameCondition( iCondition->name() );
552  if ( objectInCondition( objectRef, nameCondition ) ) {
553  const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
554  theObjectConditions.push_back( conditionRef );
555  }
556  }
557  return theObjectConditions;
558 }
559 
560 
561 // Get a vector of references to all objects, which were used in a certain algorithm given by name
562 TriggerObjectRefVector TriggerEvent::algorithmObjects( const std::string & nameAlgorithm ) const
563 {
564  TriggerObjectRefVector theAlgorithmObjects;
565  TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
566  for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
567  const std::string nameCondition( ( *iCondition )->name() );
568  TriggerObjectRefVector theObjects = conditionObjects( nameCondition );
569  for ( TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject ) {
570  theAlgorithmObjects.push_back( *iObject );
571  }
572  }
573  return theAlgorithmObjects;
574 }
575 
576 
577 // Checks, if an object was used in a certain algorithm given by name
578 bool TriggerEvent::objectInAlgorithm( const TriggerObjectRef & objectRef, const std::string & nameAlgorithm ) const
579 {
580  TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
581  for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
582  if ( objectInCondition( objectRef, ( *iCondition )->name() ) ) return true;
583  }
584  return false;
585 }
586 
587 
588 // Get a vector of references to all algorithms, which have a certain object assigned
590 {
591  TriggerAlgorithmRefVector theObjectAlgorithms;
592  for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
593  const std::string nameAlgorithm( iAlgorithm->name() );
594  if ( objectInAlgorithm( objectRef, nameAlgorithm ) ) {
596  theObjectAlgorithms.push_back( algorithmRef );
597  }
598  }
599  return theObjectAlgorithms;
600 }
601 
602 
603 // Get a vector of references to all modules assigned to a certain path given by name
604 TriggerFilterRefVector TriggerEvent::pathModules( const std::string & namePath, bool all ) const
605 {
606  TriggerFilterRefVector thePathFilters;
607  if ( const TriggerPath * pathPtr = path( namePath ) ) {
608  if ( pathPtr->modules().size() > 0 ) {
609  const unsigned onePastLastFilter = all ? pathPtr->modules().size() : pathPtr->lastActiveFilterSlot() + 1;
610  for ( unsigned iM = 0; iM < onePastLastFilter; ++iM ) {
611  const std::string labelFilter( pathPtr->modules().at( iM ) );
612  const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
613  thePathFilters.push_back( filterRef );
614  }
615  }
616  }
617  return thePathFilters;
618 }
619 
620 
621 // Get a vector of references to all active HLT filters assigned to a certain path given by name
622 TriggerFilterRefVector TriggerEvent::pathFilters( const std::string & namePath, bool firing ) const
623 {
624  TriggerFilterRefVector thePathFilters;
625  if ( const TriggerPath * pathPtr = path( namePath ) ) {
626  for ( unsigned iF = 0; iF < pathPtr->filterIndices().size(); ++iF ) {
627  const TriggerFilterRef filterRef( filters_, pathPtr->filterIndices().at( iF ) );
628  if ( ( ! firing ) || filterRef->isFiring() ) thePathFilters.push_back( filterRef );
629  }
630  }
631  return thePathFilters;
632 }
633 
634 
635 // Checks, if a filter is assigned to and was run in a certain path given by name
636 bool TriggerEvent::filterInPath( const TriggerFilterRef & filterRef, const std::string & namePath, bool firing ) const
637 {
638  TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
639  for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
640  if ( filterRef == *iFilter ) return true;
641  }
642  return false;
643 }
644 
645 
646 // Get a vector of references to all paths, which have a certain filter assigned
647 TriggerPathRefVector TriggerEvent::filterPaths( const TriggerFilterRef & filterRef, bool firing ) const
648 {
649  TriggerPathRefVector theFilterPaths;
650  size_t cPaths( 0 );
651  for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
652  const std::string namePath( iPath->name() );
653  if ( filterInPath( filterRef, namePath, firing ) ) {
654  const TriggerPathRef pathRef( paths_, cPaths );
655  theFilterPaths.push_back( pathRef );
656  }
657  ++cPaths;
658  }
659  return theFilterPaths;
660 }
661 
662 
663 // Get a list of all trigger object collections used in a certain filter given by name
664 std::vector< std::string > TriggerEvent::filterCollections( const std::string & labelFilter ) const
665 {
666  std::vector< std::string > theFilterCollections;
667  if ( const TriggerFilter * filterPtr = filter( labelFilter ) ) {
668  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
669  if ( filterPtr->hasObjectKey( iObject ) ) {
670  bool found( false );
671  const std::string objectCollection( objects()->at( iObject ).collection() );
672  for ( std::vector< std::string >::const_iterator iC = theFilterCollections.begin(); iC != theFilterCollections.end(); ++iC ) {
673  if ( *iC == objectCollection ) {
674  found = true;
675  break;
676  }
677  }
678  if ( ! found ) {
679  theFilterCollections.push_back( objectCollection );
680  }
681  }
682  }
683  }
684  return theFilterCollections;
685 }
686 
687 
688 // Get a vector of references to all objects, which were used in a certain filter given by name
689 TriggerObjectRefVector TriggerEvent::filterObjects( const std::string & labelFilter ) const
690 {
691  TriggerObjectRefVector theFilterObjects;
692  if ( const TriggerFilter * filterPtr = filter( labelFilter ) ) {
693  for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
694  if ( filterPtr->hasObjectKey( iObject ) ) {
695  const TriggerObjectRef objectRef( objects_, iObject );
696  theFilterObjects.push_back( objectRef );
697  }
698  }
699  }
700  return theFilterObjects;
701 }
702 
703 
704 // Checks, if an object was used in a certain filter given by name
705 bool TriggerEvent::objectInFilter( const TriggerObjectRef & objectRef, const std::string & labelFilter ) const {
706  if ( const TriggerFilter * filterPtr = filter( labelFilter ) ) return filterPtr->hasObjectKey( objectRef.key() );
707  return false;
708 }
709 
710 
711 // Get a vector of references to all filters, which have a certain object assigned
713 {
714  TriggerFilterRefVector theObjectFilters;
715  for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
716  const std::string labelFilter( iFilter->label() );
717  if ( objectInFilter( objectRef, labelFilter ) ) {
718  const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
719  if ( ( ! firing ) || iFilter->isFiring() ) theObjectFilters.push_back( filterRef );
720  }
721  }
722  return theObjectFilters;
723 }
724 
725 
726 // Get a vector of references to all objects, which were used in a certain path given by name
727 TriggerObjectRefVector TriggerEvent::pathObjects( const std::string & namePath, bool firing ) const
728 {
729  TriggerObjectRefVector thePathObjects;
730  TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
731  for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
732  const std::string labelFilter( ( *iFilter )->label() );
733  TriggerObjectRefVector theObjects = filterObjects( labelFilter );
734  for ( TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject ) {
735  thePathObjects.push_back( *iObject );
736  }
737  }
738  return thePathObjects;
739 }
740 
741 
742 // Checks, if an object was used in a certain path given by name
743 bool TriggerEvent::objectInPath( const TriggerObjectRef & objectRef, const std::string & namePath, bool firing ) const
744 {
745  TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
746  for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
747  if ( objectInFilter( objectRef, ( *iFilter )->label() ) ) return true;
748  }
749  return false;
750 }
751 
752 
753 // Get a vector of references to all paths, which have a certain object assigned
754 TriggerPathRefVector TriggerEvent::objectPaths( const TriggerObjectRef & objectRef, bool firing ) const
755 {
756  TriggerPathRefVector theObjectPaths;
757  for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
758  const std::string namePath( iPath->name() );
759  if ( objectInPath( objectRef, namePath, firing ) ) {
760  const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
761  theObjectPaths.push_back( pathRef );
762  }
763  }
764  return theObjectPaths;
765 }
766 
767 
768 // Add a pat::TriggerObjectMatch association
769 bool TriggerEvent::addObjectMatchResult( const TriggerObjectMatchRefProd & trigMatches, const std::string & labelMatcher )
770 {
771  if ( triggerObjectMatchResults()->find( labelMatcher ) == triggerObjectMatchResults()->end() ) {
772  objectMatchResults_[ labelMatcher ] = trigMatches;
773  return true;
774  }
775  return false;
776 }
777 
778 
779 // Get a list of all linked trigger matches
780 std::vector< std::string > TriggerEvent::triggerMatchers() const
781 {
782  std::vector< std::string > theMatchers;
783  for ( TriggerObjectMatchContainer::const_iterator iMatch = triggerObjectMatchResults()->begin(); iMatch != triggerObjectMatchResults()->end(); ++iMatch ) theMatchers.push_back( iMatch->first );
784  return theMatchers;
785 }
786 
787 
788 // Get a pointer to a certain trigger match given by label
789 const TriggerObjectMatch * TriggerEvent::triggerObjectMatchResult( const std::string & labelMatcher ) const
790 {
791  const TriggerObjectMatchContainer::const_iterator iMatch( triggerObjectMatchResults()->find( labelMatcher ) );
792  if ( iMatch != triggerObjectMatchResults()->end() ) return iMatch->second.get();
793  return 0;
794 }
const TriggerObjectMatchContainer * triggerObjectMatchResults() const
Get all trigger matches.
Definition: TriggerEvent.h:348
TriggerConditionRefVector algorithmConditions(const std::string &nameAlgorithm) const
Analysis-level L1 trigger algorithm class.
TriggerAlgorithmRefVector physAlgorithms() const
Get a vector of references to all physics L1 algorithms.
TriggerAlgorithmRefVector acceptedAlgorithmsGtl() const
Get a vector of references to all L1 algorithms succeeding on the GTL board.
TriggerConditionRefVector objectConditions(const TriggerObjectRef &objectRef) const
Get a vector of references to all conditions, which have a certain object assigned.
TriggerConditionRefProd conditions_
Reference to pat::TriggerConditionCollection in event.
Definition: TriggerEvent.h:87
const TriggerObjectRefVector objectRefs() const
std::vector< std::string > triggerMatchers() const
Get a list of all linked trigger matches.
bool objectInPath(const TriggerObjectRef &objectRef, const std::string &namePath, bool firing=true) const
Checks, if an object was used in a certain path given by name.
const TriggerPathRef pathRef(const std::string &namePath) const
const TriggerCondition * condition(const std::string &nameCondition) const
const TriggerConditionCollection * conditions() const
Definition: TriggerEvent.h:222
TriggerFilterRefVector acceptedFilters() const
Get a vector of references to all succeeding HLT filters.
const TriggerFilterRefVector filterRefs() const
TriggerAlgorithmRefVector acceptedTechAlgorithms() const
Get a vector of references to all succeeding technical L1 algorithms.
TriggerFilterRefVector pathFilters(const std::string &namePath, bool firing=true) const
Get a vector of references to all active HLT filters assigned to a certain path given by name...
TriggerEvent()
Constructors and Desctructor.
Definition: TriggerEvent.cc:16
TriggerPathRefProd paths_
Reference to pat::TriggerPathCollection in event.
Definition: TriggerEvent.h:89
TriggerAlgorithmRefVector objectAlgorithms(const TriggerObjectRef &objectRef) const
Get a vector of references to all algorithms, which have a certain object assigned.
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
const TriggerPathCollection * paths() const
Definition: TriggerEvent.h:243
unsigned indexFilter(const std::string &labelFilter) const
edm::Ref< TriggerPathCollection > TriggerPathRef
Persistent reference to an item in a TriggerPathCollection.
Definition: TriggerPath.h:157
TriggerFilterRefVector pathModules(const std::string &namePath, bool all=true) const
bool objectInAlgorithm(const TriggerObjectRef &objectRef, const std::string &nameAlgorithm) const
Checks, if an object was used in a certain algorithm given by name.
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
TriggerConditionRefVector acceptedConditions() const
Get a vector of references to all succeeding L1 condition.
TriggerAlgorithmRefProd algorithms_
Definition: TriggerEvent.h:85
edm::Ref< TriggerConditionCollection > TriggerConditionRef
Persistent reference to an item in a TriggerConditionCollection.
TriggerObjectRefVector filterObjects(const std::string &labelFilter) const
Get a vector of references to all objects, which were used in a certain filter given by name...
const TriggerObjectCollection * objects() const
Definition: TriggerEvent.h:285
unsigned indexAlgorithm(const std::string &nameAlgorithm) const
Analysis-level HLTrigger filter class.
Definition: TriggerFilter.h:37
bool filterInPath(const TriggerFilterRef &filterRef, const std::string &namePath, bool firing=true) const
Checks, if a filter is assigned to and was run in a certain path given by name.
edm::Ref< TriggerFilterCollection > TriggerFilterRef
Persistent reference to an item in a TriggerFilterCollection.
unsigned indexCondition(const std::string &nameCondition) const
Analysis-level L1 trigger condition class.
Analysis-level HLTrigger path class.
Definition: TriggerPath.h:41
bool addObjectMatchResult(const TriggerObjectMatchRefProd &trigMatches, const std::string &labelMatcher)
TriggerObjectRefVector pathObjects(const std::string &namePath, bool firing=true) const
Get a vector of references to all objects, which were used in a certain path given by name...
const TriggerPath * path(const std::string &namePath) const
const TriggerFilterRef filterRef(const std::string &labelFilter) const
TriggerAlgorithmRefVector techAlgorithms() const
Get a vector of references to all technical L1 algorithms.
bool objectInCondition(const TriggerObjectRef &objectRef, const std::string &nameCondition) const
Checks, if an object was used in a certain condition given by name.
TriggerAlgorithmRefVector acceptedPhysAlgorithms() const
Get a vector of references to all succeeding physics L1 algorithms.
const TriggerAlgorithmCollection * algorithms() const
Definition: TriggerEvent.h:184
#define end
Definition: vmac.h:38
TriggerAlgorithmRefVector acceptedAlgorithms() const
Get a vector of references to all succeeding L1 algorithms.
const TriggerObjectMatch * triggerObjectMatchResult(const std::string &labelMatcher) const
TriggerFilterRefVector objectFilters(const TriggerObjectRef &objectRef, bool firing=true) const
Get a vector of references to all filters, which have a certain object assigned.
std::vector< std::string > conditionCollections(const std::string &nameAlgorithm) const
Get a list of all trigger object collections used in a certain condition given by name...
TriggerAlgorithmRefVector conditionAlgorithms(const TriggerConditionRef &conditionRef) const
Get a vector of references to all algorithms, which have a certain condition assigned.
edm::Ref< TriggerAlgorithmCollection > TriggerAlgorithmRef
Persistent reference to an item in a TriggerAlgorithmCollection.
TriggerFilterRefProd filters_
Reference to pat::TriggerAlgorithmCollection in event.
Definition: TriggerEvent.h:91
std::string nameAlgorithm(const unsigned bitAlgorithm, const bool techAlgorithm=true) const
const TriggerAlgorithmRef algorithmRef(const std::string &nameAlgorithm) const
TriggerPathRefVector objectPaths(const TriggerObjectRef &objectRef, bool firing=true) const
Get a vector of references to all paths, which have a certain object assigned.
std::vector< std::string > filterCollections(const std::string &labelFilter) const
Get a list of all trigger object collections used in a certain filter given by name.
const TriggerFilterCollection * filters() const
Definition: TriggerEvent.h:264
bool objectInFilter(const TriggerObjectRef &objectRef, const std::string &labelFilter) const
Checks, if an object was used in a certain filter given by name.
const TriggerAlgorithmRefVector algorithmRefs() const
Definition: TriggerEvent.cc:88
TriggerObjectRefVector conditionObjects(const std::string &nameCondition) const
Get a vector of references to all objects, which were used in a certain condition given by name...
key_type key() const
Accessor for product key.
Definition: Ref.h:266
TriggerObjectRefVector algorithmObjects(const std::string &nameAlgorithm) const
Get a vector of references to all objects, which were used in a certain algorithm given by name...
TriggerAlgorithmRefVector acceptedPhysAlgorithmsGtl() const
Get a vector of references to all physics L1 algorithms succeeding on the GTL board.
TriggerAlgorithmRefVector acceptedTechAlgorithmsGtl() const
Get a vector of references to all technical L1 algorithms succeeding on the GTL board.
#define begin
Definition: vmac.h:31
const TriggerConditionRefVector conditionRefs() const
const TriggerAlgorithm * algorithm(const std::string &nameAlgorithm) const
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
TriggerPathRefVector filterPaths(const TriggerFilterRef &filterRef, bool firing=true) const
Get a vector of references to all paths, which have a certain filter assigned.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
TriggerObjectRefProd objects_
Reference to pat::TriggerObjectCollection in event.
Definition: TriggerEvent.h:93
const TriggerFilter * filter(const std::string &labelFilter) const
bool conditionInAlgorithm(const TriggerConditionRef &conditionRef, const std::string &nameAlgorithm) const
Checks, if a condition is assigned to a certain algorithm given by name.
TriggerObjectMatchContainer objectMatchResults_
Table of references to pat::TriggerObjectMatch associations in event.
Definition: TriggerEvent.h:95
const TriggerConditionRef conditionRef(const std::string &nameCondition) const
tuple size
Write out results.
TriggerPathRefVector acceptedPaths() const
Get a vector of references to all succeeding HLT paths.
unsigned indexPath(const std::string &namePath) const
const TriggerPathRefVector pathRefs() const
list at
Definition: asciidump.py:428