CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AnalysisTasksAnalyzerJEC.cc
Go to the documentation of this file.
5 #include "TH2.h"
6 #include "TProfile.h"
9  edm::BasicAnalyzer::BasicAnalyzer(cfg, fs),
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 {
15 
16  hists_["Response" ] = fs.make<TH2F>("Response" , "response; #eta;p_{T}(reco)/p_{T}(gen)" , 5, -3.3, 3.3, 100, 0.4, 1.6);
17  jetInEvents_=0;
18 }
21 {
22 
24  TFile* file=new TFile("myResponse"+TString(jecLevel_)+".root", "RECREATE");
25  TProfile* prof = hists_["Response" ]->ProfileX();
26  prof->Write();
27  file->Write();
28  file->Close();
29 }
31 void
33 {
34  // define what Jet you are using; this is necessary as FWLite is not
35  // capable of reading edm::Views
36  using pat::Jet;
37 
38  // Handle to the Jet collection
40  event.getByLabel(Jets_, Jets);
41 
42  // loop Jet collection and fill histograms
43  for(std::vector<Jet>::const_iterator jet_it=Jets->begin(); jet_it!=Jets->end(); ++jet_it){
44 
45 
47  if(help_==true){
48  if(jetInEvents_==0){
49  std::cout<<"\n \n number of available JEC sets: "<< jet_it->availableJECSets().size() << std::endl;
50  for(unsigned int k=0; k< jet_it->availableJECSets().size(); ++k){
51  std::cout<<"\n \n available JEC Set: "<< jet_it->availableJECSets()[k] << std::endl;
52  }
53  std::cout<<"\n \n*** You found out which JEC Sets exist! Now correct it in your config file."<<std::endl;
54  std::cout<<"\n \n number of available JEC levels "<< jet_it->availableJECLevels().size() << std::endl;
55  for(unsigned int k=0; k< jet_it->availableJECLevels().size(); ++k){
56  std::cout<<"\n \n available JEC: "<< jet_it->availableJECLevels(patJetCorrFactors_)[k] << std::endl;
57  }
58  std::cout<<"\n \n**** You did it correctly congratulations!!!! And you found out which JEC levels are saved within the jets. Correct this in your configuration file." <<std::endl;
59  }
60  }
61 
62  if(jet_it->genParticlesSize()>0){
63  hists_["Response" ]->Fill( jet_it->correctedJet(jecLevel_).eta(), jet_it->correctedJet(jecLevel_).pt()/ jet_it->genParticle(0)->pt());
64  std::cout<<"\n \n**** You did it correctly congratulations!!!! "<< std::endl;
65  }
66  jetInEvents_+=1;
67  }
68 }
AnalysisTasksAnalyzerJEC(const edm::ParameterSet &cfg, TFileDirectory &fs)
default constructor
edm::InputTag Jets_
input tag for mouns
void analyze(const edm::EventBase &event)
everything that needs to be done during the event loop
virtual ~AnalysisTasksAnalyzerJEC()
default destructor
Abstract base class for FWLite and EDM friendly analyzers.
tuple Jets
Definition: METSkim_cff.py:17
T * make(const Args &...args) const
make new ROOT object
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int k[5][pyjets_maxn]
Analysis-level calorimeter jet class.
Definition: Jet.h:70
std::map< std::string, TH2 * > hists_
histograms
tuple cout
Definition: gather_cfg.py:121