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
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 ()
 
- 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

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 

Private Attributes

std::string jetname
 
int nEvt
 
int njets
 
edm::EDGetTokenT
< reco::JetCorrector
tauCorrectortoken
 
edm::EDGetTokenT
< reco::IsolatedTauTagInfoCollection
tautoken
 

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

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 ( )

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 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 129 of file TauJetCorrectorExample.cc.

References gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByToken(), nEvt, njets, EnergyCorrector::pt, pileupReCalc_HLTpaths::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:462
edm::EDGetTokenT< reco::JetCorrector > tauCorrectortoken
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollection > tautoken
const T & get() const
Definition: EventSetup.h:56
tuple cout
Definition: gather_cfg.py:145
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.

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().