00001 #include "HLTriggerOffline/JetMET/interface/HLTJetMETValidation.h"
00002 #include "Math/GenVector/VectorUtil.h"
00003 #include "FWCore/Common/interface/TriggerNames.h"
00004
00005 HLTJetMETValidation::HLTJetMETValidation(const edm::ParameterSet& ps) :
00006 triggerEventObject_(ps.getUntrackedParameter<edm::InputTag>("triggerEventObject")),
00007 CaloJetAlgorithm( ps.getUntrackedParameter<edm::InputTag>( "CaloJetAlgorithm" ) ),
00008 GenJetAlgorithm( ps.getUntrackedParameter<edm::InputTag>( "GenJetAlgorithm" ) ),
00009 CaloMETColl( ps.getUntrackedParameter<edm::InputTag>( "CaloMETCollection" ) ),
00010 GenMETColl( ps.getUntrackedParameter<edm::InputTag>( "GenMETCollection" ) ),
00011 HLTriggerResults( ps.getParameter<edm::InputTag>( "HLTriggerResults" ) ),
00012 triggerTag_(ps.getUntrackedParameter<std::string>("DQMFolder","SingleJet")),
00013 _HLTPath(ps.getUntrackedParameter<edm::InputTag>("HLTPath")),
00014 _HLTLow(ps.getUntrackedParameter<edm::InputTag>("HLTLow")),
00015 outFile_(ps.getUntrackedParameter<std::string>("OutputFileName","")),
00016 HLTinit_(false),
00017
00018 writeFile_(ps.getUntrackedParameter<bool>("WriteFile",false))
00019 {
00020 evtCnt=0;
00021
00022
00023 DQMStore* store = &*edm::Service<DQMStore>();
00024
00025 if(store)
00026 {
00027
00028 store->setCurrentFolder(triggerTag_);
00029 _meRecoJetPt= store->book1D("_meRecoJetPt","Single Reconstructed Jet Pt",100,0,500);
00030 _meRecoJetPtTrg= store->book1D("_meRecoJetPtTrg","Single Reconstructed Jet Pt -- HLT Triggered",100,0,500);
00031 _meRecoJetPtTrgLow= store->book1D("_meRecoJetPtTrgLow","Single Reconstructed Jet Pt -- HLT Triggered Low",100,0,500);
00032
00033 _meRecoJetEta= store->book1D("_meRecoJetEta","Single Reconstructed Jet Eta",100,-10,10);
00034 _meRecoJetEtaTrg= store->book1D("_meRecoJetEtaTrg","Single Reconstructed Jet Eta -- HLT Triggered",100,-10,10);
00035 _meRecoJetEtaTrgLow= store->book1D("_meRecoJetEtaTrgLow","Single Reconstructed Jet Eta -- HLT Triggered Low",100,-10,10);
00036
00037 _meRecoJetPhi= store->book1D("_meRecoJetPhi","Single Reconstructed Jet Phi",100,-4.,4.);
00038 _meRecoJetPhiTrg= store->book1D("_meRecoJetPhiTrg","Single Reconstructed Jet Phi -- HLT Triggered",100,-4.,4.);
00039 _meRecoJetPhiTrgLow= store->book1D("_meRecoJetPhiTrgLow","Single Reconstructed Jet Phi -- HLT Triggered Low",100,-4.,4.);
00040
00041 _meGenJetPt= store->book1D("_meGenJetPt","Single Generated Jet Pt",100,0,500);
00042 _meGenJetPtTrg= store->book1D("_meGenJetPtTrg","Single Generated Jet Pt -- HLT Triggered",100,0,500);
00043 _meGenJetPtTrgLow= store->book1D("_meGenJetPtTrgLow","Single Generated Jet Pt -- HLT Triggered Low",100,0,500);
00044
00045 _meGenJetEta= store->book1D("_meGenJetEta","Single Generated Jet Eta",100,-10,10);
00046 _meGenJetEtaTrg= store->book1D("_meGenJetEtaTrg","Single Generated Jet Eta -- HLT Triggered",100,-10,10);
00047 _meGenJetEtaTrgLow= store->book1D("_meGenJetEtaTrgLow","Single Generated Jet Eta -- HLT Triggered Low",100,-10,10);
00048
00049 _meGenJetPhi= store->book1D("_meGenJetPhi","Single Generated Jet Phi",100,-4.,4.);
00050 _meGenJetPhiTrg= store->book1D("_meGenJetPhiTrg","Single Generated Jet Phi -- HLT Triggered",100,-4.,4.);
00051 _meGenJetPhiTrgLow= store->book1D("_meGenJetPhiTrgLow","Single Generated Jet Phi -- HLT Triggered Low",100,-4.,4.);
00052
00053 _meRecoMET= store->book1D("_meRecoMET","Reconstructed Missing ET",100,0,500);
00054 _meRecoMETTrg= store->book1D("_meRecoMETTrg","Reconstructed Missing ET -- HLT Triggered",100,0,500);
00055 _meRecoMETTrgLow= store->book1D("_meRecoMETTrgLow","Reconstructed Missing ET -- HLT Triggered Low",100,0,500);
00056
00057 _meGenMET= store->book1D("_meGenMET","Generated Missing ET",100,0,500);
00058 _meGenMETTrg= store->book1D("_meGenMETTrg","Generated Missing ET -- HLT Triggered",100,0,500);
00059 _meGenMETTrgLow= store->book1D("_meGenMETTrgLow","Generated Missing ET -- HLT Triggered Low",100,0,500);
00060
00061 _meGenHT= store->book1D("_meGenHT","Generated HT",100,0,1000);
00062 _meGenHTTrg= store->book1D("_meGenHTTrg","Generated HT -- HLT Triggered",100,0,1000);
00063 _meGenHTTrgLow= store->book1D("_meGenHTTrgLow","Generated HT -- HLT Triggered Low",100,0,1000);
00064
00065 _meRecoHT= store->book1D("_meRecoHT","Reconstructed HT",100,0,1000);
00066 _meRecoHTTrg= store->book1D("_meRecoHTTrg","Reconstructed HT -- HLT Triggered",100,0,1000);
00067 _meRecoHTTrgLow= store->book1D("_meRecoHTTrgLow","Reconstructed HT -- HLT Triggered Low",100,0,1000);
00068
00069 _triggerResults = store->book1D( "_triggerResults", "HLT Results", 200, 0, 200 );
00070
00071 }
00072
00073
00074 }
00075
00076 HLTJetMETValidation::~HLTJetMETValidation()
00077 {
00078 }
00079
00080
00081
00082
00083
00084 void
00085 HLTJetMETValidation::endJob()
00086 {
00087
00088
00089 if(outFile_.size()>0)
00090 if (&*edm::Service<DQMStore>() && writeFile_) {
00091 edm::Service<DQMStore>()->save (outFile_);
00092 }
00093
00094 }
00095
00096 void
00097 HLTJetMETValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00098 {
00099 using namespace std;
00100 using namespace edm;
00101 using namespace reco;
00102 using namespace l1extra;
00103 using namespace trigger;
00104
00105 evtCnt++;
00106
00107
00108 Handle<TriggerEventWithRefs> trigEv;
00109 iEvent.getByLabel(triggerEventObject_,trigEv);
00110
00111
00112
00113 bool gotHLT=true;
00114 bool myTrig=false;
00115 bool myTrigLow=false;
00116
00117 Handle<TriggerResults> hltresults,hltresultsDummy;
00118 iEvent.getByLabel(HLTriggerResults,hltresults);
00119 if (! hltresults.isValid() ) {
00120
00121
00122 gotHLT=false;
00123 }
00124
00125 if (gotHLT) {
00126 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*hltresults);
00127 getHLTResults(*hltresults, triggerNames);
00128
00129
00130
00131
00132
00133 for( map<std::string,bool>::iterator ii=hltTriggerMap.begin(); ii!=hltTriggerMap.end(); ++ii)
00134 {
00135
00136
00137
00138
00139 if ( ((*ii).first).find(_HLTPath.label()) != string::npos) trig_iter=ii;
00140 }
00141 if (trig_iter==hltTriggerMap.end()){
00142
00143
00144 }else{
00145 myTrig=trig_iter->second;
00146 }
00147
00148 for( map<std::string,bool>::iterator ii=hltTriggerMap.begin(); ii!=hltTriggerMap.end(); ++ii)
00149 {
00150
00151 if ( ((*ii).first).find(_HLTLow.label()) != string::npos) trig_iter=ii;
00152 }
00153 if (trig_iter==hltTriggerMap.end()){
00154
00155
00156 }else{
00157 myTrigLow=trig_iter->second;
00158 }
00159 }
00160
00161 Handle<CaloJetCollection> caloJets,caloJetsDummy;
00162 iEvent.getByLabel( CaloJetAlgorithm, caloJets );
00163 double calJetPt=-1.;
00164 double calJetEta=-999.;
00165 double calJetPhi=-999.;
00166 double calHT=0;
00167 if (caloJets.isValid()) {
00168
00169 int jetInd = 0;
00170 for( CaloJetCollection::const_iterator cal = caloJets->begin(); cal != caloJets->end(); ++ cal ) {
00171
00172
00173 if (jetInd == 0){
00174
00175 calJetPt=cal->pt();
00176 calJetEta=cal->eta();
00177 calJetPhi=cal->phi();
00178 _meRecoJetPt->Fill( calJetPt );
00179 _meRecoJetEta->Fill( calJetEta );
00180 _meRecoJetPhi->Fill( calJetPhi );
00181 if (myTrig) _meRecoJetPtTrg->Fill( calJetPt );
00182 if (myTrig) _meRecoJetEtaTrg->Fill( calJetEta );
00183 if (myTrig) _meRecoJetPhiTrg->Fill( calJetPhi );
00184 if (myTrigLow) _meRecoJetPtTrgLow->Fill( calJetPt );
00185 if (myTrigLow) _meRecoJetEtaTrgLow->Fill( calJetEta );
00186 if (myTrigLow) _meRecoJetPhiTrgLow->Fill( calJetPhi );
00187
00188
00189
00190
00191
00192 jetInd++;
00193 }
00194 if (cal->pt()>30) {
00195 calHT+=cal->pt();
00196 }
00197 }
00198 _meRecoHT->Fill( calHT );
00199 if (myTrig) _meRecoHTTrg->Fill( calHT );
00200 if (myTrigLow) _meRecoHTTrgLow->Fill( calHT );
00201 }else{
00202
00203
00204 }
00205
00206 Handle<GenJetCollection> genJets,genJetsDummy;
00207 iEvent.getByLabel( GenJetAlgorithm, genJets );
00208 double genJetPt=-1.;
00209 double genJetEta=-999.;
00210 double genJetPhi=-999.;
00211 double genHT=0;
00212 if (genJets.isValid()) {
00213
00214 int jetInd = 0;
00215 for( GenJetCollection::const_iterator gen = genJets->begin(); gen != genJets->end(); ++ gen ) {
00216
00217
00218 if (jetInd == 0){
00219
00220 genJetPt=gen->pt();
00221 genJetEta=gen->eta();
00222 genJetPhi=gen->phi();
00223 _meGenJetPt->Fill( genJetPt );
00224 _meGenJetEta->Fill( genJetEta );
00225 _meGenJetPhi->Fill( genJetPhi );
00226 if (myTrig) _meGenJetPtTrg->Fill( genJetPt );
00227 if (myTrig) _meGenJetEtaTrg->Fill( genJetEta );
00228 if (myTrig) _meGenJetPhiTrg->Fill( genJetPhi );
00229 if (myTrigLow) _meGenJetPtTrgLow->Fill( genJetPt );
00230 if (myTrigLow) _meGenJetEtaTrgLow->Fill( genJetEta );
00231 if (myTrigLow) _meGenJetPhiTrgLow->Fill( genJetPhi );
00232
00233
00234
00235
00236 jetInd++;
00237 }
00238 if (gen->pt()>30) {
00239 genHT+=gen->pt();
00240 }
00241 }
00242 _meGenHT->Fill( genHT );
00243 if (myTrig) _meGenHTTrg->Fill( genHT );
00244 if (myTrigLow) _meGenHTTrgLow->Fill( genHT );
00245 }else{
00246
00247
00248 }
00249
00250 edm::Handle<CaloMETCollection> recmet, recmetDummy;
00251 iEvent.getByLabel(CaloMETColl,recmet);
00252
00253 double calMet=-1;
00254 if (recmet.isValid()) {
00255 typedef CaloMETCollection::const_iterator cmiter;
00256
00257 for ( cmiter i=recmet->begin(); i!=recmet->end(); i++) {
00258 calMet = i->pt();
00259
00260
00261 _meRecoMET -> Fill(calMet);
00262 if (myTrig) _meRecoMETTrg -> Fill(calMet);
00263 if (myTrigLow) _meRecoMETTrgLow -> Fill(calMet);
00264 }
00265 }else{
00266
00267
00268 }
00269
00270 edm::Handle<GenMETCollection> genmet, genmetDummy;
00271 iEvent.getByLabel(GenMETColl,genmet);
00272
00273 double genMet=-1;
00274 if (genmet.isValid()) {
00275 typedef GenMETCollection::const_iterator cmiter;
00276
00277 for ( cmiter i=genmet->begin(); i!=genmet->end(); i++) {
00278 genMet = i->pt();
00279
00280
00281 _meGenMET -> Fill(genMet);
00282 if (myTrig) _meGenMETTrg -> Fill(genMet);
00283 if (myTrigLow) _meGenMETTrgLow -> Fill(genMet);
00284 }
00285 }else{
00286
00287
00288 }
00289 }
00290
00291 void HLTJetMETValidation::getHLTResults(const edm::TriggerResults& hltresults,
00292 const edm::TriggerNames & triggerNames) {
00293
00294 int ntrigs=hltresults.size();
00295 if (! HLTinit_){
00296 HLTinit_=true;
00297
00298
00299 for (int itrig = 0; itrig != ntrigs; ++itrig){
00300 std::string trigName = triggerNames.triggerName(itrig);
00301
00302 }
00303 }
00304
00305 for (int itrig = 0; itrig != ntrigs; ++itrig){
00306 std::string trigName = triggerNames.triggerName(itrig);
00307 bool accept=hltresults.accept(itrig);
00308
00309 if (accept) _triggerResults->Fill(float(itrig));
00310
00311
00312 typedef std::map<std::string,bool>::value_type valType;
00313 trig_iter=hltTriggerMap.find(trigName);
00314 if (trig_iter==hltTriggerMap.end())
00315 hltTriggerMap.insert(valType(trigName,accept));
00316 else
00317 trig_iter->second=accept;
00318 }
00319 }