Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:26

0001 //
0002 //
0003 
0004 #include "DataFormats/PatCandidates/interface/TriggerEvent.h"
0005 
0006 using namespace pat;
0007 
0008 // Constructors and Destructor
0009 
0010 // Default constructor
0011 TriggerEvent::TriggerEvent()
0012     : nameL1Menu_(),
0013       nameHltTable_(),
0014       run_(),
0015       accept_(),
0016       error_(),
0017       physDecl_(),
0018       lhcFill_(),
0019       beamMode_(),
0020       beamMomentum_(),
0021       intensityBeam1_(),
0022       intensityBeam2_(),
0023       bstMasterStatus_(),
0024       turnCount_(),
0025       bCurrentStart_(),
0026       bCurrentStop_(),
0027       bCurrentAvg_() {
0028   objectMatchResults_.clear();
0029 }
0030 
0031 // Constructor from values, HLT only
0032 TriggerEvent::TriggerEvent(const std::string& nameHltTable, bool run, bool accept, bool error, bool physDecl)
0033     : nameL1Menu_(),
0034       nameHltTable_(nameHltTable),
0035       run_(run),
0036       accept_(accept),
0037       error_(error),
0038       physDecl_(physDecl),
0039       lhcFill_(),
0040       beamMode_(),
0041       beamMomentum_(),
0042       intensityBeam1_(),
0043       intensityBeam2_(),
0044       bstMasterStatus_(),
0045       turnCount_(),
0046       bCurrentStart_(),
0047       bCurrentStop_(),
0048       bCurrentAvg_() {
0049   objectMatchResults_.clear();
0050 }
0051 
0052 // Constructor from values, HLT and L1/GT
0053 TriggerEvent::TriggerEvent(
0054     const std::string& nameL1Menu, const std::string& nameHltTable, bool run, bool accept, bool error, bool physDecl)
0055     : nameL1Menu_(nameL1Menu),
0056       nameHltTable_(nameHltTable),
0057       run_(run),
0058       accept_(accept),
0059       error_(error),
0060       physDecl_(physDecl),
0061       lhcFill_(),
0062       beamMode_(),
0063       beamMomentum_(),
0064       intensityBeam1_(),
0065       intensityBeam2_(),
0066       bstMasterStatus_(),
0067       turnCount_(),
0068       bCurrentStart_(),
0069       bCurrentStop_(),
0070       bCurrentAvg_() {
0071   objectMatchResults_.clear();
0072 }
0073 
0074 // Methods
0075 
0076 // Get a vector of references to all L1 algorithms
0077 const TriggerAlgorithmRefVector TriggerEvent::algorithmRefs() const {
0078   TriggerAlgorithmRefVector theAlgorithms;
0079   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0080        ++iAlgorithm) {
0081     const std::string nameAlgorithm(iAlgorithm->name());
0082     const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0083     theAlgorithms.push_back(algorithmRef);
0084   }
0085   return theAlgorithms;
0086 }
0087 
0088 // Get a pointer to a certain L1 algorithm by name
0089 const TriggerAlgorithm* TriggerEvent::algorithm(const std::string& nameAlgorithm) const {
0090   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0091        ++iAlgorithm) {
0092     if (nameAlgorithm == iAlgorithm->name())
0093       return &*iAlgorithm;
0094   }
0095   return nullptr;
0096 }
0097 
0098 // Get a reference to a certain L1 algorithm by name
0099 const TriggerAlgorithmRef TriggerEvent::algorithmRef(const std::string& nameAlgorithm) const {
0100   for (TriggerAlgorithmRefVector::const_iterator iAlgorithm = algorithmRefs().begin();
0101        iAlgorithm != algorithmRefs().end();
0102        ++iAlgorithm) {
0103     if (nameAlgorithm == (*iAlgorithm)->name())
0104       return *iAlgorithm;
0105   }
0106   return TriggerAlgorithmRef();
0107 }
0108 
0109 // Get the name of a certain L1 algorithm in the event collection by bit number physics or technical algorithms,
0110 std::string TriggerEvent::nameAlgorithm(const unsigned bitAlgorithm, const bool techAlgorithm) const {
0111   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0112        ++iAlgorithm) {
0113     if (bitAlgorithm == iAlgorithm->bit() && techAlgorithm == iAlgorithm->techTrigger())
0114       return iAlgorithm->name();
0115   }
0116   return std::string("");
0117 }
0118 
0119 // Get the index of a certain L1 algorithm in the event collection by name
0120 unsigned TriggerEvent::indexAlgorithm(const std::string& nameAlgorithm) const {
0121   unsigned iAlgorithm(0);
0122   while (iAlgorithm < algorithms()->size() && algorithms()->at(iAlgorithm).name() != nameAlgorithm)
0123     ++iAlgorithm;
0124   return iAlgorithm;
0125 }
0126 
0127 // Get a vector of references to all succeeding L1 algorithms
0128 TriggerAlgorithmRefVector TriggerEvent::acceptedAlgorithms() const {
0129   TriggerAlgorithmRefVector theAcceptedAlgorithms;
0130   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0131        ++iAlgorithm) {
0132     if (iAlgorithm->decision()) {
0133       const std::string nameAlgorithm(iAlgorithm->name());
0134       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0135       theAcceptedAlgorithms.push_back(algorithmRef);
0136     }
0137   }
0138   return theAcceptedAlgorithms;
0139 }
0140 
0141 // Get a vector of references to all L1 algorithms succeeding on the GTL board
0142 TriggerAlgorithmRefVector TriggerEvent::acceptedAlgorithmsGtl() const {
0143   TriggerAlgorithmRefVector theAcceptedAlgorithms;
0144   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0145        ++iAlgorithm) {
0146     if (iAlgorithm->gtlResult()) {
0147       const std::string nameAlgorithm(iAlgorithm->name());
0148       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0149       theAcceptedAlgorithms.push_back(algorithmRef);
0150     }
0151   }
0152   return theAcceptedAlgorithms;
0153 }
0154 
0155 // Get a vector of references to all technical L1 algorithms
0156 TriggerAlgorithmRefVector TriggerEvent::techAlgorithms() const {
0157   TriggerAlgorithmRefVector theTechAlgorithms;
0158   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0159        ++iAlgorithm) {
0160     if (iAlgorithm->techTrigger()) {
0161       const std::string nameAlgorithm(iAlgorithm->name());
0162       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0163       theTechAlgorithms.push_back(algorithmRef);
0164     }
0165   }
0166   return theTechAlgorithms;
0167 }
0168 
0169 // Get a vector of references to all succeeding technical L1 algorithms
0170 TriggerAlgorithmRefVector TriggerEvent::acceptedTechAlgorithms() const {
0171   TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
0172   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0173        ++iAlgorithm) {
0174     if (iAlgorithm->techTrigger() && iAlgorithm->decision()) {
0175       const std::string nameAlgorithm(iAlgorithm->name());
0176       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0177       theAcceptedTechAlgorithms.push_back(algorithmRef);
0178     }
0179   }
0180   return theAcceptedTechAlgorithms;
0181 }
0182 
0183 // Get a vector of references to all technical L1 algorithms succeeding on the GTL board
0184 TriggerAlgorithmRefVector TriggerEvent::acceptedTechAlgorithmsGtl() const {
0185   TriggerAlgorithmRefVector theAcceptedTechAlgorithms;
0186   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0187        ++iAlgorithm) {
0188     if (iAlgorithm->techTrigger() && iAlgorithm->gtlResult()) {
0189       const std::string nameAlgorithm(iAlgorithm->name());
0190       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0191       theAcceptedTechAlgorithms.push_back(algorithmRef);
0192     }
0193   }
0194   return theAcceptedTechAlgorithms;
0195 }
0196 
0197 // Get a vector of references to all physics L1 algorithms
0198 TriggerAlgorithmRefVector TriggerEvent::physAlgorithms() const {
0199   TriggerAlgorithmRefVector thePhysAlgorithms;
0200   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0201        ++iAlgorithm) {
0202     if (!iAlgorithm->techTrigger()) {
0203       const std::string nameAlgorithm(iAlgorithm->name());
0204       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0205       thePhysAlgorithms.push_back(algorithmRef);
0206     }
0207   }
0208   return thePhysAlgorithms;
0209 }
0210 
0211 // Get a vector of references to all succeeding physics L1 algorithms
0212 TriggerAlgorithmRefVector TriggerEvent::acceptedPhysAlgorithms() const {
0213   TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
0214   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0215        ++iAlgorithm) {
0216     if (!iAlgorithm->techTrigger() && iAlgorithm->decision()) {
0217       const std::string nameAlgorithm(iAlgorithm->name());
0218       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0219       theAcceptedPhysAlgorithms.push_back(algorithmRef);
0220     }
0221   }
0222   return theAcceptedPhysAlgorithms;
0223 }
0224 
0225 // Get a vector of references to all physics L1 algorithms succeeding on the GTL board
0226 TriggerAlgorithmRefVector TriggerEvent::acceptedPhysAlgorithmsGtl() const {
0227   TriggerAlgorithmRefVector theAcceptedPhysAlgorithms;
0228   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0229        ++iAlgorithm) {
0230     if (!iAlgorithm->techTrigger() && iAlgorithm->gtlResult()) {
0231       const std::string nameAlgorithm(iAlgorithm->name());
0232       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0233       theAcceptedPhysAlgorithms.push_back(algorithmRef);
0234     }
0235   }
0236   return theAcceptedPhysAlgorithms;
0237 }
0238 
0239 // Get a vector of references to all L1 conditions
0240 const TriggerConditionRefVector TriggerEvent::conditionRefs() const {
0241   TriggerConditionRefVector theConditions;
0242   for (TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end();
0243        ++iCondition) {
0244     const std::string nameCondition(iCondition->name());
0245     const TriggerConditionRef conditionRef(conditions_, indexCondition(nameCondition));
0246     theConditions.push_back(conditionRef);
0247   }
0248   return theConditions;
0249 }
0250 
0251 // Get a pointer to a certain L1 condition by name
0252 const TriggerCondition* TriggerEvent::condition(const std::string& nameCondition) const {
0253   for (TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end();
0254        ++iCondition) {
0255     if (nameCondition == iCondition->name())
0256       return &*iCondition;
0257   }
0258   return nullptr;
0259 }
0260 
0261 // Get a reference to a certain L1 condition by name
0262 const TriggerConditionRef TriggerEvent::conditionRef(const std::string& nameCondition) const {
0263   for (TriggerConditionRefVector::const_iterator iCondition = conditionRefs().begin();
0264        iCondition != conditionRefs().end();
0265        ++iCondition) {
0266     if (nameCondition == (*iCondition)->name())
0267       return *iCondition;
0268   }
0269   return TriggerConditionRef();
0270 }
0271 
0272 // Get the index of a certain L1 condition in the event collection by name
0273 unsigned TriggerEvent::indexCondition(const std::string& nameCondition) const {
0274   unsigned iCondition(0);
0275   while (iCondition < conditions()->size() && conditions()->at(iCondition).name() != nameCondition)
0276     ++iCondition;
0277   return iCondition;
0278 }
0279 
0280 // Get a vector of references to all succeeding L1 conditions
0281 TriggerConditionRefVector TriggerEvent::acceptedConditions() const {
0282   TriggerConditionRefVector theAcceptedConditions;
0283   for (TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end();
0284        ++iCondition) {
0285     if (iCondition->wasAccept()) {
0286       const std::string nameCondition(iCondition->name());
0287       const TriggerConditionRef conditionRef(conditions_, indexCondition(nameCondition));
0288       theAcceptedConditions.push_back(conditionRef);
0289     }
0290   }
0291   return theAcceptedConditions;
0292 }
0293 
0294 // Get a vector of references to all HLT paths
0295 const TriggerPathRefVector TriggerEvent::pathRefs() const {
0296   TriggerPathRefVector thePaths;
0297   for (TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath) {
0298     const std::string namePath(iPath->name());
0299     const TriggerPathRef pathRef(paths_, indexPath(namePath));
0300     thePaths.push_back(pathRef);
0301   }
0302   return thePaths;
0303 }
0304 
0305 // Get a pointer to a certain HLT path by name
0306 const TriggerPath* TriggerEvent::path(const std::string& namePath) const {
0307   for (TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath) {
0308     if (namePath == iPath->name())
0309       return &*iPath;
0310   }
0311   return nullptr;
0312 }
0313 
0314 // Get a reference to a certain HLT path by name
0315 const TriggerPathRef TriggerEvent::pathRef(const std::string& namePath) const {
0316   for (TriggerPathRefVector::const_iterator iPath = pathRefs().begin(); iPath != pathRefs().end(); ++iPath) {
0317     if (namePath == (*iPath)->name())
0318       return *iPath;
0319   }
0320   return TriggerPathRef();
0321 }
0322 
0323 // Get the index of a certain HLT path in the event collection by name
0324 unsigned TriggerEvent::indexPath(const std::string& namePath) const {
0325   unsigned iPath(0);
0326   while (iPath < paths()->size() && paths()->at(iPath).name() != namePath)
0327     ++iPath;
0328   return iPath;
0329 }
0330 
0331 // Get a vector of references to all succeeding HLT paths
0332 TriggerPathRefVector TriggerEvent::acceptedPaths() const {
0333   TriggerPathRefVector theAcceptedPaths;
0334   for (TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath) {
0335     if (iPath->wasAccept()) {
0336       const std::string namePath(iPath->name());
0337       const TriggerPathRef pathRef(paths_, indexPath(namePath));
0338       theAcceptedPaths.push_back(pathRef);
0339     }
0340   }
0341   return theAcceptedPaths;
0342 }
0343 
0344 // Get a vector of references to all HLT filters
0345 const TriggerFilterRefVector TriggerEvent::filterRefs() const {
0346   TriggerFilterRefVector theFilters;
0347   for (TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter) {
0348     const std::string labelFilter(iFilter->label());
0349     const TriggerFilterRef filterRef(filters_, indexFilter(labelFilter));
0350     theFilters.push_back(filterRef);
0351   }
0352   return theFilters;
0353 }
0354 
0355 // Get a pointer to a certain HLT filter by label
0356 const TriggerFilter* TriggerEvent::filter(const std::string& labelFilter) const {
0357   for (TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter) {
0358     if (labelFilter == iFilter->label())
0359       return &*iFilter;
0360   }
0361   return nullptr;
0362 }
0363 
0364 // Get a reference to a certain HLT filter by label
0365 const TriggerFilterRef TriggerEvent::filterRef(const std::string& labelFilter) const {
0366   for (TriggerFilterRefVector::const_iterator iFilter = filterRefs().begin(); iFilter != filterRefs().end();
0367        ++iFilter) {
0368     if (labelFilter == (*iFilter)->label())
0369       return *iFilter;
0370   }
0371   return TriggerFilterRef();
0372 }
0373 
0374 // Get the index of a certain HLT filter in the event collection by label
0375 unsigned TriggerEvent::indexFilter(const std::string& labelFilter) const {
0376   unsigned iFilter(0);
0377   while (iFilter < filters()->size() && filters()->at(iFilter).label() != labelFilter)
0378     ++iFilter;
0379   return iFilter;
0380 }
0381 
0382 // Get a vector of references to all succeeding HLT filters
0383 TriggerFilterRefVector TriggerEvent::acceptedFilters() const {
0384   TriggerFilterRefVector theAcceptedFilters;
0385   for (TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter) {
0386     if (iFilter->status() == 1) {
0387       const std::string labelFilter(iFilter->label());
0388       const TriggerFilterRef filterRef(filters_, indexFilter(labelFilter));
0389       theAcceptedFilters.push_back(filterRef);
0390     }
0391   }
0392   return theAcceptedFilters;
0393 }
0394 
0395 // Get a vector of references to all trigger objects
0396 const TriggerObjectRefVector TriggerEvent::objectRefs() const {
0397   TriggerObjectRefVector theObjects;
0398   for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0399     const TriggerObjectRef objectRef(objects_, iObject);
0400     theObjects.push_back(objectRef);
0401   }
0402   return theObjects;
0403 }
0404 
0405 // Get a vector of references to all trigger objects by trigger object type
0406 TriggerObjectRefVector TriggerEvent::objects(trigger::TriggerObjectType triggerObjectType) const {
0407   TriggerObjectRefVector theObjects;
0408   for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0409     if (objects()->at(iObject).hasTriggerObjectType(triggerObjectType)) {
0410       const TriggerObjectRef objectRef(objects_, iObject);
0411       theObjects.push_back(objectRef);
0412     }
0413   }
0414   return theObjects;
0415 }
0416 
0417 // Get a vector of references to all conditions assigned to a certain algorithm given by name
0418 TriggerConditionRefVector TriggerEvent::algorithmConditions(const std::string& nameAlgorithm) const {
0419   TriggerConditionRefVector theAlgorithmConditions;
0420   if (const TriggerAlgorithm* algorithmPtr = algorithm(nameAlgorithm)) {
0421     for (unsigned iC = 0; iC < algorithmPtr->conditionKeys().size(); ++iC) {
0422       const TriggerConditionRef conditionRef(conditions_, algorithmPtr->conditionKeys().at(iC));
0423       theAlgorithmConditions.push_back(conditionRef);
0424     }
0425   }
0426   return theAlgorithmConditions;
0427 }
0428 
0429 // Checks, if a condition is assigned to a certain algorithm given by name
0430 bool TriggerEvent::conditionInAlgorithm(const TriggerConditionRef& conditionRef,
0431                                         const std::string& nameAlgorithm) const {
0432   TriggerConditionRefVector theConditions = algorithmConditions(nameAlgorithm);
0433   for (TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end();
0434        ++iCondition) {
0435     if (conditionRef == *iCondition)
0436       return true;
0437   }
0438   return false;
0439 }
0440 
0441 // Get a vector of references to all algorithms, which have a certain condition assigned
0442 TriggerAlgorithmRefVector TriggerEvent::conditionAlgorithms(const TriggerConditionRef& conditionRef) const {
0443   TriggerAlgorithmRefVector theConditionAlgorithms;
0444   size_t cAlgorithms(0);
0445   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0446        ++iAlgorithm) {
0447     const std::string nameAlgorithm(iAlgorithm->name());
0448     if (conditionInAlgorithm(conditionRef, nameAlgorithm)) {
0449       const TriggerAlgorithmRef algorithmRef(algorithms_, cAlgorithms);
0450       theConditionAlgorithms.push_back(algorithmRef);
0451     }
0452     ++cAlgorithms;
0453   }
0454   return theConditionAlgorithms;
0455 }
0456 
0457 // Get a list of all trigger object collections used in a certain condition given by name
0458 std::vector<std::string> TriggerEvent::conditionCollections(const std::string& nameCondition) const {
0459   std::vector<std::string> theConditionCollections;
0460   if (const TriggerCondition* conditionPtr = condition(nameCondition)) {
0461     for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0462       if (conditionPtr->hasObjectKey(iObject)) {
0463         bool found(false);
0464         std::string objectCollection(objects()->at(iObject).collection());
0465         for (std::vector<std::string>::const_iterator iC = theConditionCollections.begin();
0466              iC != theConditionCollections.end();
0467              ++iC) {
0468           if (*iC == objectCollection) {
0469             found = true;
0470             break;
0471           }
0472         }
0473         if (!found) {
0474           theConditionCollections.push_back(objectCollection);
0475         }
0476       }
0477     }
0478   }
0479   return theConditionCollections;
0480 }
0481 
0482 // Get a vector of references to all objects, which were used in a certain condition given by name
0483 TriggerObjectRefVector TriggerEvent::conditionObjects(const std::string& nameCondition) const {
0484   TriggerObjectRefVector theConditionObjects;
0485   if (const TriggerCondition* conditionPtr = condition(nameCondition)) {
0486     for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0487       if (conditionPtr->hasObjectKey(iObject)) {
0488         const TriggerObjectRef objectRef(objects_, iObject);
0489         theConditionObjects.push_back(objectRef);
0490       }
0491     }
0492   }
0493   return theConditionObjects;
0494 }
0495 
0496 // Checks, if an object was used in a certain condition given by name
0497 bool TriggerEvent::objectInCondition(const TriggerObjectRef& objectRef, const std::string& nameCondition) const {
0498   if (const TriggerCondition* conditionPtr = condition(nameCondition))
0499     return conditionPtr->hasObjectKey(objectRef.key());
0500   return false;
0501 }
0502 
0503 // Get a vector of references to all conditions, which have a certain object assigned
0504 TriggerConditionRefVector TriggerEvent::objectConditions(const TriggerObjectRef& objectRef) const {
0505   TriggerConditionRefVector theObjectConditions;
0506   for (TriggerConditionCollection::const_iterator iCondition = conditions()->begin(); iCondition != conditions()->end();
0507        ++iCondition) {
0508     const std::string nameCondition(iCondition->name());
0509     if (objectInCondition(objectRef, nameCondition)) {
0510       const TriggerConditionRef conditionRef(conditions_, indexCondition(nameCondition));
0511       theObjectConditions.push_back(conditionRef);
0512     }
0513   }
0514   return theObjectConditions;
0515 }
0516 
0517 // Get a vector of references to all objects, which were used in a certain algorithm given by name
0518 TriggerObjectRefVector TriggerEvent::algorithmObjects(const std::string& nameAlgorithm) const {
0519   TriggerObjectRefVector theAlgorithmObjects;
0520   TriggerConditionRefVector theConditions = algorithmConditions(nameAlgorithm);
0521   for (TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end();
0522        ++iCondition) {
0523     const std::string nameCondition((*iCondition)->name());
0524     TriggerObjectRefVector theObjects = conditionObjects(nameCondition);
0525     for (TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject) {
0526       theAlgorithmObjects.push_back(*iObject);
0527     }
0528   }
0529   return theAlgorithmObjects;
0530 }
0531 
0532 // Checks, if an object was used in a certain algorithm given by name
0533 bool TriggerEvent::objectInAlgorithm(const TriggerObjectRef& objectRef, const std::string& nameAlgorithm) const {
0534   TriggerConditionRefVector theConditions = algorithmConditions(nameAlgorithm);
0535   for (TriggerConditionRefVectorIterator iCondition = theConditions.begin(); iCondition != theConditions.end();
0536        ++iCondition) {
0537     if (objectInCondition(objectRef, (*iCondition)->name()))
0538       return true;
0539   }
0540   return false;
0541 }
0542 
0543 // Get a vector of references to all algorithms, which have a certain object assigned
0544 TriggerAlgorithmRefVector TriggerEvent::objectAlgorithms(const TriggerObjectRef& objectRef) const {
0545   TriggerAlgorithmRefVector theObjectAlgorithms;
0546   for (TriggerAlgorithmCollection::const_iterator iAlgorithm = algorithms()->begin(); iAlgorithm != algorithms()->end();
0547        ++iAlgorithm) {
0548     const std::string nameAlgorithm(iAlgorithm->name());
0549     if (objectInAlgorithm(objectRef, nameAlgorithm)) {
0550       const TriggerAlgorithmRef algorithmRef(algorithms_, indexAlgorithm(nameAlgorithm));
0551       theObjectAlgorithms.push_back(algorithmRef);
0552     }
0553   }
0554   return theObjectAlgorithms;
0555 }
0556 
0557 // Get a vector of references to all modules assigned to a certain path given by name
0558 TriggerFilterRefVector TriggerEvent::pathModules(const std::string& namePath, bool all) const {
0559   TriggerFilterRefVector thePathFilters;
0560   if (const TriggerPath* pathPtr = path(namePath)) {
0561     if (!pathPtr->modules().empty()) {
0562       const unsigned onePastLastFilter = all ? pathPtr->modules().size() : pathPtr->lastActiveFilterSlot() + 1;
0563       for (unsigned iM = 0; iM < onePastLastFilter; ++iM) {
0564         const std::string labelFilter(pathPtr->modules().at(iM));
0565         const TriggerFilterRef filterRef(filters_, indexFilter(labelFilter));
0566         thePathFilters.push_back(filterRef);
0567       }
0568     }
0569   }
0570   return thePathFilters;
0571 }
0572 
0573 // Get a vector of references to all active HLT filters assigned to a certain path given by name
0574 TriggerFilterRefVector TriggerEvent::pathFilters(const std::string& namePath, bool firing) const {
0575   TriggerFilterRefVector thePathFilters;
0576   if (const TriggerPath* pathPtr = path(namePath)) {
0577     for (unsigned iF = 0; iF < pathPtr->filterIndices().size(); ++iF) {
0578       const TriggerFilterRef filterRef(filters_, pathPtr->filterIndices().at(iF));
0579       if ((!firing) || filterRef->isFiring())
0580         thePathFilters.push_back(filterRef);
0581     }
0582   }
0583   return thePathFilters;
0584 }
0585 
0586 // Checks, if a filter is assigned to and was run in a certain path given by name
0587 bool TriggerEvent::filterInPath(const TriggerFilterRef& filterRef, const std::string& namePath, bool firing) const {
0588   TriggerFilterRefVector theFilters = pathFilters(namePath, firing);
0589   for (TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter) {
0590     if (filterRef == *iFilter)
0591       return true;
0592   }
0593   return false;
0594 }
0595 
0596 // Get a vector of references to all paths, which have a certain filter assigned
0597 TriggerPathRefVector TriggerEvent::filterPaths(const TriggerFilterRef& filterRef, bool firing) const {
0598   TriggerPathRefVector theFilterPaths;
0599   size_t cPaths(0);
0600   for (TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath) {
0601     const std::string namePath(iPath->name());
0602     if (filterInPath(filterRef, namePath, firing)) {
0603       const TriggerPathRef pathRef(paths_, cPaths);
0604       theFilterPaths.push_back(pathRef);
0605     }
0606     ++cPaths;
0607   }
0608   return theFilterPaths;
0609 }
0610 
0611 // Get a list of all trigger object collections used in a certain filter given by name
0612 std::vector<std::string> TriggerEvent::filterCollections(const std::string& labelFilter) const {
0613   std::vector<std::string> theFilterCollections;
0614   if (const TriggerFilter* filterPtr = filter(labelFilter)) {
0615     for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0616       if (filterPtr->hasObjectKey(iObject)) {
0617         bool found(false);
0618         const std::string objectCollection(objects()->at(iObject).collection());
0619         for (std::vector<std::string>::const_iterator iC = theFilterCollections.begin();
0620              iC != theFilterCollections.end();
0621              ++iC) {
0622           if (*iC == objectCollection) {
0623             found = true;
0624             break;
0625           }
0626         }
0627         if (!found) {
0628           theFilterCollections.push_back(objectCollection);
0629         }
0630       }
0631     }
0632   }
0633   return theFilterCollections;
0634 }
0635 
0636 // Get a vector of references to all objects, which were used in a certain filter given by name
0637 TriggerObjectRefVector TriggerEvent::filterObjects(const std::string& labelFilter) const {
0638   TriggerObjectRefVector theFilterObjects;
0639   if (const TriggerFilter* filterPtr = filter(labelFilter)) {
0640     for (unsigned iObject = 0; iObject < objects()->size(); ++iObject) {
0641       if (filterPtr->hasObjectKey(iObject)) {
0642         const TriggerObjectRef objectRef(objects_, iObject);
0643         theFilterObjects.push_back(objectRef);
0644       }
0645     }
0646   }
0647   return theFilterObjects;
0648 }
0649 
0650 // Checks, if an object was used in a certain filter given by name
0651 bool TriggerEvent::objectInFilter(const TriggerObjectRef& objectRef, const std::string& labelFilter) const {
0652   if (const TriggerFilter* filterPtr = filter(labelFilter))
0653     return filterPtr->hasObjectKey(objectRef.key());
0654   return false;
0655 }
0656 
0657 // Get a vector of references to all filters, which have a certain object assigned
0658 TriggerFilterRefVector TriggerEvent::objectFilters(const TriggerObjectRef& objectRef, bool firing) const {
0659   TriggerFilterRefVector theObjectFilters;
0660   for (TriggerFilterCollection::const_iterator iFilter = filters()->begin(); iFilter != filters()->end(); ++iFilter) {
0661     const std::string labelFilter(iFilter->label());
0662     if (objectInFilter(objectRef, labelFilter)) {
0663       const TriggerFilterRef filterRef(filters_, indexFilter(labelFilter));
0664       if ((!firing) || iFilter->isFiring())
0665         theObjectFilters.push_back(filterRef);
0666     }
0667   }
0668   return theObjectFilters;
0669 }
0670 
0671 // Get a vector of references to all objects, which were used in a certain path given by name
0672 TriggerObjectRefVector TriggerEvent::pathObjects(const std::string& namePath, bool firing) const {
0673   TriggerObjectRefVector thePathObjects;
0674   TriggerFilterRefVector theFilters = pathFilters(namePath, firing);
0675   for (TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter) {
0676     const std::string labelFilter((*iFilter)->label());
0677     TriggerObjectRefVector theObjects = filterObjects(labelFilter);
0678     for (TriggerObjectRefVectorIterator iObject = theObjects.begin(); iObject != theObjects.end(); ++iObject) {
0679       thePathObjects.push_back(*iObject);
0680     }
0681   }
0682   return thePathObjects;
0683 }
0684 
0685 // Checks, if an object was used in a certain path given by name
0686 bool TriggerEvent::objectInPath(const TriggerObjectRef& objectRef, const std::string& namePath, bool firing) const {
0687   TriggerFilterRefVector theFilters = pathFilters(namePath, firing);
0688   for (TriggerFilterRefVectorIterator iFilter = theFilters.begin(); iFilter != theFilters.end(); ++iFilter) {
0689     if (objectInFilter(objectRef, (*iFilter)->label()))
0690       return true;
0691   }
0692   return false;
0693 }
0694 
0695 // Get a vector of references to all paths, which have a certain object assigned
0696 TriggerPathRefVector TriggerEvent::objectPaths(const TriggerObjectRef& objectRef, bool firing) const {
0697   TriggerPathRefVector theObjectPaths;
0698   for (TriggerPathCollection::const_iterator iPath = paths()->begin(); iPath != paths()->end(); ++iPath) {
0699     const std::string namePath(iPath->name());
0700     if (objectInPath(objectRef, namePath, firing)) {
0701       const TriggerPathRef pathRef(paths_, indexPath(namePath));
0702       theObjectPaths.push_back(pathRef);
0703     }
0704   }
0705   return theObjectPaths;
0706 }
0707 
0708 // Add a pat::TriggerObjectMatch association
0709 bool TriggerEvent::addObjectMatchResult(const TriggerObjectMatchRefProd& trigMatches, const std::string& labelMatcher) {
0710   if (triggerObjectMatchResults()->find(labelMatcher) == triggerObjectMatchResults()->end()) {
0711     objectMatchResults_[labelMatcher] = trigMatches;
0712     return true;
0713   }
0714   return false;
0715 }
0716 
0717 // Get a list of all linked trigger matches
0718 std::vector<std::string> TriggerEvent::triggerMatchers() const {
0719   std::vector<std::string> theMatchers;
0720   for (TriggerObjectMatchContainer::const_iterator iMatch = triggerObjectMatchResults()->begin();
0721        iMatch != triggerObjectMatchResults()->end();
0722        ++iMatch)
0723     theMatchers.push_back(iMatch->first);
0724   return theMatchers;
0725 }
0726 
0727 // Get a pointer to a certain trigger match given by label
0728 const TriggerObjectMatch* TriggerEvent::triggerObjectMatchResult(const std::string& labelMatcher) const {
0729   const TriggerObjectMatchContainer::const_iterator iMatch(triggerObjectMatchResults()->find(labelMatcher));
0730   if (iMatch != triggerObjectMatchResults()->end())
0731     return iMatch->second.get();
0732   return nullptr;
0733 }