26 std::cout <<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
30 produces<GsfElectronCollection>();
31 produces<GsfElectronCoreCollection>();
40 electronToken_ = consumes<reco::GsfElectronCollection>(electronSrc_);
41 ebScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEB_);
42 eeScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEE_);
45 std::cout <<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
54 std::cout <<
"GEDElectronRecalibSuperClusterAssociator::produce" << std::endl;
58 auto pOutEle = std::make_unique<GsfElectronCollection>();
59 auto pOutEleCore = std::make_unique<GsfElectronCoreCollection>();
63 e.getByToken(ebScToken_, superClusterEBHandle);
67 std::cout <<
"EB scCollection->size()" << superClusterEBHandle->size() << std::endl;
72 e.getByToken(eeScToken_, superClusterEEHandle);
76 std::cout <<
"EE scCollection->size()" << superClusterEEHandle->size() << std::endl;
81 e.getByToken(electronToken_, eleHandle);
88 for (reco::GsfElectronCollection::const_iterator eleIt = eleHandle->begin(); eleIt != eleHandle->end(); eleIt++) {
89 float DeltaRMineleSCbarrel(0.15);
90 float DeltaRMineleSCendcap(0.15);
93 int iscRef = -1, iscRefendcap = -1;
96 if (eleIt->trackerDrivenSeed()) {
97 edm::LogError(
"trackerDriven") <<
"skipping trackerDriven electrons";
102 for (reco::SuperClusterCollection::const_iterator scIt = superClusterEBHandle->begin();
103 scIt != superClusterEBHandle->end();
105 double DeltaReleSC =
sqrt(
reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
107 if (DeltaReleSC < DeltaRMineleSCbarrel)
109 DeltaRMineleSCbarrel = DeltaReleSC;
110 nearestSCbarrel = &*scIt;
114 std::cout <<
"EB: " << scIt - superClusterEBHandle->begin() <<
" " << iSC <<
" " << iscRef <<
"\t"
115 << std::setprecision(4) << scIt->energy() <<
" " << scIt->eta() <<
" " << scIt->phi() <<
"\t--\t"
116 << eleIt->energy() <<
" " << eleIt->eta() <<
" " << eleIt->phi() <<
"\t" << DeltaRMineleSCbarrel
123 for (reco::SuperClusterCollection::const_iterator scIt = superClusterEEHandle->begin();
124 scIt != superClusterEEHandle->end();
127 std::cout <<
"EE: " << scIt - superClusterEEHandle->begin() <<
" " << iSC <<
" " << iscRef <<
"\t"
128 << std::setprecision(4) << scIt->energy() <<
" " << scIt->eta() <<
" " << scIt->phi() <<
"\t--\t "
129 << eleIt->energy() <<
" " << eleIt->eta() <<
" " << eleIt->phi() <<
"\t" << DeltaRMineleSCendcap
133 double DeltaReleSC =
sqrt(
reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
135 if (DeltaReleSC < DeltaRMineleSCendcap) {
136 DeltaRMineleSCendcap = DeltaReleSC;
137 nearestSCendcap = &*scIt;
144 if (eleIt->isEB() && DeltaRMineleSCbarrel > DeltaRMineleSCendcap) {
145 edm::LogError(
"ElectronRecalibAssociator") <<
"EB electron, but nearest SC is in EE";
150 if (eleIt->isEB() && nearestSCbarrel) {
151 pOutEleCore->push_back(*eleIt->core());
179 }
else if (!(eleIt->isEB()) && nearestSCendcap) {
180 pOutEleCore->push_back(*eleIt->core());
209 edm::LogError(
"Failed SC association") <<
"No SC to be associated to the electron";
214 std::cout <<
"Filled new electrons " << pOutEle->size() << std::endl;
215 std::cout <<
"Filled new electronsCore " << pOutEleCore->size() << std::endl;