CMS 3D CMS Logo

HFRecoEcalCandidateAlgo.cc
Go to the documentation of this file.
1 
9 //#includes
13 #include "CLHEP/Vector/LorentzVector.h"
14 #include <iostream>
17 #include "HFEGammaSLCorrector.h"
18 
19 using namespace std;
20 using namespace reco;
21 
23  const std::vector<double>& e1e9Cut,
24  const std::vector<double>& eCOREe9Cut,
25  const std::vector<double>& eSeLCut,
26  const reco::HFValueStruct hfvv
27 ) :
28  m_correct(correct),
29  m_e9e25Cut(e9e25Cut),
30  m_intercept2DCut(intercept2DCut),
31  m_intercept2DSlope(intercept2DSlope),
32  m_e1e9Cuthi(e1e9Cut[1]),
33  m_eCOREe9Cuthi(eCOREe9Cut[1]),
34  m_eSeLCuthi(eSeLCut[1]),
35  m_e1e9Cutlo(e1e9Cut[0]),
36  m_eCOREe9Cutlo(eCOREe9Cut[0]),
37  m_eSeLCutlo(eSeLCut[0]),
38  m_era(4),
39  m_hfvv(hfvv)
40 {
41 }
42 
44  double corEta=original.eta();
45  //piece-wise log energy correction to eta
46  double logel=log(shape.eLong3x3()/100.0);
47  double lowC= 0.00911;
48  double hiC = 0.0193;
49  double logSlope = 0.0146;
50  double logIntercept=-0.00988;
51  double sgn=(original.eta()>0)?(1.0):(-1.0);
52  if(logel<=1.25)corEta+=(lowC)*sgn;
53  else if((logel>1.25)&&(logel<=2))corEta+=(logIntercept+logSlope*logel)*sgn;
54  else if(logel>2)corEta+=hiC*sgn;
55  //poly-3 cell eta correction to eta (de)
56  double p0= 0.0125;
57  double p1=-0.0475;
58  double p2= 0.0732;
59  double p3=-0.0506;
60  double de= sgn*(p0+(p1*(shape.CellEta()))+(p2*(shape.CellEta()*shape.CellEta()))+(p3*(shape.CellEta()*shape.CellEta()*shape.CellEta())));
61  corEta+=de;
62 
63  double corPhi=original.phi();
64  //poly-3 cell phi correction to phi (dp)
65  p0= 0.0115;
66  p1=-0.0394;
67  p2= 0.0486;
68  p3=-0.0335;
69  double dp =p0+(p1*(shape.CellPhi()))+(p2*(shape.CellPhi()*shape.CellPhi()))+(p3*(shape.CellPhi()*shape.CellPhi()*shape.CellPhi()));
70  corPhi+=dp;
71 
72 
73  double corEnergy= original.energy();
74  //energy corrections
75  //flat correction for using only long fibers
76  double energyCorrect=0.7397;
77  corEnergy= corEnergy/energyCorrect;
78  //corection based on ieta for pileup and general
79  //find ieta
80  int ieta=0;
81  double etabounds[30]={
82  2.846,2.957,3.132,3.307,3.482,
83  3.657,3.833,4.006,4.184,4.357,
84  4.532,4.709,4.882,5.184};
85  for (int kk=0;kk<=12;kk++){
86  if((fabs(corEta) < etabounds[kk+1])&&(fabs(corEta) > etabounds[kk])){
87  ieta = (corEta > 0)?(kk+29):(-kk-29);
88  }
89  }
90  //check if ieta is in bounds, should be [-41, -29] U [29, 41]
91  if (ieta != 0) corEnergy=(m_hfvv.PUSlope(ieta)*1.0*(nvtx-1)+m_hfvv.PUIntercept(ieta)*1.0)*corEnergy*1.0*m_hfvv.EnCor(ieta);
92 
93  //re-calculate the energy vector
94  double corPx=corEnergy*cos(corPhi)/cosh(corEta);
95  double corPy=corEnergy*sin(corPhi)/cosh(corEta);
96  double corPz=corEnergy*tanh(corEta);
97 
98  //make the candidate
99  RecoEcalCandidate corCand(0,
100  math::XYZTLorentzVector(corPx,corPy,corPz,corEnergy),
101  math::XYZPoint(0,0,0));
102 
103  return corCand;
104 }
105 
107  const HFEMClusterShapeAssociationCollection& AssocShapes,
108  RecoEcalCandidateCollection& RecoECand,
109  int nvtx) const {
110 
111 
112 
113  //get super's and cluster shapes and associations
114  for (unsigned int i=0; i < SuperClusters->size(); ++i) {
115  const SuperCluster& supClus=(*SuperClusters)[i];
116  reco::SuperClusterRef theClusRef=edm::Ref<SuperClusterCollection>(SuperClusters,i);
117  const HFEMClusterShapeRef clusShapeRef=AssocShapes.find(theClusRef)->val;
118  const HFEMClusterShape& clusShape=*clusShapeRef;
119 
120  // basic candidate
121  double px=supClus.energy()*cos(supClus.phi())/cosh(supClus.eta());
122  double py=supClus.energy()*sin(supClus.phi())/cosh(supClus.eta());
123  double pz=supClus.energy()*tanh(supClus.eta());
124  RecoEcalCandidate theCand(0,
125  math::XYZTLorentzVector(px,py,pz,supClus.energy()),
126  math::XYZPoint(0,0,0));
127 
128  // correct it?
129  if (m_correct)
130  theCand=correctEPosition(supClus,clusShape,nvtx);
131 
132  double e9e25=clusShape.eLong3x3()/clusShape.eLong5x5();
133  double e1e9=clusShape.eLong1x1()/clusShape.eLong3x3();
134  double eSeL=hf_egamma::eSeLCorrected(clusShape.eShort3x3(),clusShape.eLong3x3(),4);
135  double var2d=(clusShape.eCOREe9()-(eSeL*m_intercept2DSlope));
136 
137  bool isAcceptable=true;
138  isAcceptable=isAcceptable && (e9e25> m_e9e25Cut);
139  isAcceptable=isAcceptable && (var2d > m_intercept2DCut);
140  isAcceptable=isAcceptable && ((e1e9< m_e1e9Cuthi)&&(e1e9> m_e1e9Cutlo));
141  isAcceptable=isAcceptable && ((clusShape.eCOREe9()< m_eCOREe9Cuthi)&&(clusShape.eCOREe9()> m_eCOREe9Cutlo));
142  isAcceptable=isAcceptable && ((clusShape.eSeL()<m_eSeLCuthi)&&(clusShape.eSeL()> m_eSeLCutlo));
143 
144 
145  if(isAcceptable){
146 
147  theCand.setSuperCluster(theClusRef);
148  RecoECand.push_back(theCand);
149  }
150  }
151 }
152 
const reco::HFValueStruct m_hfvv
float sgn(float val)
Definition: FWPFMaths.cc:9
double eLong5x5() const
double eLong1x1() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const_iterator find(const key_type &k) const
find element with specified reference key
double CellPhi() const
double PUIntercept(int ieta) const
void produce(const edm::Handle< reco::SuperClusterCollection > &SuperClusters, const reco::HFEMClusterShapeAssociationCollection &AssocShapes, reco::RecoEcalCandidateCollection &RecoECand, int nvtx) const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:168
double EnCor(int ieta) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::RecoEcalCandidate correctEPosition(const reco::SuperCluster &original, const reco::HFEMClusterShape &shape, int nvtx) const
double eShort3x3() const
double eLong3x3() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double energy() const
cluster energy
Definition: CaloCluster.h:126
double p2[4]
Definition: TauolaWrapper.h:90
double PUSlope(int ieta) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double eSeLCorrected(double es, double el, double pc, double px, double py)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
fixed size matrix
double p1[4]
Definition: TauolaWrapper.h:89
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:171
double CellEta() const
HFRecoEcalCandidateAlgo(bool correct, double e9e25Cut, double intercept2DCut, double intercept2DSlope, const std::vector< double > &e1e9Cut, const std::vector< double > &eCOREe9Cut, const std::vector< double > &eSeLCut, const reco::HFValueStruct hfvv)
double p3[4]
Definition: TauolaWrapper.h:91