CMS 3D CMS Logo

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

#include <RecoHI/HiJetAlgos/plugins/HiL1Subtractor.cc>

Inheritance diagram for HiL1Subtractor:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HiL1Subtractor (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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)
 

Protected Attributes

std::string jetType_
 
edm::EDGetTokenT< std::vector< double > > rhoTag_
 
std::string rhoTagString_
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::EDGetTokenT< edm::View< reco::CaloJet > > caloJetSrc_
 
edm::EDGetTokenT< edm::View< reco::GenJet > > genJetSrc_
 
edm::EDGetTokenT< edm::View< reco::PFJet > > pfJetSrc_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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:

Implementation:

Definition at line 42 of file HiL1Subtractor.h.

Constructor & Destructor Documentation

◆ HiL1Subtractor()

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

Definition at line 18 of file HiL1Subtractor.cc.

References caloJetSrc_, Exception, genJetSrc_, edm::ParameterSet::getParameter(), jetType_, pfJetSrc_, rhoTag_, and rhoTagString_.

19  : jetType_(iConfig.getParameter<std::string>("jetType")),
20  rhoTagString_(iConfig.getParameter<std::string>("rhoTag"))
21 
22 {
23  rhoTag_ = (consumes<std::vector<double> >(rhoTagString_));
24 
25  if (jetType_ == "CaloJet") {
26  produces<reco::CaloJetCollection>();
27  caloJetSrc_ = (consumes<edm::View<reco::CaloJet> >(iConfig.getParameter<edm::InputTag>("src")));
28  } else if (jetType_ == "PFJet") {
29  produces<reco::PFJetCollection>();
30  pfJetSrc_ = (consumes<edm::View<reco::PFJet> >(iConfig.getParameter<edm::InputTag>("src")));
31  } else if (jetType_ == "GenJet") {
32  produces<reco::GenJetCollection>();
33  genJetSrc_ = (consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src")));
34 
35  } else {
36  throw cms::Exception("InvalidInput") << "invalid jet type in HiL1Subtractor\n";
37  }
38 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string rhoTagString_
std::string jetType_
edm::EDGetTokenT< edm::View< reco::GenJet > > genJetSrc_
edm::EDGetTokenT< edm::View< reco::CaloJet > > caloJetSrc_
edm::EDGetTokenT< edm::View< reco::PFJet > > pfJetSrc_
edm::EDGetTokenT< std::vector< double > > rhoTag_

Member Function Documentation

◆ produce()

void HiL1Subtractor::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 45 of file HiL1Subtractor.cc.

References caloJetSrc_, genJetSrc_, iEvent, dqmiolumiharvest::j, metsig::jet, PDWG_EXODelayedJetMET_cff::jets, jetType_, eostools::move(), pfJetSrc_, rho, and rhoTag_.

45  {
46  // get the input jet collection and create output jet collection
47 
48  double medianPtkt[12] = {0};
49  // right now, identical loop for calo and PF jets, should template
50  if (jetType_ == "GenJet") {
51  auto jets = std::make_unique<reco::GenJetCollection>();
53  iEvent.getByToken(genJetSrc_, h_jets);
54 
55  // Grab appropriate rho, hard coded for the moment
57  iEvent.getByToken(rhoTag_, rs);
58 
59  int rsize = rs->size();
60 
61  for (int j = 0; j < rsize; j++) {
62  double medianpt = rs->at(j);
63  medianPtkt[j] = medianpt;
64  }
65 
66  // loop over the jets
67  int jetsize = h_jets->size();
68  for (int ijet = 0; ijet < jetsize; ++ijet) {
69  reco::GenJet jet = ((*h_jets)[ijet]);
70 
71  double jet_eta = jet.eta();
72  double jet_et = jet.et();
73 
74  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
75 
76  if (fabs(jet_eta) <= 3) {
77  double rho = -999;
78 
79  if (jet_eta < -2.5 && jet_eta > -3.5)
80  rho = medianPtkt[2];
81  if (jet_eta < -1.5 && jet_eta > -2.5)
82  rho = medianPtkt[3];
83  if (jet_eta < -0.5 && jet_eta > -1.5)
84  rho = medianPtkt[4];
85  if (jet_eta < 0.5 && jet_eta > -0.5)
86  rho = medianPtkt[5];
87  if (jet_eta < 1.5 && jet_eta > 0.5)
88  rho = medianPtkt[6];
89  if (jet_eta < 2.5 && jet_eta > 1.5)
90  rho = medianPtkt[7];
91  if (jet_eta < 3.5 && jet_eta > 2.5)
92  rho = medianPtkt[8];
93 
94  double jet_area = jet.jetArea();
95 
96  double CorrFactor = 0.;
97  if (rho * jet_area < jet_et)
98  CorrFactor = 1.0 - rho * jet_area / jet_et;
99  jet.scaleEnergy(CorrFactor);
100  jet.setPileup(rho * jet_area);
101 
102  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
103  }
104 
105  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
106  jets->push_back(jet);
107  }
108  iEvent.put(std::move(jets));
109 
110  } else if (jetType_ == "CaloJet") {
111  auto jets = std::make_unique<reco::CaloJetCollection>();
113  iEvent.getByToken(caloJetSrc_, h_jets);
114 
115  // Grab appropriate rho, hard coded for the moment
117  iEvent.getByToken(rhoTag_, rs);
118 
119  int rsize = rs->size();
120 
121  for (int j = 0; j < rsize; j++) {
122  double medianpt = rs->at(j);
123  medianPtkt[j] = medianpt;
124  }
125 
126  // loop over the jets
127 
128  int jetsize = h_jets->size();
129 
130  for (int ijet = 0; ijet < jetsize; ++ijet) {
131  reco::CaloJet jet = ((*h_jets)[ijet]);
132 
133  double jet_eta = jet.eta();
134  double jet_et = jet.et();
135 
136  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
137 
138  if (fabs(jet_eta) <= 3) {
139  double rho = -999;
140 
141  if (jet_eta < -2.5 && jet_eta > -3.5)
142  rho = medianPtkt[2];
143  if (jet_eta < -1.5 && jet_eta > -2.5)
144  rho = medianPtkt[3];
145  if (jet_eta < -0.5 && jet_eta > -1.5)
146  rho = medianPtkt[4];
147  if (jet_eta < 0.5 && jet_eta > -0.5)
148  rho = medianPtkt[5];
149  if (jet_eta < 1.5 && jet_eta > 0.5)
150  rho = medianPtkt[6];
151  if (jet_eta < 2.5 && jet_eta > 1.5)
152  rho = medianPtkt[7];
153  if (jet_eta < 3.5 && jet_eta > 2.5)
154  rho = medianPtkt[8];
155 
156  double jet_area = jet.jetArea();
157 
158  double CorrFactor = 0.;
159  if (rho * jet_area < jet_et)
160  CorrFactor = 1.0 - rho * jet_area / jet_et;
161  jet.scaleEnergy(CorrFactor);
162  jet.setPileup(rho * jet_area);
163 
164  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
165  }
166 
167  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
168 
169  jets->push_back(jet);
170  }
171  iEvent.put(std::move(jets));
172 
173  } else if (jetType_ == "PFJet") {
174  auto jets = std::make_unique<reco::PFJetCollection>();
176  iEvent.getByToken(pfJetSrc_, h_jets);
177 
178  // Grab appropriate rho, hard coded for the moment
180  iEvent.getByToken(rhoTag_, rs);
181 
182  int rsize = rs->size();
183 
184  for (int j = 0; j < rsize; j++) {
185  double medianpt = rs->at(j);
186  medianPtkt[j] = medianpt;
187  }
188 
189  // loop over the jets
190 
191  int jetsize = h_jets->size();
192 
193  for (int ijet = 0; ijet < jetsize; ++ijet) {
194  reco::PFJet jet = ((*h_jets)[ijet]);
195 
196  double jet_eta = jet.eta();
197  double jet_et = jet.et();
198 
199  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
200 
201  if (fabs(jet_eta) <= 3) {
202  double rho = -999;
203 
204  if (jet_eta < -2.5 && jet_eta > -3.5)
205  rho = medianPtkt[2];
206  if (jet_eta < -1.5 && jet_eta > -2.5)
207  rho = medianPtkt[3];
208  if (jet_eta < -0.5 && jet_eta > -1.5)
209  rho = medianPtkt[4];
210  if (jet_eta < 0.5 && jet_eta > -0.5)
211  rho = medianPtkt[5];
212  if (jet_eta < 1.5 && jet_eta > 0.5)
213  rho = medianPtkt[6];
214  if (jet_eta < 2.5 && jet_eta > 1.5)
215  rho = medianPtkt[7];
216  if (jet_eta < 3.5 && jet_eta > 2.5)
217  rho = medianPtkt[8];
218 
219  double jet_area = jet.jetArea();
220 
221  double CorrFactor = 0.;
222  if (rho * jet_area < jet_et)
223  CorrFactor = 1.0 - rho * jet_area / jet_et;
224  jet.scaleEnergy(CorrFactor);
225  jet.setPileup(rho * jet_area);
226 
227  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
228  }
229 
230  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
231 
232  jets->push_back(jet);
233  }
234  iEvent.put(std::move(jets));
235  }
236 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
Jets made from PFObjects.
Definition: PFJet.h:20
std::string jetType_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< reco::GenJet > > genJetSrc_
Jets made from MC generator particles.
Definition: GenJet.h:23
edm::EDGetTokenT< edm::View< reco::CaloJet > > caloJetSrc_
edm::EDGetTokenT< edm::View< reco::PFJet > > pfJetSrc_
edm::EDGetTokenT< std::vector< double > > rhoTag_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ caloJetSrc_

edm::EDGetTokenT<edm::View<reco::CaloJet> > HiL1Subtractor::caloJetSrc_
private

Definition at line 57 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

◆ genJetSrc_

edm::EDGetTokenT<edm::View<reco::GenJet> > HiL1Subtractor::genJetSrc_
private

Definition at line 56 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

◆ jetType_

std::string HiL1Subtractor::jetType_
protected

Definition at line 61 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

◆ pfJetSrc_

edm::EDGetTokenT<edm::View<reco::PFJet> > HiL1Subtractor::pfJetSrc_
private

Definition at line 58 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

◆ rhoTag_

edm::EDGetTokenT<std::vector<double> > HiL1Subtractor::rhoTag_
protected

Definition at line 64 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

◆ rhoTagString_

std::string HiL1Subtractor::rhoTagString_
protected

Definition at line 62 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor().