12 cfg_(config),ecalRegressionInitialized_(
false),combinationRegressionInitialized_(
false),
13 caloTopologyCacheId_(0), caloGeometryCacheId_(0),regressionCacheId_(0)
32 unsigned long long newCaloTopologyCacheId
43 unsigned long long newCaloGeometryCacheId
58 unsigned long long newRegressionCacheId
93 unsigned long long newRegressionCacheId
143 double & energyFactor,
double & errorFactor)
const {
145 energyFactor = -999.;
147 std::vector<float> rInputs;
153 const size_t nVtx = vertices->size();
154 float maxDR=999., maxDRDPhi=999., maxDRDEta=999., maxDRRawEnergy=0.;
155 float subClusRawE[3], subClusDPhi[3], subClusDEta[3];
156 memset(subClusRawE,0,3*
sizeof(
float));
157 memset(subClusDPhi,0,3*
sizeof(
float));
158 memset(subClusDEta,0,3*
sizeof(
float));
161 const float this_deta = (*clus)->eta() - seed->eta();
163 const float this_dr = std::hypot(this_deta,this_dphi);
164 if(this_dr > maxDR || maxDR == 999.0
f) {
166 maxDRDEta = this_deta;
167 maxDRDPhi = this_dphi;
168 maxDRRawEnergy = (*clus)->energy();
171 subClusRawE[iclus] = (*clus)->energy();
172 subClusDEta[iclus] = this_deta;
173 subClusDPhi[iclus] = this_dphi;
177 if ( seed->hitsAndFractions()[0].first.subdetId()==
EcalBarrel ) {
195 const float eLpeR = eLeft + eRight;
196 const float eTpeB = eTop + eBottom;
197 const float eLmeR = eLeft - eRight;
198 const float eTmeB = eTop - eBottom;
199 std::vector<float> vCov =
201 const float see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
202 const float spp = (
isnan(vCov[2]) ? 0. :
sqrt(vCov[2]));
205 sep = vCov[1] / (see * spp);
206 else if (vCov[1] > 0)
210 float cryPhi, cryEta, thetatilt, phitilt;
213 ieta, iphi, thetatilt, phitilt);
215 rInputs[1] = sc.
eta();
216 rInputs[2] = sc.
phi();
219 rInputs[5] = e3x3/rawEnergy;
220 rInputs[6] = sc.
seed()->energy()/rawEnergy;
221 rInputs[7] = eMax/rawEnergy;
222 rInputs[8] = e2nd/rawEnergy;
223 rInputs[9] = (eLpeR!=0. ? eLmeR/eLpeR : 0.);
224 rInputs[10] = (eTpeB!=0.? eTmeB/eTpeB : 0.);
230 rInputs[16] = maxDRDPhi;
231 rInputs[17] = maxDRDEta;
232 rInputs[18] = maxDRRawEnergy/rawEnergy;
233 rInputs[19] = subClusRawE[0]/rawEnergy;
234 rInputs[20] = subClusRawE[1]/rawEnergy;
235 rInputs[21] = subClusRawE[2]/rawEnergy;
236 rInputs[22] = subClusDPhi[0];
237 rInputs[23] = subClusDPhi[1];
238 rInputs[24] = subClusDPhi[2];
239 rInputs[25] = subClusDEta[0];
240 rInputs[26] = subClusDEta[1];
241 rInputs[27] = subClusDEta[2];
242 rInputs[28] = cryEta;
243 rInputs[29] = cryPhi;
246 rInputs[32] = calibEnergy;
250 else if(seed->hitsAndFractions()[0].first.subdetId()==
EcalEndcap)
269 const float eLpeR = eLeft + eRight;
270 const float eTpeB = eTop + eBottom;
271 const float eLmeR = eLeft - eRight;
272 const float eTmeB = eTop - eBottom;
273 std::vector<float> vCov =
275 const float see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
276 const float spp = (
isnan(vCov[2]) ? 0. :
sqrt(vCov[2]));
279 sep = vCov[1] / (see * spp);
280 else if (vCov[1] > 0)
285 rInputs[1] = sc.
eta();
286 rInputs[2] = sc.
phi();
289 rInputs[5] = e3x3/rawEnergy;
290 rInputs[6] = sc.
seed()->energy()/rawEnergy;
291 rInputs[7] = eMax/rawEnergy;
292 rInputs[8] = e2nd/rawEnergy;
293 rInputs[9] = (eLpeR!=0. ? eLmeR/eLpeR : 0.);
294 rInputs[10] = (eTpeB!=0.? eTmeB/eTpeB : 0.);
300 rInputs[16] = maxDRDPhi;
301 rInputs[17] = maxDRDEta;
302 rInputs[18] = maxDRRawEnergy/rawEnergy;
303 rInputs[19] = subClusRawE[0]/rawEnergy;
304 rInputs[20] = subClusRawE[1]/rawEnergy;
305 rInputs[21] = subClusRawE[2]/rawEnergy;
306 rInputs[22] = subClusDPhi[0];
307 rInputs[23] = subClusDPhi[1];
308 rInputs[24] = subClusDPhi[2];
309 rInputs[25] = subClusDEta[0];
310 rInputs[26] = subClusDEta[1];
311 rInputs[27] = subClusDEta[2];
312 rInputs[28] = scPreshowerSum/rawEnergy;
313 rInputs[29] = calibEnergy;
320 throw cms::Exception(
"RegressionHelper::calculateRegressedEnergy")
321 <<
"Supercluster seed is either EB nor EE!" << std::endl;
355 bool isEB = ele.
isEB();
358 float energyRelError = energyError /
energy;
359 float momentumRelError = momentumError / momentum;
360 float errorRatio = energyRelError / momentumRelError;
363 float eOverP = energy / momentum;
364 float eOverPerror = eOverP*std::hypot(energyRelError,momentumRelError);
367 std::vector<float> regressionInputs ;
368 regressionInputs.resize(11,0.);
370 regressionInputs[0] =
energy;
371 regressionInputs[1] = energyRelError;
372 regressionInputs[2] = momentum;
373 regressionInputs[3] = momentumRelError;
374 regressionInputs[4] = errorRatio;
375 regressionInputs[5] = eOverP;
376 regressionInputs[6] = eOverPerror;
377 regressionInputs[7] =
static_cast<float>(isEcalDriven);
378 regressionInputs[8] =
static_cast<float>(isTrackerDriven);
379 regressionInputs[9] =
static_cast<float>(elClass);
380 regressionInputs[10] =
static_cast<float>(isEB);
385 &&fabs(momentum-energy)<15.*
sqrt(momentumError*momentumError + energyError*energyError)
389 if(weight>1.) weight = 1.;
390 else if(weight<0.) weight = 0.;
393 float combinedMomentum = weight*momentum + (1.-
weight)*energy;
394 float combinedMomentumError =
sqrt(weight*weight*momentumError*momentumError + (1.-weight)*(1.-weight)*energyError*energyError);
398 if(momentumError!=999. || weight==0.)
402 oldMomentum.y()*combinedMomentum/oldMomentum.t(),
403 oldMomentum.z()*combinedMomentum/oldMomentum.t(),
double GetResponse(const float *vector) const
std::vector< std::string > ecalRegressionWeightFiles
unsigned long long caloGeometryCacheId_
void applyCombinationRegression(reco::GsfElectron &ele) const
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
std::vector< std::string > combinationRegressionWeightLabels
unsigned long long regressionCacheId_
float trackMomentumError() const
const GBRForest * ecalRegEndcap_
double correctedEnergy() const
const LorentzVector & p4(P4Kind kind) const
std::vector< std::string > ecalRegressionWeightLabels
double phiWidth() const
obtain phi and eta width of the Super Cluster
unsigned long long caloTopologyCacheId_
math::XYZVectorF trackMomentumAtVtx() const
bool combinationWeightsFromDB
double Phi_mpi_pi(double x)
double eta() const
pseudorapidity of cluster centroid
const CaloTopology * caloTopology_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const GBRForest * ecalRegBarrel_
const GBRForest * ecalRegErrorBarrel_
void setCorrectedEcalEnergyError(float newEnergyError)
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
void get(HolderT &iHolder) const
std::vector< std::string > combinationRegressionWeightFiles
float correctedEcalEnergy() const
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
void getEcalRegression(const reco::SuperCluster &sc, const edm::Handle< reco::VertexCollection > &vertices, const edm::Handle< EcalRecHitCollection > &rechitsEB, const edm::Handle< EcalRecHitCollection > &rechitsEE, double &energyFactor, double &errorFactor) const
size_t clustersSize() const
number of BasicCluster constituents
Classification classification() const
void readEvent(const edm::Event &)
bool ecalRegressionInitialized_
void localCoordsEB(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
const GBRForest * ecalRegErrorEndcap_
float correctedEcalEnergyError() const
void setCorrectedEcalEnergy(float newEnergy)
void applyEcalRegression(reco::GsfElectron &electron, const edm::Handle< reco::VertexCollection > &vertices, const edm::Handle< EcalRecHitCollection > &rechitsEB, const edm::Handle< EcalRecHitCollection > &rechitsEE) const
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
bool trackerDrivenSeed() const
const CaloClusterPtr & seed() const
seed BasicCluster
double preshowerEnergy() const
energy deposited in preshower
volatile std::atomic< bool > shutdown_flag false
RegressionHelper(const Configuration &)
double phi() const
azimuthal angle of cluster centroid
bool combinationRegressionInitialized_
void checkSetup(const edm::EventSetup &)
float energyError(float E, float *par)
const CaloGeometry * caloGeometry_
const GBRForest * combinationReg_
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents