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 11 of file HiEgammaSCEnergyCorrectionAlgo.cc.

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

16 {
17  sigmaElectronicNoise_ = noise;
19 
20  // Parameters
21  p_fBrem_ = pSet.getParameter< std::vector <double> > ("fBremVect");
22  p_fBremTh_ = pSet.getParameter< std::vector <double> > ("fBremThVect");
23  p_fEta_ = pSet.getParameter< std::vector <double> > ("fEtaVect");
24  p_fEtEta_ = pSet.getParameter< std::vector <double> > ("fEtEtaVect");
25 
26  // Min R9
27  minR9Barrel_ = pSet.getParameter<double>("minR9Barrel");
28  minR9Endcap_ = pSet.getParameter<double>("minR9Endcap");
29 
30  // Max R9
31  maxR9_ = pSet.getParameter<double>("maxR9");
32 
33 }
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 38 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References SuperClusterShapeAlgo::Calculate_Covariances(), reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, EcalClusterTools::e3x3(), EcalClusterTools::e5x5(), 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().

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

Definition at line 206 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, f, reco::CaloCluster::island, evf::evtn::offset(), p_fBrem_, and p_fBremTh_.

Referenced by applyCorrection().

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

Definition at line 187 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, eta(), f, reco::CaloCluster::island, evf::evtn::offset(), and p_fEta_.

Referenced by applyCorrection().

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

Definition at line 163 of file HiEgammaSCEnergyCorrectionAlgo.cc.

References EcalBarrel, EcalEndcap, eta(), f, reco::CaloCluster::island, evf::evtn::offset(), p_fEtEta_, and mathSSE::sqrt().

Referenced by applyCorrection().

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

Definition at line 234 of file HiEgammaSCEnergyCorrectionAlgo.cc.

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

235 {
236 
237  float x = (float) nCry;
238  float result =1.f;
239 
240  if((theBase == EcalBarrel) && (theAlgo == reco::CaloCluster::island)) {
241  float const p0 = 0.682554f;
242  float const p1 = 0.0253013f;
243  float const p2 = -0.0007907f;
244  float const p3 = 1.166e-5f;
245  float const p4 = -6.7387e-8f;
246  if (x < 10.f) x = 10.f;
247  if (x < 40.f) result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4))); else result = 1.f;
248  }
249 
250  else if((theBase == EcalEndcap) && (theAlgo == reco::CaloCluster::island)) {
251 
252  float const p0 = 0.712185f;
253  float const p1 = 0.0273609f;
254  float const p2 = -0.00103818f;
255  float const p3 = 2.01828e-05f;
256  float const p4 = -1.71438e-07f;
257  if (x < 10.f) x = 10.f;
258  if (x < 40.f) result = p0 + x*(p1 + x*(p2 + x*(p3 + x*p4))); else result = 1.f;
259  }
260 
261  else {
262  if (verbosity_ <= pINFO)
263  {
264  std::cout << "trying to correct unknown cluster!!!" << std::endl;
265  }
266  }
267 
268  if (result > 1.5f) result = 1.5f;
269  if (result < 0.5f) result = 0.5f;
270 
271  return result;
272 }
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 274 of file HiEgammaSCEnergyCorrectionAlgo.cc.

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

Referenced by applyCorrection().

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