CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 algoId, const CaloSubdetectorGeometry &geometry, const CaloTopology &topology) const
 
 HiEgammaSCEnergyCorrectionAlgo (float noise, const edm::ParameterSet &pSet, VerbosityLevel verbosity=pERROR)
 

Private Member Functions

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

Private Attributes

const double maxR9_
 
const double minR9Barrel_
 
const double minR9Endcap_
 
const std::vector< double > p_fBrem_
 
const std::vector< double > p_fBremTh_
 
const std::vector< double > p_fEta_
 
const std::vector< double > p_fEtEta_
 
const float sigmaElectronicNoise_
 
const VerbosityLevel verbosity_
 

Detailed Description

Definition at line 21 of file HiEgammaSCEnergyCorrectionAlgo.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

HiEgammaSCEnergyCorrectionAlgo::HiEgammaSCEnergyCorrectionAlgo ( float  noise,
const edm::ParameterSet pSet,
HiEgammaSCEnergyCorrectionAlgo::VerbosityLevel  verbosity = pERROR 
)

Definition at line 10 of file HiEgammaSCEnergyCorrectionAlgo.cc.

15 
16  // Parameters
17  p_fEta_(pSet.getParameter<std::vector<double> >("fEtaVect")),
18  p_fBremTh_(pSet.getParameter<std::vector<double> >("fBremThVect")),
19  p_fBrem_(pSet.getParameter<std::vector<double> >("fBremVect")),
20  p_fEtEta_(pSet.getParameter<std::vector<double> >("fEtEtaVect")),
21 
22  // Min R9
23  minR9Barrel_(pSet.getParameter<double>("minR9Barrel")),
24  minR9Endcap_(pSet.getParameter<double>("minR9Endcap")),
25 
26  // Max R9
27  maxR9_(pSet.getParameter<double>("maxR9")) {}
__shared__ int noise
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

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

Definition at line 29 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_.

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

Definition at line 197 of file HiEgammaSCEnergyCorrectionAlgo.cc.

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

Referenced by applyCorrection().

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

Definition at line 177 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, PVValHelper::eta, validate-o2o-wbm::f, reco::CaloCluster::island, hltrates_dqm_sourceclient-live_cfg::offset, and p_fEta_.

Referenced by applyCorrection().

177  {
178  int offset = 0;
179  float factor;
180  if ((theBase == EcalBarrel) && (algoId == reco::CaloCluster::island)) {
181  offset = 0;
182  } else if ((theBase == EcalEndcap) && (algoId == reco::CaloCluster::island)) {
183  offset = 3;
184  }
185 
186  factor = (p_fEta_[0 + offset] + p_fEta_[1 + offset] * fabs(eta) + p_fEta_[2 + offset] * eta * eta);
187 
188  // Constraint correction factor
189  if (factor < 0.66f)
190  factor = 0.66f;
191  if (factor > 1.5f)
192  factor = 1.5f;
193 
194  return factor;
195 }
float HiEgammaSCEnergyCorrectionAlgo::fEtEta ( float  et,
float  eta,
reco::CaloCluster::AlgoId  algoId,
EcalSubdetector  theBase 
) const
private

Definition at line 150 of file HiEgammaSCEnergyCorrectionAlgo.cc.

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

Referenced by applyCorrection().

153  {
154  int offset = 0;
155  float factor;
156  if ((theBase == EcalBarrel) && (algoId == reco::CaloCluster::island)) {
157  offset = 0;
158  } else if ((theBase == EcalEndcap) && (algoId == reco::CaloCluster::island)) {
159  offset = 7;
160  }
161 
162  // Et dependent correction
163  factor = (p_fEtEta_[0 + offset] + p_fEtEta_[1 + offset] * sqrt(et));
164  // eta dependent correction
165  factor *= (p_fEtEta_[2 + offset] + p_fEtEta_[3 + offset] * fabs(eta) + p_fEtEta_[4 + offset] * eta * eta +
166  p_fEtEta_[5 + offset] * eta * eta * fabs(eta) + +p_fEtEta_[6 + offset] * eta * eta * eta * eta);
167 
168  // Constraint correction factor
169  if (factor < 0.66f)
170  factor = 0.66f;
171  if (factor > 1.5f)
172  factor = 1.5f;
173 
174  return factor;
175 }
T sqrt(T t)
Definition: SSEVec.h:19
float HiEgammaSCEnergyCorrectionAlgo::fNCrystals ( int  nCry,
reco::CaloCluster::AlgoId  algoId,
EcalSubdetector  theBase 
) const
private

Definition at line 228 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, EcalBarrel, EcalEndcap, validate-o2o-wbm::f, reco::CaloCluster::island, fireworks::p1, fireworks::p2, pINFO, mps_fire::result, verbosity_, and x.

230  {
231  float x = (float)nCry;
232  float result = 1.f;
233 
234  if ((theBase == EcalBarrel) && (algoId == reco::CaloCluster::island)) {
235  float const p0 = 0.682554f;
236  float const p1 = 0.0253013f;
237  float const p2 = -0.0007907f;
238  float const p3 = 1.166e-5f;
239  float const p4 = -6.7387e-8f;
240  if (x < 10.f)
241  x = 10.f;
242  if (x < 40.f)
243  result = p0 + x * (p1 + x * (p2 + x * (p3 + x * p4)));
244  else
245  result = 1.f;
246  }
247 
248  else if ((theBase == EcalEndcap) && (algoId == reco::CaloCluster::island)) {
249  float const p0 = 0.712185f;
250  float const p1 = 0.0273609f;
251  float const p2 = -0.00103818f;
252  float const p3 = 2.01828e-05f;
253  float const p4 = -1.71438e-07f;
254  if (x < 10.f)
255  x = 10.f;
256  if (x < 40.f)
257  result = p0 + x * (p1 + x * (p2 + x * (p3 + x * p4)));
258  else
259  result = 1.f;
260  }
261 
262  else {
263  if (verbosity_ <= pINFO) {
264  std::cout << "trying to correct unknown cluster!!!" << std::endl;
265  }
266  }
267 
268  if (result > 1.5f)
269  result = 1.5f;
270  if (result < 0.5f)
271  result = 0.5f;
272 
273  return result;
274 }
const TString p2
Definition: fwPaths.cc:13
tuple result
Definition: mps_fire.py:311
const TString p1
Definition: fwPaths.cc:12
tuple cout
Definition: gather_cfg.py:144
int HiEgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma ( reco::BasicCluster const &  seed,
EcalRecHitCollection const &  rhc 
) const
private

Definition at line 276 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References gather_cfg::cout, edm::SortedCollection< T, SORT >::find(), reco::CaloCluster::hitsAndFractions(), pINFO, sigmaElectronicNoise_, trackerHitRTTI::vector, and verbosity_.

Referenced by applyCorrection().

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

Member Data Documentation

const double HiEgammaSCEnergyCorrectionAlgo::maxR9_
private

Definition at line 60 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by applyCorrection().

const double HiEgammaSCEnergyCorrectionAlgo::minR9Barrel_
private

Definition at line 58 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by applyCorrection().

const double HiEgammaSCEnergyCorrectionAlgo::minR9Endcap_
private

Definition at line 59 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by applyCorrection().

const std::vector<double> HiEgammaSCEnergyCorrectionAlgo::p_fBrem_
private

Definition at line 55 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fBrem().

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

Definition at line 55 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fBrem().

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

Definition at line 54 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fEta().

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

Definition at line 56 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by fEtEta().

const float HiEgammaSCEnergyCorrectionAlgo::sigmaElectronicNoise_
private

Definition at line 48 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by nCrystalsGT2Sigma().

const VerbosityLevel HiEgammaSCEnergyCorrectionAlgo::verbosity_
private

Definition at line 51 of file HiEgammaSCEnergyCorrectionAlgo.h.

Referenced by applyCorrection(), fNCrystals(), and nCrystalsGT2Sigma().