CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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

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_
 
RangeDefPtr fjRangeDef_
 
CaloGeometry const * geo_
 
std::map< int, int > geomtowers_
 
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 19 of file PileUpSubtractor.h.

Member Typedef Documentation

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

Definition at line 24 of file PileUpSubtractor.h.

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

Definition at line 23 of file PileUpSubtractor.h.

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

Definition at line 26 of file PileUpSubtractor.h.

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

Definition at line 25 of file PileUpSubtractor.h.

Constructor & Destructor Documentation

PileUpSubtractor::PileUpSubtractor ( const edm::ParameterSet iConfig)

Definition at line 18 of file PileUpSubtractor.cc.

References doAreaFastjet_, doRhoFastjet_, edm::ParameterSet::exists(), fjActiveArea_, fjRangeDef_, edm::ParameterSet::getParameter(), and puPtMin_.

18  :
19  reRunAlgo_ (iConfig.getUntrackedParameter<bool>("reRunAlgo",false)),
20  doAreaFastjet_ (iConfig.getParameter<bool> ("doAreaFastjet")),
21  doRhoFastjet_ (iConfig.getParameter<bool> ("doRhoFastjet")),
22  jetPtMin_(iConfig.getParameter<double> ("jetPtMin")),
23  nSigmaPU_(iConfig.getParameter<double>("nSigmaPU")),
24  radiusPU_(iConfig.getParameter<double>("radiusPU")),
25  geo_(0)
26 {
27  if (iConfig.exists("puPtMin"))
28  puPtMin_=iConfig.getParameter<double> ("puPtMin");
29  else{
30  puPtMin_=10;
31  edm::LogWarning("MisConfiguration")<<"the parameter puPtMin is now necessary for PU substraction. setting it to "<<puPtMin_;
32  }
33  if ( doAreaFastjet_ || doRhoFastjet_ ) {
34  // default Ghost_EtaMax should be 5
35  double ghostEtaMax = iConfig.getParameter<double>("Ghost_EtaMax");
36  // default Active_Area_Repeats 1
37  int activeAreaRepeats = iConfig.getParameter<int> ("Active_Area_Repeats");
38  // default GhostArea 0.01
39  double ghostArea = iConfig.getParameter<double> ("GhostArea");
40  fjActiveArea_ = ActiveAreaSpecPtr(new fastjet::ActiveAreaSpec(ghostEtaMax,
41  activeAreaRepeats,
42  ghostArea));
43  fjRangeDef_ = RangeDefPtr( new fastjet::RangeDefinition(ghostEtaMax) );
44  }
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
RangeDefPtr fjRangeDef_
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
ActiveAreaSpecPtr fjActiveArea_
boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
CaloGeometry const * geo_
virtual PileUpSubtractor::~PileUpSubtractor ( )
inlinevirtual

Definition at line 29 of file PileUpSubtractor.h.

29 {;}

Member Function Documentation

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

Reimplemented in ParametrizedSubtractor.

Definition at line 205 of file PileUpSubtractor.cc.

References allgeomid_, reco::deltaR(), spr::find(), fjInputs_, fjJets_, fjOriginalInputs_, geo_, CaloGeometry::getPosition(), ieta(), cmsHarvester::index, inputs_, iphi(), LogDebug, ntowersWithJets_, puPtMin_, and radiusPU_.

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

References emean_, esigma_, geomtowers_, gt, i, ieta(), ietamax_, ietamin_, LogDebug, nSigmaPU_, nt, ntowersWithJets_, edm::second(), and mathSSE::sqrt().

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

Definition at line 308 of file PileUpSubtractor.cc.

References allgeomid_, reco::deltaR(), emean_, esigma_, PV3DBase< T, PVType, FrameType >::eta(), eta(), geo_, CaloGeometry::getPosition(), phi, PV3DBase< T, PVType, FrameType >::phi(), and point.

308  {
309  pu = 0;
310 
311  for(vector<HcalDetId>::const_iterator im = allgeomid_.begin(); im != allgeomid_.end(); im++){
312  if( im->depth() != 1 ) continue;
313  const GlobalPoint& point = geo_->getPosition((DetId)(*im));
314  double dr = reco::deltaR(point.eta(),point.phi(),eta,phi);
315  if( dr < cone){
316  pu += (*emean_.find(im->ieta())).second+(*esigma_.find(im->ieta())).second;
317  }
318  }
319 
320  return pu;
321 }
std::map< int, double > esigma_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
T eta() const
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
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
Definition: DDAxes.h:10
double PileUpSubtractor::getMeanAtTower ( const reco::CandidatePtr in) const
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 323 of file PileUpSubtractor.cc.

References emean_, ieta(), and edm::second().

323  {
324  int it = ieta(in);
325  return (*emean_.find(it)).second;
326 }
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 338 of file PileUpSubtractor.cc.

References geomtowers_, ieta(), n, and ntowersWithJets_.

338  {
339  int it = ieta(in);
340 
341  int n = (*(geomtowers_.find(it))).second - (*(ntowersWithJets_.find(it))).second;
342  return n;
343 
344 }
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 346 of file PileUpSubtractor.cc.

References ieta(), n, and ntowersWithJets_.

346  {
347  int it = ieta(in);
348  int n = (*(ntowersWithJets_.find(it))).second;
349  return n;
350 
351 }
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 333 of file PileUpSubtractor.cc.

References emean_, esigma_, ieta(), and edm::second().

333  {
334  int it = ieta(in);
335  return (*emean_.find(it)).second + (*esigma_.find(it)).second;
336 }
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

Definition at line 43 of file PileUpSubtractor.h.

References jetOffset_.

43 {return jetOffset_[ijet];}
std::vector< double > jetOffset_
double PileUpSubtractor::getSigmaAtTower ( const reco::CandidatePtr in) const
virtual

Reimplemented in ParametrizedSubtractor.

Definition at line 328 of file PileUpSubtractor.cc.

References esigma_, ieta(), and edm::second().

328  {
329  int it = ieta(in);
330  return (*esigma_.find(it)).second;
331 }
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 354 of file PileUpSubtractor.cc.

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

Referenced by calculateOrphanInput(), calculatePedestal(), ParametrizedSubtractor::getMeanAtTower(), getMeanAtTower(), getN(), getNwithJets(), ParametrizedSubtractor::getPileUpAtTower(), getPileUpAtTower(), ParametrizedSubtractor::getSigmaAtTower(), getSigmaAtTower(), ParametrizedSubtractor::offsetCorrectJets(), offsetCorrectJets(), ParametrizedSubtractor::setupGeometryMap(), setupGeometryMap(), ParametrizedSubtractor::subtractPedestal(), and subtractPedestal().

354  {
355  int it = 0;
356  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
357  if(ctc){
358  it = ctc->id().ieta();
359  } else
360  {
361  throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type";
362  }
363  return it;
364 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
CaloTowerDetId id() const
Definition: CaloTower.h:87
int ieta() const
get the tower ieta
int PileUpSubtractor::iphi ( const reco::CandidatePtr in) const

Definition at line 366 of file PileUpSubtractor.cc.

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

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

366  {
367  int it = 0;
368  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
369  if(ctc){
370  it = ctc->id().iphi();
371  } else
372  {
373  throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type";
374  }
375  return it;
376 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
int iphi() const
get the tower iphi
CaloTowerDetId id() const
Definition: CaloTower.h:87
void PileUpSubtractor::offsetCorrectJets ( )
virtual

Reimplemented in ParametrizedSubtractor, MultipleAlgoIterator, and ReflectedIterator.

Definition at line 262 of file PileUpSubtractor.cc.

References emean_, esigma_, fjJets_, ieta(), jetOffset_, LogDebug, dt_dqm_sourceclient_common_cff::reco, and edm::second().

263 {
264  LogDebug("PileUpSubtractor")<<"The subtractor correcting jets...\n";
265  jetOffset_.clear();
266  using namespace reco;
267 
268  //
269  // Reestimate energy of jet (energy of jet with initial map)
270  //
271  jetOffset_.reserve(fjJets_->size());
272  vector<fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin (),
273  jetsEnd = fjJets_->end();
274  for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
275  int ijet = pseudojetTMP - fjJets_->begin();
276  jetOffset_[ijet] = 0;
277 
278  std::vector<fastjet::PseudoJet> towers =
279  fastjet::sorted_by_pt( pseudojetTMP->constituents() );
280  double newjetet = 0.;
281  for(vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(),
282  towEnd = towers.end();
283  ito != towEnd;
284  ++ito)
285  {
286  const reco::CandidatePtr& originalTower = (*inputs_)[ito->user_index()];
287  int it = ieta( originalTower );
288  double Original_Et = originalTower->et();
289  double etnew = Original_Et - (*emean_.find(it)).second - (*esigma_.find(it)).second;
290  if(etnew < 0.) etnew = 0;
291  newjetet = newjetet + etnew;
292  jetOffset_[ijet] += Original_Et - etnew;
293  }
294  double mScale = newjetet/pseudojetTMP->Et();
295  LogDebug("PileUpSubtractor")<<"pseudojetTMP->Et() : "<<pseudojetTMP->Et()<<"\n";
296  LogDebug("PileUpSubtractor")<<"newjetet : "<<newjetet<<"\n";
297  LogDebug("PileUpSubtractor")<<"jetOffset_[ijet] : "<<jetOffset_[ijet]<<"\n";
298  LogDebug("PileUpSubtractor")<<"pseudojetTMP->Et() - jetOffset_[ijet] : "<<pseudojetTMP->Et() - jetOffset_[ijet]<<"\n";
299  LogDebug("PileUpSubtractor")<<"Scale is : "<<mScale<<"\n";
300  int cshist = pseudojetTMP->cluster_hist_index();
301  pseudojetTMP->reset_momentum(pseudojetTMP->px()*mScale, pseudojetTMP->py()*mScale,
302  pseudojetTMP->pz()*mScale, pseudojetTMP->e()*mScale);
303  pseudojetTMP->set_cluster_hist_index(cshist);
304 
305  }
306 }
#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)
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 47 of file PileUpSubtractor.cc.

References fjInputs_, fjJets_, fjOriginalInputs_, i, input, inputs_, and convertSQLitetoXML_cfg::output.

49  {
50 
51  inputs_ = &input;
52  fjInputs_ = &towers;
53  fjJets_ = &output;
54  fjOriginalInputs_ = (*fjInputs_);
55  for (unsigned int i = 0; i < fjInputs_->size(); ++i){
56  fjOriginalInputs_[i].set_user_index((*fjInputs_)[i].user_index());
57  }
58 
59 }
int i
Definition: DBlmapReader.cc:9
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 61 of file PileUpSubtractor.cc.

References fjJetDefinition_.

61  {
62  fjJetDefinition_ = JetDefPtr( new fastjet::JetDefinition( *jetDef ) );
63 }
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 65 of file PileUpSubtractor.cc.

References allgeomid_, geo_, geomtowers_, edm::EventSetup::get(), CaloGeometry::getValidDetIds(), DetId::Hcal, i, ieta(), ietamax_, ietamin_, LogDebug, ntowersWithJets_, and edm::ESHandle< class >::product().

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

Reimplemented in ParametrizedSubtractor, MultipleAlgoIterator, and ReflectedIterator.

Definition at line 175 of file PileUpSubtractor.cc.

References emean_, esigma_, ieta(), cmsHarvester::index, and LogDebug.

176 {
177 
178  LogDebug("PileUpSubtractor")<<"The subtractor subtracting pedestals...\n";
179 
180  int it = -100;
181  for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
182  fjInputsEnd = coll.end();
183  input_object != fjInputsEnd; ++input_object) {
184 
185  reco::CandidatePtr const & itow = (*inputs_)[ input_object->user_index() ];
186 
187  it = ieta( itow );
188 
189  double etnew = itow->et() - (*(emean_.find(it))).second - (*(esigma_.find(it))).second;
190  float mScale = etnew/input_object->Et();
191  if(etnew < 0.) mScale = 0.;
192 
193  math::XYZTLorentzVectorD towP4(input_object->px()*mScale, input_object->py()*mScale,
194  input_object->pz()*mScale, input_object->e()*mScale);
195 
196  int index = input_object->user_index();
197  input_object->reset_momentum ( towP4.px(),
198  towP4.py(),
199  towP4.pz(),
200  towP4.energy() );
201  input_object->set_user_index(index);
202  }
203 }
#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

std::vector<HcalDetId> PileUpSubtractor::allgeomid_
protected
bool PileUpSubtractor::doAreaFastjet_
protected
bool PileUpSubtractor::doRhoFastjet_
protected
std::map<int,double> PileUpSubtractor::emean_
protected
std::map<int,double> PileUpSubtractor::esigma_
protected
ActiveAreaSpecPtr PileUpSubtractor::fjActiveArea_
protected
ClusterSequencePtr PileUpSubtractor::fjClusterSeq_
protected

Definition at line 55 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

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

Definition at line 54 of file PileUpSubtractor.h.

Referenced by setDefinition().

std::vector<fastjet::PseudoJet>* PileUpSubtractor::fjJets_
protected
std::vector<fastjet::PseudoJet> PileUpSubtractor::fjOriginalInputs_
protected
RangeDefPtr PileUpSubtractor::fjRangeDef_
protected

Definition at line 71 of file PileUpSubtractor.h.

Referenced by PileUpSubtractor().

CaloGeometry const* PileUpSubtractor::geo_
protected
std::map<int,int> PileUpSubtractor::geomtowers_
protected
int PileUpSubtractor::ietamax_
protected
int PileUpSubtractor::ietamin_
protected
std::vector<edm::Ptr<reco::Candidate> >* PileUpSubtractor::inputs_
protected

Definition at line 56 of file PileUpSubtractor.h.

Referenced by calculateOrphanInput(), and reset().

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

Definition at line 65 of file PileUpSubtractor.h.

Referenced by ParametrizedSubtractor::offsetCorrectJets().

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

Definition at line 66 of file PileUpSubtractor.h.

Referenced by calculateOrphanInput(), and PileUpSubtractor().

double PileUpSubtractor::radiusPU_
protected

Definition at line 69 of file PileUpSubtractor.h.

Referenced by calculateOrphanInput().

bool PileUpSubtractor::reRunAlgo_
protected

Definition at line 62 of file PileUpSubtractor.h.