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>();
96 pfeg_->setEEtoPSAssociation(eetops);
101 pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.
product());
105 pfeg_->setESChannelStatus(esChannelStatusHandle_.
product());
112 std::ostringstream err;
113 err<<
"Cannot find vertices for this event.Continuing Without them ";
124 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
129 std::ostringstream err;
130 err<<
"cannot find blocks: (tag index)" 138 <<
"EGPFlow is starting..."<<std::endl;
141 assert( blocks.isValid() &&
"edm::Handle to blocks was null!");
142 std::ostringstream
str;
145 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
149 std::list< reco::PFBlockRef > hcalBlockRefs;
150 std::list< reco::PFBlockRef > ecalBlockRefs;
151 std::list< reco::PFBlockRef > hoBlockRefs;
152 std::list< reco::PFBlockRef > otherBlockRefs;
154 for(
unsigned i=0;
i<blocks->size(); ++
i ) {
163 <<
"Found " << elements.
size()
164 <<
" PFBlockElements in block: " <<
i << std::endl;
166 bool singleEcalOrHcal =
false;
167 if( elements.
size() == 1 ){
168 switch( elements[0].
type() ) {
171 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
175 ecalBlockRefs.push_back( blockref );
176 singleEcalOrHcal =
true;
182 hcalBlockRefs.push_back( blockref );
183 singleEcalOrHcal =
true;
187 hoBlockRefs.push_back( blockref );
188 singleEcalOrHcal =
true;
195 if(!singleEcalOrHcal) {
196 otherBlockRefs.push_back( blockref );
207 for(
const auto& blockref : otherBlockRefs ) {
210 const auto&
elements = blockref->elements();
217 pfeg_->RunPFEG(globalCache(),blockref,active);
219 if( !
pfeg_->getCandidates().empty() ) {
222 <<
" elements produced " 223 <<
pfeg_->getCandidates().size()
224 <<
" e-g candidates!" << std::endl;
227 const size_t egsize = egCandidates_->size();
228 egCandidates_->resize(egsize +
pfeg_->getCandidates().size());
229 reco::PFCandidateCollection::iterator eginsertfrom =
230 egCandidates_->begin() + egsize;
232 pfeg_->getCandidates().end(),
235 const size_t egxsize = egExtra_->size();
236 egExtra_->resize(egxsize +
pfeg_->getEGExtra().size());
237 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
238 egExtra_->begin() + egxsize;
240 pfeg_->getEGExtra().end(),
243 const size_t rscsize = sClusters_->size();
244 sClusters_->resize(rscsize +
pfeg_->getRefinedSCs().size());
245 reco::SuperClusterCollection::iterator rscinsertfrom =
246 sClusters_->begin() + rscsize;
248 pfeg_->getRefinedSCs().end(),
253 <<
"Running PFEGammaAlgo on all blocks produced = " 254 << egCandidates_->size() <<
" e-g candidates!" 264 for (
unsigned int i=0;
i < egCandidates_->size(); ++
i) {
277 auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
278 auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
280 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
281 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
283 for(
const auto&
sc : *sClusters_ ) {
285 if (!pfClusterMapEBEE.count(*pfclus)) {
287 caloClustersEBEE->push_back(caloclus);
288 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
292 <<
"Found an EB/EE pfcluster matched to more than one supercluster!" 297 if (!pfClusterMapES.count(*pfclus)) {
299 caloClustersES->push_back(caloclus);
300 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
304 <<
"Found an ES pfcluster matched to more than one supercluster!" 315 for(
auto&
sc : *sClusters_ ) {
324 sc.setClusters(clusters);
331 sc.setPreshowerClusters(psclusters);
336 auto singleLegConv_ = std::make_unique<reco::ConversionCollection>();
353 e(0, 0) = 0.0015 * 0.0015;
354 e(1, 1) = 0.0015 * 0.0015;
367 for (
unsigned short i=0 ;
i<primaryVertices->size();++
i)
369 if(primaryVertices->at(
i).isValid()&&(!primaryVertices->at(
i).isFake()))
386 for (
auto &extra : extras){
387 for (
const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
391 std::vector<reco::TrackRef> OneLegConvVector;
392 OneLegConvVector.push_back(tkrefmva.first);
393 std::vector< float > OneLegMvaVector;
394 OneLegMvaVector.push_back(tkrefmva.second);
395 std::vector<reco::CaloClusterPtr> dummymatchingBC;
399 std::vector<math::XYZPointF>trackPositionAtEcalVec;
400 std::vector<math::XYZPointF>innPointVec;
401 std::vector<math::XYZVectorF>trackPinVec;
402 std::vector<math::XYZVectorF>trackPoutVec;
404 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
407 innPointVec.push_back(innPoint);
410 trackPinVec.push_back(trackPin);
413 trackPoutVec.push_back( trackPout );
415 float DCA = trk.
d0() ;
416 float mvaval = tkrefmva.second;
419 trackPositionAtEcalVec,
429 oneLegConversions.push_back(singleLegConvCandidate);
432 extra.addSingleLegConversionRef(convref);
442 desc.
add<
bool> (
"useVerticesForNeutral",
true);
443 desc.
add<
bool> (
"produceEGCandsWithNoSuperCluster",
false)->setComment(
"Allow building of candidates with no input or output supercluster?");
444 desc.
add<
double>(
"pf_electron_mvaCut", -0.1);
445 desc.
add<
bool> (
"pf_electronID_crackCorrection",
false);
446 desc.
add<
double>(
"pf_conv_mvaCut", 0.0);
451 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/PfElectrons23Jan_BDT.weights.xml.gz"));
453 edm::FileInPath(
"RecoParticleFlow/PFProducer/data/pfConversionAug0411_BDT.weights.xml.gz"));
454 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 setPFVertexParameters(const reco::VertexCollection *primaryVertices)
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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void push_back(Ptr< T > const &iPtr)
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
unsigned int index() const
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)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
bool produceEGCandsWithNoSuperCluster
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
reco::Vertex primaryVertex_
Variables for PFEGamma.
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
T const * product() 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)
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const