17 std::cout <<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
21 produces<GsfElectronCollection>();
22 produces<GsfElectronCoreCollection>();
30 electronToken_ = consumes<reco::GsfElectronCollection>(electronSrc_);
31 ebScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEB_);
32 eeScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEE_);
35 std::cout <<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
44 std::cout <<
"GEDElectronRecalibSuperClusterAssociator::produce" << std::endl;
48 auto pOutEle = std::make_unique<GsfElectronCollection>();
49 auto pOutEleCore = std::make_unique<GsfElectronCoreCollection>();
53 e.
getByToken(ebScToken_, superClusterEBHandle);
56 std::cout <<
"EB scCollection->size()" << superClusterEBHandle->size() << std::endl;
61 e.
getByToken(eeScToken_, superClusterEEHandle);
64 std::cout <<
"EE scCollection->size()" << superClusterEEHandle->size() << std::endl;
74 for (reco::GsfElectronCollection::const_iterator eleIt = eleHandle->begin(); eleIt != eleHandle->end(); eleIt++) {
75 float DeltaRMineleSCbarrel(0.15);
76 float DeltaRMineleSCendcap(0.15);
79 int iscRef = -1, iscRefendcap = -1;
82 if (eleIt->trackerDrivenSeed()) {
83 edm::LogError(
"trackerDriven") <<
"skipping trackerDriven electrons";
88 for (reco::SuperClusterCollection::const_iterator scIt = superClusterEBHandle->begin();
89 scIt != superClusterEBHandle->end();
91 double DeltaReleSC =
sqrt(
reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
93 if (DeltaReleSC < DeltaRMineleSCbarrel)
95 DeltaRMineleSCbarrel = DeltaReleSC;
96 nearestSCbarrel = &*scIt;
100 std::cout <<
"EB: " << scIt - superClusterEBHandle->begin() <<
" " << iSC <<
" " << iscRef <<
"\t"
101 << std::setprecision(4) << scIt->energy() <<
" " << scIt->eta() <<
" " << scIt->phi() <<
"\t--\t"
102 << eleIt->energy() <<
" " << eleIt->eta() <<
" " << eleIt->phi() <<
"\t" << DeltaRMineleSCbarrel
109 for (reco::SuperClusterCollection::const_iterator scIt = superClusterEEHandle->begin();
110 scIt != superClusterEEHandle->end();
113 std::cout <<
"EE: " << scIt - superClusterEEHandle->begin() <<
" " << iSC <<
" " << iscRef <<
"\t"
114 << std::setprecision(4) << scIt->energy() <<
" " << scIt->eta() <<
" " << scIt->phi() <<
"\t--\t "
115 << eleIt->energy() <<
" " << eleIt->eta() <<
" " << eleIt->phi() <<
"\t" << DeltaRMineleSCendcap
119 double DeltaReleSC =
sqrt(
reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
121 if (DeltaReleSC < DeltaRMineleSCendcap) {
122 DeltaRMineleSCendcap = DeltaReleSC;
123 nearestSCendcap = &*scIt;
127 if (eleIt->isEB() && DeltaRMineleSCbarrel > DeltaRMineleSCendcap) {
128 edm::LogError(
"ElectronRecalibAssociator") <<
"EB electron, but nearest SC is in EE";
133 if (eleIt->isEB() && nearestSCbarrel) {
134 pOutEleCore->push_back(*eleIt->core());
161 }
else if (!(eleIt->isEB()) && nearestSCendcap) {
162 pOutEleCore->push_back(*eleIt->core());
190 edm::LogError(
"Failed SC association") <<
"No SC to be associated to the electron";
195 std::cout <<
"Filled new electrons " << pOutEle->size() << std::endl;
196 std::cout <<
"Filled new electronsCore " << pOutEleCore->size() << std::endl;
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Log< level::Error, false > LogError
ElectronRecalibSuperClusterAssociator(const edm::ParameterSet &conf)
~ElectronRecalibSuperClusterAssociator() override
void setSuperCluster(const SuperClusterRef &scl)
void setCorrectedEcalEnergyError(float newEnergyError)
void setParentSuperCluster(const SuperClusterRef &scl)
std::vector< GsfElectronCore > GsfElectronCoreCollection
RefProd< PROD > getRefBeforePut()
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
T getParameter(std::string const &) const
void setCorrectedEcalEnergy(float newEnergy)
void produce(edm::Event &e, const edm::EventSetup &c) override