28 #define docast(x,y) dynamic_cast<x>(y)
29 #define LOGVERB(x) edm::LogVerbatim(x)
30 #define LOGWARN(x) edm::LogWarning(x)
31 #define LOGERR(x) edm::LogError(x)
32 #define LOGDRESSED(x) edm::LogInfo(x)
34 #define docast(x,y) reinterpret_cast<x>(y)
35 #define LOGVERB(x) LogTrace(x)
36 #define LOGWARN(x) edm::LogWarning(x)
37 #define LOGERR(x) edm::LogError(x)
38 #define LOGDRESSED(x) LogDebug(x)
42 typedef std::list< reco::PFBlockRef >::iterator
IBR;
47 primaryVertex_(
reco::Vertex()),
48 ebeeClustersCollection_(
"EBEEClusters"),
49 esClustersCollection_(
"ESClusters") {
73 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
74 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
75 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
76 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
77 std::shared_ptr<PFSCEnergyCalibration>
78 thePFSCEnergyCalibration (
new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
79 calibPFSCEle_barrel,calibPFSCEle_endcap ));
84 iConfig.
getParameter<
bool>(
"produceEGCandsWithNoSuperCluster");
86 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_barrel");
88 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_endcap");
92 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_barrel");
94 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_endcap");
98 iConfig.
getParameter<
unsigned int>(
"nTrackIsoForEgammaSC");
102 produces<reco::PFCandidateCollection>();
103 produces<reco::PFCandidateEGammaExtraCollection>();
104 produces<reco::SuperClusterCollection>();
107 produces<reco::ConversionCollection>();
114 algo_config. mvaWeightFileEleID
118 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
135 iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
141 if(!useRegressionFromDB_) {
149 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
151 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
153 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
155 LogDebug(
"PFEGammaProducer")<<
"Will set regressions from binary files " <<std::endl;
243 <<
" in run "<<iEvent.
id().
run()<<std::endl;
254 pfeg_->setEEtoPSAssociation(eetops);
261 std::ostringstream err;
262 err<<
"Cannot find vertices for this event.Continuing Without them ";
273 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
278 std::ostringstream err;
279 err<<
"cannot find blocks: (tag index)"
287 <<
"EGPFlow is starting..."<<std::endl;
290 assert( blocks.isValid() &&
"edm::Handle to blocks was null!");
291 std::ostringstream str;
294 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
298 std::list< reco::PFBlockRef > hcalBlockRefs;
299 std::list< reco::PFBlockRef > ecalBlockRefs;
300 std::list< reco::PFBlockRef > hoBlockRefs;
301 std::list< reco::PFBlockRef > otherBlockRefs;
303 for(
unsigned i=0;
i<blocks->size(); ++
i ) {
312 <<
"Found " << elements.
size()
313 <<
" PFBlockElements in block: " <<
i << std::endl;
315 bool singleEcalOrHcal =
false;
316 if( elements.
size() == 1 ){
317 switch( elements[0].
type() ) {
320 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
324 ecalBlockRefs.push_back( blockref );
325 singleEcalOrHcal =
true;
330 hcalBlockRefs.push_back( blockref );
331 singleEcalOrHcal =
true;
335 hoBlockRefs.push_back( blockref );
336 singleEcalOrHcal =
true;
343 if(!singleEcalOrHcal) {
344 otherBlockRefs.push_back( blockref );
355 for(
const auto& blockref : otherBlockRefs ) {
358 const auto&
elements = blockref->elements();
365 pfeg_->RunPFEG(globalCache(),blockref,active);
367 if(
pfeg_->getCandidates().size() ) {
370 <<
" elements produced "
371 <<
pfeg_->getCandidates().size()
372 <<
" e-g candidates!" << std::endl;
377 reco::PFCandidateCollection::iterator eginsertfrom =
380 pfeg_->getCandidates().end(),
383 const size_t egxsize =
egExtra_->size();
385 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
388 pfeg_->getEGExtra().end(),
393 reco::SuperClusterCollection::iterator rscinsertfrom =
396 pfeg_->getRefinedSCs().end(),
401 <<
"Running PFEGammaAlgo on all blocks produced = "
428 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
429 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
433 if (!pfClusterMapEBEE.count(*pfclus)) {
435 caloClustersEBEE->push_back(caloclus);
436 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
440 <<
"Found an EB/EE pfcluster matched to more than one supercluster!"
445 if (!pfClusterMapES.count(*pfclus)) {
447 caloClustersES->push_back(caloclus);
448 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
452 <<
"Found an ES pfcluster matched to more than one supercluster!"
463 for(
auto& sc : *sClusters_ ) {
472 sc.setClusters(clusters);
479 sc.setPreshowerClusters(psclusters);
488 iEvent.
put(sClusters_);
503 std::string err =
"PFAlgo: cannot open weight file '";
506 throw std::invalid_argument( err );
512 e(0, 0) = 0.0015 * 0.0015;
513 e(1, 1) = 0.0015 * 0.0015;
520 FILE * filePhotonConvID = fopen(cfg.
mvaweightfile.c_str(),
"r");
521 if (filePhotonConvID) {
522 fclose(filePhotonConvID);
525 std::string err =
"PFAlgo: cannot open weight file '";
528 throw std::invalid_argument( err );
556 int nVtx=primaryVertices->size();
562 for (
unsigned short i=0 ;
i<primaryVertices->size();++
i)
564 if(primaryVertices->at(
i).isValid()&&(!primaryVertices->at(
i).isFake()))
579 for (
auto &extra : extras){
580 for (
const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
584 std::vector<reco::TrackRef> OneLegConvVector;
585 OneLegConvVector.push_back(tkrefmva.first);
586 std::vector< float > OneLegMvaVector;
587 OneLegMvaVector.push_back(tkrefmva.second);
588 std::vector<reco::CaloClusterPtr> dummymatchingBC;
592 std::vector<math::XYZPointF>trackPositionAtEcalVec;
593 std::vector<math::XYZPointF>innPointVec;
594 std::vector<math::XYZVectorF>trackPinVec;
595 std::vector<math::XYZVectorF>trackPoutVec;
597 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
600 innPointVec.push_back(innPoint);
603 trackPinVec.push_back(trackPin);
606 trackPoutVec.push_back( trackPout );
608 float DCA = trk.
d0() ;
609 float mvaval = tkrefmva.second;
612 trackPositionAtEcalVec,
622 oneLegConversions.push_back(singleLegConvCandidate);
625 extra.addSingleLegConversionRef(convref);
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void createSingleLegConversions(reco::PFCandidateEGammaExtraCollection &extras, reco::ConversionCollection &oneLegConversions, const edm::RefProd< reco::ConversionCollection > &convProd)
const GBRForest * ReaderRes_
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)
edm::EDGetTokenT< reco::VertexCollection > vertices_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void push_back(Ptr< T > const &iPtr)
bool useRegressionFromDB_
bool useVerticesForNeutral_
double sumPtTrackIsoForEgammaSC_endcap
unsigned int index() const
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::vector< Vertex > VertexCollection
collection of Vertex objects
double sumPtTrackIsoSlopeForPhoton
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
double sumEtEcalIsoForEgammaSC_endcap
double sumPtTrackIsoForEgammaSC_barrel
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
double coneTrackIsoForEgammaSC
tuple calibPFSCEle_barrel
const math::XYZPoint & innerPosition() const
position of the innermost hit
double sumPtTrackIsoForPhoton
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool produceEGCandsWithNoSuperCluster
tuple calibPFSCEle_Fbrem_endcap
void setPFVertexParameters(bool useVertex, const reco::VertexCollection *primaryVertices)
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
reco::Vertex primaryVertex_
std::auto_ptr< reco::PFCandidateEGammaExtraCollection > egExtra_
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
math::XYZPoint Point
point in the space
std::string ebeeClustersCollection_
tuple calibPFSCEle_endcap
std::string esClustersCollection_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
void setPFEGParameters(PFEGammaAlgo::PFEGConfigInfo &)
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
std::auto_ptr< reco::PFCandidateCollection > egCandidates_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
RefProd< PROD > getRefBeforePut()
const GBRForest * ReaderLC_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::list< reco::PFBlockRef >::iterator IBR
bool applyCrackCorrections
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
double coneEcalIsoForEgammaSC
T const * product() const
std::string mvaWeightFileEleID
bool useEGammaSupercluster
unsigned int nTrackIsoForEgammaSC
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
const GBRForest * ReaderGC_
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)
std::string mvaweightfile
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
virtual void produce(edm::Event &, const edm::EventSetup &) override
tuple calibPFSCEle_Fbrem_barrel
double sumEtEcalIsoForEgammaSC_barrel
bool useCalibrationsFromDB_
std::auto_ptr< reco::ConversionCollection > singleLegConv_
std::auto_ptr< reco::SuperClusterCollection > sClusters_