CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DataFormats/PatCandidates/src/TriggerEvent.cc

Go to the documentation of this file.
00001 //
00002 // $Id: TriggerEvent.cc,v 1.18 2011/05/24 15:56:25 vadler Exp $
00003 //
00004 
00005 
00006 #include "DataFormats/PatCandidates/interface/TriggerEvent.h"
00007 
00008 
00009 using namespace pat;
00010 
00011 
00012 // Constructors and Destructor
00013 
00014 
00015 // Constructor from values, HLT only
00016 TriggerEvent::TriggerEvent( const std::string & nameHltTable, bool run, bool accept, bool error, bool physDecl ) :
00017   nameHltTable_( nameHltTable ),
00018   run_( run ),
00019   accept_( accept ),
00020   error_( error ),
00021   physDecl_( physDecl )
00022 {
00023   objectMatchResults_.clear();
00024 }
00025 
00026 
00027 // Constructor from values, HLT and L1/GT
00028 TriggerEvent::TriggerEvent( const std::string & nameL1Menu, const std::string & nameHltTable, bool run, bool accept, bool error, bool physDecl ) :
00029   nameL1Menu_( nameL1Menu ),
00030   nameHltTable_( nameHltTable ),
00031   run_( run ),
00032   accept_( accept ),
00033   error_( error ),
00034   physDecl_( physDecl )
00035 {
00036   objectMatchResults_.clear();
00037 }
00038 
00039 
00040 // Methods
00041 
00042 
00043 // Get a vector of references to all L1 algorithms
00044 const TriggerAlgorithmRefVector TriggerEvent::algorithmRefs() const
00045 {
00046   TriggerAlgorithmRefVector theAlgorithms;
00047   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00048     const std::string nameAlgorithm( iAlgorithm->name() );
00049     const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00050     theAlgorithms.push_back( algorithmRef );
00051   }
00052   return theAlgorithms;
00053 }
00054 
00055 
00056 // Get a pointer to a certain L1 algorithm by name
00057 const TriggerAlgorithm * TriggerEvent::algorithm( const std::string & nameAlgorithm ) const
00058 {
00059   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00060     if ( nameAlgorithm == iAlgorithm->name() ) return &*iAlgorithm;
00061   }
00062   return 0;
00063 }
00064 
00065 
00066 // Get a reference to a certain L1 algorithm by name
00067 const TriggerAlgorithmRef TriggerEvent::algorithmRef( const std::string & nameAlgorithm ) const
00068 {
00069   for ( TriggerAlgorithmRefVector::const_iterator iAlgorithm = algorithmRefs().begin(); iAlgorithm != algorithmRefs().end(); ++iAlgorithm ) {
00070     if ( nameAlgorithm == ( *iAlgorithm )->name() ) return *iAlgorithm;
00071   }
00072   return TriggerAlgorithmRef();
00073 }
00074 
00075 
00076 // Get the name of a certain L1 algorithm in the event collection by bit number physics or technical algorithms,
00077 std::string TriggerEvent::nameAlgorithm( const unsigned bitAlgorithm, const bool techAlgorithm ) const
00078 {
00079   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00080     if ( bitAlgorithm == iAlgorithm->bit() && techAlgorithm == iAlgorithm->techTrigger() ) return iAlgorithm->name();
00081   }
00082   return std::string( "" );
00083 }
00084 
00085 
00086 // Get the index of a certain L1 algorithm in the event collection by name
00087 unsigned TriggerEvent::indexAlgorithm( const std::string & nameAlgorithm ) const
00088 {
00089   unsigned iAlgorithm( 0 );
00090   while ( iAlgorithm < algorithms()->size() && algorithms()->at( iAlgorithm ).name() != nameAlgorithm ) ++iAlgorithm;
00091   return iAlgorithm;
00092 }
00093 
00094 
00095 // Get a vector of references to all succeeding L1 algorithms
00096 TriggerAlgorithmRefVector TriggerEvent::acceptedAlgorithms() const
00097 {
00098   TriggerAlgorithmRefVector theAcceptedAlgorithms;
00099   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00100     if ( iAlgorithm->decision() ) {
00101       const std::string nameAlgorithm( iAlgorithm->name() );
00102       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00103       theAcceptedAlgorithms.push_back( algorithmRef );
00104     }
00105   }
00106   return theAcceptedAlgorithms;
00107 }
00108 
00109 
00110 // Get a vector of references to all L1 algorithms succeeding on the GTL board
00111 TriggerAlgorithmRefVector TriggerEvent::acceptedAlgorithmsGtl() const
00112 {
00113   TriggerAlgorithmRefVector theAcceptedAlgorithms;
00114   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00115     if ( iAlgorithm->gtlResult() ) {
00116       const std::string nameAlgorithm( iAlgorithm->name() );
00117       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00118       theAcceptedAlgorithms.push_back( algorithmRef );
00119     }
00120   }
00121   return theAcceptedAlgorithms;
00122 }
00123 
00124 
00125 // Get a vector of references to all technical L1 algorithms
00126 TriggerAlgorithmRefVector TriggerEvent::techAlgorithms() const
00127 {
00128   TriggerAlgorithmRefVector theTechAlgorithms;
00129   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00130     if ( iAlgorithm->techTrigger() ) {
00131       const std::string nameAlgorithm( iAlgorithm->name() );
00132       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00133       theTechAlgorithms.push_back( algorithmRef );
00134     }
00135   }
00136   return theTechAlgorithms;
00137 }
00138 
00139 
00140 // Get a vector of references to all succeeding technical L1 algorithms
00141 TriggerAlgorithmRefVector TriggerEvent::acceptedTechAlgorithms() const
00142 {
00143   TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
00144   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00145     if ( iAlgorithm->techTrigger() && iAlgorithm->decision() ) {
00146       const std::string nameAlgorithm( iAlgorithm->name() );
00147       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00148       theAcceptedTechAlgorithms.push_back( algorithmRef );
00149     }
00150   }
00151   return theAcceptedTechAlgorithms;
00152 }
00153 
00154 
00155 // Get a vector of references to all technical L1 algorithms succeeding on the GTL board
00156 TriggerAlgorithmRefVector TriggerEvent::acceptedTechAlgorithmsGtl() const
00157 {
00158   TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
00159   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00160     if ( iAlgorithm->techTrigger() && iAlgorithm->gtlResult() ) {
00161       const std::string nameAlgorithm( iAlgorithm->name() );
00162       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00163       theAcceptedTechAlgorithms.push_back( algorithmRef );
00164     }
00165   }
00166   return theAcceptedTechAlgorithms;
00167 }
00168 
00169 
00170 // Get a vector of references to all physics L1 algorithms
00171 TriggerAlgorithmRefVector TriggerEvent::physAlgorithms() const
00172 {
00173   TriggerAlgorithmRefVector thePhysAlgorithms;
00174   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00175     if ( ! iAlgorithm->techTrigger() ) {
00176       const std::string nameAlgorithm( iAlgorithm->name() );
00177       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00178       thePhysAlgorithms.push_back( algorithmRef );
00179     }
00180   }
00181   return thePhysAlgorithms;
00182 }
00183 
00184 
00185 // Get a vector of references to all succeeding physics L1 algorithms
00186 TriggerAlgorithmRefVector TriggerEvent::acceptedPhysAlgorithms() const
00187 {
00188   TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
00189   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00190     if ( ! iAlgorithm->techTrigger() && iAlgorithm->decision() ) {
00191       const std::string nameAlgorithm( iAlgorithm->name() );
00192       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00193       theAcceptedPhysAlgorithms.push_back( algorithmRef );
00194     }
00195   }
00196   return theAcceptedPhysAlgorithms;
00197 }
00198 
00199 
00200 // Get a vector of references to all physics L1 algorithms succeeding on the GTL board
00201 TriggerAlgorithmRefVector TriggerEvent::acceptedPhysAlgorithmsGtl() const
00202 {
00203   TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
00204   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00205     if ( ! iAlgorithm->techTrigger() && iAlgorithm->gtlResult() ) {
00206       const std::string nameAlgorithm( iAlgorithm->name() );
00207       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00208       theAcceptedPhysAlgorithms.push_back( algorithmRef );
00209     }
00210   }
00211   return theAcceptedPhysAlgorithms;
00212 }
00213 
00214 
00215 // Get a vector of references to all L1 conditions
00216 const TriggerConditionRefVector TriggerEvent::conditionRefs() const
00217 {
00218   TriggerConditionRefVector theConditions;
00219   for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
00220     const std::string nameCondition( iCondition->name() );
00221     const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
00222     theConditions.push_back( conditionRef );
00223   }
00224   return theConditions;
00225 }
00226 
00227 
00228 // Get a pointer to a certain L1 condition by name
00229 const TriggerCondition * TriggerEvent::condition( const std::string & nameCondition ) const
00230 {
00231   for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
00232     if ( nameCondition == iCondition->name() ) return &*iCondition;
00233   }
00234   return 0;
00235 }
00236 
00237 
00238 // Get a reference to a certain L1 condition by name
00239 const TriggerConditionRef TriggerEvent::conditionRef( const std::string & nameCondition ) const
00240 {
00241   for ( TriggerConditionRefVector::const_iterator iCondition = conditionRefs().begin(); iCondition != conditionRefs().end(); ++iCondition ) {
00242     if ( nameCondition == ( *iCondition )->name() ) return *iCondition;
00243   }
00244   return TriggerConditionRef();
00245 }
00246 
00247 
00248 // Get the index of a certain L1 condition in the event collection by name
00249 unsigned TriggerEvent::indexCondition( const std::string & nameCondition ) const
00250 {
00251   unsigned iCondition( 0 );
00252   while ( iCondition < conditions()->size() && conditions()->at( iCondition ).name() != nameCondition ) ++iCondition;
00253   return iCondition;
00254 }
00255 
00256 
00257 // Get a vector of references to all succeeding L1 conditions
00258 TriggerConditionRefVector TriggerEvent::acceptedConditions() const
00259 {
00260   TriggerConditionRefVector theAcceptedConditions;
00261   for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
00262     if ( iCondition->wasAccept() ) {
00263       const std::string nameCondition( iCondition->name() );
00264       const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
00265       theAcceptedConditions.push_back( conditionRef );
00266     }
00267   }
00268   return theAcceptedConditions;
00269 }
00270 
00271 
00272 // Get a vector of references to all HLT paths
00273 const TriggerPathRefVector TriggerEvent::pathRefs() const
00274 {
00275   TriggerPathRefVector thePaths;
00276   for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
00277     const std::string namePath( iPath->name() );
00278     const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
00279     thePaths.push_back( pathRef );
00280   }
00281   return thePaths;
00282 }
00283 
00284 
00285 // Get a pointer to a certain HLT path by name
00286 const TriggerPath * TriggerEvent::path( const std::string & namePath ) const
00287 {
00288   for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
00289     if ( namePath == iPath->name() ) return &*iPath;
00290   }
00291   return 0;
00292 }
00293 
00294 
00295 // Get a reference to a certain HLT path by name
00296 const TriggerPathRef TriggerEvent::pathRef( const std::string & namePath ) const
00297 {
00298   for ( TriggerPathRefVector::const_iterator iPath = pathRefs().begin(); iPath != pathRefs().end(); ++iPath ) {
00299     if ( namePath == ( *iPath )->name() ) return *iPath;
00300   }
00301   return TriggerPathRef();
00302 }
00303 
00304 
00305 // Get the index of a certain HLT path in the event collection by name
00306 unsigned TriggerEvent::indexPath( const std::string & namePath ) const
00307 {
00308   unsigned iPath( 0 );
00309   while ( iPath < paths()->size() && paths()->at( iPath ).name() != namePath ) ++iPath;
00310   return iPath;
00311 }
00312 
00313 
00314 // Get a vector of references to all succeeding HLT paths
00315 TriggerPathRefVector TriggerEvent::acceptedPaths() const
00316 {
00317   TriggerPathRefVector theAcceptedPaths;
00318   for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
00319     if ( iPath->wasAccept() ) {
00320       const std::string namePath( iPath->name() );
00321       const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
00322       theAcceptedPaths.push_back( pathRef );
00323     }
00324   }
00325   return theAcceptedPaths;
00326 }
00327 
00328 
00329 // Get a vector of references to all HLT filters
00330 const TriggerFilterRefVector TriggerEvent::filterRefs() const
00331 {
00332   TriggerFilterRefVector theFilters;
00333   for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
00334     const std::string labelFilter( iFilter->label() );
00335     const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
00336     theFilters.push_back( filterRef );
00337   }
00338   return theFilters;
00339 }
00340 
00341 
00342 // Get a pointer to a certain HLT filter by label
00343 const TriggerFilter * TriggerEvent::filter( const std::string & labelFilter ) const
00344 {
00345   for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
00346     if ( labelFilter == iFilter->label() ) return &*iFilter;
00347   }
00348   return 0;
00349 }
00350 
00351 
00352 // Get a reference to a certain HLT filter by label
00353 const TriggerFilterRef TriggerEvent::filterRef( const std::string & labelFilter ) const
00354 {
00355   for ( TriggerFilterRefVector::const_iterator iFilter = filterRefs().begin(); iFilter != filterRefs().end(); ++iFilter ) {
00356     if ( labelFilter == ( *iFilter )->label() ) return *iFilter;
00357   }
00358   return TriggerFilterRef();
00359 }
00360 
00361 
00362 // Get the index of a certain HLT filter in the event collection by label
00363 unsigned TriggerEvent::indexFilter( const std::string & labelFilter ) const
00364 {
00365   unsigned iFilter( 0 );
00366   while ( iFilter < filters()->size() && filters()->at( iFilter ).label() != labelFilter ) ++iFilter;
00367   return iFilter;
00368 }
00369 
00370 
00371 // Get a vector of references to all succeeding HLT filters
00372 TriggerFilterRefVector TriggerEvent::acceptedFilters() const
00373 {
00374   TriggerFilterRefVector theAcceptedFilters;
00375   for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
00376     if ( iFilter->status() == 1 ) {
00377       const std::string labelFilter( iFilter->label() );
00378       const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
00379       theAcceptedFilters.push_back( filterRef );
00380     }
00381   }
00382   return theAcceptedFilters;
00383 }
00384 
00385 
00386 // Get a vector of references to all trigger objects
00387 const TriggerObjectRefVector TriggerEvent::objectRefs() const
00388 {
00389   TriggerObjectRefVector theObjects;
00390   for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00391     const TriggerObjectRef objectRef( objects_, iObject );
00392     theObjects.push_back( objectRef );
00393   }
00394   return theObjects;
00395 }
00396 
00397 
00398 // Get a vector of references to all trigger objects by trigger object type
00399 TriggerObjectRefVector TriggerEvent::objects( trigger::TriggerObjectType triggerObjectType ) const
00400 {
00401   TriggerObjectRefVector theObjects;
00402   for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00403     if ( objects()->at( iObject ).hasTriggerObjectType( triggerObjectType ) ) {
00404       const TriggerObjectRef objectRef( objects_, iObject );
00405       theObjects.push_back( objectRef );
00406     }
00407   }
00408   return theObjects;
00409 }
00410 
00411 
00412 // Get a vector of references to all conditions assigned to a certain algorithm given by name
00413 TriggerConditionRefVector TriggerEvent::algorithmConditions( const std::string & nameAlgorithm ) const
00414 {
00415   TriggerConditionRefVector theAlgorithmConditions;
00416   if ( algorithm( nameAlgorithm ) ) {
00417     for ( unsigned iC = 0; iC < algorithm( nameAlgorithm )->conditionKeys().size(); ++iC ) {
00418       const TriggerConditionRef conditionRef( conditions_, algorithm( nameAlgorithm )->conditionKeys().at( iC ) );
00419       theAlgorithmConditions.push_back( conditionRef );
00420     }
00421   }
00422   return theAlgorithmConditions;
00423 }
00424 
00425 
00426 // Checks, if a condition is assigned to a certain algorithm given by name
00427 bool TriggerEvent::conditionInAlgorithm( const TriggerConditionRef & conditionRef, const std::string & nameAlgorithm ) const
00428 {
00429   TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
00430   for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
00431     if ( conditionRef == *iCondition ) return true;
00432   }
00433   return false;
00434 }
00435 
00436 
00437 // Get a vector of references to all algorithms, which have a certain condition assigned
00438 TriggerAlgorithmRefVector TriggerEvent::conditionAlgorithms( const TriggerConditionRef & conditionRef ) const
00439 {
00440   TriggerAlgorithmRefVector theConditionAlgorithms;
00441   size_t cAlgorithms( 0 );
00442   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00443     const std::string nameAlgorithm( iAlgorithm->name() );
00444     if ( conditionInAlgorithm( conditionRef, nameAlgorithm ) ) {
00445       const TriggerAlgorithmRef algorithmRef( algorithms_, cAlgorithms );
00446       theConditionAlgorithms.push_back( algorithmRef );
00447     }
00448     ++cAlgorithms;
00449   }
00450   return theConditionAlgorithms;
00451 }
00452 
00453 
00454 // Get a list of all trigger object collections used in a certain condition given by name
00455 std::vector< std::string > TriggerEvent::conditionCollections( const std::string & nameCondition ) const
00456 {
00457   std::vector< std::string > theConditionCollections;
00458   if ( condition( nameCondition ) ) {
00459     for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00460       if ( condition( nameCondition )->hasObjectKey( iObject ) ) {
00461         bool found( false );
00462         std::string objectCollection( objects()->at( iObject ).collection() );
00463         for ( std::vector< std::string >::const_iterator iC = theConditionCollections.begin(); iC != theConditionCollections.end(); ++iC ) {
00464           if ( *iC == objectCollection ) {
00465             found = true;
00466             break;
00467           }
00468         }
00469         if ( ! found ) {
00470           theConditionCollections.push_back( objectCollection );
00471         }
00472       }
00473     }
00474   }
00475   return theConditionCollections;
00476 }
00477 
00478 
00479 // Get a vector of references to all objects, which were used in a certain condition given by name
00480 TriggerObjectRefVector TriggerEvent::conditionObjects( const std::string & nameCondition ) const
00481 {
00482   TriggerObjectRefVector theConditionObjects;
00483   if ( condition( nameCondition ) ) {
00484     for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00485       if ( condition( nameCondition )->hasObjectKey( iObject ) ) {
00486         const TriggerObjectRef objectRef( objects_, iObject );
00487         theConditionObjects.push_back( objectRef );
00488       }
00489     }
00490   }
00491   return theConditionObjects;
00492 }
00493 
00494 
00495 // Checks, if an object was used in a certain condition given by name
00496 bool TriggerEvent::objectInCondition( const TriggerObjectRef & objectRef, const std::string & nameCondition ) const {
00497   if ( condition( nameCondition ) ) return condition( nameCondition )->hasObjectKey( objectRef.key() );
00498   return false;
00499 }
00500 
00501 
00502 // Get a vector of references to all conditions, which have a certain object assigned
00503 TriggerConditionRefVector TriggerEvent::objectConditions( const TriggerObjectRef & objectRef ) const
00504 {
00505   TriggerConditionRefVector theObjectConditions;
00506   for ( TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end(); ++iCondition ) {
00507     const std::string nameCondition( iCondition->name() );
00508     if ( objectInCondition( objectRef, nameCondition ) ) {
00509       const TriggerConditionRef conditionRef( conditions_, indexCondition( nameCondition ) );
00510       theObjectConditions.push_back( conditionRef );
00511     }
00512   }
00513   return theObjectConditions;
00514 }
00515 
00516 
00517 // Get a vector of references to all objects, which were used in a certain algorithm given by name
00518 TriggerObjectRefVector TriggerEvent::algorithmObjects( const std::string & nameAlgorithm ) const
00519 {
00520   TriggerObjectRefVector    theAlgorithmObjects;
00521   TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
00522   for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
00523     const std::string nameCondition( ( *iCondition )->name() );
00524     TriggerObjectRefVector theObjects = conditionObjects( nameCondition );
00525     for ( TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject ) {
00526       theAlgorithmObjects.push_back( *iObject );
00527     }
00528   }
00529   return theAlgorithmObjects;
00530 }
00531 
00532 
00533 // Checks, if an object was used in a certain algorithm given by name
00534 bool TriggerEvent::objectInAlgorithm( const TriggerObjectRef & objectRef, const std::string & nameAlgorithm ) const
00535 {
00536   TriggerConditionRefVector theConditions = algorithmConditions( nameAlgorithm );
00537   for ( TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end(); ++iCondition ) {
00538     if ( objectInCondition( objectRef, ( *iCondition )->name() ) ) return true;
00539   }
00540   return false;
00541 }
00542 
00543 
00544 // Get a vector of references to all algorithms, which have a certain object assigned
00545 TriggerAlgorithmRefVector TriggerEvent::objectAlgorithms( const TriggerObjectRef & objectRef ) const
00546 {
00547   TriggerAlgorithmRefVector theObjectAlgorithms;
00548   for ( TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end(); ++iAlgorithm ) {
00549     const std::string nameAlgorithm( iAlgorithm->name() );
00550     if ( objectInAlgorithm( objectRef, nameAlgorithm ) ) {
00551       const TriggerAlgorithmRef algorithmRef( algorithms_, indexAlgorithm( nameAlgorithm ) );
00552       theObjectAlgorithms.push_back( algorithmRef );
00553     }
00554   }
00555   return theObjectAlgorithms;
00556 }
00557 
00558 
00559 // Get a vector of references to all modules assigned to a certain path given by name
00560 TriggerFilterRefVector TriggerEvent::pathModules( const std::string & namePath, bool all ) const
00561 {
00562   TriggerFilterRefVector thePathFilters;
00563   if ( path( namePath ) && path( namePath )->modules().size() > 0 ) {
00564     const unsigned onePastLastFilter = all ? path( namePath )->modules().size() : path( namePath )->lastActiveFilterSlot() + 1;
00565     for ( unsigned iM = 0; iM < onePastLastFilter; ++iM ) {
00566       const std::string labelFilter( path( namePath )->modules().at( iM ) );
00567       const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
00568       thePathFilters.push_back( filterRef );
00569     }
00570   }
00571   return thePathFilters;
00572 }
00573 
00574 
00575 // Get a vector of references to all active HLT filters assigned to a certain path given by name
00576 TriggerFilterRefVector TriggerEvent::pathFilters( const std::string & namePath, bool firing ) const
00577 {
00578   TriggerFilterRefVector thePathFilters;
00579   if ( path( namePath ) ) {
00580     for ( unsigned iF = 0; iF < path( namePath )->filterIndices().size(); ++iF ) {
00581       const TriggerFilterRef filterRef( filters_, path( namePath )->filterIndices().at( iF ) );
00582       if ( ( ! firing ) || filterRef->isFiring() ) thePathFilters.push_back( filterRef );
00583     }
00584   }
00585   return thePathFilters;
00586 }
00587 
00588 
00589 // Checks, if a filter is assigned to and was run in a certain path given by name
00590 bool TriggerEvent::filterInPath( const TriggerFilterRef & filterRef, const std::string & namePath, bool firing ) const
00591 {
00592   TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
00593   for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
00594     if ( filterRef == *iFilter ) return true;
00595   }
00596   return false;
00597 }
00598 
00599 
00600 // Get a vector of references to all paths, which have a certain filter assigned
00601 TriggerPathRefVector TriggerEvent::filterPaths( const TriggerFilterRef & filterRef, bool firing ) const
00602 {
00603   TriggerPathRefVector theFilterPaths;
00604   size_t cPaths( 0 );
00605   for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
00606     const std::string namePath( iPath->name() );
00607     if ( filterInPath( filterRef, namePath, firing ) ) {
00608       const TriggerPathRef pathRef( paths_, cPaths );
00609       theFilterPaths.push_back( pathRef );
00610     }
00611     ++cPaths;
00612   }
00613   return theFilterPaths;
00614 }
00615 
00616 
00617 // Get a list of all trigger object collections used in a certain filter given by name
00618 std::vector< std::string > TriggerEvent::filterCollections( const std::string & labelFilter ) const
00619 {
00620   std::vector< std::string > theFilterCollections;
00621   if ( filter( labelFilter ) ) {
00622     for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00623       if ( filter( labelFilter )->hasObjectKey( iObject ) ) {
00624         bool found( false );
00625         std::string objectCollection( objects()->at( iObject ).collection() );
00626         for ( std::vector< std::string >::const_iterator iC = theFilterCollections.begin(); iC != theFilterCollections.end(); ++iC ) {
00627           if ( *iC == objectCollection ) {
00628             found = true;
00629             break;
00630           }
00631         }
00632         if ( ! found ) {
00633           theFilterCollections.push_back( objectCollection );
00634         }
00635       }
00636     }
00637   }
00638   return theFilterCollections;
00639 }
00640 
00641 
00642 // Get a vector of references to all objects, which were used in a certain filter given by name
00643 TriggerObjectRefVector TriggerEvent::filterObjects( const std::string & labelFilter ) const
00644 {
00645   TriggerObjectRefVector theFilterObjects;
00646   if ( filter( labelFilter ) ) {
00647     for ( unsigned iObject = 0; iObject < objects()->size(); ++iObject ) {
00648       if ( filter( labelFilter )->hasObjectKey( iObject ) ) {
00649         const TriggerObjectRef objectRef( objects_, iObject );
00650         theFilterObjects.push_back( objectRef );
00651       }
00652     }
00653   }
00654   return theFilterObjects;
00655 }
00656 
00657 
00658 // Checks, if an object was used in a certain filter given by name
00659 bool TriggerEvent::objectInFilter( const TriggerObjectRef & objectRef, const std::string & labelFilter ) const {
00660   if ( filter( labelFilter ) ) return filter( labelFilter )->hasObjectKey( objectRef.key() );
00661   return false;
00662 }
00663 
00664 
00665 // Get a vector of references to all filters, which have a certain object assigned
00666 TriggerFilterRefVector TriggerEvent::objectFilters( const TriggerObjectRef & objectRef, bool firing ) const
00667 {
00668   TriggerFilterRefVector theObjectFilters;
00669   for ( TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter ) {
00670     const std::string labelFilter( iFilter->label() );
00671     if ( objectInFilter( objectRef, labelFilter ) ) {
00672       const TriggerFilterRef filterRef( filters_, indexFilter( labelFilter ) );
00673       if ( ( ! firing ) || iFilter->isFiring() ) theObjectFilters.push_back( filterRef );
00674     }
00675   }
00676   return theObjectFilters;
00677 }
00678 
00679 
00680 // Get a vector of references to all objects, which were used in a certain path given by name
00681 TriggerObjectRefVector TriggerEvent::pathObjects( const std::string & namePath, bool firing ) const
00682 {
00683   TriggerObjectRefVector thePathObjects;
00684   TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
00685   for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
00686     const std::string labelFilter( ( *iFilter )->label() );
00687     TriggerObjectRefVector theObjects = filterObjects( labelFilter );
00688     for ( TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject ) {
00689       thePathObjects.push_back( *iObject );
00690     }
00691   }
00692   return thePathObjects;
00693 }
00694 
00695 
00696 // Checks, if an object was used in a certain path given by name
00697 bool TriggerEvent::objectInPath( const TriggerObjectRef & objectRef, const std::string & namePath, bool firing ) const
00698 {
00699   TriggerFilterRefVector theFilters = pathFilters( namePath, firing );
00700   for ( TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter ) {
00701     if ( objectInFilter( objectRef, ( *iFilter )->label() ) ) return true;
00702   }
00703   return false;
00704 }
00705 
00706 
00707 // Get a vector of references to all paths, which have a certain object assigned
00708 TriggerPathRefVector TriggerEvent::objectPaths( const TriggerObjectRef & objectRef, bool firing ) const
00709 {
00710   TriggerPathRefVector theObjectPaths;
00711   for ( TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath ) {
00712     const std::string namePath( iPath->name() );
00713     if ( objectInPath( objectRef, namePath, firing ) ) {
00714       const TriggerPathRef pathRef( paths_, indexPath( namePath ) );
00715       theObjectPaths.push_back( pathRef );
00716     }
00717   }
00718   return theObjectPaths;
00719 }
00720 
00721 
00722 // Add a pat::TriggerObjectMatch association
00723 bool TriggerEvent::addObjectMatchResult( const TriggerObjectMatchRefProd & trigMatches, const std::string & labelMatcher )
00724 {
00725   if ( triggerObjectMatchResults()->find( labelMatcher ) == triggerObjectMatchResults()->end() ) {
00726     objectMatchResults_[ labelMatcher ] = trigMatches;
00727     return true;
00728   }
00729   return false;
00730 }
00731 
00732 
00733 // Get a list of all linked trigger matches
00734 std::vector< std::string > TriggerEvent::triggerMatchers() const
00735 {
00736   std::vector< std::string > theMatchers;
00737   for ( TriggerObjectMatchContainer::const_iterator iMatch = triggerObjectMatchResults()->begin(); iMatch != triggerObjectMatchResults()->end(); ++iMatch ) theMatchers.push_back( iMatch->first );
00738   return theMatchers;
00739 }
00740 
00741 
00742 // Get a pointer to a certain trigger match given by label
00743 const TriggerObjectMatch * TriggerEvent::triggerObjectMatchResult( const std::string & labelMatcher ) const
00744 {
00745   const TriggerObjectMatchContainer::const_iterator iMatch( triggerObjectMatchResults()->find( labelMatcher ) );
00746   if ( iMatch != triggerObjectMatchResults()->end() ) return iMatch->second.get();
00747   return 0;
00748 }