31 #define LOGDRESSED(x) edm::LogInfo(x) 33 #define LOGDRESSED(x) LogDebug(x) 39 , eetopsSrc_ (consumes<
reco::PFCluster::EEtoPSAssociation>(
40 iConfig.getParameter<
edm::InputTag>(
"EEtoPS_source")))
42 , useVerticesForNeutral_ (iConfig.getParameter<
bool>(
"useVerticesForNeutral"))
43 , primaryVertex_ (
reco::Vertex())
44 , ebeeClustersCollection_(
"EBEEClusters")
45 , esClustersCollection_ (
"ESClusters")
51 iConfig.
getParameter<
bool>(
"produceEGCandsWithNoSuperCluster");
54 produces<reco::PFCandidateCollection>();
55 produces<reco::PFCandidateEGammaExtraCollection>();
56 produces<reco::SuperClusterCollection>();
59 produces<reco::ConversionCollection>();
67 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
85 <<
" in run "<<iEvent.
id().
run()<<std::endl;
89 auto egCandidates_ = std::make_unique<reco::PFCandidateCollection>();
90 auto egExtra_ = std::make_unique<reco::PFCandidateEGammaExtraCollection>();
91 auto sClusters_ = std::make_unique<reco::SuperClusterCollection>();
99 pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.
product());
103 pfeg_->setESChannelStatus(esChannelStatusHandle_.
product());
110 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
114 <<
"EGPFlow is starting..."<<std::endl;
117 assert(
blocks.isValid() &&
"edm::Handle to blocks was null!");
118 std::ostringstream
str;
121 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
125 std::list< reco::PFBlockRef > hcalBlockRefs;
126 std::list< reco::PFBlockRef > ecalBlockRefs;
127 std::list< reco::PFBlockRef > hoBlockRefs;
128 std::list< reco::PFBlockRef > otherBlockRefs;
130 for(
unsigned i=0;
i<
blocks->size(); ++
i ) {
139 <<
"Found " << elements.
size()
140 <<
" PFBlockElements in block: " <<
i << std::endl;
142 bool singleEcalOrHcal =
false;
143 if( elements.
size() == 1 ){
144 switch( elements[0].
type() ) {
147 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
151 ecalBlockRefs.push_back( blockref );
152 singleEcalOrHcal =
true;
158 hcalBlockRefs.push_back( blockref );
159 singleEcalOrHcal =
true;
163 hoBlockRefs.push_back( blockref );
164 singleEcalOrHcal =
true;
171 if(!singleEcalOrHcal) {
172 otherBlockRefs.push_back( blockref );
183 for(
const auto& blockref : otherBlockRefs ) {
186 const auto&
elements = blockref->elements();
190 pfeg_->buildAndRefineEGObjects(globalCache(),blockref);
192 if( !
pfeg_->getCandidates().empty() ) {
195 <<
" elements produced " 196 <<
pfeg_->getCandidates().size()
197 <<
" e-g candidates!" << std::endl;
200 const size_t egsize = egCandidates_->size();
201 egCandidates_->resize(egsize +
pfeg_->getCandidates().size());
202 reco::PFCandidateCollection::iterator eginsertfrom =
203 egCandidates_->begin() + egsize;
205 pfeg_->getCandidates().end(),
208 const size_t egxsize = egExtra_->size();
209 egExtra_->resize(egxsize +
pfeg_->getEGExtra().size());
210 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
211 egExtra_->begin() + egxsize;
213 pfeg_->getEGExtra().end(),
216 const size_t rscsize = sClusters_->size();
217 sClusters_->resize(rscsize +
pfeg_->getRefinedSCs().size());
218 reco::SuperClusterCollection::iterator rscinsertfrom =
219 sClusters_->begin() + rscsize;
221 pfeg_->getRefinedSCs().end(),
226 <<
"Running PFEGammaAlgo on all blocks produced = " 227 << egCandidates_->size() <<
" e-g candidates!" 237 for (
unsigned int i=0;
i < egCandidates_->size(); ++
i) {
250 auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
251 auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
253 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
254 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
256 for(
const auto&
sc : *sClusters_ ) {
258 if (!pfClusterMapEBEE.count(*pfclus)) {
260 caloClustersEBEE->push_back(caloclus);
261 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
265 <<
"Found an EB/EE pfcluster matched to more than one supercluster!" 270 if (!pfClusterMapES.count(*pfclus)) {
272 caloClustersES->push_back(caloclus);
273 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
277 <<
"Found an ES pfcluster matched to more than one supercluster!" 288 for(
auto&
sc : *sClusters_ ) {
297 sc.setClusters(clusters);
304 sc.setPreshowerClusters(psclusters);
309 auto singleLegConv_ = std::make_unique<reco::ConversionCollection>();
326 e(0, 0) = 0.0015 * 0.0015;
327 e(1, 1) = 0.0015 * 0.0015;
340 for(
auto const&
pv : primaryVertices) {
341 if(
pv.isValid() && !
pv.isFake()) {
356 for (
auto &extra : extras){
357 for (
const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
361 std::vector<reco::TrackRef> OneLegConvVector;
362 OneLegConvVector.push_back(tkrefmva.first);
363 std::vector< float > OneLegMvaVector;
364 OneLegMvaVector.push_back(tkrefmva.second);
365 std::vector<reco::CaloClusterPtr> dummymatchingBC;
369 std::vector<math::XYZPointF>trackPositionAtEcalVec;
370 std::vector<math::XYZPointF>innPointVec;
371 std::vector<math::XYZVectorF>trackPinVec;
372 std::vector<math::XYZVectorF>trackPoutVec;
374 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
377 innPointVec.push_back(innPoint);
380 trackPinVec.push_back(trackPin);
383 trackPoutVec.push_back( trackPout );
385 float DCA = trk.
d0() ;
386 float mvaval = tkrefmva.second;
389 trackPositionAtEcalVec,
399 oneLegConversions.push_back(singleLegConvCandidate);
402 extra.addSingleLegConversionRef(convref);
412 desc.
add<
bool> (
"useVerticesForNeutral",
true);
413 desc.
add<
bool> (
"produceEGCandsWithNoSuperCluster",
false)->setComment(
"Allow building of candidates with no input or output supercluster?");
414 desc.
add<
double>(
"pf_electron_mvaCut", -0.1);
415 desc.
add<
bool> (
"pf_electronID_crackCorrection",
false);
416 desc.
add<
double>(
"pf_conv_mvaCut", 0.0);
421 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/PfElectrons23Jan_BDT.weights.xml.gz"));
423 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/pfConversionAug0411_BDT.weights.xml.gz"));
424 descriptions.
add(
"particleFlowEGamma", desc);
const std::string esClustersCollection_
T getParameter(std::string const &) const
EventNumber_t event() const
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)
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
const bool useVerticesForNeutral_
void push_back(Ptr< T > const &iPtr)
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
void setPFVertexParameters(reco::VertexCollection const &primaryVertices)
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::vector< Variable::Flags > flags
std::vector< Vertex > VertexCollection
collection of Vertex objects
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const reco::Vertex * primaryVtx
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
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
void setPFEGParameters(PFEGammaAlgo::PFEGConfigInfo &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
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)
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const