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 | Private Member Functions | Private Attributes
HiEgammaSCEnergyCorrectionAlgo Class Reference

#include <HiEgammaSCEnergyCorrectionAlgo.h>

Public Types

enum  VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }
 

Public Member Functions

reco::SuperCluster applyCorrection (const reco::SuperCluster &cl, const EcalRecHitCollection &rhc, reco::CaloCluster::AlgoId theAlgo, const CaloSubdetectorGeometry *geometry, const CaloTopology *topology, EcalClusterFunctionBaseClass *EnergyCorrectionClass)
 
 HiEgammaSCEnergyCorrectionAlgo (float noise, reco::CaloCluster::AlgoId theAlgo, const edm::ParameterSet &pSet, VerbosityLevel verbosity=pERROR)
 
void setVerbosity (VerbosityLevel verbosity)
 
 ~HiEgammaSCEnergyCorrectionAlgo ()
 

Private Member Functions

float fBrem (float widthRatio, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
 
float fEta (float eta, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
 
float fEtEta (float et, float eta, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
 
float fNCrystals (int nCry, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
 
int nCrystalsGT2Sigma (reco::BasicCluster const &seed, EcalRecHitCollection const &rhc) const
 

Private Attributes

double maxR9_
 
double minR9Barrel_
 
double minR9Endcap_
 
std::vector< double > p_fBrem_
 
std::vector< double > p_fBremTh_
 
std::vector< double > p_fEta_
 
std::vector< double > p_fEtEta_
 
float sigmaElectronicNoise_
 
reco::CaloCluster::AlgoId theAlgo_
 
VerbosityLevel verbosity_
 

Detailed Description

Definition at line 23 of file HiEgammaSCEnergyCorrectionAlgo.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

HiEgammaSCEnergyCorrectionAlgo::HiEgammaSCEnergyCorrectionAlgo ( float  noise,
reco::CaloCluster::AlgoId  theAlgo,
const edm::ParameterSet pSet,
HiEgammaSCEnergyCorrectionAlgo::VerbosityLevel  verbosity = pERROR 
)

Definition at line 10 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References edm::ParameterSet::getParameter(), maxR9_, minR9Barrel_, minR9Endcap_, HLT_25ns14e33_v1_cff::noise, p_fBrem_, p_fBremTh_, p_fEta_, p_fEtEta_, sigmaElectronicNoise_, HLT_25ns14e33_v1_cff::verbosity, and verbosity_.

15 {
18 
19  // Parameters
20  p_fBrem_ = pSet.getParameter< std::vector <double> > ("fBremVect");
21  p_fBremTh_ = pSet.getParameter< std::vector <double> > ("fBremThVect");
22  p_fEta_ = pSet.getParameter< std::vector <double> > ("fEtaVect");
23  p_fEtEta_ = pSet.getParameter< std::vector <double> > ("fEtEtaVect");
24 
25  // Min R9
26  minR9Barrel_ = pSet.getParameter<double>("minR9Barrel");
27  minR9Endcap_ = pSet.getParameter<double>("minR9Endcap");
28 
29  // Max R9
30  maxR9_ = pSet.getParameter<double>("maxR9");
31 
32 }
T getParameter(std::string const &) const
HiEgammaSCEnergyCorrectionAlgo::~HiEgammaSCEnergyCorrectionAlgo ( )
inline

Definition at line 34 of file HiEgammaSCEnergyCorrectionAlgo.h.

34 {}

Member Function Documentation

reco::SuperCluster HiEgammaSCEnergyCorrectionAlgo::applyCorrection ( const reco::SuperCluster cl,
const EcalRecHitCollection rhc,
reco::CaloCluster::AlgoId  theAlgo,
const CaloSubdetectorGeometry geometry,
const CaloTopology topology,
EcalClusterFunctionBaseClass EnergyCorrectionClass 
)

Definition at line 37 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References SuperClusterShapeAlgo::Calculate_Covariances(), reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, EcalBarrel, EcalEndcap, reco::CaloCluster::energy(), reco::CaloCluster::eta(), SuperClusterShapeAlgo::etaWidth(), fBrem(), fEta(), fEtEta(), reco::CaloCluster::flags(), maxR9_, minR9Barrel_, minR9Endcap_, nCrystalsGT2Sigma(), SuperClusterShapeAlgo::phiWidth(), pINFO, reco::CaloCluster::position(), reco::SuperCluster::preshowerEnergy(), edm::PtrVector< T >::push_back(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), reco::CaloCluster::setFlags(), reco::CaloCluster::size(), and verbosity_.

Referenced by HiEgammaSCCorrectionMaker::produce().

41 {
42 
43  // Print out a little bit of trivial info to be sure all is well
44  if (verbosity_ <= pINFO)
45  {
46  std::cout << " HiEgammaSCEnergyCorrectionAlgo::applyCorrection" << std::endl;
47  std::cout << " SC has energy " << cl.energy() << std::endl;
48  std::cout << " Will correct now.... " << std::endl;
49  }
50 
51  // Get the seed cluster
52  reco::CaloClusterPtr seedC = cl.seed();
53 
54  if (verbosity_ <= pINFO)
55  {
56  std::cout << " Seed cluster energy... " << seedC->energy() << std::endl;
57  }
58 
59  // Get the constituent clusters
60  reco::CaloClusterPtrVector clusters_v;
61 
62  if (verbosity_ <= pINFO) std::cout << " Constituent cluster energies... ";
63 
64  for(reco::CaloCluster_iterator cluster = cl.clustersBegin(); cluster != cl.clustersEnd(); cluster ++)
65  {
66  clusters_v.push_back(*cluster);
67  if (verbosity_ <= pINFO) std::cout << (*cluster)->energy() << ", ";
68  }
69  if (verbosity_ <= pINFO) std::cout << std::endl;
70 
71  // Find the algorithm used to construct the basic clusters making up the supercluster
72  if (verbosity_ <= pINFO)
73  {
74  std::cout << " The seed cluster used algo " << theAlgo;
75  }
76 
77  // Find the detector region of the supercluster
78  // where is the seed cluster?
79  std::vector<std::pair<DetId, float> > const & seedHits = seedC->hitsAndFractions();
80  EcalSubdetector theBase = EcalSubdetector(seedHits.at(0).first.subdetId());
81  if (verbosity_ <= pINFO)
82  {
83  std::cout << " seed cluster location == " << theBase << std::endl;
84  }
85 
86  // Get number of crystals 2sigma above noise in seed basiccluster
87  int nCryGT2Sigma = nCrystalsGT2Sigma(*seedC,rhc);
88  if (verbosity_ <= pINFO)
89  {
90  std::cout << " nCryGT2Sigma " << nCryGT2Sigma << std::endl;
91  }
92 
93  // Supercluster enery - seed basiccluster energy
94  float bremsEnergy = cl.energy() - seedC->energy();
95  if (verbosity_ <= pINFO)
96  {
97  std::cout << " bremsEnergy " << bremsEnergy << std::endl;
98  }
99 
100  // Create a SuperClusterShapeAlgo
101  // which calculates phiWidth and etaWidth
102  SuperClusterShapeAlgo SCShape(&rhc, geometry);
103 
104  double phiWidth = 0.;
105  double etaWidth = 0.;
106 
107  // Calculate phiWidth & etaWidth for SuperClusters
108  SCShape.Calculate_Covariances(cl);
109  phiWidth = SCShape.phiWidth();
110  etaWidth = SCShape.etaWidth();
111 
112  // Calculate r9 and 5x5 energy
113  float e3x3 = EcalClusterTools::e3x3( *(cl.seed()), &rhc, &(*topology));
114  float e5x5 = EcalClusterTools::e5x5( *(cl.seed()), &rhc, &(*topology));
115  float r9 = e3x3 / cl.rawEnergy();
116 
117  // Calculate the new supercluster energy
118  // as a function of number of crystals in the seed basiccluster for Endcap
119  // lslslsor apply new Enegry SCale correction
120  float newEnergy = 0;
121 
122  // if r9 > maxR9_ -> uncaptured brem.
123  if ((r9 < minR9Barrel_&&theBase == EcalBarrel) || (r9 < minR9Endcap_&&theBase == EcalEndcap)) {
124  // if r9 is greater than threshold, then use the SC raw energy
125  newEnergy = (cl.rawEnergy())/ fEta(cl.eta(), theAlgo, theBase) /
126  fBrem(phiWidth/etaWidth, theAlgo, theBase)
127  /fEtEta(cl.energy()/cosh(cl.eta()), cl.eta(), theAlgo, theBase);
128 
129  } else {
130  if (r9 < maxR9_) {
131  // use 5x5 energy if r9 < threshold
132  newEnergy = e5x5 / fEta(cl.eta(), theAlgo, theBase);
133  } else {
134  // it comes from a uncaptured brem, doesn't correct
135  newEnergy = cl.rawEnergy();
136  }
137  }
138 
139  if (newEnergy > 2* cl.rawEnergy()) newEnergy = cl.rawEnergy(); // avoid very large correction due to the uncaptured brem
140 
141  // Create a new supercluster with the corrected energy
142  if (verbosity_ <= pINFO)
143  {
144  std::cout << " UNCORRECTED SC has energy... " << cl.energy() << std::endl;
145  std::cout << " CORRECTED SC has energy... " << newEnergy << std::endl;
146  std::cout << " Size..." <<cl.size() << std::endl;
147  std::cout << " Seed nCryGT2Sigma Size..." <<nCryGT2Sigma << std::endl;
148  }
149 
150  reco::SuperCluster corrCl(newEnergy,
151  math::XYZPoint(cl.position().X(), cl.position().Y(), cl.position().Z()),
152  cl.seed(), clusters_v, cl.preshowerEnergy());
153 
154  //set the flags, although we should implement a ctor in SuperCluster
155  corrCl.setFlags(cl.flags());
156  corrCl.setPhiWidth(phiWidth);
157  corrCl.setEtaWidth(etaWidth);
158 
159  return corrCl;
160 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
float fBrem(float widthRatio, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
float fEta(float eta, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
float fEtEta(float et, float eta, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
void setFlags(uint32_t flags)
Definition: CaloCluster.h:176
uint32_t flags() const
Definition: CaloCluster.h:175
int nCrystalsGT2Sigma(reco::BasicCluster const &seed, EcalRecHitCollection const &rhc) const
double energy() const
cluster energy
Definition: CaloCluster.h:121
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:169
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
tuple cout
Definition: gather_cfg.py:121
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:50
EcalSubdetector
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78
float HiEgammaSCEnergyCorrectionAlgo::fBrem ( float  widthRatio,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const
private

Definition at line 205 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, f, reco::CaloCluster::island, hltrates_dqm_sourceclient-live_cfg::offset, p_fBrem_, and p_fBremTh_.

Referenced by applyCorrection().

206 {
207  int det = 0;
208  int offset = 0;
209  float factor;
210  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
211  det = 0;
212  offset = 0;
213  } else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
214  det = 1;
215  offset = 6;
216  }
217 
218  if (brem < p_fBremTh_[det]) {
219  factor = p_fBrem_[0+offset] + p_fBrem_[1+offset]*brem + p_fBrem_[2+offset]*brem*brem;
220  } else {
221  factor = p_fBrem_[3+offset] + p_fBrem_[4+offset]*brem + p_fBrem_[5+offset]*brem*brem;
222  };
223 
224  // Constraint correction factor
225  if (factor< 0.66f ) factor = 0.66f;
226  if (factor> 1.5f ) factor = 1.5f;
227 
228  return factor;
229 }
double f[11][100]
float HiEgammaSCEnergyCorrectionAlgo::fEta ( float  eta,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const
private

Definition at line 186 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, eta(), f, reco::CaloCluster::island, hltrates_dqm_sourceclient-live_cfg::offset, and p_fEta_.

Referenced by applyCorrection().

187 {
188  int offset = 0;
189  float factor;
190  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
191  offset = 0;
192  } else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
193  offset = 3;
194  }
195 
196  factor = (p_fEta_[0+offset] + p_fEta_[1+offset]*fabs(eta) + p_fEta_[2+offset]*eta*eta);
197 
198  // Constraint correction factor
199  if (factor< 0.66f ) factor = 0.66f;
200  if (factor> 1.5f ) factor = 1.5f;
201 
202  return factor;
203 }
T eta() const
double f[11][100]
float HiEgammaSCEnergyCorrectionAlgo::fEtEta ( float  et,
float  eta,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const
private

Definition at line 162 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, eta(), f, reco::CaloCluster::island, hltrates_dqm_sourceclient-live_cfg::offset, p_fEtEta_, and mathSSE::sqrt().

Referenced by applyCorrection().

163 {
164  int offset = 0;
165  float factor;
166  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
167  offset = 0;
168  } else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
169  offset = 7;
170  }
171 
172  // Et dependent correction
173  factor = (p_fEtEta_[0+offset] + p_fEtEta_[1+offset]*sqrt(et));
174  // eta dependent correction
175  factor *= (p_fEtEta_[2+offset] + p_fEtEta_[3+offset]*fabs(eta) +
177 
178  // Constraint correction factor
179  if (factor< 0.66f ) factor = 0.66f;
180  if (factor> 1.5f ) factor = 1.5f;
181 
182  return factor;
183 
184 }
T eta() const
T sqrt(T t)
Definition: SSEVec.h:48
double f[11][100]
float HiEgammaSCEnergyCorrectionAlgo::fNCrystals ( int  nCry,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const
private

Definition at line 233 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, EcalBarrel, EcalEndcap, f, reco::CaloCluster::island, p1, p2, p3, p4, pINFO, query::result, verbosity_, and x.

234 {
235 
236  float x = (float) nCry;
237  float result =1.f;
238 
239  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
240  float const p0 = 0.682554f;
241  float const p1 = 0.0253013f;
242  float const p2 = -0.0007907f;
243  float const p3 = 1.166e-5f;
244  float const p4 = -6.7387e-8f;
245  if (x < 10.f) x = 10.f;
246  if (x < 40.f) result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4))); else result = 1.f;
247  }
248 
249  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
250 
251  float const p0 = 0.712185f;
252  float const p1 = 0.0273609f;
253  float const p2 = -0.00103818f;
254  float const p3 = 2.01828e-05f;
255  float const p4 = -1.71438e-07f;
256  if (x < 10.f) x = 10.f;
257  if (x < 40.f) result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4))); else result = 1.f;
258  }
259 
260  else {
261  if (verbosity_ <= pINFO)
262  {
263  std::cout << "trying to correct unknown cluster!!!" << std::endl;
264  }
265  }
266 
267  if (result > 1.5f) result = 1.5f;
268  if (result < 0.5f) result = 0.5f;
269 
270  return result;
271 }
double p4[4]
Definition: TauolaWrapper.h:92
tuple result
Definition: query.py:137
double f[11][100]
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
double p3[4]
Definition: TauolaWrapper.h:91
int HiEgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma ( reco::BasicCluster const &  seed,
EcalRecHitCollection const &  rhc 
) const
private

Definition at line 273 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, edm::SortedCollection< T, SORT >::find(), pINFO, sigmaElectronicNoise_, and verbosity_.

Referenced by applyCorrection().

273  {
274  // return number of crystals 2Sigma above
275  // electronic noise
276 
277  std::vector<std::pair<DetId,float > > const & hits = seed.hitsAndFractions();
278 
279  if (verbosity_ <= pINFO)
280  {
281  std::cout << " HiEgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma" << std::endl;
282  std::cout << " Will calculate number of crystals above 2sigma noise" << std::endl;
283  std::cout << " sigmaElectronicNoise = " << sigmaElectronicNoise_ << std::endl;
284  std::cout << " There are " << hits.size() << " recHits" << std::endl;
285  }
286 
287  int nCry = 0;
288  for(std::vector<std::pair<DetId,float > >::const_iterator hit = hits.begin(); hit != hits.end(); ++hit)
289  {
290  // need to get hit by DetID in order to get energy
291  EcalRecHitCollection::const_iterator aHit = rhc.find((*hit).first);
292  // better the hit to exists....
293  if(aHit->energy()>2.f*sigmaElectronicNoise_) ++nCry;
294  }
295 
296  if (verbosity_ <= pINFO)
297  {
298  std::cout << " " << nCry << " of these above 2sigma noise" << std::endl;
299  }
300 
301  return nCry;
302 }
std::vector< EcalRecHit >::const_iterator const_iterator
tuple cout
Definition: gather_cfg.py:121
void HiEgammaSCEnergyCorrectionAlgo::setVerbosity ( VerbosityLevel  verbosity)
inline

Member Data Documentation

double HiEgammaSCEnergyCorrectionAlgo::maxR9_
private
double HiEgammaSCEnergyCorrectionAlgo::minR9Barrel_
private
double HiEgammaSCEnergyCorrectionAlgo::minR9Endcap_
private
std::vector<double> HiEgammaSCEnergyCorrectionAlgo::p_fBrem_
private

Definition at line 72 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fBrem(), and HiEgammaSCEnergyCorrectionAlgo().

std::vector<double> HiEgammaSCEnergyCorrectionAlgo::p_fBremTh_
private

Definition at line 72 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fBrem(), and HiEgammaSCEnergyCorrectionAlgo().

std::vector<double> HiEgammaSCEnergyCorrectionAlgo::p_fEta_
private

Definition at line 71 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fEta(), and HiEgammaSCEnergyCorrectionAlgo().

std::vector<double> HiEgammaSCEnergyCorrectionAlgo::p_fEtEta_
private

Definition at line 73 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fEtEta(), and HiEgammaSCEnergyCorrectionAlgo().

float HiEgammaSCEnergyCorrectionAlgo::sigmaElectronicNoise_
private
reco::CaloCluster::AlgoId HiEgammaSCEnergyCorrectionAlgo::theAlgo_
private

Definition at line 68 of file HiEgammaSCEnergyCorrectionAlgo.h.

VerbosityLevel HiEgammaSCEnergyCorrectionAlgo::verbosity_
private