test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
JetValidation Class Reference

#include <JetValidation.h>

Inheritance diagram for JetValidation:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 JetValidation (edm::ParameterSet const &cfg)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
 
void beginJob ()
 
void endJob ()
 
void FillHist1D (const TString &histName, const Double_t &x)
 
void FillHist2D (const TString &histName, const Double_t &x, const Double_t &y)
 
void FillHistProfile (const TString &histName, const Double_t &x, const Double_t &y)
 

Private Attributes

std::string calAlgo
 
double dRmatch
 
std::string genAlgo
 
std::string histoFileName
 
std::string jetTracksAssociator
 
TFile * m_file
 
std::map< TString, TH1 * > m_HistNames1D
 
std::map< TString, TH2 * > m_HistNames2D
 
std::map< TString, TProfile * > m_HistNamesProfile
 
bool MCarlo
 
int Njets
 
double PtMin
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 17 of file JetValidation.h.

Constructor & Destructor Documentation

JetValidation::JetValidation ( edm::ParameterSet const &  cfg)

Definition at line 24 of file JetValidation.cc.

References edm::ParameterSet::getParameter(), diJetCalib::histoFileName, and HLT_25ns10e33_v2_cff::PtMin.

25 {
26  dRmatch = cfg.getParameter<double> ("dRmatch");
27  PtMin = cfg.getParameter<double> ("PtMin");
28  Njets = cfg.getParameter<int> ("Njets");
29  MCarlo = cfg.getParameter<bool> ("MCarlo");
30  genAlgo = cfg.getParameter<string> ("genAlgo");
31  calAlgo = cfg.getParameter<string> ("calAlgo");
32  jetTracksAssociator = cfg.getParameter<string> ("jetTracksAssociator");
33  histoFileName = cfg.getParameter<string> ("histoFileName");
34 }
tuple cfg
Definition: looper.py:293
std::string histoFileName
Definition: JetValidation.h:38
std::string jetTracksAssociator
Definition: JetValidation.h:41
std::string calAlgo
Definition: JetValidation.h:40
std::string genAlgo
Definition: JetValidation.h:39

Member Function Documentation

void JetValidation::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 81 of file JetValidation.cc.

References gather_cfg::cout, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, alignCSCRings::e, reco::CaloJet::emEnergyInEB(), reco::CaloJet::emEnergyInEE(), reco::CaloJet::emEnergyInHF(), reco::LeafCandidate::energy(), eta, reco::LeafCandidate::eta(), edm::EventID::event(), edm::Event::getByLabel(), reco::CaloJet::hadEnergyInHB(), reco::CaloJet::hadEnergyInHE(), reco::CaloJet::hadEnergyInHF(), reco::CaloJet::hadEnergyInHO(), edm::EventBase::id(), HLT_25ns10e33_v2_cff::jetTracks, ResonanceBuilder::mass, nTracks(), reco::LeafCandidate::phi(), phi(), EnergyCorrector::pt, reco::LeafCandidate::pt(), HLT_25ns10e33_v2_cff::PtMin, edm::EventID::run(), reco::JetTracksAssociation::tracksNumber(), and reco::JetTracksAssociation::tracksP4().

82 {
83  math::XYZTLorentzVector p4jet[2];
84  int jetInd,jetCounter,nTracks;
85  double dRmin,dR,e,eta,emEB,emEE,emHF,hadHB,hadHE,hadHO,hadHF,pt,phi,pthat,chf;
88  Handle<double> genEventScale;
90  CaloJetCollection::const_iterator i_caljet;
91  GenJetCollection::const_iterator i_genjet;
92  evt.getByLabel(calAlgo,caljets);
93  evt.getByLabel(jetTracksAssociator,jetTracks);
94  jetInd = 0;
95  jetCounter = 0;
96  if (caljets->size()==0)
97  cout<<"WARNING: NO calo jets in event "<<evt.id().event()<<", Run "<<evt.id().run()<<" !!!!"<<endl;
98  for(i_caljet = caljets->begin(); i_caljet != caljets->end() && jetInd<Njets; ++i_caljet)
99  {
100  e = i_caljet->energy();
101  pt = i_caljet->pt();
102  phi = i_caljet->phi();
103  eta = i_caljet->eta();
104  emEB = i_caljet->emEnergyInEB();
105  emEE = i_caljet->emEnergyInEE();
106  emHF = i_caljet->emEnergyInHF();
107  hadHB = i_caljet->hadEnergyInHB();
108  hadHE = i_caljet->hadEnergyInHE();
109  hadHO = i_caljet->hadEnergyInHO();
110  hadHF = i_caljet->hadEnergyInHF();
111  nTracks = JetTracksAssociation::tracksNumber(*jetTracks,*i_caljet);
112  chf = (JetTracksAssociation::tracksP4(*jetTracks,*i_caljet)).pt()/pt;
113  if (jetInd<2)
114  p4jet[jetInd] = i_caljet->p4();
115  if (pt>PtMin)
116  {
117  FillHist1D("ptCalo",pt);
118  FillHist1D("etaCalo",eta);
119  FillHist1D("phiCalo",phi);
120  FillHist1D("emEnergyFraction",i_caljet->emEnergyFraction());
121  FillHist1D("nTracks",nTracks);
122  FillHist1D("chargeFraction",chf);
123  FillHist1D("emEnergyInEB",emEB);
124  FillHist1D("emEnergyInEE",emEE);
125  FillHist1D("emEnergyInHF",emHF);
126  FillHist1D("hadEnergyInHB",hadHB);
127  FillHist1D("hadEnergyInHE",hadHE);
128  FillHist1D("hadEnergyInHF",hadHF);
129  FillHist1D("hadEnergyInHO",hadHO);
130  FillHistProfile("EBfractionVsEta",eta,emEB/e);
131  FillHistProfile("EEfractionVsEta",eta,emEE/e);
132  FillHistProfile("HBfractionVsEta",eta,hadHB/e);
133  FillHistProfile("HOfractionVsEta",eta,hadHO/e);
134  FillHistProfile("HEfractionVsEta",eta,hadHE/e);
135  FillHistProfile("HFfractionVsEta",eta,(hadHF+emHF)/e);
136  FillHistProfile("CaloEnergyVsEta",eta,e);
137  FillHistProfile("emEnergyVsEta",eta,emEB+emEE+emHF);
138  FillHistProfile("hadEnergyVsEta",eta,hadHB+hadHO+hadHE+hadHF);
139  jetCounter++;
140  }
141  jetInd++;
142  }
143  FillHist1D("CaloJetMulti",jetCounter);
144  if (jetInd>1)
145  FillHist1D("m2jCalo",(p4jet[0]+p4jet[1]).mass());
146  if (MCarlo)
147  {
148  evt.getByLabel(genAlgo,genjets);
149  evt.getByLabel("genEventScale",genEventScale);
150  pthat = *genEventScale;
151  FillHist1D("ptHat",pthat);
152  CaloJet MatchedJet;
153  jetInd = 0;
154  if (genjets->size()==0)
155  cout<<"WARNING: NO gen jets in event "<<evt.id().event()<<", Run "<<evt.id().run()<<" !!!!"<<endl;
156  for(i_genjet = genjets->begin(); i_genjet != genjets->end() && jetInd<Njets; ++i_genjet)
157  {
158  if (jetInd<2)
159  p4jet[jetInd] = i_genjet->p4();
160  FillHist1D("ptGen",i_genjet->pt());
161  FillHist1D("etaGen",i_genjet->eta());
162  FillHist1D("phiGen",i_genjet->phi());
163  FillHistProfile("GenEnergyVsEta",i_genjet->eta(),i_genjet->energy());
164  dRmin=1000.0;
165  for(i_caljet = caljets->begin(); i_caljet != caljets->end(); ++i_caljet)
166  {
167  dR = deltaR(i_caljet->eta(),i_caljet->phi(),i_genjet->eta(),i_genjet->phi());
168  if (dR<dRmin)
169  {
170  dRmin = dR;
171  MatchedJet = *i_caljet;
172  }
173  }
174  FillHist1D("dR",dRmin);
175  e = MatchedJet.energy();
176  pt = MatchedJet.pt();
177  eta = MatchedJet.eta();
178  phi = MatchedJet.phi();
179  emEB = MatchedJet.emEnergyInEB();
180  emEE = MatchedJet.emEnergyInEE();
181  emHF = MatchedJet.emEnergyInHF();
182  hadHB = MatchedJet.hadEnergyInHB();
183  hadHE = MatchedJet.hadEnergyInHE();
184  hadHO = MatchedJet.hadEnergyInHO();
185  hadHF = MatchedJet.hadEnergyInHF();
186  if (dRmin<dRmatch && pt>PtMin)
187  {
188  FillHistProfile("CaloErespVsEta",eta,e/i_genjet->energy());
189  FillHistProfile("emErespVsEta",eta,(emEB+emEE+emHF)/i_genjet->energy());
190  FillHistProfile("hadErespVsEta",eta,(hadHB+hadHO+hadHE+hadHF)/i_genjet->energy());
191  if (fabs(i_genjet->eta())<1.)
192  FillHistProfile("respVsPtBarrel",i_genjet->pt(),pt/i_genjet->pt());
193  }
194  jetInd++;
195  }
196  FillHist1D("GenJetMulti",jetInd);
197  if (jetInd>1)
198  FillHist1D("m2jGen",(p4jet[0]+p4jet[1]).mass());
199  }
200 }
float hadEnergyInHE() const
Definition: CaloJet.h:108
float emEnergyInEE() const
Definition: CaloJet.h:114
const unsigned int nTracks(const reco::Vertex &sv)
Jets made from CaloTowers.
Definition: CaloJet.h:29
virtual double energy() const final
energy
virtual double phi() const final
momentum azimuthal angle
float emEnergyInHF() const
Definition: CaloJet.h:116
void FillHist1D(const TString &histName, const Double_t &x)
void FillHistProfile(const TString &histName, const Double_t &x, const Double_t &y)
float hadEnergyInHO() const
Definition: CaloJet.h:106
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float emEnergyInEB() const
Definition: CaloJet.h:112
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::string jetTracksAssociator
Definition: JetValidation.h:41
LorentzVector tracksP4(const Container &, const reco::JetBaseRef)
Get LorentzVector as sum of all tracks associated with jet.
std::string calAlgo
Definition: JetValidation.h:40
std::string genAlgo
Definition: JetValidation.h:39
float hadEnergyInHB() const
Definition: CaloJet.h:104
int tracksNumber(const Container &, const reco::JetBaseRef)
Get number of tracks associated with jet.
tuple cout
Definition: gather_cfg.py:145
virtual double eta() const final
momentum pseudorapidity
float hadEnergyInHF() const
Definition: CaloJet.h:110
virtual double pt() const final
transverse momentum
void JetValidation::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 36 of file JetValidation.cc.

References diJetCalib::histoFileName, and M_PI.

37 {
38  m_file = new TFile(histoFileName.c_str(),"RECREATE");
39 
40  m_HistNames1D["CaloJetMulti"] = new TH1F("CaloJetMulti","Multiplicity of CaloJets",100,0,100);
41  m_HistNames1D["ptCalo"] = new TH1F("ptCalo","p_{T} of CaloJets",7000,0,7000);
42  m_HistNames1D["etaCalo"] = new TH1F("etaCalo","#eta of CaloJets",100,-5.0,5.0);
43  m_HistNames1D["phiCalo"] = new TH1F("phiCalo","#phi of CaloJets",72,-M_PI, M_PI);
44  m_HistNames1D["m2jCalo"] = new TH1F("m2jCalo","Dijet Mass of leading CaloJets",7000,0,14000);
45  m_HistNames1D["nTracks"] = new TH1F("nTracks","Number of tracks associated with a jet",100,0,100);
46  m_HistNames1D["chargeFraction"] = new TH1F("chargeFraction","Fraction of charged tracks pt",500,0,5);
47  m_HistNames1D["emEnergyFraction"] = new TH1F("emEnergyFraction","Jets EM Fraction",110,0,1.1);
48  m_HistNames1D["emEnergyInEB"] = new TH1F("emEnergyInEB","Jets emEnergyInEB",7000,0,14000);
49  m_HistNames1D["emEnergyInEE"] = new TH1F("emEnergyInEE","Jets emEnergyInEE",7000,0,14000);
50  m_HistNames1D["emEnergyInHF"] = new TH1F("emEnergyInHF","Jets emEnergyInHF",7000,0,14000);
51  m_HistNames1D["hadEnergyInHB"] = new TH1F("hadEnergyInHB","Jets hadEnergyInHB",7000,0,14000);
52  m_HistNames1D["hadEnergyInHE"] = new TH1F("hadEnergyInHE","Jets hadEnergyInHE",7000,0,14000);
53  m_HistNames1D["hadEnergyInHF"] = new TH1F("hadEnergyInHF","Jets hadEnergyInHF",7000,0,14000);
54  m_HistNames1D["hadEnergyInHO"] = new TH1F("hadEnergyInHO","Jets hadEnergyInHO",7000,0,14000);
55  m_HistNamesProfile["EBfractionVsEta"] = new TProfile("EBfractionVsEta","Jets EBfraction vs #eta",100,-5.0,5.0);
56  m_HistNamesProfile["EEfractionVsEta"] = new TProfile("EEfractionVsEta","Jets EEfraction vs #eta",100,-5.0,5.0);
57  m_HistNamesProfile["HBfractionVsEta"] = new TProfile("HBfractionVsEta","Jets HBfraction vs #eta",100,-5.0,5.0);
58  m_HistNamesProfile["HOfractionVsEta"] = new TProfile("HOfractionVsEta","Jets HOfraction vs #eta",100,-5.0,5.0);
59  m_HistNamesProfile["HEfractionVsEta"] = new TProfile("HEfractionVsEta","Jets HEfraction vs #eta",100,-5.0,5.0);
60  m_HistNamesProfile["HFfractionVsEta"] = new TProfile("HFfractionVsEta","Jets HFfraction vs #eta",100,-5.0,5.0);
61  m_HistNamesProfile["CaloEnergyVsEta"] = new TProfile("CaloEnergyVsEta","CaloJets Energy Vs. Eta",100,-5.0,5.0);
62  m_HistNamesProfile["emEnergyVsEta"] = new TProfile("emEnergyVsEta","Jets EM Energy Vs. Eta",100,-5.0,5.0);
63  m_HistNamesProfile["hadEnergyVsEta"] = new TProfile("hadEnergyVsEta","Jets HAD Energy Vs. Eta",100,-5.0,5.0);
64  if (MCarlo)
65  {
66  m_HistNames1D["GenJetMulti"] = new TH1F("GenJetMulti","Multiplicity of GenJets",100,0,100);
67  m_HistNames1D["ptHat"] = new TH1F("ptHat","p_{T}hat",7000,0,7000);
68  m_HistNames1D["ptGen"] = new TH1F("ptGen","p_{T} of GenJets",7000,0,7000);
69  m_HistNames1D["etaGen"] = new TH1F("etaGen","#eta of GenJets",100,-5.0,5.0);
70  m_HistNames1D["phiGen"] = new TH1F("phiGen","#phi of GenJets",72,-M_PI, M_PI);
71  m_HistNames1D["m2jGen"] = new TH1F("m2jGen","Dijet Mass of leading GenJets",7000,0,14000);
72  m_HistNames1D["dR"] = new TH1F("dR","GenJets dR with matched CaloJet",200,0,1);
73  m_HistNamesProfile["GenEnergyVsEta"] = new TProfile("GenEnergyVsEta","GenJets Energy Vs. Eta",100,-5.0,5.0);
74  m_HistNamesProfile["respVsPtBarrel"] = new TProfile("respVsPtBarrel","CaloJet Response of GenJets in Barrel",7000,0,7000);
75  m_HistNamesProfile["CaloErespVsEta"] = new TProfile("CaloErespVsEta","Jets Energy Response Vs. Eta",100,-5.0,5.0);
76  m_HistNamesProfile["emErespVsEta"] = new TProfile("emErespVsEta","Jets EM Energy Response Vs. Eta",100,-5.0,5.0);
77  m_HistNamesProfile["hadErespVsEta"] = new TProfile("hadErespVsEta","Jets HAD Energy Response Vs. Eta",100,-5.0,5.0);
78  }
79 }
std::map< TString, TH1 * > m_HistNames1D
Definition: JetValidation.h:29
std::map< TString, TProfile * > m_HistNamesProfile
Definition: JetValidation.h:31
#define M_PI
std::string histoFileName
Definition: JetValidation.h:38
TFile * m_file
Definition: JetValidation.h:32
void JetValidation::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 202 of file JetValidation.cc.

203 {
205  if (m_file !=0)
206  {
207  m_file->cd();
208  for (std::map<TString, TH1*>::iterator hid = m_HistNames1D.begin(); hid != m_HistNames1D.end(); hid++)
209  hid->second->Write();
210  for (std::map<TString, TH2*>::iterator hid = m_HistNames2D.begin(); hid != m_HistNames2D.end(); hid++)
211  hid->second->Write();
212  for (std::map<TString, TProfile*>::iterator hid = m_HistNamesProfile.begin(); hid != m_HistNamesProfile.end(); hid++)
213  hid->second->Write();
214  delete m_file;
215  m_file = 0;
216  }
217 }
std::map< TString, TH2 * > m_HistNames2D
Definition: JetValidation.h:30
std::map< TString, TH1 * > m_HistNames1D
Definition: JetValidation.h:29
std::map< TString, TProfile * > m_HistNamesProfile
Definition: JetValidation.h:31
TFile * m_file
Definition: JetValidation.h:32
void JetValidation::FillHist1D ( const TString &  histName,
const Double_t &  x 
)
private

Definition at line 219 of file JetValidation.cc.

References gather_cfg::cout.

220 {
221  std::map<TString, TH1*>::iterator hid=m_HistNames1D.find(histName);
222  if (hid==m_HistNames1D.end())
223  std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
224  else
225  hid->second->Fill(value);
226 }
std::map< TString, TH1 * > m_HistNames1D
Definition: JetValidation.h:29
tuple cout
Definition: gather_cfg.py:145
void JetValidation::FillHist2D ( const TString &  histName,
const Double_t &  x,
const Double_t &  y 
)
private

Definition at line 228 of file JetValidation.cc.

References gather_cfg::cout.

229 {
230  std::map<TString, TH2*>::iterator hid=m_HistNames2D.find(histName);
231  if (hid==m_HistNames2D.end())
232  std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
233  else
234  hid->second->Fill(valuex,valuey);
235 }
std::map< TString, TH2 * > m_HistNames2D
Definition: JetValidation.h:30
tuple cout
Definition: gather_cfg.py:145
void JetValidation::FillHistProfile ( const TString &  histName,
const Double_t &  x,
const Double_t &  y 
)
private

Definition at line 237 of file JetValidation.cc.

References gather_cfg::cout.

238 {
239  std::map<TString, TProfile*>::iterator hid=m_HistNamesProfile.find(histName);
240  if (hid==m_HistNamesProfile.end())
241  std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
242  else
243  hid->second->Fill(valuex,valuey);
244 }
std::map< TString, TProfile * > m_HistNamesProfile
Definition: JetValidation.h:31
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

std::string JetValidation::calAlgo
private

Definition at line 40 of file JetValidation.h.

double JetValidation::dRmatch
private

Definition at line 35 of file JetValidation.h.

std::string JetValidation::genAlgo
private

Definition at line 39 of file JetValidation.h.

std::string JetValidation::histoFileName
private

Definition at line 38 of file JetValidation.h.

std::string JetValidation::jetTracksAssociator
private

Definition at line 41 of file JetValidation.h.

TFile* JetValidation::m_file
private

Definition at line 32 of file JetValidation.h.

std::map<TString, TH1*> JetValidation::m_HistNames1D
private

Definition at line 29 of file JetValidation.h.

std::map<TString, TH2*> JetValidation::m_HistNames2D
private

Definition at line 30 of file JetValidation.h.

std::map<TString, TProfile*> JetValidation::m_HistNamesProfile
private

Definition at line 31 of file JetValidation.h.

bool JetValidation::MCarlo
private

Definition at line 37 of file JetValidation.h.

int JetValidation::Njets
private

Definition at line 36 of file JetValidation.h.

double JetValidation::PtMin
private

Definition at line 34 of file JetValidation.h.