00001
00017
00018 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00019
00020
00021 #include <iomanip>
00022
00023
00024 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
00026
00027 #include "FWCore/Framework/interface/ESHandle.h"
00028
00029 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00030 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00031
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033
00034
00035 bool l1AlgorithmResult(const edm::Event& iEvent,
00036 const edm::EventSetup& evSetup,
00037 const edm::InputTag& l1GtRecordInputTag,
00038 const std::string& l1AlgorithmName) {
00039
00040 edm::Handle<L1GlobalTriggerRecord> gtRecord;
00041 iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
00042
00043 if (!gtRecord.isValid()) {
00044
00045 edm::LogError("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
00046 << l1GtRecordInputTag << "\nnot found"
00047 "\n --> returning false by default!\n" << std::endl;
00048
00049 return false;
00050
00051 }
00052
00053 const DecisionWord gtDecisionWord = gtRecord->decisionWord();
00054
00055 edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
00056 evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu) ;
00057 const L1GtTriggerMenu* m_l1GtMenu = l1GtMenu.product();
00058
00059 const bool algResult = m_l1GtMenu->gtAlgorithmResult(l1AlgorithmName,
00060 gtDecisionWord);
00061
00062 edm::LogVerbatim("L1GtUtils") << "\nResult for algorithm "
00063 << l1AlgorithmName << ": " << algResult << "\n" << std::endl;
00064
00065 return algResult;
00066
00067 }
00068
00069
00070
00071 bool l1AlgorithmResult(const edm::Event& iEvent,
00072 const edm::EventSetup& evSetup, const std::string& l1AlgorithmName) {
00073
00074 typedef std::vector< edm::Provenance const*> Provenances;
00075 Provenances provenances;
00076 std::string friendlyName;
00077 std::string modLabel;
00078 std::string instanceName;
00079 std::string processName;
00080
00081 edm::InputTag l1GtRecordInputTag;
00082
00083 iEvent.getAllProvenance(provenances);
00084
00085
00086
00087
00088
00089
00090 for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
00091 provenances.end(); itProv != itProvEnd; ++itProv) {
00092
00093 friendlyName = (*itProv)->friendlyClassName();
00094 modLabel = (*itProv)->moduleLabel();
00095 instanceName = (*itProv)->productInstanceName();
00096 processName = (*itProv)->processName();
00097
00098
00099
00100
00101
00102 if (friendlyName == "L1GlobalTriggerRecord") {
00103 l1GtRecordInputTag = edm::InputTag(modLabel, instanceName,
00104 processName);
00105 }
00106 }
00107
00108 edm::LogVerbatim("L1GtUtils")
00109 << "\nL1GlobalTriggerRecord found in the event with \n "
00110 << l1GtRecordInputTag << std::endl;
00111
00112 return l1AlgorithmResult(iEvent, evSetup, l1GtRecordInputTag,
00113 l1AlgorithmName);
00114
00115 }
00116