00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "DQMOffline/JetMET/interface/JetMETAnalyzer.h"
00011
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "FWCore/Common/interface/TriggerNames.h"
00015
00016 #include "DataFormats/METReco/interface/CaloMETFwd.h"
00017 #include "DataFormats/METReco/interface/METFwd.h"
00018 #include "DataFormats/METReco/interface/PFMETFwd.h"
00019 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00020 #include "DataFormats/JetReco/interface/CaloJet.h"
00021 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
00022 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00023 #include "DataFormats/JetReco/interface/PFJet.h"
00024
00025 #include "DataFormats/Common/interface/Handle.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027
00028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00031
00032 #include <string>
00033 using namespace edm;
00034
00035 #define DEBUG 0
00036
00037
00038 JetMETAnalyzer::JetMETAnalyzer(const edm::ParameterSet& pSet) {
00039
00040 parameters = pSet;
00041
00042
00043 theAKJetCollectionLabel = parameters.getParameter<edm::InputTag>("AKJetsCollectionLabel");
00044 theSCJetCollectionLabel = parameters.getParameter<edm::InputTag>("SCJetsCollectionLabel");
00045 theICJetCollectionLabel = parameters.getParameter<edm::InputTag>("ICJetsCollectionLabel");
00046 theJPTJetCollectionLabel = parameters.getParameter<edm::InputTag>("JPTJetsCollectionLabel");
00047 thePFJetCollectionLabel = parameters.getParameter<edm::InputTag>("PFJetsCollectionLabel");
00048
00049 theTriggerResultsLabel = parameters.getParameter<edm::InputTag>("TriggerResultsLabel");
00050
00051 theJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJetAnalysis", true);
00052 theJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoJetCleaning", true);
00053 theIConeJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoIterativeCone", false);
00054 theSConeJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoSisCone", false);
00055 theJetPtAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJetPtAnalysis", false);
00056 theJetPtCleaningFlag = parameters.getUntrackedParameter<bool>("DoJetPtCleaning", false);
00057 theJPTJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJPTJetAnalysis", false);
00058 theJPTJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoJPTJetCleaning", true);
00059 thePFJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoPFJetAnalysis", false);
00060 thePFJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoPFJetCleaning", true);
00061
00062 theDiJetSelectionFlag = parameters.getUntrackedParameter<bool>("DoDiJetSelection", true);
00063
00064 theCaloMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoCaloMETAnalysis",true);
00065 theTcMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoTcMETAnalysis", true);
00066 theMuCorrMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoMuCorrMETAnalysis", true);
00067 thePfMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoPfMETAnalysis", true);
00068 theHTMHTAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoHTMHTAnalysis", true);
00069
00070
00071
00072
00073 DCSFilterCalo = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterCalo"));
00074 DCSFilterPF = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterPF"));
00075 DCSFilterJPT = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterJPT"));
00076 DCSFilterAll = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterAll"));
00077
00078
00079
00080 if(theJetAnalyzerFlag) {
00081 theAKJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
00082 theAKJetAnalyzer->setSource("AntiKtJets");
00083 if(theSConeJetAnalyzerFlag) {
00084 theSCJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
00085 theSCJetAnalyzer->setSource("SISConeJets");
00086 }
00087 if(theIConeJetAnalyzerFlag){
00088 theICJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
00089 theICJetAnalyzer->setSource("IterativeConeJets");
00090 }
00091 }
00092
00093 if(theJetCleaningFlag) {
00094 theCleanedAKJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
00095 theCleanedAKJetAnalyzer->setSource("CleanedAntiKtJets");
00096 if(theSConeJetAnalyzerFlag){
00097 theCleanedSCJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
00098 theCleanedSCJetAnalyzer->setSource("CleanedSISConeJets");
00099 }
00100 if(theIConeJetAnalyzerFlag){
00101 theCleanedICJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
00102 theCleanedICJetAnalyzer->setSource("CleanedIterativeConeJets");
00103 }
00104 }
00105
00106 if(theDiJetSelectionFlag){
00107 theDiJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("DijetAnalysis"));
00108 theDiJetAnalyzer->setSource("DiJets");
00109 }
00110
00111
00112 if(theJetPtAnalyzerFlag ) {
00113 thePtAKJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
00114 thePtAKJetAnalyzer->setSource("PtAnalysisAntiKtJets");
00115 if(theSConeJetAnalyzerFlag){
00116 thePtSCJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
00117 thePtSCJetAnalyzer->setSource("PtAnalysisSISConeJets");
00118 }
00119 if(theIConeJetAnalyzerFlag){
00120 thePtICJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
00121 thePtICJetAnalyzer->setSource("PtAnalysisIterativeConeJets");
00122 }
00123 }
00124
00125 if(theJetPtCleaningFlag ) {
00126 theCleanedPtAKJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
00127 theCleanedPtAKJetAnalyzer->setSource("PtAnalysisCleanedAntiKtJets");
00128 if(theSConeJetAnalyzerFlag){
00129 theCleanedPtSCJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
00130 theCleanedPtSCJetAnalyzer->setSource("PtAnalysisCleanedSISConeJets");
00131 }
00132 if(theIConeJetAnalyzerFlag){
00133 theCleanedPtICJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
00134 theCleanedPtICJetAnalyzer->setSource("PtAnalysisCleanedIterativeConeJets");
00135 }
00136 }
00137
00138
00139 if(theJPTJetAnalyzerFlag) {
00140 theJPTJetAnalyzer = new JPTJetAnalyzer(parameters.getParameter<ParameterSet>("JPTJetAnalysis"));
00141 }
00142
00143 if(theJPTJetCleaningFlag) {
00144 theCleanedJPTJetAnalyzer = new JPTJetAnalyzer(parameters.getParameter<ParameterSet>("CleanedJPTJetAnalysis"));
00145 }
00146
00147
00148 if(thePFJetAnalyzerFlag){
00149 thePFJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("pfJetAnalysis"));
00150 thePFJetAnalyzer->setSource("uncPFJets");
00151 }
00152
00153 if(thePFJetCleaningFlag) {
00154 theCleanedPFJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("CleanedpfJetAnalysis"));
00155 theCleanedPFJetAnalyzer->setSource("PFJets");
00156 }
00157
00158 if(theDiJetSelectionFlag){
00159 thePFDiJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("PFDijetAnalysis"));
00160 thePFDiJetAnalyzer->setSource("PFDiJets");
00161 }
00162
00163 edm::ParameterSet highptjetparms = parameters.getParameter<edm::ParameterSet>("highPtJetTrigger");
00164 edm::ParameterSet lowptjetparms = parameters.getParameter<edm::ParameterSet>("lowPtJetTrigger" );
00165
00166 _HighPtJetEventFlag = new GenericTriggerEventFlag( highptjetparms );
00167 _LowPtJetEventFlag = new GenericTriggerEventFlag( lowptjetparms );
00168
00169 highPtJetExpr_ = highptjetparms.getParameter<std::vector<std::string> >("hltPaths");
00170 lowPtJetExpr_ = lowptjetparms .getParameter<std::vector<std::string> >("hltPaths");
00171
00172
00173 if(theCaloMETAnalyzerFlag){
00174 theCaloMETAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETAnalysis"));
00175 theCaloMETNoHFAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETNoHFAnalysis"));
00176
00177
00178 }
00179 if(theTcMETAnalyzerFlag){
00180 theTcMETAnalyzer = new METAnalyzer(parameters.getParameter<ParameterSet>("tcMETAnalysis"));
00181 }
00182 if(theMuCorrMETAnalyzerFlag){
00183 theMuCorrMETAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("mucorrMETAnalysis"));
00184 }
00185 if(thePfMETAnalyzerFlag){
00186 thePfMETAnalyzer = new PFMETAnalyzer(parameters.getParameter<ParameterSet>("pfMETAnalysis"));
00187 }
00188 if(theHTMHTAnalyzerFlag){
00189 theHTMHTAnalyzer = new HTMHTAnalyzer(parameters.getParameter<ParameterSet>("HTMHTAnalysis"));
00190 }
00191
00192 _LSBegin = parameters.getParameter<int>("LSBegin");
00193 _LSEnd = parameters.getParameter<int>("LSEnd");
00194
00195 processname_ = parameters.getParameter<std::string>("processname");
00196
00197
00198 theCleaningParameters = parameters.getParameter<ParameterSet>("CleaningParameters"),
00199
00200 _hlt_PhysDec = theCleaningParameters.getParameter<std::string>("HLT_PhysDec");
00201
00202 _techTrigsAND = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsAND");
00203 _techTrigsOR = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsOR");
00204 _techTrigsNOT = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsNOT");
00205
00206 _doPVCheck = theCleaningParameters.getParameter<bool>("doPrimaryVertexCheck");
00207 _doHLTPhysicsOn = theCleaningParameters.getParameter<bool>("doHLTPhysicsOn");
00208
00209 _tightBHFiltering = theCleaningParameters.getParameter<bool>("tightBHFiltering");
00210 _tightHcalFiltering = theCleaningParameters.getParameter<bool>("tightHcalFiltering");
00211
00212 _theVertexLabel = theCleaningParameters.getParameter<edm::InputTag>("vertexLabel");
00213 _theGTLabel = theCleaningParameters.getParameter<edm::InputTag>("gtLabel");
00214
00215
00216 if (_doPVCheck) {
00217 _nvtx_min = theCleaningParameters.getParameter<int>("nvtx_min");
00218 _nvtxtrks_min = theCleaningParameters.getParameter<int>("nvtxtrks_min");
00219 _vtxndof_min = theCleaningParameters.getParameter<int>("vtxndof_min");
00220 _vtxchi2_max = theCleaningParameters.getParameter<double>("vtxchi2_max");
00221 _vtxz_max = theCleaningParameters.getParameter<double>("vtxz_max");
00222 }
00223
00224 }
00225
00226
00227 JetMETAnalyzer::~JetMETAnalyzer() {
00228
00229 if(theJetAnalyzerFlag) {
00230 delete theAKJetAnalyzer;
00231 if(theSConeJetAnalyzerFlag) delete theSCJetAnalyzer;
00232 if(theIConeJetAnalyzerFlag) delete theICJetAnalyzer;
00233 }
00234 if(theJetCleaningFlag) {
00235 delete theCleanedAKJetAnalyzer;
00236 if(theSConeJetAnalyzerFlag) delete theCleanedSCJetAnalyzer;
00237 if(theIConeJetAnalyzerFlag) delete theCleanedICJetAnalyzer;
00238 }
00239 if(theDiJetSelectionFlag) {
00240 delete theDiJetAnalyzer;
00241 }
00242 if(theJetPtAnalyzerFlag) {
00243 delete thePtAKJetAnalyzer;
00244 if(theSConeJetAnalyzerFlag) delete thePtSCJetAnalyzer;
00245 if(theIConeJetAnalyzerFlag) delete thePtICJetAnalyzer;
00246 }
00247
00248 if(theJetPtCleaningFlag) {
00249 delete theCleanedPtAKJetAnalyzer;
00250 if(theSConeJetAnalyzerFlag) delete theCleanedPtSCJetAnalyzer;
00251 if(theIConeJetAnalyzerFlag) delete theCleanedPtICJetAnalyzer;
00252 }
00253
00254 if(theJPTJetAnalyzerFlag) delete theJPTJetAnalyzer;
00255 if(theJPTJetCleaningFlag) delete theCleanedJPTJetAnalyzer;
00256
00257 if(thePFJetAnalyzerFlag) delete thePFJetAnalyzer;
00258 if(thePFJetCleaningFlag) delete theCleanedPFJetAnalyzer;
00259 if(theDiJetSelectionFlag) delete thePFDiJetAnalyzer;
00260
00261 delete _HighPtJetEventFlag;
00262 delete _LowPtJetEventFlag;
00263
00264 if(theCaloMETAnalyzerFlag){
00265 delete theCaloMETAnalyzer;
00266 delete theCaloMETNoHFAnalyzer;
00267
00268
00269 }
00270 if(theTcMETAnalyzerFlag) delete theTcMETAnalyzer;
00271 if(theMuCorrMETAnalyzerFlag) delete theMuCorrMETAnalyzer;
00272 if(thePfMETAnalyzerFlag) delete thePfMETAnalyzer;
00273 if(theHTMHTAnalyzerFlag) delete theHTMHTAnalyzer;
00274
00275 delete DCSFilterCalo;
00276 delete DCSFilterPF;
00277 delete DCSFilterJPT;
00278 delete DCSFilterAll;
00279
00280 }
00281
00282
00283 void JetMETAnalyzer::beginJob(void) {
00284
00285 metname = "JetMETAnalyzer";
00286
00287 LogTrace(metname)<<"[JetMETAnalyzer] Parameters initialization";
00288 dbe = edm::Service<DQMStore>().operator->();
00289
00290
00291
00292 if(theJetAnalyzerFlag) {
00293 theAKJetAnalyzer->beginJob(dbe);
00294 if(theSConeJetAnalyzerFlag) theSCJetAnalyzer->beginJob(dbe);
00295 if(theIConeJetAnalyzerFlag) theICJetAnalyzer->beginJob(dbe);
00296 }
00297 if(theJetCleaningFlag) {
00298 theCleanedAKJetAnalyzer->beginJob(dbe);
00299 if(theSConeJetAnalyzerFlag) theCleanedSCJetAnalyzer->beginJob(dbe);
00300 if(theIConeJetAnalyzerFlag) theCleanedICJetAnalyzer->beginJob(dbe);
00301 }
00302 if(theDiJetSelectionFlag) theDiJetAnalyzer->beginJob(dbe);
00303 if(theJetPtAnalyzerFlag ) {
00304 thePtAKJetAnalyzer->beginJob(dbe);
00305 if(theSConeJetAnalyzerFlag) thePtSCJetAnalyzer->beginJob(dbe);
00306 if(theIConeJetAnalyzerFlag) thePtICJetAnalyzer->beginJob(dbe);
00307 }
00308 if(theJetPtCleaningFlag ) {
00309 theCleanedPtAKJetAnalyzer->beginJob(dbe);
00310 if(theSConeJetAnalyzerFlag) theCleanedPtSCJetAnalyzer->beginJob(dbe);
00311 if(theIConeJetAnalyzerFlag) theCleanedPtICJetAnalyzer->beginJob(dbe);
00312 }
00313
00314 if(theJPTJetAnalyzerFlag) theJPTJetAnalyzer->beginJob(dbe);
00315 if(theJPTJetCleaningFlag) theCleanedJPTJetAnalyzer->beginJob(dbe);
00316
00317 if(thePFJetAnalyzerFlag) thePFJetAnalyzer->beginJob(dbe);
00318 if(thePFJetCleaningFlag) theCleanedPFJetAnalyzer->beginJob(dbe);
00319 if(theDiJetSelectionFlag) thePFDiJetAnalyzer->beginJob(dbe);
00320
00321
00322
00323 if(theCaloMETAnalyzerFlag){
00324 theCaloMETAnalyzer->beginJob(dbe);
00325 theCaloMETNoHFAnalyzer->beginJob(dbe);
00326
00327
00328 }
00329 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->beginJob(dbe);
00330 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->beginJob(dbe);
00331 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->beginJob(dbe);
00332 if(theHTMHTAnalyzerFlag) theHTMHTAnalyzer->beginJob(dbe);
00333
00334 dbe->setCurrentFolder("JetMET");
00335 lumisecME = dbe->book1D("lumisec", "lumisec", 500, 0., 500.);
00336 cleanupME = dbe->book1D("cleanup", "cleanup", 10, 0., 10.);
00337 cleanupME->setBinLabel(1,"Primary Vertex");
00338 cleanupME->setBinLabel(2,"DCS::Pixel");
00339 cleanupME->setBinLabel(3,"DCS::SiStrip");
00340 cleanupME->setBinLabel(4,"DCS::ECAL");
00341 cleanupME->setBinLabel(5,"DCS::ES");
00342 cleanupME->setBinLabel(6,"DCS::HBHE");
00343 cleanupME->setBinLabel(7,"DCS::HF");
00344 cleanupME->setBinLabel(8,"DCS::HO");
00345 cleanupME->setBinLabel(9,"DCS::Muon");
00346
00347 }
00348
00349
00350 void JetMETAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00351 {
00352
00353
00354
00355 if ( _HighPtJetEventFlag->on() ) _HighPtJetEventFlag->initRun( iRun, iSetup );
00356 if ( _LowPtJetEventFlag ->on() ) _LowPtJetEventFlag ->initRun( iRun, iSetup );
00357
00358 if (_HighPtJetEventFlag->on() && _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00359 highPtJetExpr_ = _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup);
00360 if (_LowPtJetEventFlag->on() && _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00361 lowPtJetExpr_ = _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup);
00362
00363
00364
00365 bool changed(true);
00366 _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
00367 if (!_hlt_initialized) {
00368
00369 processname_ = "FU";
00370 _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
00371 if(!_hlt_initialized){
00372
00373 LogDebug("JetMETAnalyzer") << "HLTConfigProvider failed to initialize.";
00374 }
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 if(theCaloMETAnalyzerFlag){
00398 theCaloMETAnalyzer->beginRun(iRun, iSetup);
00399 theCaloMETNoHFAnalyzer->beginRun(iRun, iSetup);
00400
00401
00402 }
00403 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->beginRun(iRun, iSetup);
00404 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->beginRun(iRun, iSetup);
00405 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->beginRun(iRun, iSetup);
00406
00407
00408 }
00409
00410
00411 void JetMETAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00412 {
00413
00414
00415
00416
00417
00418 if(theCaloMETAnalyzerFlag){
00419 theCaloMETAnalyzer->endRun(iRun, iSetup, dbe);
00420 theCaloMETNoHFAnalyzer->endRun(iRun, iSetup, dbe);
00421
00422
00423 }
00424 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endRun(iRun, iSetup, dbe);
00425 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endRun(iRun, iSetup, dbe);
00426 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endRun(iRun, iSetup, dbe);
00427
00428
00429 }
00430
00431
00432 void JetMETAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00433
00434 LogTrace(metname)<<"[JetMETAnalyzer] Analysis of event # ";
00435
00436
00437 int myLuminosityBlock;
00438 myLuminosityBlock = iEvent.luminosityBlock();
00439 lumisecME->Fill(myLuminosityBlock);
00440
00441 if (myLuminosityBlock<_LSBegin) return;
00442 if (myLuminosityBlock>_LSEnd && _LSEnd>0) return;
00443
00444
00445 edm::Handle<TriggerResults> triggerResults;
00446 iEvent.getByLabel(theTriggerResultsLabel, triggerResults);
00447
00448 bool bPhysicsDeclared = false;
00449 if(!_doHLTPhysicsOn) bPhysicsDeclared = true;
00450
00451 Int_t JetLoPass = 0;
00452 Int_t JetHiPass = 0;
00453
00454 if (triggerResults.isValid()){
00455 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00456
00457 if( triggerNames.triggerIndex("HLT_PhysicsDeclared") != triggerNames.size() )
00458 if (triggerResults->accept(triggerNames.triggerIndex("HLT_PhysicsDeclared"))) {
00459 if(_doHLTPhysicsOn) bPhysicsDeclared = true;
00460 }
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 const unsigned int nTrig(triggerNames.size());
00474 for (unsigned int i=0;i<nTrig;++i)
00475 {
00476 if (triggerNames.triggerName(i).find(highPtJetExpr_[0].substr(0,highPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
00477 JetHiPass=1;
00478 else if (triggerNames.triggerName(i).find(lowPtJetExpr_[0].substr(0,lowPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
00479 JetLoPass=1;
00480 }
00481
00482 }
00483
00484 if (DEBUG) std::cout << "trigger label " << theTriggerResultsLabel << std::endl;
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 if (DEBUG) {
00495 std::cout << ">>> Trigger Lo = " << JetLoPass
00496 << " Hi = " << JetHiPass
00497 << std::endl;
00498 }
00499
00500
00501
00502
00503 bool bPrimaryVertex = true;
00504 if(_doPVCheck){
00505 bPrimaryVertex = false;
00506 Handle<reco::VertexCollection> vertexHandle;
00507
00508 iEvent.getByLabel(_theVertexLabel, vertexHandle);
00509
00510 if (!vertexHandle.isValid()) {
00511 LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
00512 if (DEBUG) std::cout << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
00513 }
00514
00515 if ( vertexHandle.isValid() ){
00516 reco::VertexCollection vertexCollection = *(vertexHandle.product());
00517 int vertex_number = vertexCollection.size();
00518 reco::VertexCollection::const_iterator v = vertexCollection.begin();
00519 for ( ; v != vertexCollection.end(); ++v) {
00520 double vertex_chi2 = v->normalizedChi2();
00521 double vertex_ndof = v->ndof();
00522 bool fakeVtx = v->isFake();
00523 double vertex_Z = v->z();
00524
00525 if ( !fakeVtx
00526 && vertex_number>=_nvtx_min
00527 && vertex_ndof >_vtxndof_min
00528 && vertex_chi2 <_vtxchi2_max
00529 && fabs(vertex_Z)<_vtxz_max )
00530 bPrimaryVertex = true;
00531 }
00532 }
00533 }
00534
00535
00536 edm::Handle< L1GlobalTriggerReadoutRecord > gtReadoutRecord;
00537 iEvent.getByLabel( _theGTLabel, gtReadoutRecord);
00538
00539 if (!gtReadoutRecord.isValid()) {
00540 LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find GT readout record" << std::endl;
00541 if (DEBUG) std::cout << "JetMETAnalyzer: Could not find GT readout record product" << std::endl;
00542 }
00543
00544 bool bTechTriggers = true;
00545 bool bTechTriggersAND = true;
00546 bool bTechTriggersOR = false;
00547 bool bTechTriggersNOT = false;
00548
00549 if (gtReadoutRecord.isValid()) {
00550 const TechnicalTriggerWord& technicalTriggerWordBeforeMask = gtReadoutRecord->technicalTriggerWord();
00551
00552 if (_techTrigsAND.size() == 0)
00553 bTechTriggersAND = true;
00554 else
00555 for (unsigned ttr = 0; ttr != _techTrigsAND.size(); ttr++) {
00556 bTechTriggersAND = bTechTriggersAND && technicalTriggerWordBeforeMask.at(_techTrigsAND.at(ttr));
00557 }
00558
00559 if (_techTrigsAND.size() == 0)
00560 bTechTriggersOR = true;
00561 else
00562 for (unsigned ttr = 0; ttr != _techTrigsOR.size(); ttr++) {
00563 bTechTriggersOR = bTechTriggersOR || technicalTriggerWordBeforeMask.at(_techTrigsOR.at(ttr));
00564 }
00565 if (_techTrigsNOT.size() == 0)
00566 bTechTriggersNOT = false;
00567 else
00568 for (unsigned ttr = 0; ttr != _techTrigsNOT.size(); ttr++) {
00569 bTechTriggersNOT = bTechTriggersNOT || technicalTriggerWordBeforeMask.at(_techTrigsNOT.at(ttr));
00570 }
00571 }
00572 else
00573 {
00574 bTechTriggersAND = true;
00575 bTechTriggersOR = true;
00576 bTechTriggersNOT = false;
00577 }
00578
00579 if (_techTrigsAND.size()==0)
00580 bTechTriggersAND = true;
00581 if (_techTrigsOR.size()==0)
00582 bTechTriggersOR = true;
00583 if (_techTrigsNOT.size()==0)
00584 bTechTriggersNOT = false;
00585
00586 bTechTriggers = bTechTriggersAND && bTechTriggersOR && !bTechTriggersNOT;
00587
00588 bool bJetCleanup = bTechTriggers && bPrimaryVertex && bPhysicsDeclared;
00589
00590 DCSFilterAll->filter(iEvent, iSetup);
00591 if (bPrimaryVertex) cleanupME->Fill(0.5);
00592 if ( DCSFilterAll->passPIX ) cleanupME->Fill(1.5);
00593 if ( DCSFilterAll->passSiStrip ) cleanupME->Fill(2.5);
00594 if ( DCSFilterAll->passECAL ) cleanupME->Fill(3.5);
00595 if ( DCSFilterAll->passES ) cleanupME->Fill(4.5);
00596 if ( DCSFilterAll->passHBHE ) cleanupME->Fill(5.5);
00597 if ( DCSFilterAll->passHF ) cleanupME->Fill(6.5);
00598 if ( DCSFilterAll->passHO ) cleanupME->Fill(7.5);
00599 if ( DCSFilterAll->passMuon ) cleanupME->Fill(8.5);
00600
00601
00602 edm::Handle<reco::CaloJetCollection> caloJets;
00603
00604
00605
00606 iEvent.getByLabel(theAKJetCollectionLabel, caloJets);
00607 if(caloJets.isValid()) {
00608
00609 if(theJetAnalyzerFlag){
00610 theAKJetAnalyzer->setJetHiPass(JetHiPass);
00611 theAKJetAnalyzer->setJetLoPass(JetLoPass);
00612 theAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00613 }
00614 if(theJetPtAnalyzerFlag){
00615 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
00616 thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00617 }
00618
00619 }
00620
00621 if(caloJets.isValid() && bJetCleanup) {
00622 if(DCSFilterCalo->filter(iEvent, iSetup)){
00623 if(theJetCleaningFlag){
00624 theCleanedAKJetAnalyzer->setJetHiPass(JetHiPass);
00625 theCleanedAKJetAnalyzer->setJetLoPass(JetLoPass);
00626 theCleanedAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00627 }
00628 if(theJetPtCleaningFlag){
00629 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
00630 theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00631 }
00632 }
00633 }
00634
00635 if(caloJets.isValid() && bJetCleanup){
00636 if(DCSFilterCalo->filter(iEvent, iSetup)){
00637 if(theDiJetSelectionFlag){
00638 theDiJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00639 }
00640 }
00641 }
00642
00643
00644 if(caloJets.isValid()){
00645 if(theJetPtAnalyzerFlag){
00646 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
00647 thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00648 }
00649 }
00650
00651 if(caloJets.isValid() && bJetCleanup){
00652 if(DCSFilterCalo->filter(iEvent, iSetup)){
00653 if(theJetPtCleaningFlag){
00654 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
00655 theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00656 }
00657 }
00658 }
00659
00660
00661 iEvent.getByLabel(theSCJetCollectionLabel, caloJets);
00662 if(theSConeJetAnalyzerFlag){
00663 if(caloJets.isValid()){
00664 if(theJetAnalyzerFlag){
00665 theSCJetAnalyzer->setJetHiPass(JetHiPass);
00666 theSCJetAnalyzer->setJetLoPass(JetLoPass);
00667 theSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00668 }
00669 if(theJetPtAnalyzerFlag){
00670 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt SisCone analyzer";
00671 thePtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00672 }
00673 }
00674
00675 if(caloJets.isValid() && bJetCleanup){
00676 if(DCSFilterCalo->filter(iEvent, iSetup)){
00677 if(theJetCleaningFlag){
00678 theCleanedSCJetAnalyzer->setJetHiPass(JetHiPass);
00679 theCleanedSCJetAnalyzer->setJetLoPass(JetLoPass);
00680 theCleanedSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00681 }
00682 if(theJetPtCleaningFlag){
00683 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt SisCone analyzer";
00684 theCleanedPtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00685 }
00686 }
00687 }
00688 }
00689
00690 iEvent.getByLabel(theICJetCollectionLabel, caloJets);
00691 if(theIConeJetAnalyzerFlag) {
00692 if(caloJets.isValid()){
00693 if(theJetAnalyzerFlag){
00694 theICJetAnalyzer->setJetHiPass(JetHiPass);
00695 theICJetAnalyzer->setJetLoPass(JetLoPass);
00696 theICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00697 }
00698 if(theJetPtAnalyzerFlag){
00699 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt ICone analyzer";
00700 thePtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00701 }
00702 }
00703
00704 if(caloJets.isValid() && bJetCleanup){
00705 if(DCSFilterCalo->filter(iEvent, iSetup)){
00706 if(theJetCleaningFlag){
00707 theCleanedICJetAnalyzer->setJetHiPass(JetHiPass);
00708 theCleanedICJetAnalyzer->setJetLoPass(JetLoPass);
00709 theCleanedICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00710 }
00711 if(theJetPtCleaningFlag){
00712 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt ICone analyzer";
00713 theCleanedPtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00714 }
00715 }
00716 }
00717 }
00718
00719
00720 edm::Handle<reco::JPTJetCollection> jptJets;
00721 iEvent.getByLabel(theJPTJetCollectionLabel, jptJets);
00722 if(jptJets.isValid() && theJPTJetAnalyzerFlag){
00723
00724
00725 theJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets);
00726 }
00727
00728 if(jptJets.isValid() && bJetCleanup && theJPTJetCleaningFlag){
00729 if(DCSFilterJPT->filter(iEvent, iSetup)){
00730
00731
00732 theCleanedJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets);
00733 }
00734 }
00735
00736
00737 edm::Handle<reco::PFJetCollection> pfJets;
00738 iEvent.getByLabel(thePFJetCollectionLabel, pfJets);
00739
00740 if(pfJets.isValid()){
00741 if(thePFJetAnalyzerFlag){
00742 thePFJetAnalyzer->setJetHiPass(JetHiPass);
00743 thePFJetAnalyzer->setJetLoPass(JetLoPass);
00744 LogTrace(metname)<<"[JetMETAnalyzer] Call to the PFJet analyzer";
00745 thePFJetAnalyzer->analyze(iEvent, iSetup, *pfJets);
00746 }
00747 if(thePFJetCleaningFlag){
00748 if(DCSFilterPF->filter(iEvent, iSetup)){
00749 theCleanedPFJetAnalyzer->setJetHiPass(JetHiPass);
00750 theCleanedPFJetAnalyzer->setJetLoPass(JetLoPass);
00751 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned PFJet analyzer";
00752 theCleanedPFJetAnalyzer->analyze(iEvent, iSetup, *pfJets);
00753 if(theDiJetSelectionFlag){
00754 thePFDiJetAnalyzer->analyze(iEvent, iSetup, *pfJets);
00755 }
00756 }
00757 }
00758 } else {
00759 if (DEBUG) LogTrace(metname)<<"[JetMETAnalyzer] pfjets NOT VALID!!";
00760 }
00761
00762
00763
00764
00765 if(theCaloMETAnalyzerFlag){
00766
00767 theCaloMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00768 theCaloMETNoHFAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00769
00770
00771 }
00772
00773
00774
00775
00776 if(theTcMETAnalyzerFlag){
00777
00778 theTcMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00779
00780 }
00781
00782
00783
00784
00785 if(theMuCorrMETAnalyzerFlag){
00786
00787 theMuCorrMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00788
00789 }
00790
00791
00792
00793
00794 if(thePfMETAnalyzerFlag){
00795
00796 thePfMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00797
00798 }
00799
00800
00801
00802
00803 if(theHTMHTAnalyzerFlag){
00804
00805 theHTMHTAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00806
00807 }
00808
00809 }
00810
00811
00812 void JetMETAnalyzer::endJob(void) {
00813 LogTrace(metname)<<"[JetMETAnalyzer] Saving the histos";
00814 bool outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
00815 std::string outputFileName = parameters.getParameter<std::string>("OutputFileName");
00816
00817
00818
00819 if(theCaloMETAnalyzerFlag){
00820 theCaloMETAnalyzer->endJob();
00821 theCaloMETNoHFAnalyzer->endJob();
00822
00823
00824 }
00825 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endJob();
00826 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endJob();
00827 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endJob();
00828
00829
00830
00831 if(theJetAnalyzerFlag) {
00832 theAKJetAnalyzer->endJob();
00833 if(theSConeJetAnalyzerFlag) theSCJetAnalyzer->endJob();
00834 if(theIConeJetAnalyzerFlag) theICJetAnalyzer->endJob();
00835 }
00836
00837 if(theJetCleaningFlag) {
00838 theCleanedAKJetAnalyzer->endJob();
00839 if(theSConeJetAnalyzerFlag) theCleanedSCJetAnalyzer->endJob();
00840 if(theIConeJetAnalyzerFlag) theCleanedICJetAnalyzer->endJob();
00841 }
00842
00843 if(theDiJetSelectionFlag) theDiJetAnalyzer->endJob();
00844
00845 if(theJetPtAnalyzerFlag ) {
00846 thePtAKJetAnalyzer->endJob();
00847 if(theSConeJetAnalyzerFlag) thePtSCJetAnalyzer->endJob();
00848 if(theIConeJetAnalyzerFlag) thePtICJetAnalyzer->endJob();
00849 }
00850
00851 if(theJetPtCleaningFlag ) {
00852 theCleanedPtAKJetAnalyzer->endJob();
00853 if(theSConeJetAnalyzerFlag) theCleanedPtSCJetAnalyzer->endJob();
00854 if(theIConeJetAnalyzerFlag) theCleanedPtICJetAnalyzer->endJob();
00855 }
00856
00857 if(theJPTJetAnalyzerFlag) theJPTJetAnalyzer->endJob();
00858 if(theJPTJetCleaningFlag) theCleanedJPTJetAnalyzer->endJob();
00859
00860 if(thePFJetAnalyzerFlag) thePFJetAnalyzer->endJob();
00861 if(thePFJetCleaningFlag) theCleanedPFJetAnalyzer->endJob();
00862 if(theDiJetSelectionFlag) thePFDiJetAnalyzer->endJob();
00863
00864 if(outputMEsInRootFile){
00865 dbe->save(outputFileName);
00866 }
00867
00868 }
00869
00870