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
EgammaSCEnergyCorrectionAlgo Class Reference

#include <EgammaSCEnergyCorrectionAlgo.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, EcalClusterFunctionBaseClass *energyCorrectionFunction)
 
reco::SuperCluster applyCrackCorrection (const reco::SuperCluster &cl, EcalClusterFunctionBaseClass *crackCorrectionFunction)
 
 EgammaSCEnergyCorrectionAlgo (float noise, reco::CaloCluster::AlgoId theAlgo, const edm::ParameterSet &pset, VerbosityLevel verbosity=pERROR)
 
void setVerbosity (VerbosityLevel verbosity)
 
 ~EgammaSCEnergyCorrectionAlgo ()
 

Private Member Functions

float fNCrystals (int nCry, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
 
int nCrystalsGT2Sigma (reco::BasicCluster const &seed, EcalRecHitCollection const &rhc) const
 

Private Attributes

float sigmaElectronicNoise_
 
reco::CaloCluster::AlgoId theAlgo_
 
VerbosityLevel verbosity_
 

Detailed Description

Definition at line 20 of file EgammaSCEnergyCorrectionAlgo.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 11 of file EgammaSCEnergyCorrectionAlgo.cc.

References sigmaElectronicNoise_, verbosity, and verbosity_.

EgammaSCEnergyCorrectionAlgo::~EgammaSCEnergyCorrectionAlgo ( )
inline

Definition at line 31 of file EgammaSCEnergyCorrectionAlgo.h.

31 {}

Member Function Documentation

reco::SuperCluster EgammaSCEnergyCorrectionAlgo::applyCorrection ( const reco::SuperCluster cl,
const EcalRecHitCollection rhc,
reco::CaloCluster::AlgoId  theAlgo,
const CaloSubdetectorGeometry geometry,
EcalClusterFunctionBaseClass energyCorrectionFunction 
)

Definition at line 23 of file EgammaSCEnergyCorrectionAlgo.cc.

References SuperClusterShapeAlgo::Calculate_Covariances(), gather_cfg::cout, reco::CaloCluster::dynamicHybrid, reco::CaloCluster::energy(), SuperClusterShapeAlgo::etaWidth(), fNCrystals(), EcalClusterFunctionBaseClass::getValue(), reco::CaloCluster::hybrid, reco::CaloCluster::multi5x5, nCrystalsGT2Sigma(), SuperClusterShapeAlgo::phiWidth(), pINFO, reco::SuperCluster::preshowerEnergy(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), reco::CaloCluster::setEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), tmp, and verbosity_.

Referenced by EgammaSCCorrectionMaker::produce().

26  {
27 
28 
29  // A little bit of trivial info to be sure all is well
30 
31  if (verbosity_ <= pINFO)
32  {
33  std::cout << " EgammaSCEnergyCorrectionAlgo::applyCorrection" << std::endl;
34  std::cout << " SC has energy " << cl.energy() << std::endl;
35  std::cout << " Will correct now.... " << std::endl;
36  }
37 
38  // Get the seed cluster
39  reco::CaloClusterPtr seedC = cl.seed();
40 
41  if (verbosity_ <= pINFO)
42  {
43  std::cout << " Seed cluster energy... " << seedC->energy() << std::endl;
44  }
45 
46 
47  // Find the algorithm used to construct the basic clusters making up the supercluster
48  if (verbosity_ <= pINFO)
49  {
50  std::cout << " The seed cluster used algo " << theAlgo;
51  }
52 
53  // Find the detector region of the supercluster
54  // where is the seed cluster?
55  std::vector<std::pair<DetId, float> > seedHits = seedC->hitsAndFractions();
56  EcalSubdetector theBase = EcalSubdetector(seedHits.at(0).first.subdetId());
57 
58  if (verbosity_ <= pINFO)
59  {
60  std::cout << " seed cluster location == " << theBase << std::endl;
61  }
62 
63  // Get number of crystals 2sigma above noise in seed basiccluster
64  int nCryGT2Sigma = nCrystalsGT2Sigma(*seedC,rhc);
65  if (verbosity_ <= pINFO)
66  {
67  std::cout << " nCryGT2Sigma " << nCryGT2Sigma << std::endl;
68  }
69 
70  // Supercluster enery - seed basiccluster energy
71  float bremsEnergy = cl.energy() - seedC->energy();
72  if (verbosity_ <= pINFO)
73  {
74  std::cout << " bremsEnergy " << bremsEnergy << std::endl;
75  }
76 
77  //Create the pointer ot class SuperClusterShapeAlgo
78  //which calculates phiWidth and etaWidth
79  SuperClusterShapeAlgo SCShape(&rhc, geometry);
80 
81  double phiWidth = 0.;
82  double etaWidth = 0.;
83  //Calculate phiWidth & etaWidth for SuperClusters
84  SCShape.Calculate_Covariances(cl);
85  phiWidth = SCShape.phiWidth();
86  etaWidth = SCShape.etaWidth();
87 
88  // Calculate the new supercluster energy
89  //as a function of number of crystals in the seed basiccluster for Endcap
90  //or apply new Enegry SCale correction
91  float newEnergy = 0;
92 
94  tmp.setPhiWidth(phiWidth);
95  tmp.setEtaWidth(etaWidth);
96 
97  if ( theAlgo == reco::CaloCluster::hybrid || theAlgo == reco::CaloCluster::dynamicHybrid ) {
98  newEnergy = tmp.rawEnergy() + energyCorrectionFunction->getValue(tmp, 3);
99 
100  } else if ( theAlgo == reco::CaloCluster::multi5x5 ) {
101  newEnergy = tmp.rawEnergy() + tmp.preshowerEnergy() + energyCorrectionFunction->getValue(tmp, 5);
102 
103  } else {
104  //Apply f(nCry) correction on island algo and fixedMatrix algo
105  newEnergy = seedC->energy()/fNCrystals(nCryGT2Sigma, theAlgo, theBase)+bremsEnergy;
106  }
107 
108  // Create a new supercluster with the corrected energy
109  if (verbosity_ <= pINFO)
110  {
111  std::cout << " UNCORRECTED SC has energy... " << cl.energy() << std::endl;
112  std::cout << " CORRECTED SC has energy... " << newEnergy << std::endl;
113  }
114 
115  reco::SuperCluster corrCl =cl;
116 
117  corrCl.setEnergy(newEnergy);
118  corrCl.setPhiWidth(phiWidth);
119  corrCl.setEtaWidth(etaWidth);
120 
121  return corrCl;
122 }
float fNCrystals(int nCry, reco::CaloCluster::AlgoId theAlgo, EcalSubdetector theBase) const
void setEnergy(double energy)
Definition: CaloCluster.h:109
void setPhiWidth(double pw)
Definition: SuperCluster.h:58
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
void setEtaWidth(double ew)
Definition: SuperCluster.h:59
double energy() const
cluster energy
Definition: CaloCluster.h:120
int nCrystalsGT2Sigma(reco::BasicCluster const &seed, EcalRecHitCollection const &rhc) const
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:41
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:62
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:50
EcalSubdetector
reco::SuperCluster EgammaSCEnergyCorrectionAlgo::applyCrackCorrection ( const reco::SuperCluster cl,
EcalClusterFunctionBaseClass crackCorrectionFunction 
)

Definition at line 242 of file EgammaSCEnergyCorrectionAlgo.cc.

References reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::CaloCluster::energy(), EcalClusterFunctionBaseClass::getValue(), reco::SuperCluster::rawEnergy(), and reco::CaloCluster::setEnergy().

Referenced by EgammaSCCorrectionMaker::produce().

243  {
244 
245 
246  double crackcor = 1.;
247 
248  for(reco::CaloCluster_iterator cIt = cl.clustersBegin(); cIt != cl.clustersEnd(); ++cIt) {
249 
250  const reco::CaloClusterPtr cc = *cIt;
251  crackcor *= ( (cl.rawEnergy() +
252  cc->energy()*(crackCorrectionFunction->getValue(*cc)-1.)) /
253  cl.rawEnergy() );
254  }// loop on BCs
255 
256 
257  reco::SuperCluster corrCl=cl;
258  corrCl.setEnergy(cl.energy()*crackcor);
259 
260 
261  return corrCl;
262 }
void setEnergy(double energy)
Definition: CaloCluster.h:109
virtual float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const =0
double energy() const
cluster energy
Definition: CaloCluster.h:120
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:65
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:68
float EgammaSCEnergyCorrectionAlgo::fNCrystals ( int  nCry,
reco::CaloCluster::AlgoId  theAlgo,
EcalSubdetector  theBase 
) const
private

Definition at line 124 of file EgammaSCEnergyCorrectionAlgo.cc.

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

Referenced by applyCorrection().

124  {
125 
126  float p0 = 0, p1 = 0, p2 = 0, p3 = 0, p4 = 0;
127  float x = nCry;
128  float result =1.f;
129 
130  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::hybrid)) {
131  if (nCry<=10)
132  {
133  p0 = 6.32879e-01f;
134  p1 = 1.14893e-01f;
135  p2 = -2.45705e-02f;
136  p3 = 2.53074e-03f;
137  p4 = -9.29654e-05f;
138  }
139  else if (nCry>10 && nCry<=30)
140  {
141  p0 = 6.93196e-01f;
142  p1 = 4.44034e-02f;
143  p2 = -2.82229e-03f;
144  p3 = 8.19495e-05f;
145  p4 = -8.96645e-07f;
146  }
147  else
148  {
149  p0 = 5.65474e+00f;
150  p1 = -6.31640e-01f;
151  p2 = 3.14218e-02f;
152  p3 = -6.84256e-04f;
153  p4 = 5.50659e-06f;
154  }
155  if (x > 40.f) x = 40.f;
156  }
157 
158  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::hybrid)) {
159  if (verbosity_ <= pERROR)
160  {
161  std::cout << "ERROR! HybridEFRYsc called" << std::endl;
162  }
163  return 1.f;
164  }
165 
166  else if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
167  p0 = 4.69976e-01f; // extracted from fit to all endcap classes with Ebrem = 0.
168  p1 = 1.45900e-01f;
169  p2 = -1.61359e-02f;
170  p3 = 7.99423e-04f;
171  p4 = -1.47873e-05f;
172  if (x > 16.f) x = 16.f;
173  }
174 
175  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
176  p0 = 4.69976e-01f; // extracted from fit to all endcap classes with Ebrem = 0.
177  p1 = 1.45900e-01f;
178  p2 = -1.61359e-02f;
179  p3 = 7.99423e-04f;
180  p4 = -1.47873e-05f;
181  if (x > 16.f) x = 16.f;
182  }
183 
184  else {
185  if (verbosity_ <= pINFO)
186  {
187  std::cout << "trying to correct unknown cluster!!!" << std::endl;
188  }
189  return 1.f;
190  }
191  result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4)));
192 
193  //Rescale energy scale correction to take into account change in calibrated
194  //RecHit definition introduced in CMSSW_1_5_0
195  float const ebfact = 1.f/0.965f;
196  float const eefact = 1.f/0.975f;
197 
198  if(theBase == EcalBarrel) {
199  result*=ebfact;
200  } else {
201  result*=eefact;
202  }
203 
204  return result;
205 }
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:41
Definition: DDAxes.h:10
double p3[4]
Definition: TauolaWrapper.h:91
int EgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma ( reco::BasicCluster const &  seed,
EcalRecHitCollection const &  rhc 
) const
private

Definition at line 207 of file EgammaSCEnergyCorrectionAlgo.cc.

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

Referenced by applyCorrection().

208 {
209  // return number of crystals 2Sigma above
210  // electronic noise
211 
212  std::vector<std::pair<DetId,float > > const & hits = seed.hitsAndFractions();
213 
214  if (verbosity_ <= pINFO)
215  {
216  std::cout << " EgammaSCEnergyCorrectionAlgo::nCrystalsGT2Sigma" << std::endl;
217  std::cout << " Will calculate number of crystals above 2sigma noise" << std::endl;
218  std::cout << " sigmaElectronicNoise = " << sigmaElectronicNoise_ << std::endl;
219  std::cout << " There are " << hits.size() << " recHits" << std::endl;
220  }
221 
222  int nCry = 0;
223  std::vector<std::pair<DetId,float > >::const_iterator hit;
225  for(hit = hits.begin(); hit != hits.end(); hit++) {
226  // need to get hit by DetID in order to get energy
227  aHit = rhc.find((*hit).first);
228  if((*aHit).energy()>2.f*sigmaElectronicNoise_) nCry++;
229  }
230 
231  if (verbosity_ <= pINFO)
232  {
233  std::cout << " " << nCry << " of these above 2sigma noise" << std::endl;
234  }
235 
236  return nCry;
237 }
std::vector< T >::const_iterator const_iterator
tuple cout
Definition: gather_cfg.py:41
void EgammaSCEnergyCorrectionAlgo::setVerbosity ( VerbosityLevel  verbosity)
inline

Definition at line 45 of file EgammaSCEnergyCorrectionAlgo.h.

References verbosity, and verbosity_.

46  {
48  }
const int verbosity

Member Data Documentation

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

Definition at line 65 of file EgammaSCEnergyCorrectionAlgo.h.

VerbosityLevel EgammaSCEnergyCorrectionAlgo::verbosity_
private