CMS 3D CMS Logo

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