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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
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

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

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

Definition at line 61 of file TauJetCorrectorExample.cc.

Constructor & Destructor Documentation

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

Definition at line 100 of file TauJetCorrectorExample.cc.

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

Definition at line 114 of file TauJetCorrectorExample.cc.

115 {
116 
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 
120 }

Member Function Documentation

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

Definition at line 129 of file TauJetCorrectorExample.cc.

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

130 {
131  using namespace edm;
132 
133  Handle<reco::JetCorrector> taucorrector;
134  iEvent.getByToken(tauCorrectortoken, taucorrector);
135 
136 #ifdef THIS_IS_AN_EVENT_EXAMPLE
138  iEvent.getByToken(exampletoken,pIn);
139 #endif
140 
141 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
142  ESHandle<SetupData> pSetup;
143  iSetup.get<SetupRecord>().get(pSetup);
144 #endif
145 
146  // this analyzer produces a small root file with basic candidates and some MC information
147  // some additional print statements
148  ++nEvt;
149  if((nEvt%10==0 && nEvt<=100)||(nEvt%100==0 && nEvt>100))
150  std::cout << "reading event " << nEvt << std::endl;
151 
152  // get taus
154  iEvent.getByToken(tautoken,tauTagInfoHandle);
155  reco::IsolatedTauTagInfoCollection::const_iterator tau=tauTagInfoHandle->begin();
156 
157  // std::cout << "setting everything to 0 just before tau loop" << std::endl;
158  njets=0;
159 
160  std::cout << "starting tau loop" << std::endl;
161  for(tau=tauTagInfoHandle->begin();tau!=tauTagInfoHandle->end() && njets<10;++tau) {
162 
163  //Should check tau discriminator, but not done here
164 
165  double pt = tau->jet().get()->et();
166 
167  //correction returns correction factor which must then be applied to original ET
168  double scale = taucorrector->correction(tau->jet().get()->p4());
169  double ptcorr = tau->jet().get()->et() * scale;
170 
171  std::cout << "Tau jet: Original Et = " << pt << " Corrected Et = " << ptcorr << std::endl;
172 
173  ++njets;
174  }
175 
176 
177 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< reco::JetCorrector > tauCorrectortoken
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:49
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollection > tautoken
HLT enums.
T get() const
Definition: EventSetup.h:63
void TauJetCorrectorExample::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 184 of file TauJetCorrectorExample.cc.

185 {
186 }
void TauJetCorrectorExample::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 190 of file TauJetCorrectorExample.cc.

References DEFINE_FWK_MODULE.

190  {
191 }

Member Data Documentation

std::string TauJetCorrectorExample::jetname
private

Definition at line 76 of file TauJetCorrectorExample.cc.

int TauJetCorrectorExample::nEvt
private

Definition at line 80 of file TauJetCorrectorExample.cc.

Referenced by analyze().

int TauJetCorrectorExample::njets
private

Definition at line 81 of file TauJetCorrectorExample.cc.

Referenced by analyze().

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

Definition at line 78 of file TauJetCorrectorExample.cc.

Referenced by analyze().

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

Definition at line 77 of file TauJetCorrectorExample.cc.

Referenced by analyze().