CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HiL1Subtractor (const edm::ParameterSet &)
 
 ~HiL1Subtractor ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

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

Private Member Functions

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

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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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:

Implementation:

Definition at line 43 of file HiL1Subtractor.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file HiL1Subtractor.cc.

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

20  :
21  jetType_ (iConfig.getParameter<std::string>("jetType") ),
22  rhoTagString_ (iConfig.getParameter<std::string>("rhoTag") )
23 
24 {
25  rhoTag_ = (consumes<std::vector<double> > (rhoTagString_));
26 
27  if(jetType_ == "CaloJet"){
28  produces<reco::CaloJetCollection >();
29  caloJetSrc_ = (consumes< edm::View<reco::CaloJet> >(iConfig.getParameter<edm::InputTag>("src")));
30  }
31  else if(jetType_ == "PFJet"){
32  produces<reco::PFJetCollection >();
33  pfJetSrc_ = (consumes< edm::View<reco::PFJet> >(iConfig.getParameter<edm::InputTag>("src")));
34  }
35  else if(jetType_ == "GenJet"){
36  produces<reco::GenJetCollection >();
37  genJetSrc_ = (consumes< edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src")));
38 
39  }
40  else{
41  throw cms::Exception("InvalidInput") << "invalid jet type in HiL1Subtractor\n";
42  }
43 
44 }
T getParameter(std::string const &) const
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_
HiL1Subtractor::~HiL1Subtractor ( )

Definition at line 47 of file HiL1Subtractor.cc.

48 {
49 }

Member Function Documentation

void HiL1Subtractor::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 253 of file HiL1Subtractor.cc.

254 {
255 }
void HiL1Subtractor::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 259 of file HiL1Subtractor.cc.

259  {
260 }
void HiL1Subtractor::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 58 of file HiL1Subtractor.cc.

References caloJetSrc_, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), genJetSrc_, edm::Event::getByToken(), j, metsig::jet, reco::Jet::jetArea(), fwrapper::jets, jetType_, medianPtkt, pfJetSrc_, edm::Event::put(), rho, rhoTag_, reco::Jet::scaleEnergy(), and reco::Jet::setPileup().

59 {
60 
61  // get the input jet collection and create output jet collection
62 
63  // right now, identical loop for calo and PF jets, should template
64  if(jetType_ == "GenJet"){
65  std::auto_ptr<reco::GenJetCollection> jets( new reco::GenJetCollection);
67  iEvent.getByToken( genJetSrc_, h_jets );
68 
69  // Grab appropriate rho, hard coded for the moment
71  iEvent.getByToken(rhoTag_, rs);
72 
73  int rsize = rs->size();
74 
75  for(int j = 0; j < rsize; j++){
76  double medianpt=rs->at(j);
77  medianPtkt[j]=medianpt;
78  }
79 
80  // loop over the jets
81  int jetsize = h_jets->size();
82  for(int ijet = 0; ijet < jetsize; ++ijet){
83 
84  reco::GenJet jet = ((*h_jets)[ijet]);
85 
86  double jet_eta = jet.eta();
87  double jet_et = jet.et();
88 
89  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
90 
91  if(fabs(jet_eta)<=3){
92 
93  double rho=-999;
94 
95  if (jet_eta<-2.5 && jet_eta>-3.5)rho=medianPtkt[2];
96  if (jet_eta<-1.5 && jet_eta>-2.5)rho=medianPtkt[3];
97  if (jet_eta<-0.5 && jet_eta>-1.5)rho=medianPtkt[4];
98  if (jet_eta<0.5 && jet_eta>-0.5)rho=medianPtkt[5];
99  if (jet_eta<1.5 && jet_eta>0.5)rho=medianPtkt[6];
100  if (jet_eta<2.5 && jet_eta>1.5)rho=medianPtkt[7];
101  if (jet_eta<3.5 && jet_eta>2.5)rho=medianPtkt[8];
102 
103  double jet_area = jet.jetArea();
104 
105  double CorrFactor =0.;
106  if(rho*jet_area<jet_et) CorrFactor = 1.0 - rho*jet_area/jet_et;
107  jet.scaleEnergy( CorrFactor );
108  jet.setPileup(rho*jet_area);
109 
110  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
111  }
112 
113  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
114  jets->push_back(jet);
115 
116 
117  }
118  iEvent.put(jets);
119 
120  }else if(jetType_ == "CaloJet"){
121  std::auto_ptr<reco::CaloJetCollection> jets( new reco::CaloJetCollection);
123  iEvent.getByToken( caloJetSrc_, h_jets );
124 
125  // Grab appropriate rho, hard coded for the moment
127  iEvent.getByToken(rhoTag_, rs);
128 
129 
130  int rsize = rs->size();
131 
132  for(int j = 0; j < rsize; j++){
133  double medianpt=rs->at(j);
134  medianPtkt[j]=medianpt;
135  }
136 
137  // loop over the jets
138 
139  int jetsize = h_jets->size();
140 
141  for(int ijet = 0; ijet < jetsize; ++ijet){
142 
143  reco::CaloJet jet = ((*h_jets)[ijet]);
144 
145  double jet_eta = jet.eta();
146  double jet_et = jet.et();
147 
148  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
149 
150  if(fabs(jet_eta)<=3){
151 
152  double rho=-999;
153 
154  if (jet_eta<-2.5 && jet_eta>-3.5)rho=medianPtkt[2];
155  if (jet_eta<-1.5 && jet_eta>-2.5)rho=medianPtkt[3];
156  if (jet_eta<-0.5 && jet_eta>-1.5)rho=medianPtkt[4];
157  if (jet_eta<0.5 && jet_eta>-0.5)rho=medianPtkt[5];
158  if (jet_eta<1.5 && jet_eta>0.5)rho=medianPtkt[6];
159  if (jet_eta<2.5 && jet_eta>1.5)rho=medianPtkt[7];
160  if (jet_eta<3.5 && jet_eta>2.5)rho=medianPtkt[8];
161 
162  double jet_area = jet.jetArea();
163 
164  double CorrFactor =0.;
165  if(rho*jet_area<jet_et) CorrFactor = 1.0 - rho*jet_area/jet_et;
166  jet.scaleEnergy( CorrFactor );
167  jet.setPileup(rho*jet_area);
168 
169  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
170  }
171 
172  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
173 
174  jets->push_back(jet);
175 
176 
177  }
178  iEvent.put(jets);
179 
180  }
181  else if(jetType_ == "PFJet"){
182  std::auto_ptr<reco::PFJetCollection> jets( new reco::PFJetCollection);
184  iEvent.getByToken( pfJetSrc_, h_jets );
185 
186  // Grab appropriate rho, hard coded for the moment
188  iEvent.getByToken(rhoTag_,rs);
189 
190 
191  int rsize = rs->size();
192 
193  for(int j = 0; j < rsize; j++){
194  double medianpt=rs->at(j);
195  medianPtkt[j]=medianpt;
196  }
197 
198  // loop over the jets
199 
200  int jetsize = h_jets->size();
201 
202  for(int ijet = 0; ijet < jetsize; ++ijet){
203 
204  reco::PFJet jet = ((*h_jets)[ijet]);
205 
206  double jet_eta = jet.eta();
207  double jet_et = jet.et();
208 
209  //std::cout<<" pre-subtracted jet_et "<<jet_et<<std::endl;
210 
211  if(fabs(jet_eta)<=3){
212 
213  double rho=-999;
214 
215  if (jet_eta<-2.5 && jet_eta>-3.5)rho=medianPtkt[2];
216  if (jet_eta<-1.5 && jet_eta>-2.5)rho=medianPtkt[3];
217  if (jet_eta<-0.5 && jet_eta>-1.5)rho=medianPtkt[4];
218  if (jet_eta<0.5 && jet_eta>-0.5)rho=medianPtkt[5];
219  if (jet_eta<1.5 && jet_eta>0.5)rho=medianPtkt[6];
220  if (jet_eta<2.5 && jet_eta>1.5)rho=medianPtkt[7];
221  if (jet_eta<3.5 && jet_eta>2.5)rho=medianPtkt[8];
222 
223  double jet_area = jet.jetArea();
224 
225  double CorrFactor =0.;
226  if(rho*jet_area<jet_et) CorrFactor = 1.0 - rho*jet_area/jet_et;
227  jet.scaleEnergy( CorrFactor );
228  jet.setPileup(rho*jet_area);
229 
230  //std::cout<<" correction factor "<<1.0 - rho*jet_area/jet_et<<std::endl;
231  }
232 
233  //std::cout<<" subtracted jet_et "<<jet.et()<<std::endl;
234 
235  jets->push_back(jet);
236 
237 
238  }
239  iEvent.put(jets);
240 
241  }
242 
243 
244 
245 
246 
247 
248 
249 }
Jets made from CaloTowers.
Definition: CaloJet.h:29
virtual void scaleEnergy(double fScale)
scale energy of the jet
virtual double et() const
transverse energy
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual void setPileup(float fEnergy)
Set pileup energy contribution as calculated by algorithm.
Definition: Jet.h:108
Definition: DDAxes.h:10
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Jets made from PFObjects.
Definition: PFJet.h:21
std::string jetType_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< edm::View< reco::GenJet > > genJetSrc_
virtual float eta() const
momentum pseudorapidity
vector< PseudoJet > jets
double medianPtkt[12]
int j
Definition: DBlmapReader.cc:9
Jets made from MC generator particles.
Definition: GenJet.h:24
edm::EDGetTokenT< edm::View< reco::CaloJet > > caloJetSrc_
edm::EDGetTokenT< edm::View< reco::PFJet > > pfJetSrc_
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual float jetArea() const
get jet area
Definition: Jet.h:105
edm::EDGetTokenT< std::vector< double > > rhoTag_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects

Member Data Documentation

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

Definition at line 65 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

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

Definition at line 64 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

std::string HiL1Subtractor::jetType_
protected

Definition at line 69 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

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

Definition at line 66 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

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

Definition at line 72 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor(), and produce().

std::string HiL1Subtractor::rhoTagString_
protected

Definition at line 70 of file HiL1Subtractor.h.

Referenced by HiL1Subtractor().