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::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 TauJetCorrectorExample (const edm::ParameterSet &)
 
 ~TauJetCorrectorExample () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

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

Definition at line 54 of file TauJetCorrectorExample.cc.

Constructor & Destructor Documentation

◆ TauJetCorrectorExample()

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

Definition at line 87 of file TauJetCorrectorExample.cc.

88  : jetname(iConfig.getUntrackedParameter<std::string>("JetHandle", "iterativeCone5CaloJets")),
89  tautoken(consumes<reco::IsolatedTauTagInfoCollection>(
90  edm::InputTag(iConfig.getUntrackedParameter<std::string>("TauHandle", "coneIsolation")))),
91  tauCorrectortoken(consumes<reco::JetCorrector>(
92  iConfig.getUntrackedParameter<std::string>("tauCorrHandle", "TauJetCorrectorIcone5"))),
93  nEvt(0),
94  njets(0) {
95  //now do what ever initialization is needed
96 }
edm::EDGetTokenT< reco::JetCorrector > tauCorrectortoken
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollection > tautoken

◆ ~TauJetCorrectorExample()

TauJetCorrectorExample::~TauJetCorrectorExample ( )
override

Definition at line 98 of file TauJetCorrectorExample.cc.

98  {
99  // do anything here that needs to be done at desctruction time
100  // (e.g. close files, deallocate resources etc.)
101 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 108 of file TauJetCorrectorExample.cc.

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

108  {
109  using namespace edm;
110 
111  Handle<reco::JetCorrector> taucorrector;
112  iEvent.getByToken(tauCorrectortoken, taucorrector);
113 
114  // this analyzer produces a small root file with basic candidates and some MC information
115  // some additional print statements
116  ++nEvt;
117  if ((nEvt % 10 == 0 && nEvt <= 100) || (nEvt % 100 == 0 && nEvt > 100))
118  std::cout << "reading event " << nEvt << std::endl;
119 
120  // get taus
122  iEvent.getByToken(tautoken, tauTagInfoHandle);
123  reco::IsolatedTauTagInfoCollection::const_iterator tau = tauTagInfoHandle->begin();
124 
125  // std::cout << "setting everything to 0 just before tau loop" << std::endl;
126  njets = 0;
127 
128  std::cout << "starting tau loop" << std::endl;
129  for (tau = tauTagInfoHandle->begin(); tau != tauTagInfoHandle->end() && njets < 10; ++tau) {
130  //Should check tau discriminator, but not done here
131 
132  double pt = tau->jet().get()->et();
133 
134  //correction returns correction factor which must then be applied to original ET
135  double scale = taucorrector->correction(tau->jet().get()->p4());
136  double ptcorr = tau->jet().get()->et() * scale;
137 
138  std::cout << "Tau jet: Original Et = " << pt << " Corrected Et = " << ptcorr << std::endl;
139 
140  ++njets;
141  }
142 }
edm::EDGetTokenT< reco::JetCorrector > tauCorrectortoken
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:46
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::IsolatedTauTagInfoCollection > tautoken
HLT enums.

◆ beginJob()

void TauJetCorrectorExample::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 147 of file TauJetCorrectorExample.cc.

147 {}

◆ endJob()

void TauJetCorrectorExample::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 150 of file TauJetCorrectorExample.cc.

150 {}

Member Data Documentation

◆ jetname

std::string TauJetCorrectorExample::jetname
private

Definition at line 65 of file TauJetCorrectorExample.cc.

◆ nEvt

int TauJetCorrectorExample::nEvt
private

Definition at line 69 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ njets

int TauJetCorrectorExample::njets
private

Definition at line 70 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ tauCorrectortoken

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

Definition at line 67 of file TauJetCorrectorExample.cc.

Referenced by analyze().

◆ tautoken

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

Definition at line 66 of file TauJetCorrectorExample.cc.

Referenced by analyze().