15 #include <vdt/vdtMath.h> 21 #include <unordered_map> 100 "EGRegressionModifierV2");
105 lowEnergy_ECALonlyThr_ = conf.getParameter<
double>(
"lowEnergy_ECALonlyThr");
106 lowEnergy_ECALTRKThr_ = conf.getParameter<
double>(
"lowEnergy_ECALTRKThr");
107 highEnergy_ECALTRKThr_ = conf.getParameter<
double>(
"highEnergy_ECALTRKThr");
108 eOverP_ECALTRKThr_ = conf.getParameter<
double>(
"eOverP_ECALTRKThr");
109 epDiffSig_ECALTRKThr_ = conf.getParameter<
double>(
"epDiffSig_ECALTRKThr");
110 epSig_ECALTRKThr_ = conf.getParameter<
double>(
"epSig_ECALTRKThr");
111 forceHighEnergyEcalTrainingIfSaturated_ = conf.getParameter<
bool>(
"forceHighEnergyEcalTrainingIfSaturated");
117 if(conf.exists(
"electron_config")) {
119 if( electrons.
exists(electronSrc) )
122 std::vector<std::string> intValueMaps;
123 if ( electrons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
124 intValueMaps = electrons.
getParameter<std::vector<std::string> >(
"intValueMaps");
131 for (
auto vmp : intValueMaps) {
147 e_forestH_mean_.reserve(2*encor);
148 e_forestH_sigma_.reserve(2*encor);
152 if( conf.exists(
"photon_config") ) {
155 if( photons.
exists(photonSrc) )
158 std::vector<std::string> intValueMaps;
159 if ( photons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
160 intValueMaps = photons.
getParameter<std::vector<std::string> >(
"intValueMaps");
167 for (
auto vmp : intValueMaps) {
181 ph_forestH_mean_.reserve(ncor);
182 ph_forestH_sigma_.reserve(ncor);
191 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);
269 unsigned int ncor = ph_condnames_ecalonly_mean.size();
270 for (
unsigned int icor=0; icor<ncor; ++icor) {
282 unsigned int encor = e_condnames_ecalonly_mean.size();
283 for (
unsigned int icor=0; icor<encor; ++icor) {
289 for (
unsigned int icor=0; icor<encor; ++icor) {
299 template<
typename T,
typename U,
typename V>
300 inline void make_consumes(
T&
tag,
U& tok,V& sume) {
301 if(!(empty_tag == tag))
302 tok = sume.template consumes<edm::ValueMap<float> >(
tag);
305 template<
typename T,
typename U,
typename V>
306 inline void make_int_consumes(
T& tag,
U& tok,V& sume) {
307 if(!(empty_tag == tag))
308 tok = sume.template consumes<edm::ValueMap<int> >(
tag);
323 make_consumes(imap->second.first, imap->second.second, sumes);
326 for ( std::unordered_map<std::string, ValMapIntTagTokenPair>::iterator imap =
e_conf.
tag_int_token_map.begin();
329 make_int_consumes(imap->second.first, imap->second.second, sumes);
339 make_consumes(imap->second.first, imap->second.second, sumes);
345 make_int_consumes(imap->second.first, imap->second.second, sumes);
350 template<
typename T,
typename U,
typename V,
typename Z>
351 inline void assignValue(
const T& ptr,
const U& tok,
const V&
map,
Z&
value) {
352 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
366 const int numberOfClusters = the_sc->clusters().size();
367 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
368 if( missing_clusters )
return ;
374 const bool iseb = ele.
isEB();
376 std::array<float, 32> eval;
377 const double raw_energy = the_sc->rawEnergy();
378 const double raw_es_energy = the_sc->preshowerEnergy();
381 float e5x5Inverse = full5x5_ess.
e5x5 != 0. ? vdt::fast_inv(full5x5_ess.e5x5) : 0.;
383 eval[0] = raw_energy;
384 eval[1] = the_sc->etaWidth();
385 eval[2] = the_sc->phiWidth();
386 eval[3] = the_sc->seed()->energy()/raw_energy;
387 eval[4] = full5x5_ess.e5x5/raw_energy;
390 eval[7] = theseed->
eta() - the_sc->position().Eta();
392 eval[9] = full5x5_ess.r9;
393 eval[10] = full5x5_ess.sigmaIetaIeta;
394 eval[11] = full5x5_ess.sigmaIetaIphi;
395 eval[12] = full5x5_ess.sigmaIphiIphi;
396 eval[13] = full5x5_ess.eMax*e5x5Inverse;
397 eval[14] = full5x5_ess.e2nd*e5x5Inverse;
398 eval[15] = full5x5_ess.eTop*e5x5Inverse;
399 eval[16] = full5x5_ess.eBottom*e5x5Inverse;
400 eval[17] = full5x5_ess.eLeft*e5x5Inverse;
401 eval[18] = full5x5_ess.eRight*e5x5Inverse;
402 eval[19] = full5x5_ess.e2x5Max*e5x5Inverse;
403 eval[20] = full5x5_ess.e2x5Left*e5x5Inverse;
404 eval[21] = full5x5_ess.e2x5Right*e5x5Inverse;
405 eval[22] = full5x5_ess.e2x5Top*e5x5Inverse;
406 eval[23] = full5x5_ess.e2x5Bottom*e5x5Inverse;
408 eval[25] =
std::max(0,numberOfClusters);
420 int signieta = ieta > 0 ? +1 : -1;
421 eval[28] = (ieta-signieta)%5;
422 eval[29] = (iphi-1)%2;
423 eval[30] = (
abs(ieta)<=25)*((ieta-signieta)) + (
abs(ieta)>25)*((ieta-26*signieta)%20);
424 eval[31] = (iphi-1)%20;
434 eval[28] = raw_es_energy/raw_energy;
442 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
443 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
447 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
448 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
452 float raw_pt = raw_energy*the_sc->position().rho()/the_sc->position().r();
470 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
471 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
476 if (mean < 0.) mean = 1.0;
478 const double ecor = mean*(raw_energy + raw_es_energy);
479 const double sigmacor = sigma*ecor;
484 double combinedEnergy = ecor;
485 double combinedEnergyError = sigmacor;
488 const float trkMomentum = el_track->pMode();
489 const float trkEta = el_track->etaMode();
490 const float trkPhi = el_track->phiMode();
491 const float trkMomentumError =
std::abs(el_track->qoverpModeError())*trkMomentum*trkMomentum;
493 const float eOverP = (raw_energy+raw_es_energy)*mean/trkMomentum;
494 const float fbrem = ele.
fbrem();
502 raw_pt = ecor/cosh(trkEta);
513 eval[1] = sigma/
mean;
514 eval[2] = trkMomentumError/trkMomentum;
517 eval[5] = full5x5_ess.r9;
522 float ecalEnergyVar = (raw_energy + raw_es_energy)*sigma;
523 float rawcombNormalization = (trkMomentumError*trkMomentumError + ecalEnergyVar*ecalEnergyVar);
524 float rawcomb = ( ecor*trkMomentumError*trkMomentumError + trkMomentum*ecalEnergyVar*ecalEnergyVar ) / rawcombNormalization;
527 double rawmean_trk =
e_forestH_mean_[coridx]->GetResponse(eval.data());
531 double mean_trk = meanoffset + meanscale*vdt::fast_sin(rawmean_trk);
532 double sigma_trk = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma_trk);
538 if (mean_trk < 0.) mean_trk = 1.0;
540 combinedEnergy = mean_trk*rawcomb;
541 combinedEnergyError = sigma_trk*rawcomb;
546 oldFourMomentum.y()*combinedEnergy/oldFourMomentum.t(),
547 oldFourMomentum.z()*combinedEnergy/oldFourMomentum.t(),
566 const int numberOfClusters = the_sc->clusters().size();
567 const bool missing_clusters = !the_sc->clusters()[numberOfClusters-1].
isAvailable();
568 if( missing_clusters )
return ;
570 const bool iseb = pho.
isEB();
572 std::array<float, 32> eval;
573 const double raw_energy = the_sc->rawEnergy();
574 const double raw_es_energy = the_sc->preshowerEnergy();
577 float e5x5Inverse = full5x5_pss.
e5x5 != 0. ? vdt::fast_inv(full5x5_pss.e5x5) : 0.;
579 eval[0] = raw_energy;
580 eval[1] = the_sc->etaWidth();
581 eval[2] = the_sc->phiWidth();
582 eval[3] = the_sc->seed()->energy()/raw_energy;
583 eval[4] = full5x5_pss.e5x5/raw_energy;
586 eval[7] = theseed->
eta() - the_sc->position().Eta();
589 eval[10] = full5x5_pss.sigmaIetaIeta;
590 eval[11] = full5x5_pss.sigmaIetaIphi;
591 eval[12] = full5x5_pss.sigmaIphiIphi;
592 eval[13] = full5x5_pss.maxEnergyXtal*e5x5Inverse;
593 eval[14] = full5x5_pss.e2nd*e5x5Inverse;
594 eval[15] = full5x5_pss.eTop*e5x5Inverse;
595 eval[16] = full5x5_pss.eBottom*e5x5Inverse;
596 eval[17] = full5x5_pss.eLeft*e5x5Inverse;
597 eval[18] = full5x5_pss.eRight*e5x5Inverse;
598 eval[19] = full5x5_pss.e2x5Max*e5x5Inverse;
599 eval[20] = full5x5_pss.e2x5Left*e5x5Inverse;
600 eval[21] = full5x5_pss.e2x5Right*e5x5Inverse;
601 eval[22] = full5x5_pss.e2x5Top*e5x5Inverse;
602 eval[23] = full5x5_pss.e2x5Bottom*e5x5Inverse;
604 eval[25] =
std::max(0,numberOfClusters);
617 int signieta = ieta > 0 ? +1 : -1;
618 eval[28] = (ieta-signieta)%5;
619 eval[29] = (iphi-1)%2;
620 eval[30] = (
abs(ieta)<=25)*((ieta-signieta)) + (
abs(ieta)>25)*((ieta-26*signieta)%20);
621 eval[31] = (iphi-1)%20;
631 eval[28] = raw_es_energy/raw_energy;
639 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
640 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
644 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
645 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
648 float raw_pt = raw_energy*the_sc->position().rho()/the_sc->position().r();
665 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
666 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
671 if (mean < 0.) mean = 1.0;
673 const double ecor = mean*(raw_energy + raw_es_energy);
674 const double sigmacor = sigma*ecor;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Analysis-level Photon class.
std::unordered_map< std::string, ValMapIntTagTokenPair > tag_int_token_map
float nSaturatedXtals() const
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
float trackMomentumError() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void setEventContent(const edm::EventSetup &) final
const LorentzVector & p4(P4Kind kind) const
EGRegressionModifierV2(const edm::ParameterSet &conf)
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
const edm::EventSetup * iSetup_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double lowEnergy_ECALonlyThr_
double epDiffSig_ECALTRKThr_
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
std::vector< std::string > condnames_ecalonly_sigma
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::pair< edm::InputTag, ValMapIntToken > ValMapIntTagTokenPair
std::vector< std::string > condnames_ecalonly_mean
std::vector< std::string > condnames_ecalonly_mean
void setEvent(const edm::Event &) final
std::vector< std::string > condnames_ecalonly_sigma
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
double eta() const
pseudorapidity of cluster centroid
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< int > > > ele_int_vmaps
U second(std::pair< T, U > const &p)
double highEnergy_ECALTRKThr_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::unordered_map< std::string, ValMapFloatTagTokenPair > tag_float_token_map
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
void setCorrectedEcalEnergyError(float newEnergyError)
const std::string & name() const
std::pair< edm::InputTag, ValMapFloatToken > ValMapFloatTagTokenPair
bool forceHighEnergyEcalTrainingIfSaturated_
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > pho_vmaps
void modifyObject(reco::GsfElectron &) const final
std::vector< const GBRForestD * > ph_forestH_sigma_
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
Abs< T >::type abs(const T &t)
void setConsumes(edm::ConsumesCollector &) final
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
std::vector< std::string > getParameterNames() const
edm::InputTag electron_src
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
float hcalOverEcalBc() const
edm::EDGetTokenT< edm::ValueMap< int > > ValMapIntToken
double deltaPhi(double phi1, double phi2)
std::vector< std::string > condnames_ecaltrk_mean
DetId seed() const
return DetId of seed
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< int > > > pho_int_vmaps
std::vector< std::string > condnames_ecaltrk_sigma
Analysis-level electron class.
double eOverP_ECALTRKThr_
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
std::unordered_map< std::string, ValMapFloatTagTokenPair > tag_float_token_map
~EGRegressionModifierV2() override
std::unordered_map< std::string, ValMapIntTagTokenPair > tag_int_token_map
void setCorrectedEcalEnergy(float newEnergy)
edm::EDGetTokenT< double > rhoToken_
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
const ShowerShape & full5x5_showerShape() const
const ShowerShape & full5x5_showerShapeVariables() const
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
std::vector< const GBRForestD * > e_forestH_sigma_
SuperClusterRef superCluster() const override
reference to a SuperCluster
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
double lowEnergy_ECALTRKThr_
Detector det() const
get the detector field from this detid
T const * product() const
edm::EDGetTokenT< edm::ValueMap< float > > ValMapFloatToken
std::vector< const GBRForestD * > ph_forestH_mean_
std::vector< const GBRForestD * > e_forestH_mean_
float nSaturatedXtals() const
bool ecalDrivenSeed() const