68 #define LOGDRESSED(x) edm::LogInfo(x)
70 #define LOGDRESSED(x) LogDebug(x)
75 eetopsSrc_(consumes<
reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<
edm::
InputTag>(
"EEtoPS_source"))),
77 pfCandidateCollectionPutToken_{produces<reco::PFCandidateCollection>()},
78 pfCandidateEGammaExtraCollectionPutToken_{produces<reco::PFCandidateEGammaExtraCollection>()},
79 superClusterCollectionPutToken_{produces<reco::SuperClusterCollection>()},
80 caloClusterCollectionEBEEPutToken_{produces<reco::CaloClusterCollection>(
"EBEEClusters")},
81 caloClusterCollectionESPutToken_{produces<reco::CaloClusterCollection>(
"ESClusters")},
82 conversionCollectionPutToken_{produces<reco::ConversionCollection>()},
84 .mvaEleCut = iConfig.getParameter<
double>(
"pf_electron_mvaCut"),
86 .produceEGCandsWithNoSuperCluster = iConfig.getParameter<
bool>(
"produceEGCandsWithNoSuperCluster"),
87 .mvaConvCut = iConfig.getParameter<
double>(
"pf_conv_mvaCut"),
94 LOGDRESSED(
"PFEGammaProducer") <<
"START event: " <<
iEvent.id().event() <<
" in run " <<
iEvent.id().run()
113 if (
pv.isValid() && !
pv.isFake()) {
122 *esEEInterCalibHandle_,
123 *esChannelStatusHandle_,
128 LOGDRESSED(
"PFEGammaProducer") <<
"getting blocks" << std::endl;
131 LOGDRESSED(
"PFEGammaProducer") <<
"EGPFlow is starting..." << std::endl;
134 assert(
blocks.isValid() &&
"edm::Handle to blocks was null!");
135 std::ostringstream
str;
142 std::list<reco::PFBlockRef> hcalBlockRefs;
143 std::list<reco::PFBlockRef> ecalBlockRefs;
144 std::list<reco::PFBlockRef> hoBlockRefs;
145 std::list<reco::PFBlockRef> otherBlockRefs;
147 for (
unsigned i = 0;
i <
blocks->size(); ++
i) {
152 LOGDRESSED(
"PFEGammaProducer") <<
"Found " <<
elements.size() <<
" PFBlockElements in block: " <<
i << std::endl;
154 bool singleEcalOrHcal =
false;
158 edm::LogError(
"PFEGammaProducer") <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
163 ecalBlockRefs.push_back(blockref);
164 singleEcalOrHcal =
true;
171 hcalBlockRefs.push_back(blockref);
172 singleEcalOrHcal =
true;
176 hoBlockRefs.push_back(blockref);
177 singleEcalOrHcal =
true;
184 if (!singleEcalOrHcal) {
185 otherBlockRefs.push_back(blockref);
196 for (
const auto& blockref : otherBlockRefs) {
199 const auto&
elements = blockref->elements();
203 auto output = pfEGammaAlgo(blockref);
205 if (!
output.candidates.empty()) {
206 LOGDRESSED(
"PFEGammaProducer") <<
"Block with " <<
elements.size() <<
" elements produced "
207 <<
output.candidates.size() <<
" e-g candidates!" << std::endl;
210 const size_t egsize = egCandidates.size();
211 egCandidates.resize(egsize +
output.candidates.size());
214 const size_t egxsize = egExtra.size();
215 egExtra.resize(egxsize +
output.candidateExtras.size());
218 const size_t rscsize = sClusters.size();
219 sClusters.resize(rscsize +
output.refinedSuperClusters.size());
220 std::move(
output.refinedSuperClusters.begin(),
output.refinedSuperClusters.end(), sClusters.begin() + rscsize);
223 LOGDRESSED(
"PFEGammaProducer") <<
"Running PFEGammaAlgo on all blocks produced = " << egCandidates.size()
224 <<
" e-g candidates!" << std::endl;
230 for (
unsigned int i = 0;
i < egCandidates.size(); ++
i) {
238 cand.setSuperClusterRef(refinedSCRef);
239 cand.setPFEGammaExtraRef(extraref);
246 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
247 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
249 for (
const auto& sc : sClusters) {
251 if (!pfClusterMapEBEE.count(*pfclus)) {
253 caloClustersEBEE.push_back(caloclus);
254 pfClusterMapEBEE[*pfclus] = caloClustersEBEE.size() - 1;
257 <<
"Found an EB/EE pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
262 if (!pfClusterMapES.count(*pfclus)) {
264 caloClustersES.push_back(caloclus);
265 pfClusterMapES[*pfclus] = caloClustersES.size() - 1;
268 <<
"Found an ES pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
278 for (
auto& sc : sClusters) {
295 sc.setPreshowerClusters(psclusters);
312 for (
auto& extra : extras) {
313 for (
const auto& tkrefmva : extra.singleLegConvTrackRefMva()) {
317 std::vector<reco::TrackRef> OneLegConvVector;
318 OneLegConvVector.push_back(tkrefmva.first);
319 std::vector<float> OneLegMvaVector;
320 OneLegMvaVector.push_back(tkrefmva.second);
321 std::vector<reco::CaloClusterPtr> dummymatchingBC;
325 std::vector<math::XYZPointF> trackPositionAtEcalVec;
326 std::vector<math::XYZPointF> innPointVec;
327 std::vector<math::XYZVectorF> trackPinVec;
328 std::vector<math::XYZVectorF> trackPoutVec;
330 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
333 innPointVec.push_back(innPoint);
336 trackPinVec.push_back(trackPin);
339 trackPoutVec.push_back(trackPout);
341 float DCA = trk.
d0();
342 float mvaval = tkrefmva.second;
345 trackPositionAtEcalVec,
355 oneLegConversions.push_back(singleLegConvCandidate);
358 extra.addSingleLegConversionRef(convref);
361 return oneLegConversions;
366 desc.
add<
bool>(
"produceEGCandsWithNoSuperCluster",
false)
367 ->setComment(
"Allow building of candidates with no input or output supercluster?");
368 desc.
add<
double>(
"pf_electron_mvaCut", -0.1);
369 desc.
add<
bool>(
"pf_electronID_crackCorrection",
false);
370 desc.
add<
double>(
"pf_conv_mvaCut", 0.0);
373 ->setComment(
"EE to PS association");
376 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/PfElectrons23Jan_BDT.weights.xml.gz"));
378 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/pfConversionAug0411_BDT.weights.xml.gz"));
379 descriptions.
add(
"particleFlowEGamma", desc);