CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
PileUpSubtractor Class Reference

#include <PileUpSubtractor.h>

Inheritance diagram for PileUpSubtractor:
JetOffsetCorrector MultipleAlgoIterator ParametrizedSubtractor ReflectedIterator

Public Types

typedef boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
 
typedef boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
 
typedef boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
 
typedef boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
 

Public Member Functions

virtual void calculateOrphanInput (std::vector< fastjet::PseudoJet > &orphanInput)
 
virtual void calculatePedestal (std::vector< fastjet::PseudoJet > const &coll)
 
virtual double getCone (double cone, double eta, double phi, double &et, double &pu)
 
virtual double getMeanAtTower (const reco::CandidatePtr &in) const
 
int getN (const reco::CandidatePtr &in) const
 
int getNwithJets (const reco::CandidatePtr &in) const
 
virtual double getPileUpAtTower (const reco::CandidatePtr &in) const
 
virtual double getPileUpEnergy (int ijet) const
 
virtual double getSigmaAtTower (const reco::CandidatePtr &in) const
 
int ieta (const reco::CandidatePtr &in) const
 
int iphi (const reco::CandidatePtr &in) const
 
virtual void offsetCorrectJets ()
 
 PileUpSubtractor (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
virtual void reset (std::vector< edm::Ptr< reco::Candidate > > &input, std::vector< fastjet::PseudoJet > &towers, std::vector< fastjet::PseudoJet > &output)
 
virtual void setDefinition (JetDefPtr const &jetDef)
 
virtual void setupGeometryMap (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual void subtractPedestal (std::vector< fastjet::PseudoJet > &coll)
 
virtual ~PileUpSubtractor ()
 

Protected Attributes

int activeAreaRepeats
 
std::vector< HcalDetIdallgeomid_
 
bool doAreaFastjet_
 
bool doRhoFastjet_
 
std::map< int, double > emean_
 
std::map< int, double > esigma_
 
ActiveAreaSpecPtr fjActiveArea_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > * fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > * fjJets_
 
std::vector< fastjet::PseudoJet > fjOriginalInputs_
 
CaloGeometry const * geo_
 
std::map< int, int > geomtowers_
 
double ghostArea
 
double ghostEtaMax
 
int ietamax_
 
int ietamin_
 
std::vector< edm::Ptr< reco::Candidate > > * inputs_
 
std::vector< double > jetOffset_
 
double jetPtMin_
 
double nSigmaPU_
 
std::map< int, int > ntowersWithJets_
 
double puPtMin_
 
double radiusPU_
 
bool reRunAlgo_
 

Detailed Description

Definition at line 23 of file PileUpSubtractor.h.

Member Typedef Documentation

typedef boost::shared_ptr<fastjet::GhostedAreaSpec> PileUpSubtractor::ActiveAreaSpecPtr

Definition at line 28 of file PileUpSubtractor.h.

typedef boost::shared_ptr<fastjet::ClusterSequence> PileUpSubtractor::ClusterSequencePtr

Definition at line 27 of file PileUpSubtractor.h.

typedef boost::shared_ptr<fastjet::JetDefinition> PileUpSubtractor::JetDefPtr

Definition at line 30 of file PileUpSubtractor.h.

typedef boost::shared_ptr<fastjet::RangeDefinition> PileUpSubtractor::RangeDefPtr

Definition at line 29 of file PileUpSubtractor.h.

Constructor & Destructor Documentation

PileUpSubtractor::PileUpSubtractor ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 18 of file PileUpSubtractor.cc.

References Exception, and edm::ParameterSet::getParameter().

18  {
19 
20  geo_ = nullptr;
21  doAreaFastjet_ = iConfig.getParameter<bool>("doAreaFastjet");
22  doRhoFastjet_ = iConfig.getParameter<bool>("doRhoFastjet");
23  nSigmaPU_ = iConfig.getParameter<double>("nSigmaPU");
24  radiusPU_ = iConfig.getParameter<double>("radiusPU");
25  jetPtMin_ = iConfig.getParameter<double>("jetPtMin");
26  puPtMin_ = iConfig.getParameter<double>("puPtMin");
27  ghostEtaMax = iConfig.getParameter<double>("Ghost_EtaMax");
28  activeAreaRepeats = iConfig.getParameter<int>("Active_Area_Repeats");
29  ghostArea = iConfig.getParameter<double>("GhostArea");
30 
31  if ( doAreaFastjet_ || doRhoFastjet_ ) {
32  fjActiveArea_ = ActiveAreaSpecPtr(new fastjet::ActiveAreaSpec(ghostEtaMax,
33  activeAreaRepeats,
34  ghostArea));
35  if ( ( ghostEtaMax < 0 ) || ( activeAreaRepeats < 0 ) || ( ghostArea < 0 ) )
36  throw cms::Exception("doAreaFastjet or doRhoFastjet") << "Parameters ghostEtaMax, activeAreaRepeats or ghostArea for doAreaFastjet/doRhoFastjet are not defined." << std::endl;
37  }
38 
39 }
T getParameter(std::string const &) const
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
ActiveAreaSpecPtr fjActiveArea_
CaloGeometry const * geo_
virtual PileUpSubtractor::~PileUpSubtractor ( )
inlinevirtual

Member Function Documentation

void PileUpSubtractor::calculateOrphanInput ( std::vector< fastjet::PseudoJet > &  orphanInput)
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 199 of file PileUpSubtractor.cc.

References reco::deltaR(), runTauDisplay::dr, spr::find(), and LogDebug.

Referenced by ~PileUpSubtractor().

200 {
201 
202  LogDebug("PileUpSubtractor")<<"The subtractor calculating orphan input...\n";
203 
204  (*fjInputs_) = fjOriginalInputs_;
205 
206  vector<int> jettowers; // vector of towers indexed by "user_index"
207  vector<pair<int,int> > excludedTowers; // vector of excluded ieta, iphi values
208 
209  vector <fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin (),
210  fjJetsEnd = fjJets_->end();
211  for (; pseudojetTMP != fjJetsEnd ; ++pseudojetTMP) {
212  if(pseudojetTMP->perp() < puPtMin_) continue;
213 
214  // find towers within radiusPU_ of this jet
215  for(vector<HcalDetId>::const_iterator im = allgeomid_.begin(); im != allgeomid_.end(); im++)
216  {
217  double dr = reco::deltaR(geo_->getPosition((DetId)(*im)),(*pseudojetTMP));
218  vector<pair<int,int> >::const_iterator exclude = find(excludedTowers.begin(),excludedTowers.end(),pair<int,int>(im->ieta(),im->iphi()));
219  if( dr < radiusPU_ && exclude == excludedTowers.end()) {
220  ntowersWithJets_[(*im).ieta()]++;
221  excludedTowers.push_back(pair<int,int>(im->ieta(),im->iphi()));
222  }
223  }
224  vector<fastjet::PseudoJet>::const_iterator it = fjInputs_->begin(),
225  fjInputsEnd = fjInputs_->end();
226 
227  for (; it != fjInputsEnd; ++it ) {
228  int index = it->user_index();
229  int ie = ieta((*inputs_)[index]);
230  int ip = iphi((*inputs_)[index]);
231  vector<pair<int,int> >::const_iterator exclude = find(excludedTowers.begin(),excludedTowers.end(),pair<int,int>(ie,ip));
232  if(exclude != excludedTowers.end()) {
233  jettowers.push_back(index);
234  } //dr < radiusPU_
235  } // initial input collection
236  } // pseudojets
237 
238  //
239  // Create a new collections from the towers not included in jets
240  //
241  for(vector<fastjet::PseudoJet>::const_iterator it = fjInputs_->begin(),
242  fjInputsEnd = fjInputs_->end(); it != fjInputsEnd; ++it ) {
243  int index = it->user_index();
244  vector<int>::const_iterator itjet = find(jettowers.begin(),jettowers.end(),index);
245  if( itjet == jettowers.end() ){
246  const reco::CandidatePtr& originalTower = (*inputs_)[index];
247  fastjet::PseudoJet orphan(originalTower->px(),originalTower->py(),originalTower->pz(),originalTower->energy());
248  orphan.set_user_index(index);
249 
250  orphanInput.push_back(orphan);
251  }
252  }
253 }
#define LogDebug(id)
std::vector< fastjet::PseudoJet > * fjJets_
std::vector< fastjet::PseudoJet > fjOriginalInputs_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int ieta(const reco::CandidatePtr &in) const
std::vector< fastjet::PseudoJet > * fjInputs_
std::map< int, int > ntowersWithJets_
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
Definition: DetId.h:18
int iphi(const reco::CandidatePtr &in) const
CaloGeometry const * geo_
std::vector< HcalDetId > allgeomid_
std::vector< edm::Ptr< reco::Candidate > > * inputs_
void PileUpSubtractor::calculatePedestal ( std::vector< fastjet::PseudoJet > const &  coll)
virtual

Reimplemented in ParametrizedSubtractor, MultipleAlgoIterator, and ReflectedIterator.

Definition at line 101 of file PileUpSubtractor.cc.

References mps_fire::i, LogDebug, nt, edm::second(), and mathSSE::sqrt().

Referenced by ~PileUpSubtractor().

102 {
103  LogDebug("PileUpSubtractor")<<"The subtractor calculating pedestals...\n";
104  map<int,double> emean2;
105  map<int,int> ntowers;
106 
107  int ietaold = -10000;
108  int ieta0 = -100;
109 
110  // Initial values for emean_, emean2, esigma_, ntowers
111 
112  for(int i = ietamin_; i < ietamax_+1; i++)
113  {
114  emean_[i] = 0.;
115  emean2[i] = 0.;
116  esigma_[i] = 0.;
117  ntowers[i] = 0;
118  }
119 
120  for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin (),
121  fjInputsEnd = coll.end();
122  input_object != fjInputsEnd; ++input_object) {
123  const reco::CandidatePtr & originalTower=(*inputs_)[ input_object->user_index()];
124  ieta0 = ieta( originalTower );
125  double Original_Et = originalTower->et();
126  if( ieta0-ietaold != 0 )
127  {
128  emean_[ieta0] = emean_[ieta0]+Original_Et;
129  emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
130  ntowers[ieta0] = 1;
131  ietaold = ieta0;
132  }
133  else
134  {
135  emean_[ieta0] = emean_[ieta0]+Original_Et;
136  emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
137  ntowers[ieta0]++;
138  }
139  }
140 
141  for(map<int,int>::const_iterator gt = geomtowers_.begin(); gt != geomtowers_.end(); gt++)
142  {
143  int it = (*gt).first;
144 
145  double e1 = (*(emean_.find(it))).second;
146  double e2 = (*emean2.find(it)).second;
147  int nt = (*gt).second - (*(ntowersWithJets_.find(it))).second;
148 
149  LogDebug("PileUpSubtractor")<<" ieta : "<<it<<" number of towers : "<<nt<<" e1 : "<<e1<<" e2 : "<<e2<<"\n";
150  if(nt > 0) {
151  emean_[it] = e1/nt;
152  double eee = e2/nt - e1*e1/(nt*nt);
153  if(eee<0.) eee = 0.;
154  esigma_[it] = nSigmaPU_*sqrt(eee);
155  }
156  else
157  {
158  emean_[it] = 0.;
159  esigma_[it] = 0.;
160  }
161  LogDebug("PileUpSubtractor")<<" ieta : "<<it<<" Pedestals : "<<emean_[it]<<" "<<esigma_[it]<<"\n";
162  }
163 }
#define LogDebug(id)
std::map< int, double > esigma_
std::map< int, int > geomtowers_
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
std::map< int, int > ntowersWithJets_
T sqrt(T t)
Definition: SSEVec.h:18
int nt
Definition: AMPTWrapper.h:32
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::map< int, double > emean_
double PileUpSubtractor::getCone ( double  cone,
double  eta,
double  phi,
double &  et,
double &  pu 
)
virtual

Definition at line 302 of file PileUpSubtractor.cc.

References reco::deltaR(), runTauDisplay::dr, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), PV3DBase< T, PVType, FrameType >::phi(), point, and muons2muons_cfi::pu.

Referenced by getPileUpEnergy().

302  {
303  pu = 0;
304 
305  for(vector<HcalDetId>::const_iterator im = allgeomid_.begin(); im != allgeomid_.end(); im++){
306  if( im->depth() != 1 ) continue;
307  const GlobalPoint& point = geo_->getPosition((DetId)(*im));
308  double dr = reco::deltaR(point.eta(),point.phi(),eta,phi);
309  if( dr < cone){
310  pu += (*emean_.find(im->ieta())).second+(*esigma_.find(im->ieta())).second;
311  }
312  }
313 
314  return pu;
315 }
std::map< int, double > esigma_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
Definition: DetId.h:18
T eta() const
Definition: PV3DBase.h:76
CaloGeometry const * geo_
std::map< int, double > emean_
std::vector< HcalDetId > allgeomid_
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double PileUpSubtractor::getMeanAtTower ( const reco::CandidatePtr in) const
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 317 of file PileUpSubtractor.cc.

References edm::second().

Referenced by ~PileUpSubtractor().

317  {
318  int it = ieta(in);
319  return (*emean_.find(it)).second;
320 }
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
std::map< int, double > emean_
int PileUpSubtractor::getN ( const reco::CandidatePtr in) const

Definition at line 332 of file PileUpSubtractor.cc.

References gen::n.

Referenced by getPileUpEnergy().

332  {
333  int it = ieta(in);
334 
335  int n = (*(geomtowers_.find(it))).second - (*(ntowersWithJets_.find(it))).second;
336  return n;
337 
338 }
std::map< int, int > geomtowers_
int ieta(const reco::CandidatePtr &in) const
std::map< int, int > ntowersWithJets_
int PileUpSubtractor::getNwithJets ( const reco::CandidatePtr in) const

Definition at line 340 of file PileUpSubtractor.cc.

References gen::n.

Referenced by getPileUpEnergy().

340  {
341  int it = ieta(in);
342  int n = (*(ntowersWithJets_.find(it))).second;
343  return n;
344 
345 }
int ieta(const reco::CandidatePtr &in) const
std::map< int, int > ntowersWithJets_
double PileUpSubtractor::getPileUpAtTower ( const reco::CandidatePtr in) const
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 327 of file PileUpSubtractor.cc.

References edm::second().

Referenced by ~PileUpSubtractor().

327  {
328  int it = ieta(in);
329  return (*emean_.find(it)).second + (*esigma_.find(it)).second;
330 }
std::map< int, double > esigma_
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
std::map< int, double > emean_
virtual double PileUpSubtractor::getPileUpEnergy ( int  ijet) const
inlinevirtual
double PileUpSubtractor::getSigmaAtTower ( const reco::CandidatePtr in) const
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 322 of file PileUpSubtractor.cc.

References edm::second().

Referenced by ~PileUpSubtractor().

322  {
323  int it = ieta(in);
324  return (*esigma_.find(it)).second;
325 }
std::map< int, double > esigma_
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
int PileUpSubtractor::ieta ( const reco::CandidatePtr in) const

Definition at line 348 of file PileUpSubtractor.cc.

References Exception, edm::Ptr< T >::get(), CaloTower::id(), and CaloTowerDetId::ieta().

Referenced by ParametrizedSubtractor::getMeanAtTower(), ParametrizedSubtractor::getPileUpAtTower(), getPileUpEnergy(), ParametrizedSubtractor::getSigmaAtTower(), ParametrizedSubtractor::offsetCorrectJets(), ParametrizedSubtractor::setupGeometryMap(), and ParametrizedSubtractor::subtractPedestal().

348  {
349  int it = 0;
350  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
351  if(ctc){
352  it = ctc->id().ieta();
353  } else
354  {
355  throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type";
356  }
357  return it;
358 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
CaloTowerDetId id() const
Definition: CaloTower.h:103
int ieta() const
get the tower ieta
int PileUpSubtractor::iphi ( const reco::CandidatePtr in) const

Definition at line 360 of file PileUpSubtractor.cc.

References Exception, edm::Ptr< T >::get(), CaloTower::id(), and CaloTowerDetId::iphi().

Referenced by getPileUpEnergy(), and ParametrizedSubtractor::subtractPedestal().

360  {
361  int it = 0;
362  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
363  if(ctc){
364  it = ctc->id().iphi();
365  } else
366  {
367  throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type";
368  }
369  return it;
370 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
int iphi() const
get the tower iphi
CaloTowerDetId id() const
Definition: CaloTower.h:103
void PileUpSubtractor::offsetCorrectJets ( )
virtual

Reimplemented in ParametrizedSubtractor, MultipleAlgoIterator, and ReflectedIterator.

Definition at line 256 of file PileUpSubtractor.cc.

References LogDebug, and edm::second().

Referenced by ~PileUpSubtractor().

257 {
258  LogDebug("PileUpSubtractor")<<"The subtractor correcting jets...\n";
259  jetOffset_.clear();
260  using namespace reco;
261 
262  //
263  // Reestimate energy of jet (energy of jet with initial map)
264  //
265  jetOffset_.reserve(fjJets_->size());
266  vector<fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin (),
267  jetsEnd = fjJets_->end();
268  for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
269  int ijet = pseudojetTMP - fjJets_->begin();
270  jetOffset_[ijet] = 0;
271 
272  std::vector<fastjet::PseudoJet> towers =
273  fastjet::sorted_by_pt( pseudojetTMP->constituents() );
274  double newjetet = 0.;
275  for(vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(),
276  towEnd = towers.end();
277  ito != towEnd;
278  ++ito)
279  {
280  const reco::CandidatePtr& originalTower = (*inputs_)[ito->user_index()];
281  int it = ieta( originalTower );
282  double Original_Et = originalTower->et();
283  double etnew = Original_Et - (*emean_.find(it)).second - (*esigma_.find(it)).second;
284  if(etnew < 0.) etnew = 0;
285  newjetet = newjetet + etnew;
286  jetOffset_[ijet] += Original_Et - etnew;
287  }
288  double mScale = newjetet/pseudojetTMP->Et();
289  LogDebug("PileUpSubtractor")<<"pseudojetTMP->Et() : "<<pseudojetTMP->Et()<<'\n';
290  LogDebug("PileUpSubtractor")<<"newjetet : "<<newjetet<<'\n';
291  LogDebug("PileUpSubtractor")<<"jetOffset_[ijet] : "<<jetOffset_[ijet]<<'\n';
292  LogDebug("PileUpSubtractor")<<"pseudojetTMP->Et() - jetOffset_[ijet] : "<<pseudojetTMP->Et() - jetOffset_[ijet]<<'\n';
293  LogDebug("PileUpSubtractor")<<"Scale is : "<<mScale<<'\n';
294  int cshist = pseudojetTMP->cluster_hist_index();
295  pseudojetTMP->reset_momentum(pseudojetTMP->px()*mScale, pseudojetTMP->py()*mScale,
296  pseudojetTMP->pz()*mScale, pseudojetTMP->e()*mScale);
297  pseudojetTMP->set_cluster_hist_index(cshist);
298 
299  }
300 }
#define LogDebug(id)
std::vector< double > jetOffset_
std::vector< fastjet::PseudoJet > * fjJets_
std::map< int, double > esigma_
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
fixed size matrix
std::map< int, double > emean_
void PileUpSubtractor::reset ( std::vector< edm::Ptr< reco::Candidate > > &  input,
std::vector< fastjet::PseudoJet > &  towers,
std::vector< fastjet::PseudoJet > &  output 
)
virtual

Definition at line 41 of file PileUpSubtractor.cc.

References mps_fire::i, input, and convertSQLitetoXML_cfg::output.

Referenced by ~PileUpSubtractor().

43  {
44 
45  inputs_ = &input;
46  fjInputs_ = &towers;
47  fjJets_ = &output;
48  fjOriginalInputs_ = (*fjInputs_);
49  for (unsigned int i = 0; i < fjInputs_->size(); ++i){
50  fjOriginalInputs_[i].set_user_index((*fjInputs_)[i].user_index());
51  }
52 
53 }
std::vector< fastjet::PseudoJet > * fjJets_
std::vector< fastjet::PseudoJet > fjOriginalInputs_
static std::string const input
Definition: EdmProvDump.cc:44
std::vector< fastjet::PseudoJet > * fjInputs_
std::vector< edm::Ptr< reco::Candidate > > * inputs_
void PileUpSubtractor::setDefinition ( JetDefPtr const &  jetDef)
virtual

Definition at line 55 of file PileUpSubtractor.cc.

Referenced by ~PileUpSubtractor().

55  {
56  fjJetDefinition_ = JetDefPtr( new fastjet::JetDefinition( *jetDef ) );
57 }
JetDefPtr fjJetDefinition_
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
void PileUpSubtractor::setupGeometryMap ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 59 of file PileUpSubtractor.cc.

References egammaForCoreTracking_cff::depth, edm::EventSetup::get(), CaloGeometry::getValidDetIds(), DetId::Hcal, mps_fire::i, LogDebug, and edm::ESHandle< T >::product().

Referenced by ~PileUpSubtractor().

60 {
61 
62  LogDebug("PileUpSubtractor")<<"The subtractor setting up geometry...\n";
63 
64  if(geo_ == nullptr) {
66  iSetup.get<CaloGeometryRecord>().get(pG);
67  geo_ = pG.product();
68  std::vector<DetId> alldid = geo_->getValidDetIds();
69 
70  int ietaold = -10000;
71  ietamax_ = -10000;
72  ietamin_ = 10000;
73  for(std::vector<DetId>::const_iterator did=alldid.begin(); did != alldid.end(); did++){
74  if( (*did).det() == DetId::Hcal ){
75  HcalDetId hid = HcalDetId(*did);
76  if( (hid).depth() == 1 ) {
77  allgeomid_.push_back(*did);
78 
79  if((hid).ieta() != ietaold){
80  ietaold = (hid).ieta();
81  geomtowers_[(hid).ieta()] = 1;
82  if((hid).ieta() > ietamax_) ietamax_ = (hid).ieta();
83  if((hid).ieta() < ietamin_) ietamin_ = (hid).ieta();
84  }
85  else{
86  geomtowers_[(hid).ieta()]++;
87  }
88  }
89  }
90  }
91  }
92 
93  for (int i = ietamin_; i<ietamax_+1; i++) {
94  ntowersWithJets_[i] = 0;
95  }
96 }
#define LogDebug(id)
std::map< int, int > geomtowers_
int ieta(const reco::CandidatePtr &in) const
std::map< int, int > ntowersWithJets_
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
T get() const
Definition: EventSetup.h:63
CaloGeometry const * geo_
T const * product() const
Definition: ESHandle.h:86
std::vector< HcalDetId > allgeomid_
void PileUpSubtractor::subtractPedestal ( std::vector< fastjet::PseudoJet > &  coll)
virtual

Reimplemented in ParametrizedSubtractor, MultipleAlgoIterator, and ReflectedIterator.

Definition at line 169 of file PileUpSubtractor.cc.

References LogDebug.

Referenced by ~PileUpSubtractor().

170 {
171 
172  LogDebug("PileUpSubtractor")<<"The subtractor subtracting pedestals...\n";
173 
174  int it = -100;
175  for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
176  fjInputsEnd = coll.end();
177  input_object != fjInputsEnd; ++input_object) {
178 
179  reco::CandidatePtr const & itow = (*inputs_)[ input_object->user_index() ];
180 
181  it = ieta( itow );
182 
183  double etnew = itow->et() - (*(emean_.find(it))).second - (*(esigma_.find(it))).second;
184  float mScale = etnew/input_object->Et();
185  if(etnew < 0.) mScale = 0.;
186 
187  math::XYZTLorentzVectorD towP4(input_object->px()*mScale, input_object->py()*mScale,
188  input_object->pz()*mScale, input_object->e()*mScale);
189 
190  int index = input_object->user_index();
191  input_object->reset_momentum ( towP4.px(),
192  towP4.py(),
193  towP4.pz(),
194  towP4.energy() );
195  input_object->set_user_index(index);
196  }
197 }
#define LogDebug(id)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
std::map< int, double > esigma_
int ieta(const reco::CandidatePtr &in) const
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::map< int, double > emean_

Member Data Documentation

int PileUpSubtractor::activeAreaRepeats
protected

Definition at line 73 of file PileUpSubtractor.h.

std::vector<HcalDetId> PileUpSubtractor::allgeomid_
protected

Definition at line 82 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

bool PileUpSubtractor::doAreaFastjet_
protected

Definition at line 67 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

bool PileUpSubtractor::doRhoFastjet_
protected

Definition at line 68 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

std::map<int,double> PileUpSubtractor::emean_
protected

Definition at line 86 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

std::map<int,double> PileUpSubtractor::esigma_
protected

Definition at line 85 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

ActiveAreaSpecPtr PileUpSubtractor::fjActiveArea_
protected

Definition at line 78 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

ClusterSequencePtr PileUpSubtractor::fjClusterSeq_
protected

Definition at line 59 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

std::vector<fastjet::PseudoJet>* PileUpSubtractor::fjInputs_
protected
JetDefPtr PileUpSubtractor::fjJetDefinition_
protected

Definition at line 58 of file PileUpSubtractor.h.

std::vector<fastjet::PseudoJet>* PileUpSubtractor::fjJets_
protected

Definition at line 62 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

std::vector<fastjet::PseudoJet> PileUpSubtractor::fjOriginalInputs_
protected

Definition at line 63 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

CaloGeometry const* PileUpSubtractor::geo_
protected
std::map<int,int> PileUpSubtractor::geomtowers_
protected

Definition at line 83 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

double PileUpSubtractor::ghostArea
protected

Definition at line 74 of file PileUpSubtractor.h.

double PileUpSubtractor::ghostEtaMax
protected

Definition at line 72 of file PileUpSubtractor.h.

int PileUpSubtractor::ietamax_
protected

Definition at line 80 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

int PileUpSubtractor::ietamin_
protected

Definition at line 81 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

std::vector<edm::Ptr<reco::Candidate> >* PileUpSubtractor::inputs_
protected

Definition at line 60 of file PileUpSubtractor.h.

std::vector<double> PileUpSubtractor::jetOffset_
protected
double PileUpSubtractor::jetPtMin_
protected

Definition at line 69 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

double PileUpSubtractor::nSigmaPU_
protected
std::map<int,int> PileUpSubtractor::ntowersWithJets_
protected

Definition at line 84 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::setupGeometryMap().

double PileUpSubtractor::puPtMin_
protected

Definition at line 70 of file PileUpSubtractor.h.

double PileUpSubtractor::radiusPU_
protected

Definition at line 77 of file PileUpSubtractor.h.

bool PileUpSubtractor::reRunAlgo_
protected

Definition at line 66 of file PileUpSubtractor.h.