CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
ReflectedIterator Class Reference

#include <ReflectedIterator.h>

Inheritance diagram for ReflectedIterator:
PileUpSubtractor

Public Member Functions

virtual void calculatePedestal (std::vector< fastjet::PseudoJet > const &coll)
 
double getEt (const reco::CandidatePtr &in) const
 
double getEta (const reco::CandidatePtr &in) const
 
virtual void offsetCorrectJets ()
 
 ReflectedIterator (const edm::ParameterSet &iConfig)
 
void rescaleRMS (double s)
 
virtual void subtractPedestal (std::vector< fastjet::PseudoJet > &coll)
 
 ~ReflectedIterator ()
 
- 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)
 
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)
 
 ~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
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 6 of file ReflectedIterator.h.

Constructor & Destructor Documentation

ReflectedIterator::ReflectedIterator ( const edm::ParameterSet iConfig)
inline

Definition at line 8 of file ReflectedIterator.h.

8  : PileUpSubtractor(iConfig),
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)
ReflectedIterator::~ReflectedIterator ( )
inline

Definition at line 21 of file ReflectedIterator.h.

21 {;}

Member Function Documentation

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

Reimplemented from PileUpSubtractor.

Definition at line 111 of file ReflectedIterator.cc.

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

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)
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:46
int nt
Definition: AMPTWrapper.h:32
JetCorrectorParametersCollection coll
Definition: classes.h:14
DTRecHit1DPair & gt
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(), relval_parameters_module::energy, edm::Ptr< T >::get(), CaloTower::hadEnergy(), CaloTower::id(), pos, funct::sin(), and PV3DBase< T, PVType, FrameType >::theta().

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 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
double emEnergy() const
Definition: CaloTower.h:79
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
double hadEnergy() const
Definition: CaloTower.h:80
CaloTowerDetId id() const
Definition: CaloTower.h:72
CaloGeometry const * geo_
double ReflectedIterator::getEta ( const reco::CandidatePtr in) const

Definition at line 192 of file ReflectedIterator.cc.

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

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 eta() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
CaloTowerDetId id() const
Definition: CaloTower.h:72
T eta() const
Definition: PV3DBase.h:75
CaloGeometry const * geo_
void ReflectedIterator::offsetCorrectJets ( )
virtual

Reimplemented from PileUpSubtractor.

Definition at line 16 of file ReflectedIterator.cc.

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

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_
ActiveAreaSpecPtr fjActiveArea_
ClusterSequencePtr fjClusterSeq_
virtual void subtractPedestal(std::vector< fastjet::PseudoJet > &coll)
std::map< int, double > emean_
void rescaleRMS(double s)
JetCorrectorParameters::Definitions def
Definition: classes.h:10
void ReflectedIterator::rescaleRMS ( double  s)

Definition at line 8 of file ReflectedIterator.cc.

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)
virtual

Reimplemented from PileUpSubtractor.

Definition at line 67 of file ReflectedIterator.cc.

References getHLTprescales::index, and LogDebug.

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:15
std::map< int, double > esigma_
int ieta(const reco::CandidatePtr &in) const
int iphi(const reco::CandidatePtr &in) const
JetCorrectorParametersCollection coll
Definition: classes.h:14
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.