CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TauJetCorrectorExample Class Reference

#include <MyTauAndHLTAnalyzer/TauJetCorrectorExample/src/TauJetCorrectorExample.cc>

Inheritance diagram for TauJetCorrectorExample:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 TauJetCorrectorExample (const edm::ParameterSet &)
 
 ~TauJetCorrectorExample () override
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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 &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::string jetname
 
int nEvt
 
int njets
 
edm::EDGetTokenT< reco::JetCorrectortauCorrectortoken
 
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollectiontautoken
 

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 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>
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 60 of file TauJetCorrectorExample.cc.

Constructor & Destructor Documentation

◆ TauJetCorrectorExample()

TauJetCorrectorExample::TauJetCorrectorExample ( const edm::ParameterSet iConfig)
explicit

Definition at line 96 of file TauJetCorrectorExample.cc.

97  :
98 #ifdef THIS_IS_AN_EVENT_EXAMPLE
99  exampletoken(consumes<ExampleData>(edm::InputTag("example"))),
100 #endif
101  jetname(iConfig.getUntrackedParameter<std::string>("JetHandle", "iterativeCone5CaloJets")),
102  tautoken(consumes<reco::IsolatedTauTagInfoCollection>(
103  edm::InputTag(iConfig.getUntrackedParameter<std::string>("TauHandle", "coneIsolation")))),
104  tauCorrectortoken(consumes<reco::JetCorrector>(
105  iConfig.getUntrackedParameter<std::string>("tauCorrHandle", "TauJetCorrectorIcone5"))),
106  nEvt(0),
107  njets(0) {
108  //now do what ever initialization is needed
109 }

◆ ~TauJetCorrectorExample()

TauJetCorrectorExample::~TauJetCorrectorExample ( )
override

Definition at line 111 of file TauJetCorrectorExample.cc.

111  {
112  // do anything here that needs to be done at desctruction time
113  // (e.g. close files, deallocate resources etc.)
114 }

Member Function Documentation

◆ analyze()

void TauJetCorrectorExample::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 121 of file TauJetCorrectorExample.cc.

121  {
122  using namespace edm;
123 
124  Handle<reco::JetCorrector> taucorrector;
125  iEvent.getByToken(tauCorrectortoken, taucorrector);
126 
127 #ifdef THIS_IS_AN_EVENT_EXAMPLE
129  iEvent.getByToken(exampletoken, pIn);
130 #endif
131 
132 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
133  ESHandle<SetupData> pSetup;
134  iSetup.get<SetupRecord>().get(pSetup);
135 #endif
136 
137  // this analyzer produces a small root file with basic candidates and some MC information
138  // some additional print statements
139  ++nEvt;
140  if ((nEvt % 10 == 0 && nEvt <= 100) || (nEvt % 100 == 0 && nEvt > 100))
141  std::cout << "reading event " << nEvt << std::endl;
142 
143  // get taus
145  iEvent.getByToken(tautoken, tauTagInfoHandle);
146  reco::IsolatedTauTagInfoCollection::const_iterator tau = tauTagInfoHandle->begin();
147 
148  // std::cout << "setting everything to 0 just before tau loop" << std::endl;
149  njets = 0;
150 
151  std::cout << "starting tau loop" << std::endl;
152  for (tau = tauTagInfoHandle->begin(); tau != tauTagInfoHandle->end() && njets < 10; ++tau) {
153  //Should check tau discriminator, but not done here
154 
155  double pt = tau->jet().get()->et();
156 
157  //correction returns correction factor which must then be applied to original ET
158  double scale = taucorrector->correction(tau->jet().get()->p4());
159  double ptcorr = tau->jet().get()->et() * scale;
160 
161  std::cout << "Tau jet: Original Et = " << pt << " Corrected Et = " << ptcorr << std::endl;
162 
163  ++njets;
164  }
165 }

References reco::JetCorrector::correction(), gather_cfg::cout, edm::EventSetup::get(), get, iEvent, nEvt, njets, DiDispStaMuonMonitor_cfi::pt, Scenarios_cff::scale, metsig::tau, tauCorrectortoken, and tautoken.

◆ beginJob()

void TauJetCorrectorExample::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 170 of file TauJetCorrectorExample.cc.

170 {}

◆ endJob()

void TauJetCorrectorExample::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 173 of file TauJetCorrectorExample.cc.

173 {}

Member Data Documentation

◆ jetname

std::string TauJetCorrectorExample::jetname
private

Definition at line 74 of file TauJetCorrectorExample.cc.

◆ nEvt

int TauJetCorrectorExample::nEvt
private

Definition at line 78 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ njets

int TauJetCorrectorExample::njets
private

Definition at line 79 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ tauCorrectortoken

edm::EDGetTokenT<reco::JetCorrector> TauJetCorrectorExample::tauCorrectortoken
private

Definition at line 76 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ tautoken

edm::EDGetTokenT<reco::IsolatedTauTagInfoCollection> TauJetCorrectorExample::tautoken
private

Definition at line 75 of file TauJetCorrectorExample.cc.

Referenced by analyze().

TauJetCorrectorExample::njets
int njets
Definition: TauJetCorrectorExample.cc:79
metsig::tau
Definition: SignAlgoResolutions.h:49
TauJetCorrectorExample::jetname
std::string jetname
Definition: TauJetCorrectorExample.cc:74
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
TauJetCorrectorExample::tauCorrectortoken
edm::EDGetTokenT< reco::JetCorrector > tauCorrectortoken
Definition: TauJetCorrectorExample.cc:76
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::JetCorrector::correction
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:47
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< reco::JetCorrector >
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle
Definition: DTSurvey.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
TauJetCorrectorExample::tautoken
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollection > tautoken
Definition: TauJetCorrectorExample.cc:75
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
edm::InputTag
Definition: InputTag.h:15
TauJetCorrectorExample::nEvt
int nEvt
Definition: TauJetCorrectorExample.cc:78