CMS 3D CMS Logo

AnalysisTasksAnalyzerJEC.cc
Go to the documentation of this file.
5 #include "TH2.h"
6 #include "TProfile.h"
10  Jets_(cfg.getParameter<edm::InputTag>("Jets")),
11  jecLevel_(cfg.getParameter<std::string>("jecLevel")),
12  patJetCorrFactors_(cfg.getParameter<std::string>("patJetCorrFactors")),
13  help_(cfg.getParameter<bool>("help")) {
14  hists_["Response"] = fs.make<TH2F>("Response", "response; #eta;p_{T}(reco)/p_{T}(gen)", 5, -3.3, 3.3, 100, 0.4, 1.6);
15  jetInEvents_ = 0;
16 }
18  TFileDirectory& fs,
21  Jets_(cfg.getParameter<edm::InputTag>("Jets")),
22  JetsToken_(iC.consumes<std::vector<pat::Jet> >(Jets_)),
23  jecLevel_(cfg.getParameter<std::string>("jecLevel")),
24  patJetCorrFactors_(cfg.getParameter<std::string>("patJetCorrFactors")),
25  help_(cfg.getParameter<bool>("help")) {
26  hists_["Response"] = fs.make<TH2F>("Response", "response; #eta;p_{T}(reco)/p_{T}(gen)", 5, -3.3, 3.3, 100, 0.4, 1.6);
27  jetInEvents_ = 0;
28 }
32  TFile* file = new TFile("myResponse" + TString(jecLevel_) + ".root", "RECREATE");
33  TProfile* prof = hists_["Response"]->ProfileX();
34  prof->Write();
35  file->Write();
36  file->Close();
37 }
40  // define what Jet you are using; this is necessary as FWLite is not
41  // capable of reading edm::Views
42  using pat::Jet;
43 
44  // Handle to the Jet collection
46  event.getByLabel(Jets_, Jets);
47 
48  // loop Jet collection and fill histograms
49  for (std::vector<Jet>::const_iterator jet_it = Jets->begin(); jet_it != Jets->end(); ++jet_it) {
51  if (help_ == true) {
52  if (jetInEvents_ == 0) {
53  std::cout << "\n \n number of available JEC sets: " << jet_it->availableJECSets().size() << std::endl;
54  for (unsigned int k = 0; k < jet_it->availableJECSets().size(); ++k) {
55  std::cout << "\n \n available JEC Set: " << jet_it->availableJECSets()[k] << std::endl;
56  }
57  std::cout << "\n \n*** You found out which JEC Sets exist! Now correct it in your config file." << std::endl;
58  std::cout << "\n \n number of available JEC levels " << jet_it->availableJECLevels().size() << std::endl;
59  for (unsigned int k = 0; k < jet_it->availableJECLevels().size(); ++k) {
60  std::cout << "\n \n available JEC: " << jet_it->availableJECLevels(patJetCorrFactors_)[k] << std::endl;
61  }
62  std::cout << "\n \n**** You did it correctly congratulations!!!! And you found out which JEC levels are saved "
63  "within the jets. Correct this in your configuration file."
64  << std::endl;
65  }
66  }
67 
68  if (jet_it->genParticlesSize() > 0) {
69  hists_["Response"]->Fill(jet_it->correctedJet(jecLevel_).eta(),
70  jet_it->correctedJet(jecLevel_).pt() / jet_it->genParticle(0)->pt());
71  std::cout << "\n \n**** You did it correctly congratulations!!!! " << std::endl;
72  }
73  jetInEvents_ += 1;
74  }
75 }
AnalysisTasksAnalyzerJEC.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
TFileDirectory::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileDirectory.h:53
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
Jet.h
TFileDirectory
Definition: TFileDirectory.h:24
edm::Handle
Definition: AssociativeIterator.h:50
AnalysisTasksAnalyzerJEC::AnalysisTasksAnalyzerJEC
AnalysisTasksAnalyzerJEC(const edm::ParameterSet &cfg, TFileDirectory &fs)
default constructor
Definition: AnalysisTasksAnalyzerJEC.cc:8
AnalysisTasksAnalyzerJEC::jecLevel_
std::string jecLevel_
Definition: AnalysisTasksAnalyzerJEC.h:37
Jet
Definition: Jet.py:1
BasicAnalyzer
Abstract base class for FWLite and EDM friendly analyzers.
L1TRate_cfi.Jet
Jet
Definition: L1TRate_cfi.py:43
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AnalysisTasksAnalyzerJEC::~AnalysisTasksAnalyzerJEC
~AnalysisTasksAnalyzerJEC() override
default destructor
Definition: AnalysisTasksAnalyzerJEC.cc:30
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
AnalysisTasksAnalyzerJEC::help_
bool help_
Definition: AnalysisTasksAnalyzerJEC.h:39
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
pat
Definition: HeavyIon.h:7
Jet.h
AnalysisTasksAnalyzerJEC::hists_
std::map< std::string, TH2 * > hists_
histograms
Definition: AnalysisTasksAnalyzerJEC.h:42
METSkim_cff.Jets
Jets
Definition: METSkim_cff.py:17
looper.cfg
cfg
Definition: looper.py:297
AnalysisTasksAnalyzerJEC::jetInEvents_
unsigned int jetInEvents_
Definition: AnalysisTasksAnalyzerJEC.h:40
AnalysisTasksAnalyzerJEC::patJetCorrFactors_
std::string patJetCorrFactors_
Definition: AnalysisTasksAnalyzerJEC.h:38
AnalysisTasksAnalyzerJEC::analyze
void analyze(const edm::EventBase &event) override
everything that needs to be done during the event loop
Definition: AnalysisTasksAnalyzerJEC.cc:39
std
Definition: JetResolutionObject.h:76
edm::EventBase
Definition: EventBase.h:46
AnalysisTasksAnalyzerJEC::Jets_
edm::InputTag Jets_
input tag for mouns
Definition: AnalysisTasksAnalyzerJEC.h:35
event
Definition: event.py:1
edm::ConsumesCollector
Definition: ConsumesCollector.h:45