18 #include <vdt/vdtMath.h>
24 #include <unordered_map>
64 void setConsumes(edm::ConsumesCollector&) override final;
100 "EGExtraInfoModifierFromDB");
106 autoDetectBunchSpacing_ = conf.getParameter<
bool>(
"autoDetectBunchSpacing");
109 vtxTag_ = conf.getParameter<
edm::InputTag>(
"vertexCollection");
111 if (autoDetectBunchSpacing_) {
112 bunchspacingTag_ = conf.getParameter<
edm::InputTag>(
"bunchSpacingTag");
114 bunchspacing_ = conf.getParameter<
int>(
"manualBunchSpacing");
117 constexpr char electronSrc[] =
"electronSrc";
118 constexpr char photonSrc[] =
"photonSrc";
120 if(conf.exists(
"electron_config")) {
122 if( electrons.
exists(electronSrc) )
125 std::vector<std::string> intValueMaps;
126 if ( electrons.
existsAs<std::vector<std::string> >(
"intValueMaps"))
127 intValueMaps = electrons.
getParameter<std::vector<std::string> >(
"intValueMaps");
134 for (
auto vmp : intValueMaps) {
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) {
203 for(
unsigned i = 0;
i < eles->size(); ++
i ) {
225 for(
unsigned i = 0;
i < phos->size(); ++
i ) {
257 else if (run < 253000) {
286 unsigned int ncor = ph_condnames_mean.size();
287 for (
unsigned int icor=0; icor<ncor; ++icor) {
298 unsigned int encor = e_condnames_mean.size();
302 for (
unsigned int icor=0; icor<encor; ++icor) {
310 template<
typename T,
typename U,
typename V>
312 if(!(empty_tag == tag))
313 tok = sume.template consumes<edm::ValueMap<float> >(
tag);
316 template<
typename T,
typename U,
typename V>
318 if(!(empty_tag == tag))
319 tok = sume.template consumes<edm::ValueMap<int> >(
tag);
337 make_consumes(imap->second.first, imap->second.second, sumes);
340 for ( std::unordered_map<std::string, ValMapIntTagTokenPair>::iterator imap =
e_conf.
tag_int_token_map.begin();
353 make_consumes(imap->second.first, imap->second.second, sumes);
363 template<
typename T,
typename U,
typename V,
typename Z>
365 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
381 <<
" not found in cache!";
384 std::array<float, 33> eval;
391 eval[1] = sc->rawEnergy();
394 eval[4] = sc->etaWidth();
395 eval[5] = sc->phiWidth();
397 eval[7] = theseed->energy()/sc->rawEnergy();
399 float sieip=0, cryPhi=0, cryEta=0;
401 float eMax=0, e2nd=0, eTop=0, eBottom=0, eLeft=0, eRight=0;
402 float clusterMaxDR=0, clusterMaxDRDPhi=0, clusterMaxDRDEta=0, clusterMaxDRRawEnergy=0;
403 float clusterRawEnergy0=0, clusterRawEnergy1=0, clusterRawEnergy2=0;
404 float clusterDPhiToSeed0=0, clusterDPhiToSeed1=0, clusterDPhiToSeed2=0;
405 float clusterDEtaToSeed0=0, clusterDEtaToSeed1=0, clusterDEtaToSeed2=0;
432 eval[8] = eMax/sc->rawEnergy();
433 eval[9] = e2nd/sc->rawEnergy();
434 eval[10] = (eLeft+eRight!=0. ? (eLeft-eRight)/(eLeft+eRight) : 0.);
435 eval[11] = (eTop+eBottom!=0. ? (eTop-eBottom)/(eTop+eBottom) : 0.);
439 const int N_ECAL = sc->clustersEnd() - sc->clustersBegin();
441 eval[16] = clusterMaxDR;
442 eval[17] = clusterMaxDRDPhi;
443 eval[18] = clusterMaxDRDEta;
444 eval[19] = clusterMaxDRRawEnergy/sc->rawEnergy();
445 eval[20] = clusterRawEnergy0/sc->rawEnergy();
446 eval[21] = clusterRawEnergy1/sc->rawEnergy();
447 eval[22] = clusterRawEnergy2/sc->rawEnergy();
448 eval[23] = clusterDPhiToSeed0;
449 eval[24] = clusterDPhiToSeed1;
450 eval[25] = clusterDPhiToSeed2;
451 eval[26] = clusterDEtaToSeed0;
452 eval[27] = clusterDEtaToSeed1;
453 eval[28] = clusterDEtaToSeed2;
455 bool iseb = ele.
isEB();
463 eval[29] = sc->preshowerEnergy()/sc->rawEnergy();
470 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
471 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
475 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
476 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
487 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
488 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
492 double ecor = mean*(eval[1]);
494 ecor = mean*(eval[1]+sc->preshowerEnergy());
495 const double sigmacor = sigma*ecor;
505 const float tot_energy = sc->rawEnergy()+sc->preshowerEnergy();
508 const float eOverP = tot_energy*mean/ep;
509 eval_ep[0] = tot_energy*
mean;
510 eval_ep[1] = sigma/
mean;
512 eval_ep[3] = trkMomentumRelError;
513 eval_ep[4] = sigma/mean/trkMomentumRelError;
514 eval_ep[5] = tot_energy*mean/ep;
515 eval_ep[6] = tot_energy*mean/ep*
sqrt(sigma/mean*sigma/mean+trkMomentumRelError*trkMomentumRelError);
529 if ( eOverP > 0.025 &&
530 std::abs(ep-ecor) < 15.*
std::sqrt( momentumError*momentumError + sigmacor*sigmacor ) ) {
544 oldMomentum.y()*combinedMomentum/oldMomentum.t(),
545 oldMomentum.z()*combinedMomentum/oldMomentum.t(),
564 <<
"Original object pointer with key = " << pho.
originalObjectRef().
key() <<
" not found in cache!";
568 std::array<float, 31> eval;
573 eval[0] = sc->rawEnergy();
577 eval[2] = sc->etaWidth();
578 eval[3] = sc->phiWidth();
579 const int N_ECAL = sc->clustersEnd() - sc->clustersBegin();
584 eval[8] = theseed->eta()-sc->position().Eta();
590 float sipip=0, sieip=0, e2x5Max=0, e2x5Left=0, e2x5Right=0, e2x5Top=0, e2x5Bottom=0;
607 eval[21] = e2x5Max/pho.
e5x5();
608 eval[22] = e2x5Left/pho.
e5x5();
609 eval[23] = e2x5Right/pho.
e5x5();
610 eval[24] = e2x5Top/pho.
e5x5();
611 eval[25] = e2x5Bottom/pho.
e5x5();
613 bool iseb = pho.
isEB();
616 EBDetId ebseedid(theseed->seed());
618 eval[27] = ebseedid.ieta();
619 eval[28] = ebseedid.iphi();
621 EEDetId eeseedid(theseed->seed());
622 eval[26] = sc->preshowerEnergy()/sc->rawEnergy();
623 eval[27] = sc->preshowerEnergyPlane1()/sc->rawEnergy();
624 eval[28] = sc->preshowerEnergyPlane2()/sc->rawEnergy();
625 eval[29] = eeseedid.ix();
626 eval[30] = eeseedid.iy();
631 const double meanlimlow = 0.2;
632 const double meanlimhigh = 2.0;
633 const double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
634 const double meanscale = 0.5*(meanlimhigh-meanlimlow);
636 const double sigmalimlow = 0.0002;
637 const double sigmalimhigh = 0.5;
638 const double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
639 const double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
649 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
650 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
654 double ecor = mean*eval[0];
656 ecor = mean*(eval[0]+sc->preshowerEnergy());
658 double sigmacor = sigma*ecor;
const double Z[kNumberCalorimeter]
float sigmaIphiIphi() const
double GetResponse(const float *vector) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Analysis-level Photon class.
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
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
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
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
void setCorrectedEcalEnergyError(float newEnergyError)
float sigmaIetaIeta() const
const std::string & name() const
float seedEnergy() const
input variables for regression energy corrections
float sigmaIetaIeta() const
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
double deltaPhi(double phi1, double phi2)
Classification classification() const
T const * product() const
Analysis-level electron class.
void setCorrectedEcalEnergy(float newEnergy)
bool trackerDrivenSeed() const
bool isUninitialized() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
float maxEnergyXtal() const