15 #include <vdt/vdtMath.h> 21 #include <unordered_map> 99 "EGExtraInfoModifierFromDB");
104 lowEnergy_ECALonlyThr_ = conf.getParameter<
double>(
"lowEnergy_ECALonlyThr");
105 lowEnergy_ECALTRKThr_ = conf.getParameter<
double>(
"lowEnergy_ECALTRKThr");
106 highEnergy_ECALTRKThr_ = conf.getParameter<
double>(
"highEnergy_ECALTRKThr");
107 eOverP_ECALTRKThr_ = conf.getParameter<
double>(
"eOverP_ECALTRKThr");
108 epDiffSig_ECALTRKThr_ = conf.getParameter<
double>(
"epDiffSig_ECALTRKThr");
109 epSig_ECALTRKThr_ = conf.getParameter<
double>(
"epSig_ECALTRKThr");
116 if(conf.exists(
"electron_config")) {
118 if( electrons.
exists(electronSrc) )
121 std::vector<std::string> intValueMaps;
122 if ( electrons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
123 intValueMaps = electrons.
getParameter<std::vector<std::string> >(
"intValueMaps");
130 for (
auto vmp : intValueMaps) {
146 e_forestH_mean_.reserve(2*encor);
147 e_forestH_sigma_.reserve(2*encor);
151 if( conf.exists(
"photon_config") ) {
154 if( photons.
exists(photonSrc) )
157 std::vector<std::string> intValueMaps;
158 if ( photons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
159 intValueMaps = photons.
getParameter<std::vector<std::string> >(
"intValueMaps");
166 for (
auto vmp : intValueMaps) {
180 ph_forestH_mean_.reserve(ncor);
181 ph_forestH_sigma_.reserve(ncor);
190 inline void get_product(
const edm::Event& evt,
212 for(
unsigned i = 0;
i < eles->size(); ++
i ) {
221 get_product(evt, imap->second.second,
ele_vmaps);
234 for(
unsigned i = 0;
i < phos->size(); ++
i ) {
244 get_product(evt, imap->second.second,
pho_vmaps);
268 unsigned int ncor = ph_condnames_ecalonly_mean.size();
269 for (
unsigned int icor=0; icor<ncor; ++icor) {
281 unsigned int encor = e_condnames_ecalonly_mean.size();
282 for (
unsigned int icor=0; icor<encor; ++icor) {
288 for (
unsigned int icor=0; icor<encor; ++icor) {
298 template<
typename T,
typename U,
typename V>
299 inline void make_consumes(
T&
tag,
U& tok,V& sume) {
300 if(!(empty_tag == tag))
301 tok = sume.template consumes<edm::ValueMap<float> >(
tag);
304 template<
typename T,
typename U,
typename V>
305 inline void make_int_consumes(
T& tag,
U& tok,V& sume) {
306 if(!(empty_tag == tag))
307 tok = sume.template consumes<edm::ValueMap<int> >(
tag);
322 make_consumes(imap->second.first, imap->second.second, sumes);
325 for ( std::unordered_map<std::string, ValMapIntTagTokenPair>::iterator imap =
e_conf.
tag_int_token_map.begin();
328 make_int_consumes(imap->second.first, imap->second.second, sumes);
338 make_consumes(imap->second.first, imap->second.second, sumes);
344 make_int_consumes(imap->second.first, imap->second.second, sumes);
349 template<
typename T,
typename U,
typename V,
typename Z>
350 inline void assignValue(
const T& ptr,
const U& tok,
const V&
map,
Z&
value) {
351 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
365 const int numberOfClusters = the_sc->clusters().size();
366 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
367 if( missing_clusters )
return ;
369 const bool iseb = ele.
isEB();
371 std::array<float, 32> eval;
372 const double raw_energy = the_sc->rawEnergy();
373 const double raw_es_energy = the_sc->preshowerEnergy();
376 float e5x5Inverse = full5x5_ess.
e5x5 != 0. ? vdt::fast_inv(full5x5_ess.e5x5) : 0.;
378 eval[0] = raw_energy;
379 eval[1] = the_sc->etaWidth();
380 eval[2] = the_sc->phiWidth();
381 eval[3] = the_sc->seed()->energy()/raw_energy;
382 eval[4] = full5x5_ess.e5x5/raw_energy;
385 eval[7] = theseed->
eta() - the_sc->position().Eta();
387 eval[9] = full5x5_ess.r9;
388 eval[10] = full5x5_ess.sigmaIetaIeta;
389 eval[11] = full5x5_ess.sigmaIetaIphi;
390 eval[12] = full5x5_ess.sigmaIphiIphi;
391 eval[13] = full5x5_ess.eMax*e5x5Inverse;
392 eval[14] = full5x5_ess.e2nd*e5x5Inverse;
393 eval[15] = full5x5_ess.eTop*e5x5Inverse;
394 eval[16] = full5x5_ess.eBottom*e5x5Inverse;
395 eval[17] = full5x5_ess.eLeft*e5x5Inverse;
396 eval[18] = full5x5_ess.eRight*e5x5Inverse;
397 eval[19] = full5x5_ess.e2x5Max*e5x5Inverse;
398 eval[20] = full5x5_ess.e2x5Left*e5x5Inverse;
399 eval[21] = full5x5_ess.e2x5Right*e5x5Inverse;
400 eval[22] = full5x5_ess.e2x5Top*e5x5Inverse;
401 eval[23] = full5x5_ess.e2x5Bottom*e5x5Inverse;
403 eval[25] =
std::max(0,numberOfClusters);
415 int signieta = ieta > 0 ? +1 : -1;
416 eval[28] = (ieta-signieta)%5;
417 eval[29] = (iphi-1)%2;
418 eval[30] = (
abs(ieta)<=25)*((ieta-signieta)) + (
abs(ieta)>25)*((ieta-26*signieta)%20);
419 eval[31] = (iphi-1)%20;
429 eval[28] = raw_es_energy/raw_energy;
437 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
438 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
442 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
443 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
447 float raw_pt = raw_energy*the_sc->position().rho()/the_sc->position().r();
463 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
464 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
469 if (mean < 0.) mean = 1.0;
471 const double ecor = mean*(raw_energy + raw_es_energy);
472 const double sigmacor = sigma*ecor;
477 double combinedEnergy = ecor;
478 double combinedEnergyError = sigmacor;
481 const float trkMomentum = el_track->pMode();
482 const float trkEta = el_track->etaMode();
483 const float trkPhi = el_track->phiMode();
484 const float trkMomentumError =
std::abs(el_track->qoverpModeError())*trkMomentum*trkMomentum;
486 const float eOverP = (raw_energy+raw_es_energy)*mean/trkMomentum;
487 const float fbrem = ele.
fbrem();
495 raw_pt = ecor/cosh(trkEta);
506 eval[1] = sigma/
mean;
507 eval[2] = trkMomentumError/trkMomentum;
510 eval[5] = full5x5_ess.r9;
515 float ecalEnergyVar = (raw_energy + raw_es_energy)*sigma;
516 float rawcombNormalization = (trkMomentumError*trkMomentumError + ecalEnergyVar*ecalEnergyVar);
517 float rawcomb = ( ecor*trkMomentumError*trkMomentumError + trkMomentum*ecalEnergyVar*ecalEnergyVar ) / rawcombNormalization;
520 double rawmean_trk =
e_forestH_mean_[coridx]->GetResponse(eval.data());
524 double mean_trk = meanoffset + meanscale*vdt::fast_sin(rawmean_trk);
525 double sigma_trk = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma_trk);
531 if (mean_trk < 0.) mean_trk = 1.0;
533 combinedEnergy = mean_trk*rawcomb;
534 combinedEnergyError = sigma_trk*rawcomb;
539 oldFourMomentum.y()*combinedEnergy/oldFourMomentum.t(),
540 oldFourMomentum.z()*combinedEnergy/oldFourMomentum.t(),
559 const int numberOfClusters = the_sc->clusters().size();
560 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
561 if( missing_clusters )
return ;
563 const bool iseb = pho.
isEB();
565 std::array<float, 32> eval;
566 const double raw_energy = the_sc->rawEnergy();
567 const double raw_es_energy = the_sc->preshowerEnergy();
570 float e5x5Inverse = full5x5_pss.
e5x5 != 0. ? vdt::fast_inv(full5x5_pss.e5x5) : 0.;
572 eval[0] = raw_energy;
573 eval[1] = the_sc->etaWidth();
574 eval[2] = the_sc->phiWidth();
575 eval[3] = the_sc->seed()->energy()/raw_energy;
576 eval[4] = full5x5_pss.e5x5/raw_energy;
579 eval[7] = theseed->
eta() - the_sc->position().Eta();
582 eval[10] = full5x5_pss.sigmaIetaIeta;
583 eval[11] = full5x5_pss.sigmaIetaIphi;
584 eval[12] = full5x5_pss.sigmaIphiIphi;
585 eval[13] = full5x5_pss.maxEnergyXtal*e5x5Inverse;
586 eval[14] = full5x5_pss.e2nd*e5x5Inverse;
587 eval[15] = full5x5_pss.eTop*e5x5Inverse;
588 eval[16] = full5x5_pss.eBottom*e5x5Inverse;
589 eval[17] = full5x5_pss.eLeft*e5x5Inverse;
590 eval[18] = full5x5_pss.eRight*e5x5Inverse;
591 eval[19] = full5x5_pss.e2x5Max*e5x5Inverse;
592 eval[20] = full5x5_pss.e2x5Left*e5x5Inverse;
593 eval[21] = full5x5_pss.e2x5Right*e5x5Inverse;
594 eval[22] = full5x5_pss.e2x5Top*e5x5Inverse;
595 eval[23] = full5x5_pss.e2x5Bottom*e5x5Inverse;
597 eval[25] =
std::max(0,numberOfClusters);
610 int signieta = ieta > 0 ? +1 : -1;
611 eval[28] = (ieta-signieta)%5;
612 eval[29] = (iphi-1)%2;
613 eval[30] = (
abs(ieta)<=25)*((ieta-signieta)) + (
abs(ieta)>25)*((ieta-26*signieta)%20);
614 eval[31] = (iphi-1)%20;
624 eval[28] = raw_es_energy/raw_energy;
632 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
633 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
637 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
638 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
641 float raw_pt = raw_energy*the_sc->position().rho()/the_sc->position().r();
657 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
658 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
663 if (mean < 0.) mean = 1.0;
665 const double ecor = mean*(raw_energy + raw_es_energy);
666 const double sigmacor = sigma*ecor;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Analysis-level Photon class.
float nSaturatedXtals() const
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)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double eta() const
pseudorapidity of cluster centroid
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
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
float hcalOverEcalBc() const
double deltaPhi(double phi1, double phi2)
DetId seed() const
return DetId of seed
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
return(e1-e2)*(e1-e2)+dp *dp
void setCorrectedEcalEnergy(float newEnergy)
const ShowerShape & full5x5_showerShape() const
const ShowerShape & full5x5_showerShapeVariables() const
bool isUninitialized() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
double phi() const
azimuthal angle of cluster centroid
void localCoordsEE(const reco::CaloCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const
Detector det() const
get the detector field from this detid
T const * product() const
float nSaturatedXtals() const
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
bool ecalDrivenSeed() const