CMS 3D CMS Logo

EcalRegressionData.cc
Go to the documentation of this file.
2 
9 
12 
15 
17 {
18  float eLeftRightSum = eLeft()+eRight();
19  float eLeftRightDiff = eLeft()-eRight();
20  return eLeftRightSum !=0 ? eLeftRightDiff/eLeftRightSum : 0.;
21 }
22 
24 {
25  float eTopBottomSum = eTop()+eBottom();
26  float eTopBottomDiff = eTop()-eBottom();
27  return eTopBottomSum !=0 ? eTopBottomDiff/eTopBottomSum : 0.;
28 }
29 
30 float EcalRegressionData::subClusRawEnergy(size_t clusNr)const
31 {
32  if(clusNr<subClusRawEnergy_.size()) return subClusRawEnergy_[clusNr];
33  else return 0.;
34 }
35 
36 float EcalRegressionData::subClusDEta(size_t clusNr)const
37 {
38  if(clusNr<subClusDEta_.size()) return subClusDEta_[clusNr];
39  else return 0.;
40 }
41 
42 float EcalRegressionData::subClusDPhi(size_t clusNr)const
43 {
44  if(clusNr<subClusDPhi_.size()) return subClusDPhi_[clusNr];
45  else return 0.;
46 }
47 
49  const EcalRecHitCollection* ebRecHits,const EcalRecHitCollection* eeRecHits,
50  const CaloGeometry* geom,const CaloTopology* topology,
51  int nrVertices)
52 {
53  clear();
54 
55  const DetId& seedid = superClus.seed()->hitsAndFractions().at(0).first;
56  isEB_ = ( seedid.subdetId()==EcalBarrel );
57 
58  // skip HGCal
59  if( EcalTools::isHGCalDet(seedid.det()) ) return;
60 
61  const EcalRecHitCollection* recHits = isEB_ ? ebRecHits : eeRecHits;
62 
63  scRawEnergy_ = superClus.rawEnergy();
64  scCalibEnergy_ = superClus.correctedEnergy();
65  scPreShowerEnergy_ = superClus.preshowerEnergy();
66  scEta_ = superClus.eta();
67  scPhi_ = superClus.phi();
68  scEtaWidth_ = superClus.etaWidth();
69  scPhiWidth_ = superClus.phiWidth();
70  scNrAdditionalClusters_ = superClus.clustersSize()-1;
71 
72  seedClusEnergy_ = superClus.seed()->energy();
73  eMax_ = EcalClusterTools::eMax(*superClus.seed(),recHits);
74  e2nd_ = EcalClusterTools::e2nd(*superClus.seed(),recHits);
75  e3x3_ = EcalClusterTools::e3x3(*superClus.seed(),recHits,topology);
76  eTop_ = EcalClusterTools::eTop(*superClus.seed(),recHits,topology);
77  eBottom_ = EcalClusterTools::eBottom(*superClus.seed(),recHits,topology);
78  eLeft_ = EcalClusterTools::eLeft(*superClus.seed(),recHits,topology);
79  eRight_ = EcalClusterTools::eRight(*superClus.seed(),recHits,topology);
80  std::vector<float> localCovs = EcalClusterTools::localCovariances(*superClus.seed(),recHits,topology);
81  sigmaIEtaIEta_ = edm::isNotFinite(localCovs[0]) ? 0. : std::sqrt(localCovs[0]);
82  sigmaIPhiIPhi_ = edm::isNotFinite(localCovs[2]) ? 0. : std::sqrt(localCovs[2]);
83 
84  if(sigmaIEtaIEta_*sigmaIPhiIPhi_>0) sigmaIEtaIPhi_ = localCovs[1]/(sigmaIEtaIEta_*sigmaIPhiIPhi_);
85  else if(localCovs[1]>0) sigmaIEtaIPhi_ = 1.;
86  else sigmaIEtaIPhi_ = -1.;
87 
88 
89  EcalClusterLocal ecalClusterLocal; //not clear why this doesnt use static functions
90  float thetaTilt=0,phiTilt=0; //dummy variables that are not used but are required by below function
91  void (EcalClusterLocal::*localCoordFunc)(const reco::CaloCluster &, const CaloGeometry &,
92  float &, float &, int &, int &,
93  float &, float &)const;
94  localCoordFunc = &EcalClusterLocal::localCoordsEB;
95  if(!isEB()) localCoordFunc = &EcalClusterLocal::localCoordsEE;
96  (ecalClusterLocal.*localCoordFunc)(*superClus.seed(),*geom,
99  thetaTilt,phiTilt);
100 
101  for( auto clus = superClus.clustersBegin()+1;clus != superClus.clustersEnd(); ++clus ) {
102  const float dEta = (*clus)->eta() - superClus.seed()->eta();
103  const float dPhi = reco::deltaPhi((*clus)->phi(),superClus.seed()->phi());
104  const float dR2 = dEta*dEta+dPhi*dPhi;
105  if(dR2 > maxSubClusDR2_ || maxSubClusDR2_ == 998001.) {
106  maxSubClusDR2_ = dR2;
109  maxSubClusDRRawEnergy_ = (*clus)->energy();
110  }
111  subClusRawEnergy_.push_back((*clus)->energy());
112  subClusDEta_.push_back(dEta);
113  subClusDPhi_.push_back(dPhi);
114 
115  }
116 
117  nrVtx_ = nrVertices;
118 
119 }
120 
122 {
123  isEB_=false;
124  scRawEnergy_=0.;
125  scCalibEnergy_=0.;
127  scEta_=0.;
128  scPhi_=0.;
129  scEtaWidth_=0.;
130  scPhiWidth_=0.;
132 
133  seedClusEnergy_=0.;
134  eMax_=0.;
135  e2nd_=0.;
136  e3x3_=0.;
137  eTop_=0.;
138  eBottom_=0.;
139  eLeft_=0.;
140  eRight_=0.;
141  sigmaIEtaIEta_=0.;
142  sigmaIEtaIPhi_=0.;
143  sigmaIPhiIPhi_=0.;
144 
145  seedCrysPhiOrY_=0.;
146  seedCrysEtaOrX_=0.;
149 
150  maxSubClusDR2_=998001.;
151  maxSubClusDRDPhi_=999.;
152  maxSubClusDRDEta_=999;
154 
155  subClusRawEnergy_.clear();
156  subClusDPhi_.clear();
157  subClusDEta_.clear();
158 
159  nrVtx_=0;
160 
161 }
162 
163 void EcalRegressionData::fillVec(std::vector<float>& inputVec)const
164 {
165  if(isEB()) fillVecEB_(inputVec);
166  else fillVecEE_(inputVec);
167 }
168 
169 void EcalRegressionData::fillVecEB_(std::vector<float>& inputVec)const
170 {
171  inputVec.clear();
172  inputVec.resize(33);
173  inputVec[0] = nrVtx(); //nVtx
174  inputVec[1] = scEta(); //scEta
175  inputVec[2] = scPhi(); //scPhi
176  inputVec[3] = scEtaWidth(); //scEtaWidth
177  inputVec[4] = scPhiWidth(); //scPhiWidth
178  inputVec[5] = scSeedR9(); //scSeedR9
179  inputVec[6] = seedClusEnergyOverSCRawEnergy(); //scSeedRawEnergy/scRawEnergy
180  inputVec[7] = eMaxOverSCRawEnergy(); //scSeedEmax/scRawEnergy
181  inputVec[8] = e2ndOverSCRawEnergy(); //scSeedE2nd/scRawEnergy
182  inputVec[9] = seedLeftRightAsym();//scSeedLeftRightAsym
183  inputVec[10] = seedTopBottomAsym();//scSeedTopBottomAsym
184  inputVec[11] = sigmaIEtaIEta(); //scSeedSigmaIetaIeta
185  inputVec[12] = sigmaIEtaIPhi(); //scSeedSigmaIetaIphi
186  inputVec[13] = sigmaIPhiIPhi(); //scSeedSigmaIphiIphi
187  inputVec[14] = scNrAdditionalClusters(); //N_ECALClusters
188  inputVec[15] = maxSubClusDR(); //clusterMaxDR
189  inputVec[16] = maxSubClusDRDPhi(); //clusterMaxDRDPhi
190  inputVec[17] = maxSubClusDRDEta(); //clusterMaxDRDEta
191  inputVec[18] = maxSubClusDRRawEnergyOverSCRawEnergy(); //clusMaxDRRawEnergy/scRawEnergy
192  inputVec[19] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C1); //clusterRawEnergy[0]/scRawEnergy
193  inputVec[20] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C2); //clusterRawEnergy[1]/scRawEnergy float scPreShowerEnergy()const{return scPreShowerEnergy_;}
194 
195  inputVec[21] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C3); //clusterRawEnergy[2]/scRawEnergy
196  inputVec[22] = subClusDPhi(SubClusNr::C1); //clusterDPhiToSeed[0]
197  inputVec[23] = subClusDPhi(SubClusNr::C2); //clusterDPhiToSeed[1]
198  inputVec[24] = subClusDPhi(SubClusNr::C3); //clusterDPhiToSeed[2]
199  inputVec[25] = subClusDEta(SubClusNr::C1); //clusterDEtaToSeed[0]
200  inputVec[26] = subClusDEta(SubClusNr::C2); //clusterDEtaToSeed[1]
201  inputVec[27] = subClusDEta(SubClusNr::C3); //clusterDEtaToSeed[2]
202  inputVec[28] = seedCrysEtaOrX(); //scSeedCryEta
203  inputVec[29] = seedCrysPhiOrY(); //scSeedCryPhi
204  inputVec[30] = seedCrysIEtaOrIX(); //scSeedCryIeta
205  inputVec[31] = seedCrysIPhiOrIY(); //scSeedCryIphi
206  inputVec[32] = scCalibEnergy(); //scCalibratedEnergy
207 }
208 
209 void EcalRegressionData::fillVecEE_(std::vector<float>& inputVec)const
210 {
211  inputVec.clear();
212  inputVec.resize(33); //this emulates the old behaviour of RegressionHelper, even if past 29 we dont use elements
213  inputVec[0] = nrVtx(); //nVtx
214  inputVec[1] = scEta(); //scEta
215  inputVec[2] = scPhi(); //scPhi
216  inputVec[3] = scEtaWidth(); //scEtaWidth
217  inputVec[4] = scPhiWidth(); //scPhiWidth
218  inputVec[5] = scSeedR9(); //scSeedR9
219  inputVec[6] = seedClusEnergyOverSCRawEnergy(); //scSeedRawEnergy/scRawEnergy
220  inputVec[7] = eMaxOverSCRawEnergy(); //scSeedEmax/scRawEnergy
221  inputVec[8] = e2ndOverSCRawEnergy(); //scSeedE2nd/scRawEnergy
222  inputVec[9] = seedLeftRightAsym();//scSeedLeftRightAsym
223  inputVec[10] = seedTopBottomAsym();//scSeedTopBottomAsym
224  inputVec[11] = sigmaIEtaIEta(); //scSeedSigmaIetaIeta
225  inputVec[12] = sigmaIEtaIPhi(); //scSeedSigmaIetaIphi
226  inputVec[13] = sigmaIPhiIPhi(); //scSeedSigmaIphiIphi
227  inputVec[14] = scNrAdditionalClusters(); //N_ECALClusters
228  inputVec[15] = maxSubClusDR(); //clusterMaxDR
229  inputVec[16] = maxSubClusDRDPhi(); //clusterMaxDRDPhi
230  inputVec[17] = maxSubClusDRDEta(); //clusterMaxDRDEta
231  inputVec[18] = maxSubClusDRRawEnergyOverSCRawEnergy(); //clusMaxDRRawEnergy/scRawEnergy
232  inputVec[19] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C1); //clusterRawEnergy[0]/scRawEnergy
233  inputVec[20] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C2); //clusterRawEnergy[1]/scRawEnergy
234  inputVec[21] = subClusRawEnergyOverSCRawEnergy(SubClusNr::C3); //clusterRawEnergy[2]/scRawEnergy
235  inputVec[22] = subClusDPhi(SubClusNr::C1); //clusterDPhiToSeed[0]
236  inputVec[23] = subClusDPhi(SubClusNr::C2); //clusterDPhiToSeed[1]
237  inputVec[24] = subClusDPhi(SubClusNr::C3); //clusterDPhiToSeed[2]
238  inputVec[25] = subClusDEta(SubClusNr::C1); //clusterDEtaToSeed[0]
239  inputVec[26] = subClusDEta(SubClusNr::C2); //clusterDEtaToSeed[1]
240  inputVec[27] = subClusDEta(SubClusNr::C3); //clusterDEtaToSeed[2]
241  inputVec[28] = scPreShowerEnergyOverSCRawEnergy();
242  inputVec[29] = scCalibEnergy(); //scCalibratedEnergy
243 }
float sigmaIPhiIPhi() const
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:54
const std::vector< float > & subClusRawEnergy() const
float e2ndOverSCRawEnergy() const
float maxSubClusDRDEta() const
double correctedEnergy() const
Definition: CaloCluster.h:127
float scEtaWidth() const
CaloTopology const * topology(0)
double phiWidth() const
obtain phi and eta width of the Super Cluster
Definition: SuperCluster.h:55
void fill(const reco::SuperCluster &superClus, const EcalRecHitCollection *ebRecHits, const EcalRecHitCollection *eeRecHits, const CaloGeometry *geom, const CaloTopology *topology, const reco::VertexCollection *vertices)
int scNrAdditionalClusters() const
float eLeft() const
float seedCrysPhiOrY() const
float sigmaIEtaIEta() const
float sigmaIEtaIPhi() const
float scSeedR9() const
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:168
float subClusRawEnergyOverSCRawEnergy(size_t clusNr) const
float seedClusEnergyOverSCRawEnergy() const
std::vector< float > subClusDPhi_
bool isNotFinite(T x)
Definition: isFinite.h:10
double etaWidth() const
Definition: SuperCluster.h:56
float scPhi() const
float seedCrysIPhiOrIY() const
T sqrt(T t)
Definition: SSEVec.h:18
float maxSubClusDR() const
float seedCrysIEtaOrIX() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
std::vector< float > subClusRawEnergy_
float maxSubClusDRDPhi() const
void fillVec(std::vector< float > &inputVec) const
float scPhiWidth() const
float scPreShowerEnergyOverSCRawEnergy() const
float seedCrysEtaOrX() const
float seedLeftRightAsym() const
Definition: DetId.h:18
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
std::vector< float > subClusDEta_
size_t clustersSize() const
number of BasicCluster constituents
Definition: SuperCluster.h:87
float eMaxOverSCRawEnergy() const
float maxSubClusDRRawEnergyOverSCRawEnergy() const
const std::vector< float > & subClusDEta() const
void localCoordsEB(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
float scEta() const
const std::vector< float > & subClusDPhi() const
float seedTopBottomAsym() const
float eRight() const
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
void fillVecEB_(std::vector< float > &inputVec) const
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:50
float scCalibEnergy() const
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:171
void localCoordsEE(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const
void fillVecEE_(std::vector< float > &inputVec) const
float eBottom() const
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39