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