85 std::unique_ptr<PFEGammaAlgo>
pfeg_;
95 #define LOGDRESSED(x) edm::LogInfo(x) 97 #define LOGDRESSED(x) LogDebug(x) 113 produces<reco::PFCandidateCollection>();
114 produces<reco::PFCandidateEGammaExtraCollection>();
115 produces<reco::SuperClusterCollection>();
118 produces<reco::ConversionCollection>();
131 e(0, 0) = 0.0015 * 0.0015;
132 e(1, 1) = 0.0015 * 0.0015;
137 pfeg_ = std::make_unique<PFEGammaAlgo>(algo_config, *gbrForests);
142 LOGDRESSED(
"PFEGammaProducer") <<
"START event: " << iEvent.
id().
event() <<
" in run " << iEvent.
id().
run()
146 auto egCandidates_ = std::make_unique<reco::PFCandidateCollection>();
147 auto egExtra_ = std::make_unique<reco::PFCandidateEGammaExtraCollection>();
148 auto sClusters_ = std::make_unique<reco::SuperClusterCollection>();
156 pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.
product());
160 pfeg_->setESChannelStatus(esChannelStatusHandle_.
product());
167 LOGDRESSED(
"PFEGammaProducer") <<
"getting blocks" << std::endl;
170 LOGDRESSED(
"PFEGammaProducer") <<
"EGPFlow is starting..." << std::endl;
173 assert(
blocks.isValid() &&
"edm::Handle to blocks was null!");
174 std::ostringstream
str;
177 LOGDRESSED(
"PFEGammaProducer") << str.str() << std::endl;
181 std::list<reco::PFBlockRef> hcalBlockRefs;
182 std::list<reco::PFBlockRef> ecalBlockRefs;
183 std::list<reco::PFBlockRef> hoBlockRefs;
184 std::list<reco::PFBlockRef> otherBlockRefs;
186 for (
unsigned i = 0;
i <
blocks->size(); ++
i) {
191 LOGDRESSED(
"PFEGammaProducer") <<
"Found " << elements.
size() <<
" PFBlockElements in block: " <<
i << std::endl;
193 bool singleEcalOrHcal =
false;
194 if (elements.
size() == 1) {
195 switch (elements[0].
type()) {
197 edm::LogError(
"PFEGammaProducer") <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
202 ecalBlockRefs.push_back(blockref);
203 singleEcalOrHcal =
true;
210 hcalBlockRefs.push_back(blockref);
211 singleEcalOrHcal =
true;
215 hoBlockRefs.push_back(blockref);
216 singleEcalOrHcal =
true;
223 if (!singleEcalOrHcal) {
224 otherBlockRefs.push_back(blockref);
235 for (
const auto& blockref : otherBlockRefs) {
238 const auto&
elements = blockref->elements();
242 auto output = (*pfeg_)(blockref);
244 if (!
output.candidates.empty()) {
245 LOGDRESSED(
"PFEGammaProducer") <<
"Block with " <<
elements.size() <<
" elements produced " 246 <<
output.candidates.size() <<
" e-g candidates!" << std::endl;
249 const size_t egsize = egCandidates_->size();
250 egCandidates_->resize(egsize +
output.candidates.size());
253 const size_t egxsize = egExtra_->size();
254 egExtra_->resize(egxsize +
output.candidateExtras.size());
255 std::move(
output.candidateExtras.begin(),
output.candidateExtras.end(), egExtra_->begin() + egxsize);
257 const size_t rscsize = sClusters_->size();
258 sClusters_->resize(rscsize +
output.refinedSuperClusters.size());
259 std::move(
output.refinedSuperClusters.begin(),
output.refinedSuperClusters.end(), sClusters_->begin() + rscsize);
262 LOGDRESSED(
"PFEGammaProducer") <<
"Running PFEGammaAlgo on all blocks produced = " << egCandidates_->size()
263 <<
" e-g candidates!" << std::endl;
271 for (
unsigned int i = 0;
i < egCandidates_->size(); ++
i) {
284 auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
285 auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
287 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
288 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
290 for (
const auto&
sc : *sClusters_) {
292 if (!pfClusterMapEBEE.count(*pfclus)) {
294 caloClustersEBEE->push_back(caloclus);
295 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
298 <<
"Found an EB/EE pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
303 if (!pfClusterMapES.count(*pfclus)) {
305 caloClustersES->push_back(caloclus);
306 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
309 <<
"Found an ES pfcluster matched to more than one supercluster!" <<
std::dec << std::endl;
319 for (
auto&
sc : *sClusters_) {
328 sc.setClusters(clusters);
336 sc.setPreshowerClusters(psclusters);
341 auto singleLegConv_ = std::make_unique<reco::ConversionCollection>();
353 for (
auto const&
pv : primaryVertices) {
354 if (
pv.isValid() && !
pv.isFake()) {
367 for (
auto& extra : extras) {
368 for (
const auto& tkrefmva : extra.singleLegConvTrackRefMva()) {
372 std::vector<reco::TrackRef> OneLegConvVector;
373 OneLegConvVector.push_back(tkrefmva.first);
374 std::vector<float> OneLegMvaVector;
375 OneLegMvaVector.push_back(tkrefmva.second);
376 std::vector<reco::CaloClusterPtr> dummymatchingBC;
380 std::vector<math::XYZPointF> trackPositionAtEcalVec;
381 std::vector<math::XYZPointF> innPointVec;
382 std::vector<math::XYZVectorF> trackPinVec;
383 std::vector<math::XYZVectorF> trackPoutVec;
385 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
388 innPointVec.push_back(innPoint);
391 trackPinVec.push_back(trackPin);
394 trackPoutVec.push_back(trackPout);
396 float DCA = trk.
d0();
397 float mvaval = tkrefmva.second;
400 trackPositionAtEcalVec,
410 oneLegConversions.push_back(singleLegConvCandidate);
413 extra.addSingleLegConversionRef(convref);
420 desc.
add<
bool>(
"useVerticesForNeutral",
true);
421 desc.
add<
bool>(
"produceEGCandsWithNoSuperCluster",
false)
422 ->setComment(
"Allow building of candidates with no input or output supercluster?");
423 desc.
add<
double>(
"pf_electron_mvaCut", -0.1);
424 desc.
add<
bool>(
"pf_electronID_crackCorrection",
false);
425 desc.
add<
double>(
"pf_conv_mvaCut", 0.0);
428 ->setComment(
"EE to PS association");
431 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/PfElectrons23Jan_BDT.weights.xml.gz"));
433 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/pfConversionAug0411_BDT.weights.xml.gz"));
434 descriptions.
add(
"particleFlowEGamma", desc);
const std::string esClustersCollection_
T getParameter(std::string const &) const
EventNumber_t event() const
static std::unique_ptr< PFEGammaAlgo::GBRForests > initializeGlobalCache(const edm::ParameterSet &conf)
const std::string ebeeClustersCollection_
void createSingleLegConversions(reco::PFCandidateEGammaExtraCollection &extras, reco::ConversionCollection &oneLegConversions, const edm::RefProd< reco::ConversionCollection > &convProd)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
PFEGammaProducer(const edm::ParameterSet &, const PFEGammaAlgo::GBRForests *)
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
const bool useVerticesForNeutral_
void push_back(Ptr< T > const &iPtr)
void setPFVertexParameters(reco::VertexCollection const &primaryVertices)
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::vector< Vertex > VertexCollection
collection of Vertex objects
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const math::XYZPoint & outerPosition() const
position of the outermost hit
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
const math::XYZPoint & innerPosition() const
position of the innermost hit
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
#define DEFINE_FWK_MODULE(type)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
bool produceEGCandsWithNoSuperCluster
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
reco::Vertex primaryVertex_
Variables for PFEGamma.
bool get(ProductID const &oid, Handle< PROD > &result) const
math::XYZPoint Point
point in the space
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
RefProd< PROD > getRefBeforePut()
const edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
bool applyCrackCorrections
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
static void globalEndJob(PFEGammaAlgo::GBRForests const *)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< PFEGammaAlgo > pfeg_
particle flow algorithm
const edm::EDGetTokenT< reco::VertexCollection > vertices_
const edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
Particle reconstructed by the particle flow algorithm.
void setOneLegMVA(const std::vector< float > &mva)
set the MVS output from PF for one leg conversions
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Producer for particle flow reconstructed particles (PFCandidates)
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const