CMS 3D CMS Logo

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 () override
 default destructor More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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
 
- 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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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 42 of file PatJetAnalyzer.cc.

Constructor & Destructor Documentation

◆ PatJetAnalyzer()

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

default contructor

Definition at line 72 of file PatJetAnalyzer.cc.

73  : corrLevel_(cfg.getParameter<std::string>("corrLevel")),
74  jetsToken_(consumes<edm::View<pat::Jet> >(cfg.getParameter<edm::InputTag>("src"))) {
75  // register TFileService
77 
78  // jet multiplicity
79  hists_["mult"] = fs->make<TH1F>("mult", "N_{Jet}", 15, 0., 15.);
80  // jet pt (for all jets)
81  hists_["pt"] = fs->make<TH1F>("pt", "p_{T}(Jet) [GeV]", 60, 0., 300.);
82  // jet eta (for all jets)
83  hists_["eta"] = fs->make<TH1F>("eta", "#eta (Jet)", 60, -3., 3.);
84  // jet phi (for all jets)
85  hists_["phi"] = fs->make<TH1F>("phi", "#phi (Jet)", 60, 3.2, 3.2);
86  // dijet mass (if available)
87  hists_["mass"] = fs->make<TH1F>("mass", "M_{jj} [GeV]", 50, 0., 500.);
88  // basic histograms for jet energy response
89  for (unsigned int idx = 0; idx < MAXBIN; ++idx) {
90  char buffer[10];
91  sprintf(buffer, "jes_%i", idx);
92  char title[50];
93  sprintf(title, "p_{T}^{rec}/p_{T}^{gen} [%i GeV - %i GeV]", (int)BINS[idx], (int)BINS[idx + 1]);
94  hists_[buffer] = fs->make<TH1F>(buffer, title, 100, 0., 2.);
95  }
96 }

References BINS, edmScanValgrind::buffer, hists_, heavyIonCSV_trainingSettings::idx, TFileService::make(), MAXBIN, and runGCPTkAlMap::title.

◆ ~PatJetAnalyzer()

PatJetAnalyzer::~PatJetAnalyzer ( )
inlineoverride

default destructor

Definition at line 47 of file PatJetAnalyzer.cc.

47 {};

Member Function Documentation

◆ analyze()

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.

98  {
99  // recieve jet collection label
101  event.getByToken(jetsToken_, jets);
102 
103  // loop jets
104  for (edm::View<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
105  // print jec factors
106  // print(jet, jet-jets->begin());
107 
108  // fill basic kinematics
109  fill("pt", jet->correctedJet(corrLevel_).pt());
110  fill("eta", jet->eta());
111  fill("phi", jet->phi());
112  // basic plots for jet responds plot as a function of pt
113  if (jet->genJet()) {
114  double resp = jet->correctedJet(corrLevel_).pt() / jet->genJet()->pt();
115  for (unsigned int idx = 0; idx < MAXBIN; ++idx) {
116  if (BINS[idx] <= jet->genJet()->pt() && jet->genJet()->pt() < BINS[idx + 1]) {
117  char buffer[10];
118  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) {
128  fill("mass", ((*jets)[0].p4() + (*jets)[1].p4()).mass());
129  }
130 }

References BINS, edmScanValgrind::buffer, corrLevel_, fill(), heavyIonCSV_trainingSettings::idx, metsig::jet, singleTopDQM_cfi::jets, jetsToken_, EgHLTOffHistBins_cfi::mass, MAXBIN, and p4.

◆ booked()

bool PatJetAnalyzer::booked ( const std::string  histName) const
inlineprivate

check if histogram was booked

Definition at line 54 of file PatJetAnalyzer.cc.

54 { return hists_.find(histName) != hists_.end(); };

References hists_.

Referenced by fill().

◆ fill()

void PatJetAnalyzer::fill ( const std::string  histName,
double  value 
) const
inlineprivate

fill histogram if it had been booked before

Definition at line 56 of file PatJetAnalyzer.cc.

56  {
57  if (booked(histName))
58  hists_.find(histName)->second->Fill(value);
59  };

References booked(), and hists_.

Referenced by analyze().

◆ print()

void PatJetAnalyzer::print ( edm::View< pat::Jet >::const_iterator &  jet,
unsigned int  idx 
)
private

Definition at line 132 of file PatJetAnalyzer.cc.

132  {
133  //edm::LogInfo log("JEC");
134  std::cout << "[" << idx << "] :: eta=" << std::setw(10) << jet->eta() << " phi=" << std::setw(10) << jet->phi()
135  << " size: " << jet->availableJECLevels().size() << std::endl;
136  for (unsigned int idx = 0; idx < jet->availableJECLevels().size(); ++idx) {
137  pat::Jet correctedJet;
138  if (jet->availableJECLevels()[idx].find("L5Flavor") != std::string::npos ||
139  jet->availableJECLevels()[idx].find("L7Parton") != std::string::npos) {
140  correctedJet = jet->correctedJet(idx, pat::JetCorrFactors::UDS);
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()
145  << std::endl;
146  }
147 }

References gather_cfg::cout, pat::Jet::currentJECLevel(), heavyIonCSV_trainingSettings::idx, metsig::jet, pat::JetCorrFactors::NONE, reco::LeafCandidate::pt(), and pat::JetCorrFactors::UDS.

Member Data Documentation

◆ corrLevel_

std::string PatJetAnalyzer::corrLevel_
private

correction level for pat jet

Definition at line 65 of file PatJetAnalyzer.cc.

Referenced by analyze().

◆ hists_

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

management of 1d histograms

Definition at line 69 of file PatJetAnalyzer.cc.

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

◆ jetsToken_

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

pat jets

Definition at line 67 of file PatJetAnalyzer.cc.

Referenced by analyze().

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
gather_cfg.cout
cout
Definition: gather_cfg.py:144
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
edm::Handle
Definition: AssociativeIterator.h:50
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
PatJetAnalyzer::hists_
std::map< std::string, TH1F * > hists_
management of 1d histograms
Definition: PatJetAnalyzer.cc:69
PatJetAnalyzer::booked
bool booked(const std::string histName) const
check if histogram was booked
Definition: PatJetAnalyzer.cc:54
pat::Jet::currentJECLevel
std::string currentJECLevel() const
return the name of the current step of jet energy corrections
Definition: Jet.h:141
pat::JetCorrFactors::UDS
Definition: JetCorrFactors.h:46
MAXBIN
static const unsigned int MAXBIN
Definition: PatJetAnalyzer.cc:21
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
edm::Service< TFileService >
p4
double p4[4]
Definition: TauolaWrapper.h:92
value
Definition: value.py:1
looper.cfg
cfg
Definition: looper.py:297
PatJetAnalyzer::corrLevel_
std::string corrLevel_
correction level for pat jet
Definition: PatJetAnalyzer.cc:65
PatJetAnalyzer::fill
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
Definition: PatJetAnalyzer.cc:56
metsig::jet
Definition: SignAlgoResolutions.h:47
PatJetAnalyzer::jetsToken_
edm::EDGetTokenT< edm::View< pat::Jet > > jetsToken_
pat jets
Definition: PatJetAnalyzer.cc:67
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
pat::JetCorrFactors::NONE
Definition: JetCorrFactors.h:46
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
BINS
static const float BINS[]
Definition: PatJetAnalyzer.cc:25