CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
ReflectedIterator Class Reference

#include <ReflectedIterator.h>

Inheritance diagram for ReflectedIterator:
PileUpSubtractor

Public Member Functions

void calculatePedestal (std::vector< fastjet::PseudoJet > const &coll) override
 
double getEt (const reco::CandidatePtr &in) const
 
double getEta (const reco::CandidatePtr &in) const
 
void offsetCorrectJets () override
 
 ReflectedIterator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
void rescaleRMS (double s)
 
void subtractPedestal (std::vector< fastjet::PseudoJet > &coll) override
 
 ~ReflectedIterator () override
 
- Public Member Functions inherited from PileUpSubtractor
virtual void calculateOrphanInput (std::vector< fastjet::PseudoJet > &orphanInput)
 
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
 
 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 ~PileUpSubtractor ()
 

Public Attributes

bool dropZeroTowers_
 
bool sumRecHits_
 

Additional Inherited Members

- Public Types inherited from PileUpSubtractor
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
 
- Protected Attributes inherited from PileUpSubtractor
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 6 of file ReflectedIterator.h.

Constructor & Destructor Documentation

ReflectedIterator::ReflectedIterator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 8 of file ReflectedIterator.h.

References calculatePedestal(), coll, getEt(), getEta(), recoMuon::in, offsetCorrectJets(), rescaleRMS(), alignCSCRings::s, and subtractPedestal().

8  : PileUpSubtractor(iConfig, std::move(iC)),
9  sumRecHits_(iConfig.getParameter<bool>("sumRecHits")),
10  dropZeroTowers_(iConfig.getUntrackedParameter<bool>("dropZeroTowers",true))
11  {;}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
PileUpSubtractor(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
def move(src, dest)
Definition: eostools.py:510
ReflectedIterator::~ReflectedIterator ( )
inlineoverride

Definition at line 21 of file ReflectedIterator.h.

21 {;}

Member Function Documentation

void ReflectedIterator::calculatePedestal ( std::vector< fastjet::PseudoJet > const &  coll)
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 111 of file ReflectedIterator.cc.

References reco::e1, reco::e2, reco::Candidate::et(), mps_fire::i, LogDebug, nt, edm::second(), and mathSSE::sqrt().

Referenced by ReflectedIterator().

112 {
113  LogDebug("PileUpSubtractor")<<"The subtractor calculating pedestals...\n";
114 
115  map<int,double> emean2;
116  map<int,int> ntowers;
117 
118  int ietaold = -10000;
119  int ieta0 = -100;
120 
121  // Initial values for emean_, emean2, esigma_, ntowers
122 
123  for(int i = ietamin_; i < ietamax_+1; i++)
124  {
125  emean_[i] = 0.;
126  emean2[i] = 0.;
127  esigma_[i] = 0.;
128  ntowers[i] = 0;
129  }
130 
131  for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin (),
132  fjInputsEnd = coll.end();
133  input_object != fjInputsEnd; ++input_object) {
134 
135  const reco::CandidatePtr & originalTower=(*inputs_)[ input_object->user_index()];
136  ieta0 = ieta( originalTower );
137  double Original_Et = originalTower->et();
138  if(sumRecHits_){
139  Original_Et = getEt(originalTower);
140  }
141 
142  if( ieta0-ietaold != 0 )
143  {
144  emean_[ieta0] = emean_[ieta0]+Original_Et;
145  emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
146  ntowers[ieta0] = 1;
147  ietaold = ieta0;
148  }
149  else
150  {
151  emean_[ieta0] = emean_[ieta0]+Original_Et;
152  emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
153  ntowers[ieta0]++;
154  }
155 
156  }
157 
158  for(map<int,int>::const_iterator gt = geomtowers_.begin(); gt != geomtowers_.end(); gt++)
159  {
160 
161  int it = (*gt).first;
162 
163  double e1 = (*(emean_.find(it))).second;
164  double e2 = (*emean2.find(it)).second;
165  int nt = (*gt).second - (*(ntowersWithJets_.find(it))).second;
166 
167  LogDebug("PileUpSubtractor")<<" ieta : "<<it<<" number of towers : "<<nt<<" e1 : "<<e1<<" e2 : "<<e2<<"\n";
168 
169  if(nt > 0) {
170  emean_[it] = e1/nt;
171  double eee = e2/nt - e1*e1/(nt*nt);
172  if(eee<0.) eee = 0.;
173  esigma_[it] = nSigmaPU_*sqrt(eee);
174  }
175  else
176  {
177  emean_[it] = 0.;
178  esigma_[it] = 0.;
179  }
180  LogDebug("PileUpSubtractor")<<" ieta : "<<it<<" Pedestals : "<<emean_[it]<<" "<<esigma_[it]<<"\n";
181  }
182 }
#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)
virtual double et() const =0
transverse energy
std::map< int, int > ntowersWithJets_
T sqrt(T t)
Definition: SSEVec.h:18
int nt
Definition: AMPTWrapper.h:32
Float e1
Definition: deltaR.h:20
JetCorrectorParametersCollection coll
Definition: classes.h:10
Float e2
Definition: deltaR.h:21
double getEt(const reco::CandidatePtr &in) const
std::map< int, double > emean_
double ReflectedIterator::getEt ( const reco::CandidatePtr in) const

Definition at line 184 of file ReflectedIterator.cc.

References CaloTower::emEnergy(), stringResolutionProvider_cfi::et, edm::Ptr< T >::get(), CaloTower::hadEnergy(), CaloTower::id(), funct::sin(), and PV3DBase< T, PVType, FrameType >::theta().

Referenced by ReflectedIterator().

184  {
185  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
186  const GlobalPoint& pos=geo_->getPosition(ctc->id());
187  double energy = ctc->emEnergy() + ctc->hadEnergy();
188  double et = energy*sin(pos.theta());
189  return et;
190 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
double emEnergy() const
Definition: CaloTower.h:110
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
double hadEnergy() const
Definition: CaloTower.h:111
CaloTowerDetId id() const
Definition: CaloTower.h:103
et
define resolution functions of each parameter
CaloGeometry const * geo_
double ReflectedIterator::getEta ( const reco::CandidatePtr in) const

Definition at line 192 of file ReflectedIterator.cc.

References PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), edm::Ptr< T >::get(), and CaloTower::id().

Referenced by ReflectedIterator().

192  {
193  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
194  const GlobalPoint& pos=geo_->getPosition(ctc->id());
195  double eta = pos.eta();
196  return eta;
197 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
CaloTowerDetId id() const
Definition: CaloTower.h:103
T eta() const
Definition: PV3DBase.h:76
CaloGeometry const * geo_
void ReflectedIterator::offsetCorrectJets ( )
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 16 of file ReflectedIterator.cc.

References def, reco::Candidate::et(), LogDebug, and edm::second().

Referenced by ReflectedIterator().

17 {
18 
19  LogDebug("PileUpSubtractor")<<"The subtractor correcting jets...\n";
20  jetOffset_.clear();
21 
22  using namespace reco;
23 
24  (*fjInputs_) = fjOriginalInputs_;
27  const fastjet::JetDefinition& def = fjClusterSeq_->jet_def();
28  if ( !doAreaFastjet_ && !doRhoFastjet_) {
29  fastjet::ClusterSequence newseq( *fjInputs_, def );
30  (*fjClusterSeq_) = newseq;
31  } else {
32  fastjet::ClusterSequenceArea newseq( *fjInputs_, def , *fjActiveArea_ );
33  (*fjClusterSeq_) = newseq;
34  }
35 
36  (*fjJets_) = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
37 
38  jetOffset_.reserve(fjJets_->size());
39 
40  vector<fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin (),
41  jetsEnd = fjJets_->end();
42  for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
43 
44  int ijet = pseudojetTMP - fjJets_->begin();
45  jetOffset_[ijet] = 0;
46 
47  std::vector<fastjet::PseudoJet> towers =
48  sorted_by_pt(fjClusterSeq_->constituents(*pseudojetTMP));
49 
50  double newjetet = 0.;
51  for(vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(),
52  towEnd = towers.end();
53  ito != towEnd;
54  ++ito)
55  {
56  const reco::CandidatePtr& originalTower = (*inputs_)[ito->user_index()];
57  int it = ieta( originalTower );
58  double Original_Et = originalTower->et();
59  double etnew = Original_Et - (*emean_.find(-it)).second - (*esigma_.find(-it)).second;
60  if(etnew < 0.) etnew = 0;
61  newjetet = newjetet + etnew;
62  jetOffset_[ijet] += Original_Et - etnew;
63  }
64  }
65 }
#define LogDebug(id)
std::vector< double > jetOffset_
std::vector< fastjet::PseudoJet > * fjJets_
std::map< int, double > esigma_
std::vector< fastjet::PseudoJet > fjOriginalInputs_
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
std::vector< fastjet::PseudoJet > * fjInputs_
virtual double et() const =0
transverse energy
ActiveAreaSpecPtr fjActiveArea_
ClusterSequencePtr fjClusterSeq_
fixed size matrix
std::map< int, double > emean_
void rescaleRMS(double s)
void subtractPedestal(std::vector< fastjet::PseudoJet > &coll) override
JetCorrectorParameters::Definitions def
Definition: classes.h:6
void ReflectedIterator::rescaleRMS ( double  s)

Definition at line 8 of file ReflectedIterator.cc.

Referenced by ReflectedIterator().

8  {
9  for ( std::map<int, double>::iterator iter = esigma_.begin();
10  iter != esigma_.end(); ++iter ){
11  iter->second = s*(iter->second);
12  }
13 }
std::map< int, double > esigma_
void ReflectedIterator::subtractPedestal ( std::vector< fastjet::PseudoJet > &  coll)
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 67 of file ReflectedIterator.cc.

References reco::Candidate::et(), and LogDebug.

Referenced by ReflectedIterator().

68 {
69 
70  LogDebug("PileUpSubtractor")<<"The subtractor subtracting pedestals...\n";
71 
72  int it = -100;
73 
74  vector<fastjet::PseudoJet> newcoll;
75 
76  for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
77  fjInputsEnd = coll.end();
78  input_object != fjInputsEnd; ++input_object) {
79 
80  reco::CandidatePtr const & itow = (*inputs_)[ input_object->user_index() ];
81 
82  it = ieta( itow );
83  iphi( itow );
84 
85  double Original_Et = itow->et();
86  if(sumRecHits_){
87  Original_Et = getEt(itow);
88  }
89 
90  double etnew = Original_Et - (*(emean_.find(-it))).second - (*(esigma_.find(-it))).second;
91  float mScale = etnew/input_object->Et();
92  if(etnew < 0.) mScale = 0.;
93 
94  math::XYZTLorentzVectorD towP4(input_object->px()*mScale, input_object->py()*mScale,
95  input_object->pz()*mScale, input_object->e()*mScale);
96 
97  int index = input_object->user_index();
98  input_object->reset ( towP4.px(),
99  towP4.py(),
100  towP4.pz(),
101  towP4.energy() );
102  input_object->set_user_index(index);
103 
104  if(etnew > 0. && dropZeroTowers_) newcoll.push_back(*input_object);
105  }
106 
107  if(dropZeroTowers_) coll = newcoll;
108 
109 }
#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
virtual double et() const =0
transverse energy
int iphi(const reco::CandidatePtr &in) const
JetCorrectorParametersCollection coll
Definition: classes.h:10
double getEt(const reco::CandidatePtr &in) const
std::map< int, double > emean_

Member Data Documentation

bool ReflectedIterator::dropZeroTowers_

Definition at line 20 of file ReflectedIterator.h.

bool ReflectedIterator::sumRecHits_

Definition at line 19 of file ReflectedIterator.h.