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
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
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
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 verticesME = dbe->book1D("vertices", "vertices", 50, 0, 50);
00348 }
00349
00350
00351 void JetMETAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00352 {
00353
00354
00355
00356 if ( _HighPtJetEventFlag->on() ) _HighPtJetEventFlag->initRun( iRun, iSetup );
00357 if ( _LowPtJetEventFlag ->on() ) _LowPtJetEventFlag ->initRun( iRun, iSetup );
00358
00359 if (_HighPtJetEventFlag->on() && _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00360 highPtJetExpr_ = _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup);
00361 if (_LowPtJetEventFlag->on() && _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00362 lowPtJetExpr_ = _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup);
00363
00364
00365
00366 bool changed(true);
00367 _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
00368 if (!_hlt_initialized) {
00369
00370 processname_ = "FU";
00371 _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
00372 if(!_hlt_initialized){
00373
00374 LogDebug("JetMETAnalyzer") << "HLTConfigProvider failed to initialize.";
00375 }
00376 }
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398 if(theCaloMETAnalyzerFlag){
00399 theCaloMETAnalyzer->beginRun(iRun, iSetup);
00400
00401
00402
00403 }
00404 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->beginRun(iRun, iSetup);
00405 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->beginRun(iRun, iSetup);
00406 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->beginRun(iRun, iSetup);
00407
00408
00409 }
00410
00411
00412 void JetMETAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00413 {
00414
00415
00416
00417
00418
00419 if(theCaloMETAnalyzerFlag){
00420 theCaloMETAnalyzer->endRun(iRun, iSetup, dbe);
00421
00422
00423
00424 }
00425 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endRun(iRun, iSetup, dbe);
00426 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endRun(iRun, iSetup, dbe);
00427 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endRun(iRun, iSetup, dbe);
00428
00429
00430 }
00431
00432
00433 void JetMETAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00434
00435 LogTrace(metname)<<"[JetMETAnalyzer] Analysis of event # ";
00436
00437
00438 int myLuminosityBlock;
00439 myLuminosityBlock = iEvent.luminosityBlock();
00440 lumisecME->Fill(myLuminosityBlock);
00441
00442 if (myLuminosityBlock<_LSBegin) return;
00443 if (myLuminosityBlock>_LSEnd && _LSEnd>0) return;
00444
00445
00446 edm::Handle<TriggerResults> triggerResults;
00447 iEvent.getByLabel(theTriggerResultsLabel, triggerResults);
00448
00449 bool bPhysicsDeclared = false;
00450 if(!_doHLTPhysicsOn) bPhysicsDeclared = true;
00451
00452 Int_t JetLoPass = 0;
00453 Int_t JetHiPass = 0;
00454
00455 if (triggerResults.isValid()){
00456 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00457
00458 if( triggerNames.triggerIndex("HLT_PhysicsDeclared") != triggerNames.size() )
00459 if (triggerResults->accept(triggerNames.triggerIndex("HLT_PhysicsDeclared"))) {
00460 if(_doHLTPhysicsOn) bPhysicsDeclared = true;
00461 }
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 const unsigned int nTrig(triggerNames.size());
00475 for (unsigned int i=0;i<nTrig;++i)
00476 {
00477 if (triggerNames.triggerName(i).find(highPtJetExpr_[0].substr(0,highPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
00478 JetHiPass=1;
00479 else if (triggerNames.triggerName(i).find(lowPtJetExpr_[0].substr(0,lowPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
00480 JetLoPass=1;
00481 }
00482
00483 }
00484
00485 if (DEBUG) std::cout << "trigger label " << theTriggerResultsLabel << std::endl;
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495 if (DEBUG) {
00496 std::cout << ">>> Trigger Lo = " << JetLoPass
00497 << " Hi = " << JetHiPass
00498 << std::endl;
00499 }
00500
00501
00502
00503
00504 int _numPV = 0;
00505 bool bPrimaryVertex = true;
00506 if(_doPVCheck){
00507 bPrimaryVertex = false;
00508 Handle<reco::VertexCollection> vertexHandle;
00509
00510 iEvent.getByLabel(_theVertexLabel, vertexHandle);
00511
00512 if (!vertexHandle.isValid()) {
00513 LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
00514 if (DEBUG) std::cout << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
00515 }
00516
00517 if ( vertexHandle.isValid() ){
00518 reco::VertexCollection vertexCollection = *(vertexHandle.product());
00519 int vertex_number = vertexCollection.size();
00520 reco::VertexCollection::const_iterator v = vertexCollection.begin();
00521 for ( ; v != vertexCollection.end(); ++v) {
00522 double vertex_chi2 = v->normalizedChi2();
00523 double vertex_ndof = v->ndof();
00524 bool fakeVtx = v->isFake();
00525 double vertex_Z = v->z();
00526
00527 if ( !fakeVtx
00528 && vertex_number>=_nvtx_min
00529 && vertex_ndof >_vtxndof_min
00530 && vertex_chi2 <_vtxchi2_max
00531 && fabs(vertex_Z)<_vtxz_max ) {
00532 bPrimaryVertex = true;
00533 ++_numPV;
00534 }
00535 }
00536 }
00537 }
00538 verticesME->Fill(_numPV);
00539
00540
00541 edm::Handle< L1GlobalTriggerReadoutRecord > gtReadoutRecord;
00542 iEvent.getByLabel( _theGTLabel, gtReadoutRecord);
00543
00544 if (!gtReadoutRecord.isValid()) {
00545 LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find GT readout record" << std::endl;
00546 if (DEBUG) std::cout << "JetMETAnalyzer: Could not find GT readout record product" << std::endl;
00547 }
00548
00549 bool bTechTriggers = true;
00550 bool bTechTriggersAND = true;
00551 bool bTechTriggersOR = false;
00552 bool bTechTriggersNOT = false;
00553
00554 if (gtReadoutRecord.isValid()) {
00555 const TechnicalTriggerWord& technicalTriggerWordBeforeMask = gtReadoutRecord->technicalTriggerWord();
00556
00557 if (_techTrigsAND.size() == 0)
00558 bTechTriggersAND = true;
00559 else
00560 for (unsigned ttr = 0; ttr != _techTrigsAND.size(); ttr++) {
00561 bTechTriggersAND = bTechTriggersAND && technicalTriggerWordBeforeMask.at(_techTrigsAND.at(ttr));
00562 }
00563
00564 if (_techTrigsAND.size() == 0)
00565 bTechTriggersOR = true;
00566 else
00567 for (unsigned ttr = 0; ttr != _techTrigsOR.size(); ttr++) {
00568 bTechTriggersOR = bTechTriggersOR || technicalTriggerWordBeforeMask.at(_techTrigsOR.at(ttr));
00569 }
00570 if (_techTrigsNOT.size() == 0)
00571 bTechTriggersNOT = false;
00572 else
00573 for (unsigned ttr = 0; ttr != _techTrigsNOT.size(); ttr++) {
00574 bTechTriggersNOT = bTechTriggersNOT || technicalTriggerWordBeforeMask.at(_techTrigsNOT.at(ttr));
00575 }
00576 }
00577 else
00578 {
00579 bTechTriggersAND = true;
00580 bTechTriggersOR = true;
00581 bTechTriggersNOT = false;
00582 }
00583
00584 if (_techTrigsAND.size()==0)
00585 bTechTriggersAND = true;
00586 if (_techTrigsOR.size()==0)
00587 bTechTriggersOR = true;
00588 if (_techTrigsNOT.size()==0)
00589 bTechTriggersNOT = false;
00590
00591 bTechTriggers = bTechTriggersAND && bTechTriggersOR && !bTechTriggersNOT;
00592
00593 bool bJetCleanup = bTechTriggers && bPrimaryVertex && bPhysicsDeclared;
00594
00595 DCSFilterAll->filter(iEvent, iSetup);
00596 if (bPrimaryVertex) cleanupME->Fill(0.5);
00597 if ( DCSFilterAll->passPIX ) cleanupME->Fill(1.5);
00598 if ( DCSFilterAll->passSiStrip ) cleanupME->Fill(2.5);
00599 if ( DCSFilterAll->passECAL ) cleanupME->Fill(3.5);
00600 if ( DCSFilterAll->passES ) cleanupME->Fill(4.5);
00601 if ( DCSFilterAll->passHBHE ) cleanupME->Fill(5.5);
00602 if ( DCSFilterAll->passHF ) cleanupME->Fill(6.5);
00603 if ( DCSFilterAll->passHO ) cleanupME->Fill(7.5);
00604 if ( DCSFilterAll->passMuon ) cleanupME->Fill(8.5);
00605
00606
00607 edm::Handle<reco::CaloJetCollection> caloJets;
00608
00609
00610
00611 iEvent.getByLabel(theAKJetCollectionLabel, caloJets);
00612 if(caloJets.isValid()) {
00613
00614 if(theJetAnalyzerFlag){
00615 theAKJetAnalyzer->setJetHiPass(JetHiPass);
00616 theAKJetAnalyzer->setJetLoPass(JetLoPass);
00617 theAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00618 }
00619 if(theJetPtAnalyzerFlag){
00620 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
00621 thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00622 }
00623
00624 }
00625
00626 if(caloJets.isValid() && bJetCleanup) {
00627 if(DCSFilterCalo->filter(iEvent, iSetup)){
00628 if(theJetCleaningFlag){
00629 theCleanedAKJetAnalyzer->setJetHiPass(JetHiPass);
00630 theCleanedAKJetAnalyzer->setJetLoPass(JetLoPass);
00631 theCleanedAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00632 }
00633 if(theJetPtCleaningFlag){
00634 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
00635 theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00636 }
00637 }
00638 }
00639
00640 if(caloJets.isValid() && bJetCleanup){
00641 if(DCSFilterCalo->filter(iEvent, iSetup)){
00642 if(theDiJetSelectionFlag){
00643 theDiJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00644 }
00645 }
00646 }
00647
00648
00649 if(caloJets.isValid()){
00650 if(theJetPtAnalyzerFlag){
00651 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
00652 thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00653 }
00654 }
00655
00656 if(caloJets.isValid() && bJetCleanup){
00657 if(DCSFilterCalo->filter(iEvent, iSetup)){
00658 if(theJetPtCleaningFlag){
00659 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
00660 theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00661 }
00662 }
00663 }
00664
00665
00666 iEvent.getByLabel(theSCJetCollectionLabel, caloJets);
00667 if(theSConeJetAnalyzerFlag){
00668 if(caloJets.isValid()){
00669 if(theJetAnalyzerFlag){
00670 theSCJetAnalyzer->setJetHiPass(JetHiPass);
00671 theSCJetAnalyzer->setJetLoPass(JetLoPass);
00672 theSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00673 }
00674 if(theJetPtAnalyzerFlag){
00675 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt SisCone analyzer";
00676 thePtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00677 }
00678 }
00679
00680 if(caloJets.isValid() && bJetCleanup){
00681 if(DCSFilterCalo->filter(iEvent, iSetup)){
00682 if(theJetCleaningFlag){
00683 theCleanedSCJetAnalyzer->setJetHiPass(JetHiPass);
00684 theCleanedSCJetAnalyzer->setJetLoPass(JetLoPass);
00685 theCleanedSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00686 }
00687 if(theJetPtCleaningFlag){
00688 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt SisCone analyzer";
00689 theCleanedPtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00690 }
00691 }
00692 }
00693 }
00694
00695 iEvent.getByLabel(theICJetCollectionLabel, caloJets);
00696 if(theIConeJetAnalyzerFlag) {
00697 if(caloJets.isValid()){
00698 if(theJetAnalyzerFlag){
00699 theICJetAnalyzer->setJetHiPass(JetHiPass);
00700 theICJetAnalyzer->setJetLoPass(JetLoPass);
00701 theICJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00702 }
00703 if(theJetPtAnalyzerFlag){
00704 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt ICone analyzer";
00705 thePtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00706 }
00707 }
00708
00709 if(caloJets.isValid() && bJetCleanup){
00710 if(DCSFilterCalo->filter(iEvent, iSetup)){
00711 if(theJetCleaningFlag){
00712 theCleanedICJetAnalyzer->setJetHiPass(JetHiPass);
00713 theCleanedICJetAnalyzer->setJetLoPass(JetLoPass);
00714 theCleanedICJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
00715 }
00716 if(theJetPtCleaningFlag){
00717 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt ICone analyzer";
00718 theCleanedPtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
00719 }
00720 }
00721 }
00722 }
00723
00724
00725 edm::Handle<reco::JPTJetCollection> jptJets;
00726 iEvent.getByLabel(theJPTJetCollectionLabel, jptJets);
00727 if(jptJets.isValid() && theJPTJetAnalyzerFlag){
00728
00729
00730 theJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets, _numPV);
00731 }
00732
00733 if(jptJets.isValid() && bJetCleanup && theJPTJetCleaningFlag){
00734 if(DCSFilterJPT->filter(iEvent, iSetup)){
00735
00736
00737 theCleanedJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets, _numPV);
00738 }
00739 }
00740
00741
00742 edm::Handle<reco::PFJetCollection> pfJets;
00743 iEvent.getByLabel(thePFJetCollectionLabel, pfJets);
00744
00745 if(pfJets.isValid()){
00746 if(thePFJetAnalyzerFlag){
00747 thePFJetAnalyzer->setJetHiPass(JetHiPass);
00748 thePFJetAnalyzer->setJetLoPass(JetLoPass);
00749 LogTrace(metname)<<"[JetMETAnalyzer] Call to the PFJet analyzer";
00750 thePFJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
00751 }
00752 if(thePFJetCleaningFlag){
00753 if(DCSFilterPF->filter(iEvent, iSetup)){
00754 theCleanedPFJetAnalyzer->setJetHiPass(JetHiPass);
00755 theCleanedPFJetAnalyzer->setJetLoPass(JetLoPass);
00756 LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned PFJet analyzer";
00757 theCleanedPFJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
00758 if(theDiJetSelectionFlag){
00759 thePFDiJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
00760 }
00761 }
00762 }
00763 } else {
00764 if (DEBUG) LogTrace(metname)<<"[JetMETAnalyzer] pfjets NOT VALID!!";
00765 }
00766
00767
00768
00769
00770 if(theCaloMETAnalyzerFlag){
00771
00772 theCaloMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00773
00774
00775
00776 }
00777
00778
00779
00780
00781 if(theTcMETAnalyzerFlag){
00782
00783 theTcMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00784
00785 }
00786
00787
00788
00789
00790 if(theMuCorrMETAnalyzerFlag){
00791
00792 theMuCorrMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00793
00794 }
00795
00796
00797
00798
00799 if(thePfMETAnalyzerFlag){
00800
00801 thePfMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00802
00803 }
00804
00805
00806
00807
00808 if(theHTMHTAnalyzerFlag){
00809
00810 theHTMHTAnalyzer->analyze(iEvent, iSetup, *triggerResults);
00811
00812 }
00813
00814 }
00815
00816
00817 void JetMETAnalyzer::endJob(void) {
00818 LogTrace(metname)<<"[JetMETAnalyzer] Saving the histos";
00819 bool outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
00820 std::string outputFileName = parameters.getParameter<std::string>("OutputFileName");
00821
00822
00823
00824 if(theCaloMETAnalyzerFlag){
00825 theCaloMETAnalyzer->endJob();
00826
00827
00828
00829 }
00830 if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endJob();
00831 if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endJob();
00832 if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endJob();
00833
00834
00835
00836 if(theJetAnalyzerFlag) {
00837 theAKJetAnalyzer->endJob();
00838 if(theSConeJetAnalyzerFlag) theSCJetAnalyzer->endJob();
00839 if(theIConeJetAnalyzerFlag) theICJetAnalyzer->endJob();
00840 }
00841
00842 if(theJetCleaningFlag) {
00843 theCleanedAKJetAnalyzer->endJob();
00844 if(theSConeJetAnalyzerFlag) theCleanedSCJetAnalyzer->endJob();
00845 if(theIConeJetAnalyzerFlag) theCleanedICJetAnalyzer->endJob();
00846 }
00847
00848 if(theDiJetSelectionFlag) theDiJetAnalyzer->endJob();
00849
00850 if(theJetPtAnalyzerFlag ) {
00851 thePtAKJetAnalyzer->endJob();
00852 if(theSConeJetAnalyzerFlag) thePtSCJetAnalyzer->endJob();
00853 if(theIConeJetAnalyzerFlag) thePtICJetAnalyzer->endJob();
00854 }
00855
00856 if(theJetPtCleaningFlag ) {
00857 theCleanedPtAKJetAnalyzer->endJob();
00858 if(theSConeJetAnalyzerFlag) theCleanedPtSCJetAnalyzer->endJob();
00859 if(theIConeJetAnalyzerFlag) theCleanedPtICJetAnalyzer->endJob();
00860 }
00861
00862 if(theJPTJetAnalyzerFlag) theJPTJetAnalyzer->endJob();
00863 if(theJPTJetCleaningFlag) theCleanedJPTJetAnalyzer->endJob();
00864
00865 if(thePFJetAnalyzerFlag) thePFJetAnalyzer->endJob();
00866 if(thePFJetCleaningFlag) theCleanedPFJetAnalyzer->endJob();
00867 if(theDiJetSelectionFlag) thePFDiJetAnalyzer->endJob();
00868
00869 if(outputMEsInRootFile){
00870 dbe->save(outputFileName);
00871 }
00872
00873 }
00874
00875