71 #define LOGDRESSED(x) edm::LogInfo(x)
73 #define LOGDRESSED(x) LogDebug(x)
78 eetopsSrc_(consumes<
reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<
edm::
InputTag>(
"EEtoPS_source"))),
80 pfCandidateCollectionPutToken_{produces<reco::PFCandidateCollection>()},
81 pfCandidateEGammaExtraCollectionPutToken_{produces<reco::PFCandidateEGammaExtraCollection>()},
82 superClusterCollectionPutToken_{produces<reco::SuperClusterCollection>()},
83 caloClusterCollectionEBEEPutToken_{produces<reco::CaloClusterCollection>(
"EBEEClusters")},
84 caloClusterCollectionESPutToken_{produces<reco::CaloClusterCollection>(
"ESClusters")},
85 conversionCollectionPutToken_{produces<reco::ConversionCollection>()},
87 .mvaEleCut = iConfig.getParameter<
double>(
"pf_electron_mvaCut"),
89 .produceEGCandsWithNoSuperCluster = iConfig.getParameter<
bool>(
"produceEGCandsWithNoSuperCluster"),
90 .mvaConvCut = iConfig.getParameter<
double>(
"pf_conv_mvaCut"),
99 LOGDRESSED(
"PFEGammaProducer") <<
"START event: " <<
iEvent.id().event() <<
" in run " <<
iEvent.id().run()
115 if (
pv.isValid() && !
pv.isFake()) {
124 *esEEInterCalibHandle_,
125 *esChannelStatusHandle_,
130 LOGDRESSED(
"PFEGammaProducer") <<
"getting blocks" << std::endl;
133 LOGDRESSED(
"PFEGammaProducer") <<
"EGPFlow is starting..." << std::endl;
136 assert(
blocks.isValid() &&
"edm::Handle to blocks was null!");
137 std::ostringstream
str;
144 std::list<reco::PFBlockRef> hcalBlockRefs;
145 std::list<reco::PFBlockRef> ecalBlockRefs;
146 std::list<reco::PFBlockRef> hoBlockRefs;
147 std::list<reco::PFBlockRef> otherBlockRefs;
149 for (
unsigned i = 0;
i <
blocks->size(); ++
i) {
154 LOGDRESSED(
"PFEGammaProducer") <<
"Found " <<
elements.size() <<
" PFBlockElements in block: " <<
i << std::endl;
156 bool singleEcalOrHcal =
false;
160 edm::LogError(
"PFEGammaProducer") <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
165 ecalBlockRefs.push_back(blockref);
166 singleEcalOrHcal =
true;
173 hcalBlockRefs.push_back(blockref);
174 singleEcalOrHcal =
true;
178 hoBlockRefs.push_back(blockref);
179 singleEcalOrHcal =
true;
186 if (!singleEcalOrHcal) {
187 otherBlockRefs.push_back(blockref);
198 for (
const auto& blockref : otherBlockRefs) {
201 const auto&
elements = blockref->elements();
205 auto output = pfEGammaAlgo(blockref);
207 if (!
output.candidates.empty()) {
208 LOGDRESSED(
"PFEGammaProducer") <<
"Block with " <<
elements.size() <<
" elements produced "
209 <<
output.candidates.size() <<
" e-g candidates!" << std::endl;
212 const size_t egsize = egCandidates.size();
213 egCandidates.resize(egsize +
output.candidates.size());
216 const size_t egxsize = egExtra.size();
217 egExtra.resize(egxsize +
output.candidateExtras.size());
220 const size_t rscsize = sClusters.size();
221 sClusters.resize(rscsize +
output.refinedSuperClusters.size());
222 std::move(
output.refinedSuperClusters.begin(),
output.refinedSuperClusters.end(), sClusters.begin() + rscsize);
225 LOGDRESSED(
"PFEGammaProducer") <<
"Running PFEGammaAlgo on all blocks produced = " << egCandidates.size()
226 <<
" e-g candidates!" << std::endl;
232 for (
unsigned int i = 0;
i < egCandidates.size(); ++
i) {
240 cand.setSuperClusterRef(refinedSCRef);
241 cand.setPFEGammaExtraRef(extraref);
248 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
249 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
251 for (
const auto& sc : sClusters) {
253 if (!pfClusterMapEBEE.count(*pfclus)) {
255 caloClustersEBEE.push_back(caloclus);
256 pfClusterMapEBEE[*pfclus] = caloClustersEBEE.size() - 1;
259 <<
"Found an EB/EE pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
264 if (!pfClusterMapES.count(*pfclus)) {
266 caloClustersES.push_back(caloclus);
267 pfClusterMapES[*pfclus] = caloClustersES.size() - 1;
270 <<
"Found an ES pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
280 for (
auto& sc : sClusters) {
297 sc.setPreshowerClusters(psclusters);
314 for (
auto& extra : extras) {
315 for (
const auto& tkrefmva : extra.singleLegConvTrackRefMva()) {
319 std::vector<reco::TrackRef> OneLegConvVector;
320 OneLegConvVector.push_back(tkrefmva.first);
321 std::vector<float> OneLegMvaVector;
322 OneLegMvaVector.push_back(tkrefmva.second);
323 std::vector<reco::CaloClusterPtr> dummymatchingBC;
327 std::vector<math::XYZPointF> trackPositionAtEcalVec;
328 std::vector<math::XYZPointF> innPointVec;
329 std::vector<math::XYZVectorF> trackPinVec;
330 std::vector<math::XYZVectorF> trackPoutVec;
332 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
335 innPointVec.push_back(innPoint);
338 trackPinVec.push_back(trackPin);
341 trackPoutVec.push_back(trackPout);
343 float DCA = trk.
d0();
344 float mvaval = tkrefmva.second;
347 trackPositionAtEcalVec,
357 oneLegConversions.push_back(singleLegConvCandidate);
360 extra.addSingleLegConversionRef(convref);
363 return oneLegConversions;
368 desc.add<
bool>(
"produceEGCandsWithNoSuperCluster",
false)
369 ->setComment(
"Allow building of candidates with no input or output supercluster?");
370 desc.add<
double>(
"pf_electron_mvaCut", -0.1);
371 desc.add<
bool>(
"pf_electronID_crackCorrection",
false);
372 desc.add<
double>(
"pf_conv_mvaCut", 0.0);
375 ->setComment(
"EE to PS association");
378 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/PfElectrons23Jan_BDT.weights.xml.gz"));
380 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/pfConversionAug0411_BDT.weights.xml.gz"));
381 descriptions.
add(
"particleFlowEGamma",
desc);