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) {
186 inline void get_product(
const edm::Event& evt,
205 for(
unsigned i = 0;
i < eles->size(); ++
i ) {
214 get_product(evt, imap->second.second,
ele_vmaps);
227 for(
unsigned i = 0;
i < phos->size(); ++
i ) {
237 get_product(evt, imap->second.second,
pho_vmaps);
268 unsigned int ncor = ph_condnames_mean.size();
269 for (
unsigned int icor=0; icor<ncor; ++icor) {
280 unsigned int encor = e_condnames_mean.size();
284 for (
unsigned int icor=0; icor<encor; ++icor) {
293 template<
typename T,
typename U,
typename V>
294 inline void make_consumes(
T&
tag,U&
tok,V& sume) {
295 if(!(empty_tag == tag))
296 tok = sume.template consumes<edm::ValueMap<float> >(
tag);
299 template<
typename T,
typename U,
typename V>
300 inline void make_int_consumes(
T& tag,U& tok,V& sume) {
301 if(!(empty_tag == tag))
302 tok = sume.template consumes<edm::ValueMap<int> >(
tag);
321 make_consumes(imap->second.first, imap->second.second, sumes);
324 for ( std::unordered_map<std::string, ValMapIntTagTokenPair>::iterator imap =
e_conf.
tag_int_token_map.begin();
327 make_int_consumes(imap->second.first, imap->second.second, sumes);
337 make_consumes(imap->second.first, imap->second.second, sumes);
343 make_int_consumes(imap->second.first, imap->second.second, sumes);
348 template<
typename T,
typename U,
typename V,
typename Z>
349 inline void assignValue(
const T& ptr,
const U& tok,
const V&
map,
Z&
value) {
350 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
367 <<
" not found in cache!";
370 std::array<float, 33> eval;
377 eval[1] = sc->rawEnergy();
380 eval[4] = sc->etaWidth();
381 eval[5] = sc->phiWidth();
383 eval[7] = theseed->energy()/sc->rawEnergy();
385 float sieip=0, cryPhi=0, cryEta=0;
387 float eMax=0, e2nd=0, eTop=0, eBottom=0, eLeft=0, eRight=0;
388 float clusterMaxDR=0, clusterMaxDRDPhi=0, clusterMaxDRDEta=0, clusterMaxDRRawEnergy=0;
389 float clusterRawEnergy0=0, clusterRawEnergy1=0, clusterRawEnergy2=0;
390 float clusterDPhiToSeed0=0, clusterDPhiToSeed1=0, clusterDPhiToSeed2=0;
391 float clusterDEtaToSeed0=0, clusterDEtaToSeed1=0, clusterDEtaToSeed2=0;
418 eval[8] = eMax/sc->rawEnergy();
419 eval[9] = e2nd/sc->rawEnergy();
420 eval[10] = (eLeft+eRight!=0. ? (eLeft-eRight)/(eLeft+eRight) : 0.);
421 eval[11] = (eTop+eBottom!=0. ? (eTop-eBottom)/(eTop+eBottom) : 0.);
425 const int N_ECAL = sc->clustersEnd() - sc->clustersBegin();
427 eval[16] = clusterMaxDR;
428 eval[17] = clusterMaxDRDPhi;
429 eval[18] = clusterMaxDRDEta;
430 eval[19] = clusterMaxDRRawEnergy/sc->rawEnergy();
431 eval[20] = clusterRawEnergy0/sc->rawEnergy();
432 eval[21] = clusterRawEnergy1/sc->rawEnergy();
433 eval[22] = clusterRawEnergy2/sc->rawEnergy();
434 eval[23] = clusterDPhiToSeed0;
435 eval[24] = clusterDPhiToSeed1;
436 eval[25] = clusterDPhiToSeed2;
437 eval[26] = clusterDEtaToSeed0;
438 eval[27] = clusterDEtaToSeed1;
439 eval[28] = clusterDEtaToSeed2;
441 bool iseb = ele.
isEB();
449 eval[29] = sc->preshowerEnergy()/sc->rawEnergy();
456 constexpr double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
457 constexpr double meanscale = 0.5*(meanlimhigh-meanlimlow);
461 constexpr double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
462 constexpr double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
473 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
474 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
478 double ecor = mean*(eval[1]);
480 ecor = mean*(eval[1]+sc->preshowerEnergy());
481 const double sigmacor = sigma*ecor;
491 const float tot_energy = sc->rawEnergy()+sc->preshowerEnergy();
494 const float eOverP = tot_energy*mean/ep;
495 eval_ep[0] = tot_energy*
mean;
496 eval_ep[1] = sigma/
mean;
498 eval_ep[3] = trkMomentumRelError;
499 eval_ep[4] = sigma/mean/trkMomentumRelError;
500 eval_ep[5] = tot_energy*mean/ep;
501 eval_ep[6] = tot_energy*mean/ep*
sqrt(sigma/mean*sigma/mean+trkMomentumRelError*trkMomentumRelError);
515 if ( eOverP > 0.025 &&
516 std::abs(ep-ecor) < 15.*
std::sqrt( momentumError*momentumError + sigmacor*sigmacor ) ) {
530 oldMomentum.y()*combinedMomentum/oldMomentum.t(),
531 oldMomentum.z()*combinedMomentum/oldMomentum.t(),
550 <<
"Original object pointer with key = " << pho.
originalObjectRef().
key() <<
" not found in cache!";
554 std::array<float, 31> eval;
559 eval[0] = sc->rawEnergy();
563 eval[2] = sc->etaWidth();
564 eval[3] = sc->phiWidth();
565 const int N_ECAL = sc->clustersEnd() - sc->clustersBegin();
570 eval[8] = theseed->eta()-sc->position().Eta();
577 float sipip=0, sieip=0, e2x5Max=0, e2x5Left=0, e2x5Right=0, e2x5Top=0, e2x5Bottom=0;
587 eval[14] = sieip/(sieie*sipip);
594 eval[21] = e2x5Max/pho.
e5x5();
595 eval[22] = e2x5Left/pho.
e5x5();
596 eval[23] = e2x5Right/pho.
e5x5();
597 eval[24] = e2x5Top/pho.
e5x5();
598 eval[25] = e2x5Bottom/pho.
e5x5();
600 bool iseb = pho.
isEB();
603 EBDetId ebseedid(theseed->seed());
605 eval[27] = ebseedid.ieta();
606 eval[28] = ebseedid.iphi();
608 EEDetId eeseedid(theseed->seed());
609 eval[26] = sc->preshowerEnergy()/sc->rawEnergy();
610 eval[27] = sc->preshowerEnergyPlane1()/sc->rawEnergy();
611 eval[28] = sc->preshowerEnergyPlane2()/sc->rawEnergy();
612 eval[29] = eeseedid.ix();
613 eval[30] = eeseedid.iy();
618 const double meanlimlow = 0.2;
619 const double meanlimhigh = 2.0;
620 const double meanoffset = meanlimlow + 0.5*(meanlimhigh-meanlimlow);
621 const double meanscale = 0.5*(meanlimhigh-meanlimlow);
623 const double sigmalimlow = 0.0002;
624 const double sigmalimhigh = 0.5;
625 const double sigmaoffset = sigmalimlow + 0.5*(sigmalimhigh-sigmalimlow);
626 const double sigmascale = 0.5*(sigmalimhigh-sigmalimlow);
636 double mean = meanoffset + meanscale*vdt::fast_sin(rawmean);
637 double sigma = sigmaoffset + sigmascale*vdt::fast_sin(rawsigma);
641 double ecor = mean*eval[0];
643 ecor = mean*(eval[0]+sc->preshowerEnergy());
645 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