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
PatJetAnalyzer Class Reference

Module to analyze pat::Jets in the context of a more complex exercise. More...

Inheritance diagram for PatJetAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 PatJetAnalyzer (const edm::ParameterSet &cfg)
 default contructor More...
 
 ~PatJetAnalyzer ()
 default destructor More...
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 everything that needs to be done during the even loop More...
 
bool booked (const std::string histName) const
 check if histogram was booked More...
 
void fill (const std::string histName, double value) const
 fill histogram if it had been booked before More...
 
void print (edm::View< pat::Jet >::const_iterator &jet, unsigned int idx)
 

Private Attributes

std::string corrLevel_
 correction level for pat jet More...
 
std::map< std::string, TH1F * > hists_
 management of 1d histograms More...
 
edm::EDGetTokenT< edm::View
< pat::Jet > > 
jetsToken_
 pat jets More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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

Module to analyze pat::Jets in the context of a more complex exercise.

Basic quantities of jets like the transverse momentum, eta and phi as well as the invariant dijet mass are plotted. Basic histograms for a jet energy response plot as a function of the pt of the reference object are filled. As reference matched partons are chosen. Input parameters are:

Definition at line 43 of file PatJetAnalyzer.cc.

Constructor & Destructor Documentation

PatJetAnalyzer::PatJetAnalyzer ( const edm::ParameterSet cfg)
explicit

default contructor

Definition at line 72 of file PatJetAnalyzer.cc.

References BINS, hists_, customizeTrackingMonitorSeedNumber::idx, TFileService::make(), MAXBIN, and indexGen::title.

72  :
73  corrLevel_(cfg.getParameter<std::string>("corrLevel")),
75 {
76  // register TFileService
78 
79  // jet multiplicity
80  hists_["mult" ]=fs->make<TH1F>("mult" , "N_{Jet}" , 15, 0., 15.);
81  // jet pt (for all jets)
82  hists_["pt" ]=fs->make<TH1F>("pt" , "p_{T}(Jet) [GeV]" , 60, 0., 300.);
83  // jet eta (for all jets)
84  hists_["eta" ]=fs->make<TH1F>("eta" , "#eta (Jet)" , 60, -3., 3.);
85  // jet phi (for all jets)
86  hists_["phi" ]=fs->make<TH1F>("phi" , "#phi (Jet)" , 60, 3.2, 3.2);
87  // dijet mass (if available)
88  hists_["mass" ]=fs->make<TH1F>("mass" , "M_{jj} [GeV]" , 50, 0., 500.);
89  // basic histograms for jet energy response
90  for(unsigned int idx=0; idx<MAXBIN; ++idx){
91  char buffer [10]; sprintf (buffer, "jes_%i", idx);
92  char title [50]; sprintf (title , "p_{T}^{rec}/p_{T}^{gen} [%i GeV - %i GeV]", (int)BINS[idx], (int)BINS[idx+1]);
93  hists_[buffer]=fs->make<TH1F>(buffer, title, 100, 0., 2.);
94  }
95 }
T getParameter(std::string const &) const
std::string corrLevel_
correction level for pat jet
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Jet > > jetsToken_
pat jets
std::map< std::string, TH1F * > hists_
management of 1d histograms
static const float BINS[]
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static const unsigned int MAXBIN
PatJetAnalyzer::~PatJetAnalyzer ( )
inline

default destructor

Definition at line 49 of file PatJetAnalyzer.cc.

49 {};

Member Function Documentation

void PatJetAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

everything that needs to be done during the even loop

Implements edm::EDAnalyzer.

Definition at line 98 of file PatJetAnalyzer.cc.

References BINS, corrLevel_, fill(), customizeTrackingMonitorSeedNumber::idx, metsig::jet, fwrapper::jets, jetsToken_, MAXBIN, and p4.

99 {
100  // recieve jet collection label
102  event.getByToken(jetsToken_,jets);
103 
104  // loop jets
105  for(edm::View<pat::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
106  // print jec factors
107  // print(jet, jet-jets->begin());
108 
109  // fill basic kinematics
110  fill( "pt" , jet->correctedJet(corrLevel_).pt());
111  fill( "eta", jet->eta());
112  fill( "phi", jet->phi());
113  // basic plots for jet responds plot as a function of pt
114  if( jet->genJet() ){
115  double resp=jet->correctedJet(corrLevel_).pt()/jet->genJet()->pt();
116  for(unsigned int idx=0; idx<MAXBIN; ++idx){
117  if(BINS[idx]<=jet->genJet()->pt() && jet->genJet()->pt()<BINS[idx+1]){
118  char buffer [10]; sprintf (buffer, "jes_%i", idx);
119  fill( buffer, resp );
120  }
121  }
122  }
123  }
124  // jet multiplicity
125  fill( "mult" , jets->size());
126  // invariant dijet mass for first two leading jets
127  if(jets->size()>1){ fill( "mass", ((*jets)[0].p4()+(*jets)[1].p4()).mass());}
128 }
std::string corrLevel_
correction level for pat jet
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
edm::EDGetTokenT< edm::View< pat::Jet > > jetsToken_
pat jets
double p4[4]
Definition: TauolaWrapper.h:92
static const float BINS[]
vector< PseudoJet > jets
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static const unsigned int MAXBIN
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool PatJetAnalyzer::booked ( const std::string  histName) const
inlineprivate

check if histogram was booked

Definition at line 56 of file PatJetAnalyzer.cc.

References hists_.

Referenced by fill().

56 { return hists_.find(histName.c_str())!=hists_.end(); };
std::map< std::string, TH1F * > hists_
management of 1d histograms
void PatJetAnalyzer::fill ( const std::string  histName,
double  value 
) const
inlineprivate

fill histogram if it had been booked before

Definition at line 58 of file PatJetAnalyzer.cc.

References booked(), hists_, and edm::second().

Referenced by analyze().

58 { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(value); };
U second(std::pair< T, U > const &p)
std::map< std::string, TH1F * > hists_
management of 1d histograms
bool booked(const std::string histName) const
check if histogram was booked
void PatJetAnalyzer::print ( edm::View< pat::Jet >::const_iterator &  jet,
unsigned int  idx 
)
private

Definition at line 131 of file PatJetAnalyzer.cc.

References gather_cfg::cout, pat::Jet::currentJECLevel(), customizeTrackingMonitorSeedNumber::idx, pat::JetCorrFactors::NONE, reco::LeafCandidate::pt(), edm::View< T >::size(), and pat::JetCorrFactors::UDS.

132 {
133  //edm::LogInfo log("JEC");
134  std::cout << "[" << idx << "] :: eta=" << std::setw(10) << jet->eta() << " phi=" << std::setw(10) << jet->phi() << " size: " << jet->availableJECLevels().size() << std::endl;
135  for(unsigned int idx=0; idx<jet->availableJECLevels().size(); ++idx){
136  pat::Jet correctedJet;
137  if(jet->availableJECLevels()[idx].find("L5Flavor")!=std::string::npos||
138  jet->availableJECLevels()[idx].find("L7Parton")!=std::string::npos ){
139  correctedJet=jet->correctedJet(idx, pat::JetCorrFactors::UDS);
140  }
141  else{
142  correctedJet=jet->correctedJet(idx, pat::JetCorrFactors::NONE );
143  }
144  std::cout << std::setw(10) << correctedJet.currentJECLevel() << " pt=" << std::setw(10) << correctedJet.pt() << std::endl;
145  }
146 }
size_type size() const
virtual double pt() const
transverse momentum
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::string currentJECLevel() const
return the name of the current step of jet energy corrections
Definition: Jet.h:138
Analysis-level calorimeter jet class.
Definition: Jet.h:77
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

std::string PatJetAnalyzer::corrLevel_
private

correction level for pat jet

Definition at line 64 of file PatJetAnalyzer.cc.

Referenced by analyze().

std::map<std::string,TH1F*> PatJetAnalyzer::hists_
private

management of 1d histograms

Definition at line 68 of file PatJetAnalyzer.cc.

Referenced by booked(), fill(), and PatJetAnalyzer().

edm::EDGetTokenT<edm::View<pat::Jet> > PatJetAnalyzer::jetsToken_
private

pat jets

Definition at line 66 of file PatJetAnalyzer.cc.

Referenced by analyze().