20 #include <vdt/vdtMath.h>
26 #include <unordered_map>
66 void setConsumes(edm::ConsumesCollector&) override final;
108 "EGExtraInfoModifierFromDB");
114 autoDetectBunchSpacing_ = conf.getParameter<
bool>(
"autoDetectBunchSpacing");
117 vtxTag_ = conf.getParameter<
edm::InputTag>(
"vertexCollection");
119 if (autoDetectBunchSpacing_) {
120 bunchspacingTag_ = conf.getParameter<
edm::InputTag>(
"bunchSpacingTag");
122 bunchspacing_ = conf.getParameter<
int>(
"manualBunchSpacing");
125 constexpr char electronSrc[] =
"electronSrc";
126 constexpr char photonSrc[] =
"photonSrc";
128 if(conf.exists(
"electron_config")) {
130 if( electrons.
exists(electronSrc) )
133 std::vector<std::string> intValueMaps;
134 if ( electrons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
135 intValueMaps = electrons.
getParameter<std::vector<std::string> >(
"intValueMaps");
142 for (
auto vmp : intValueMaps) {
160 if( conf.exists(
"photon_config") ) {
163 if( photons.
exists(photonSrc) )
166 std::vector<std::string> intValueMaps;
167 if ( photons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
168 intValueMaps = photons.
getParameter<std::vector<std::string> >(
"intValueMaps");
175 for (
auto vmp : intValueMaps) {
194 inline void get_product(
const edm::Event& evt,
213 for(
unsigned i = 0;
i < eles->size(); ++
i ) {
222 get_product(evt, imap->second.second,
ele_vmaps);
235 for(
unsigned i = 0;
i < phos->size(); ++
i ) {
245 get_product(evt, imap->second.second,
pho_vmaps);
278 unsigned int ncor = ph_condnames_mean.size();
279 for (
unsigned int icor=0; icor<ncor; ++icor) {
290 unsigned int encor = e_condnames_mean.size();
294 for (
unsigned int icor=0; icor<encor; ++icor) {
303 template<
typename T,
typename U,
typename V>
304 inline void make_consumes(
T&
tag,U&
tok,V& sume) {
305 if(!(empty_tag == tag))
306 tok = sume.template consumes<edm::ValueMap<float> >(
tag);
309 template<
typename T,
typename U,
typename V>
310 inline void make_int_consumes(
T& tag,U& tok,V& sume) {
311 if(!(empty_tag == tag))
312 tok = sume.template consumes<edm::ValueMap<int> >(
tag);
331 make_consumes(imap->second.first, imap->second.second, sumes);
334 for ( std::unordered_map<std::string, ValMapIntTagTokenPair>::iterator imap =
e_conf.
tag_int_token_map.begin();
337 make_int_consumes(imap->second.first, imap->second.second, sumes);
347 make_consumes(imap->second.first, imap->second.second, sumes);
353 make_int_consumes(imap->second.first, imap->second.second, sumes);
358 template<
typename T,
typename U,
typename V,
typename Z>
359 inline void assignValue(
const T& ptr,
const U& tok,
const V&
map,
Z&
value) {
360 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
369 const int numberOfClusters = the_sc->clusters().size();
370 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
372 if( missing_clusters )
return ;
374 std::array<float, 33> eval;
375 const double raw_energy = the_sc->rawEnergy();
380 eval[1] = raw_energy;
381 eval[2] = the_sc->eta();
382 eval[3] = the_sc->phi();
383 eval[4] = the_sc->etaWidth();
384 eval[5] = the_sc->phiWidth();
386 eval[7] = theseed->energy()/raw_energy;
387 eval[8] = ess.eMax/raw_energy;
388 eval[9] = ess.e2nd/raw_energy;
389 eval[10] = (ess.eLeft + ess.eRight != 0.f ? (ess.eLeft-ess.eRight)/(ess.eLeft+ess.eRight) : 0.f);
390 eval[11] = (ess.eTop + ess.eBottom != 0.f ? (ess.eTop-ess.eBottom)/(ess.eTop+ess.eBottom) : 0.f);
391 eval[12] = ess.sigmaIetaIeta;
392 eval[13] = ess.sigmaIetaIphi;
393 eval[14] = ess.sigmaIphiIphi;
394 eval[15] =
std::max(0,numberOfClusters-1);
397 std::vector<float> clusterRawEnergy;
398 clusterRawEnergy.resize(
std::max(3, numberOfClusters), 0);
399 std::vector<float> clusterDEtaToSeed;
400 clusterDEtaToSeed.resize(
std::max(3, numberOfClusters), 0);
401 std::vector<float> clusterDPhiToSeed;
402 clusterDPhiToSeed.resize(
std::max(3, numberOfClusters), 0);
403 float clusterMaxDR = 999.;
404 float clusterMaxDRDPhi = 999.;
405 float clusterMaxDRDEta = 999.;
406 float clusterMaxDRRawEnergy = 0.;
412 auto clusend = the_sc->clustersEnd();
413 for(
auto clus = the_sc->clustersBegin(); clus != clusend; ++clus ) {
416 if(theseed == pclus )
418 clusterRawEnergy[iclus] = pclus->energy();
419 clusterDPhiToSeed[iclus] =
reco::deltaPhi(pclus->phi(),theseed->phi());
420 clusterDEtaToSeed[iclus] = pclus->eta() - theseed->eta();
426 clusterMaxDR = maxDR;
427 clusterMaxDRDPhi = clusterDPhiToSeed[iclus];
428 clusterMaxDRDEta = clusterDEtaToSeed[iclus];
429 clusterMaxDRRawEnergy = clusterRawEnergy[iclus];
434 eval[16] = clusterMaxDR;
435 eval[17] = clusterMaxDRDPhi;
436 eval[18] = clusterMaxDRDEta;
437 eval[19] = clusterMaxDRRawEnergy/raw_energy;
438 eval[20] = clusterRawEnergy[0]/raw_energy;
439 eval[21] = clusterRawEnergy[1]/raw_energy;
440 eval[22] = clusterRawEnergy[2]/raw_energy;
441 eval[23] = clusterDPhiToSeed[0];
442 eval[24] = clusterDPhiToSeed[1];
443 eval[25] = clusterDPhiToSeed[2];
444 eval[26] = clusterDEtaToSeed[0];
445 eval[27] = clusterDEtaToSeed[1];
446 eval[28] = clusterDEtaToSeed[2];
449 const bool iseb = ele.
isEB();
467 eval[29] = the_sc->preshowerEnergy()/the_sc->rawEnergy();
474 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
475 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
479 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
480 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
491 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
492 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
496 double ecor = mean*(eval[1]);
498 ecor = mean*(eval[1]+the_sc->preshowerEnergy());
499 const double sigmacor = sigma*ecor;
509 const float tot_energy = the_sc->rawEnergy()+the_sc->preshowerEnergy();
512 const float eOverP = tot_energy*mean/ep;
513 eval_ep[0] = tot_energy*
mean;
514 eval_ep[1] = sigma/
mean;
516 eval_ep[3] = trkMomentumRelError;
517 eval_ep[4] = sigma/mean/trkMomentumRelError;
518 eval_ep[5] = tot_energy*mean/ep;
519 eval_ep[6] = tot_energy*mean/ep*
sqrt(sigma/mean*sigma/mean+trkMomentumRelError*trkMomentumRelError);
533 if ( eOverP > 0.025 &&
534 std::abs(ep-ecor) < 15.*
std::sqrt( momentumError*momentumError + sigmacor*sigmacor ) ) {
548 oldMomentum.y()*combinedMomentum/oldMomentum.t(),
549 oldMomentum.z()*combinedMomentum/oldMomentum.t(),
563 std::array<float, 31> eval;
567 const int numberOfClusters = the_sc->clusters().size();
568 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
570 if( missing_clusters )
return ;
572 const double raw_energy = the_sc->rawEnergy();
576 eval[0] = raw_energy;
578 eval[2] = the_sc->etaWidth();
579 eval[3] = the_sc->phiWidth();
580 eval[4] =
std::max(0,numberOfClusters - 1);
584 eval[8] = theseed->eta()-the_sc->position().Eta();
585 eval[9] =
reco::deltaPhi(theseed->phi(),the_sc->position().Phi());
586 eval[10] = theseed->energy()/raw_energy;
587 eval[11] = ess.e3x3/ess.e5x5;
588 eval[12] = ess.sigmaIetaIeta;
589 eval[13] = ess.sigmaIphiIphi;
590 eval[14] = ess.sigmaIetaIphi/(ess.sigmaIphiIphi*ess.sigmaIetaIeta);
591 eval[15] = ess.maxEnergyXtal/ess.e5x5;
592 eval[16] = ess.e2nd/ess.e5x5;
593 eval[17] = ess.eTop/ess.e5x5;
594 eval[18] = ess.eBottom/ess.e5x5;
595 eval[19] = ess.eLeft/ess.e5x5;
596 eval[20] = ess.eRight/ess.e5x5;
597 eval[21] = ess.e2x5Max/ess.e5x5;
598 eval[22] = ess.e2x5Left/ess.e5x5;
599 eval[23] = ess.e2x5Right/ess.e5x5;
600 eval[24] = ess.e2x5Top/ess.e5x5;
601 eval[25] = ess.e2x5Bottom/ess.e5x5;
603 const bool iseb = pho.
isEB();
605 EBDetId ebseedid(theseed->seed());
606 eval[26] = pho.
e5x5()/theseed->energy();
607 eval[27] = ebseedid.ieta();
608 eval[28] = ebseedid.iphi();
610 EEDetId eeseedid(theseed->seed());
611 eval[26] = the_sc->preshowerEnergy()/raw_energy;
612 eval[27] = the_sc->preshowerEnergyPlane1()/raw_energy;
613 eval[28] = the_sc->preshowerEnergyPlane2()/raw_energy;
614 eval[29] = eeseedid.ix();
615 eval[30] = eeseedid.iy();
620 const double meanlimlow = 0.2;
621 const double meanlimhigh = 2.0;
622 const double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
623 const double meanscale = 0.5*(meanlimhigh-meanlimlow);
625 const double sigmalimlow = 0.0002;
626 const double sigmalimhigh = 0.5;
627 const double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
628 const double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
638 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
639 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
643 double ecor = mean*eval[0];
645 ecor = mean*(eval[0]+the_sc->preshowerEnergy());
647 double sigmacor = sigma*ecor;
const double Z[kNumberCalorimeter]
double GetResponse(const float *vector) const
const ShowerShape & showerShape() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Analysis-level Photon class.
float trackMomentumError() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const LorentzVector & p4(P4Kind kind) const
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
math::XYZVectorF trackMomentumAtVtx() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
double deltaR(const T1 &t1, const T2 &t2)
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setCorrectedEcalEnergyError(float newEnergyError)
const std::string & name() const
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Abs< T >::type abs(const T &t)
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
std::vector< std::string > getParameterNames() const
double deltaPhi(double phi1, double phi2)
Classification classification() const
T const * product() const
Analysis-level electron class.
void localCoordsEB(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
void setCorrectedEcalEnergy(float newEnergy)
bool trackerDrivenSeed() const
bool isUninitialized() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
void localCoordsEE(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const
const ShowerShape & showerShapeVariables() const