CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFMCTruthTreeProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 
23 using namespace edm;
24 using namespace reco;
25 using namespace std;
26 //namespace cms
27 //{
28 
30 {
31  jets_ = cfg.getParameter<std::string> ("jets");
32  genjets_ = cfg.getParameter<std::string> ("genjets");
33  histogramFile_ = cfg.getParameter<std::string> ("histogramFile");
34 }
37 {
38  file_ = new TFile(histogramFile_.c_str(),"RECREATE");
39  mcTruthTree_ = new TTree("mcTruthTree","mcTruthTree");
40 
41  mcTruthTree_->Branch("ptJet", &ptJet_, "ptJet_/F");
42  mcTruthTree_->Branch("ptGen", &ptGen_, "ptGen_/F");
43  mcTruthTree_->Branch("ptHat", &ptHat_, "ptHat_/F");
44  mcTruthTree_->Branch("chfJet", &chfJet_, "chfJet_/F");
45  mcTruthTree_->Branch("nhfJet", &nhfJet_, "nhfJet_/F");
46  mcTruthTree_->Branch("cemfJet", &cemfJet_, "cemfJet_/F");
47  mcTruthTree_->Branch("nemfJet", &nemfJet_, "nemfJet_/F");
48  mcTruthTree_->Branch("cmultiJet", &cmultiJet_, "cmultiJet_/I");
49  mcTruthTree_->Branch("nmultiJet", &nmultiJet_, "nmultiJet_/I");
50  mcTruthTree_->Branch("etaJet", &etaJet_, "etaJet_/F");
51  mcTruthTree_->Branch("etaGen", &etaGen_, "etaGen_/F");
52  mcTruthTree_->Branch("phiJet", &phiJet_, "phiJet_/F");
53  mcTruthTree_->Branch("phiGen", &phiGen_, "phiGen_/F");
54  mcTruthTree_->Branch("dR", &dR_, "dR_/F");
55  mcTruthTree_->Branch("rank", &rank_, "rank_/I");
56 }
59 {
60  if (file_ !=0)
61  {
62  file_->cd();
63  mcTruthTree_->Write();
64  }
65  file_ = 0;
66 }
69 {
73  PFJetCollection::const_iterator i_jet,i_matched;
74  GenJetCollection::const_iterator i_genjet;
75  event.getByLabel (genjets_,genjets);
76  event.getByLabel (jets_,jets);
77  event.getByLabel("generator",hEventInfo);
78  ptHat_ = hEventInfo->binningValues()[0];
79  float rr;
80  int njet(0);
81  if (jets->size()>0 && genjets->size()>0)
82  {
83  for (i_genjet = genjets->begin(); i_genjet != genjets->end(); i_genjet++)
84  {
85  float rmin(99);
86  for(i_jet = jets->begin();i_jet != jets->end(); i_jet++)
87  {
88  rr=radius(i_genjet,i_jet);
89  if (rr<rmin)
90  {
91  rmin = rr;
92  i_matched = i_jet;
93  }
94  }
95  ptGen_ = i_genjet->pt();
96  etaGen_ = i_genjet->eta();
97  phiGen_ = i_genjet->phi();
98  ptJet_ = i_matched->pt();
99  etaJet_ = i_matched->eta();
100  phiJet_ = i_matched->phi();
101  chfJet_ = i_matched->chargedHadronEnergyFraction();
102  nhfJet_ = i_matched->neutralHadronEnergyFraction();
103  cemfJet_ = i_matched->chargedEmEnergyFraction();
104  nemfJet_ = i_matched->neutralEmEnergyFraction();
105  cmultiJet_ = i_matched->chargedMultiplicity();
106  nmultiJet_ = i_matched->neutralMultiplicity();
107  dR_ = rmin;
108  rank_ = njet;
109  mcTruthTree_->Fill();
110  njet++;
111  }
112  }
113 }
116 {
117  delete file_;
118  delete mcTruthTree_;
119 }
120 //}
T getParameter(std::string const &) const
int njet
Definition: HydjetWrapper.h:91
vector< PseudoJet > jets
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
virtual void analyze(edm::Event const &e, edm::EventSetup const &iSetup)
PFMCTruthTreeProducer(edm::ParameterSet const &cfg)