00001
00002
00003
00004
00005 #include <boost/foreach.hpp>
00006
00007 #include "HLTrigger/HLTanalyzers/interface/HLTBitAnalyzer.h"
00008 #include "HLTMessages.h"
00009
00010 typedef std::pair<const char *, const edm::InputTag *> MissingCollectionInfo;
00011
00012 template <class T>
00013 static inline
00014 bool getCollection(const edm::Event & event, std::vector<MissingCollectionInfo> & missing, edm::Handle<T> & handle, const edm::InputTag & name, const char * description)
00015 {
00016 event.getByLabel(name, handle);
00017 bool valid = handle.isValid();
00018 if (not valid) {
00019 missing.push_back( std::make_pair(description, & name) );
00020 handle.clear();
00021 }
00022 return valid;
00023 }
00024
00025
00026 HLTBitAnalyzer::HLTBitAnalyzer(edm::ParameterSet const& conf) {
00027
00028
00029
00030
00031 std::cout << " Beginning HLTBitAnalyzer Analysis " << std::endl;
00032
00033 l1extramu_ = conf.getParameter<std::string> ("l1extramu");
00034 m_l1extramu = edm::InputTag(l1extramu_, "");
00035
00036
00037 l1extramc_ = conf.getParameter<std::string> ("l1extramc");
00038 m_l1extraemi = edm::InputTag(l1extramc_, "Isolated");
00039 m_l1extraemn = edm::InputTag(l1extramc_, "NonIsolated");
00040 m_l1extrajetc = edm::InputTag(l1extramc_, "Central");
00041 m_l1extrajetf = edm::InputTag(l1extramc_, "Forward");
00042 m_l1extrataujet = edm::InputTag(l1extramc_, "Tau");
00043 m_l1extramet = edm::InputTag(l1extramc_, "MET");
00044 m_l1extramht = edm::InputTag(l1extramc_, "MHT");
00045
00046 hltresults_ = conf.getParameter<edm::InputTag> ("hltresults");
00047 gtReadoutRecord_ = conf.getParameter<edm::InputTag> ("l1GtReadoutRecord");
00048 gtObjectMap_ = conf.getParameter<edm::InputTag> ("l1GtObjectMapRecord");
00049
00050 gctBitCounts_ = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFBitCounts").label(), "" );
00051 gctRingSums_ = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFRingSums").label(), "" );
00052
00053 m_file = 0;
00054 errCnt = 0;
00055
00056
00057 edm::ParameterSet runParameters = conf.getParameter<edm::ParameterSet>("RunParameters");
00058 _HistName = runParameters.getUntrackedParameter<std::string>("HistogramFile", "test.root");
00059
00060
00061 m_file = new TFile(_HistName.c_str(), "RECREATE");
00062 if (m_file)
00063 m_file->cd();
00064
00065
00066 HltTree = new TTree("HltTree", "");
00067
00068
00069 hlt_analysis_.setup(conf, HltTree);
00070 evt_header_.setup(HltTree);
00071 }
00072
00073
00074 void HLTBitAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
00075
00076 edm::Handle<edm::TriggerResults> hltresults;
00077 edm::Handle<l1extra::L1EmParticleCollection> l1extemi, l1extemn;
00078 edm::Handle<l1extra::L1MuonParticleCollection> l1extmu;
00079 edm::Handle<l1extra::L1JetParticleCollection> l1extjetc, l1extjetf, l1exttaujet;
00080 edm::Handle<l1extra::L1EtMissParticleCollection> l1extmet,l1extmht;
00081 edm::Handle<L1GlobalTriggerReadoutRecord> l1GtRR;
00082 edm::Handle<L1GlobalTriggerObjectMapRecord> l1GtOMRec;
00083 edm::Handle<L1GlobalTriggerObjectMap> l1GtOM;
00084 edm::Handle< L1GctHFBitCountsCollection > gctBitCounts ;
00085 edm::Handle< L1GctHFRingEtSumsCollection > gctRingSums ;
00086
00087
00088 std::vector<MissingCollectionInfo> missing;
00089
00090 getCollection( iEvent, missing, hltresults, hltresults_, kHltresults );
00091 getCollection( iEvent, missing, l1extemi, m_l1extraemi, kL1extemi );
00092 getCollection( iEvent, missing, l1extemn, m_l1extraemn, kL1extemn );
00093 getCollection( iEvent, missing, l1extmu, m_l1extramu, kL1extmu );
00094 getCollection( iEvent, missing, l1extjetc, m_l1extrajetc, kL1extjetc );
00095 getCollection( iEvent, missing, l1extjetf, m_l1extrajetf, kL1extjetf );
00096 getCollection( iEvent, missing, l1exttaujet, m_l1extrataujet, kL1exttaujet );
00097 getCollection( iEvent, missing, l1extmet, m_l1extramet, kL1extmet );
00098 getCollection( iEvent, missing, l1extmht, m_l1extramht, kL1extmht );
00099 getCollection( iEvent, missing, l1GtRR, gtReadoutRecord_, kL1GtRR );
00100 getCollection( iEvent, missing, l1GtOMRec, gtObjectMap_, kL1GtOMRec );
00101 getCollection( iEvent, missing, gctBitCounts, gctBitCounts_, kL1GctBitCounts );
00102 getCollection( iEvent, missing, gctRingSums, gctRingSums_, kL1GctRingSums );
00103
00104
00105
00106 if (not missing.empty() and (errCnt < errMax())) {
00107 errCnt++;
00108 std::stringstream out;
00109 out << "OpenHLT analyser - missing collections:";
00110 BOOST_FOREACH(const MissingCollectionInfo & entry, missing)
00111 out << "\n\t" << entry.first << ": " << entry.second->encode();
00112 edm::LogPrint("OpenHLT") << out.str() << std::endl;
00113 if (errCnt == errMax())
00114 edm::LogWarning("OpenHLT") << "Maximum error count reached -- No more messages will be printed.";
00115 }
00116
00117
00118 hlt_analysis_.analyze(
00119 hltresults,
00120 l1extemi,
00121 l1extemn,
00122 l1extmu,
00123 l1extjetc,
00124 l1extjetf,
00125 l1exttaujet,
00126 l1extmet,
00127 l1extmht,
00128 l1GtRR,
00129 gctBitCounts,
00130 gctRingSums,
00131 iSetup,
00132 iEvent,
00133 HltTree);
00134
00135 evt_header_.analyze(iEvent, HltTree);
00136
00137
00138
00139 if (m_file)
00140 m_file->cd();
00141 HltTree->Fill();
00142 }
00143
00144
00145 void HLTBitAnalyzer::endJob() {
00146
00147 if (m_file)
00148 m_file->cd();
00149
00150 HltTree->Write();
00151 delete HltTree;
00152 HltTree = 0;
00153
00154 if (m_file) {
00155 m_file->Write();
00156 delete m_file;
00157 m_file = 0;
00158 }
00159
00160 }