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 trig_iter=hltTriggerMap.find(_HLTPath.label());
00130 if (trig_iter==hltTriggerMap.end()){
00131
00132
00133 }else{
00134 myTrig=trig_iter->second;
00135 }
00136 trig_iter=hltTriggerMap.find(_HLTLow.label());
00137 if (trig_iter==hltTriggerMap.end()){
00138
00139
00140 }else{
00141 myTrigLow=trig_iter->second;
00142 }
00143 }
00144
00145 Handle<CaloJetCollection> caloJets,caloJetsDummy;
00146 iEvent.getByLabel( CaloJetAlgorithm, caloJets );
00147 double calJetPt=-1.;
00148 double calJetEta=-999.;
00149 double calJetPhi=-999.;
00150 double calHT=0;
00151 if (caloJets.isValid()) {
00152
00153 int jetInd = 0;
00154 for( CaloJetCollection::const_iterator cal = caloJets->begin(); cal != caloJets->end(); ++ cal ) {
00155
00156
00157 if (jetInd == 0){
00158
00159 calJetPt=cal->pt();
00160 calJetEta=cal->eta();
00161 calJetPhi=cal->phi();
00162 _meRecoJetPt->Fill( calJetPt );
00163 _meRecoJetEta->Fill( calJetEta );
00164 _meRecoJetPhi->Fill( calJetPhi );
00165 if (myTrig) _meRecoJetPtTrg->Fill( calJetPt );
00166 if (myTrig) _meRecoJetEtaTrg->Fill( calJetEta );
00167 if (myTrig) _meRecoJetPhiTrg->Fill( calJetPhi );
00168 if (myTrigLow) _meRecoJetPtTrgLow->Fill( calJetPt );
00169 if (myTrigLow) _meRecoJetEtaTrgLow->Fill( calJetEta );
00170 if (myTrigLow) _meRecoJetPhiTrgLow->Fill( calJetPhi );
00171
00172
00173
00174
00175
00176 jetInd++;
00177 }
00178 if (cal->pt()>30) {
00179 calHT+=cal->pt();
00180 }
00181 }
00182 _meRecoHT->Fill( calHT );
00183 if (myTrig) _meRecoHTTrg->Fill( calHT );
00184 if (myTrigLow) _meRecoHTTrgLow->Fill( calHT );
00185 }else{
00186
00187
00188 }
00189
00190 Handle<GenJetCollection> genJets,genJetsDummy;
00191 iEvent.getByLabel( GenJetAlgorithm, genJets );
00192 double genJetPt=-1.;
00193 double genJetEta=-999.;
00194 double genJetPhi=-999.;
00195 double genHT=0;
00196 if (genJets.isValid()) {
00197
00198 int jetInd = 0;
00199 for( GenJetCollection::const_iterator gen = genJets->begin(); gen != genJets->end(); ++ gen ) {
00200
00201
00202 if (jetInd == 0){
00203
00204 genJetPt=gen->pt();
00205 genJetEta=gen->eta();
00206 genJetPhi=gen->phi();
00207 _meGenJetPt->Fill( genJetPt );
00208 _meGenJetEta->Fill( genJetEta );
00209 _meGenJetPhi->Fill( genJetPhi );
00210 if (myTrig) _meGenJetPtTrg->Fill( genJetPt );
00211 if (myTrig) _meGenJetEtaTrg->Fill( genJetEta );
00212 if (myTrig) _meGenJetPhiTrg->Fill( genJetPhi );
00213 if (myTrigLow) _meGenJetPtTrgLow->Fill( genJetPt );
00214 if (myTrigLow) _meGenJetEtaTrgLow->Fill( genJetEta );
00215 if (myTrigLow) _meGenJetPhiTrgLow->Fill( genJetPhi );
00216
00217
00218
00219
00220 jetInd++;
00221 }
00222 if (gen->pt()>30) {
00223 genHT+=gen->pt();
00224 }
00225 }
00226 _meGenHT->Fill( genHT );
00227 if (myTrig) _meGenHTTrg->Fill( genHT );
00228 if (myTrigLow) _meGenHTTrgLow->Fill( genHT );
00229 }else{
00230
00231
00232 }
00233
00234 edm::Handle<CaloMETCollection> recmet, recmetDummy;
00235 iEvent.getByLabel(CaloMETColl,recmet);
00236
00237 double calMet=-1;
00238 if (recmet.isValid()) {
00239 typedef CaloMETCollection::const_iterator cmiter;
00240
00241 for ( cmiter i=recmet->begin(); i!=recmet->end(); i++) {
00242 calMet = i->pt();
00243
00244
00245 _meRecoMET -> Fill(calMet);
00246 if (myTrig) _meRecoMETTrg -> Fill(calMet);
00247 if (myTrigLow) _meRecoMETTrgLow -> Fill(calMet);
00248 }
00249 }else{
00250
00251
00252 }
00253
00254 edm::Handle<GenMETCollection> genmet, genmetDummy;
00255 iEvent.getByLabel(GenMETColl,genmet);
00256
00257 double genMet=-1;
00258 if (genmet.isValid()) {
00259 typedef GenMETCollection::const_iterator cmiter;
00260
00261 for ( cmiter i=genmet->begin(); i!=genmet->end(); i++) {
00262 genMet = i->pt();
00263
00264
00265 _meGenMET -> Fill(genMet);
00266 if (myTrig) _meGenMETTrg -> Fill(genMet);
00267 if (myTrigLow) _meGenMETTrgLow -> Fill(genMet);
00268 }
00269 }else{
00270
00271
00272 }
00273 }
00274
00275 void HLTJetMETValidation::getHLTResults(const edm::TriggerResults& hltresults,
00276 const edm::TriggerNames & triggerNames) {
00277
00278 int ntrigs=hltresults.size();
00279 if (! HLTinit_){
00280 HLTinit_=true;
00281
00282
00283 for (int itrig = 0; itrig != ntrigs; ++itrig){
00284 std::string trigName = triggerNames.triggerName(itrig);
00285
00286 }
00287 }
00288
00289 for (int itrig = 0; itrig != ntrigs; ++itrig){
00290 std::string trigName = triggerNames.triggerName(itrig);
00291 bool accept=hltresults.accept(itrig);
00292
00293 if (accept) _triggerResults->Fill(float(itrig));
00294
00295
00296 typedef std::map<std::string,bool>::value_type valType;
00297 trig_iter=hltTriggerMap.find(trigName);
00298 if (trig_iter==hltTriggerMap.end())
00299 hltTriggerMap.insert(valType(trigName,accept));
00300 else
00301 trig_iter->second=accept;
00302 }
00303 }