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 ebeeClustersCollection_(
"EBEEClusters"),
48 esClustersCollection_(
"ESClusters") {
67 std::vector<double> calibPFSCEle_Fbrem_barrel;
68 std::vector<double> calibPFSCEle_Fbrem_endcap;
69 std::vector<double> calibPFSCEle_barrel;
70 std::vector<double> calibPFSCEle_endcap;
72 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
73 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
74 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
75 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
76 std::shared_ptr<PFSCEnergyCalibration>
77 thePFSCEnergyCalibration (
new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
78 calibPFSCEle_barrel,calibPFSCEle_endcap ));
83 iConfig.
getParameter<
bool>(
"produceEGCandsWithNoSuperCluster");
85 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_barrel");
87 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_endcap");
91 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_barrel");
93 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_endcap");
97 iConfig.
getParameter<
unsigned int>(
"nTrackIsoForEgammaSC");
101 produces<reco::PFCandidateCollection>();
102 produces<reco::PFCandidateEGammaExtraCollection>();
103 produces<reco::SuperClusterCollection>();
106 produces<reco::ConversionCollection>();
113 algo_config. mvaWeightFileEleID
117 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
142 iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
148 if(!useRegressionFromDB_) {
156 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
158 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
160 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
162 LogDebug(
"PFEGammaProducer")<<
"Will set regressions from binary files " <<std::endl;
248 <<
" in run "<<iEvent.
id().
run()<<std::endl;
259 pfeg_->setEEtoPSAssociation(eetops);
266 std::ostringstream err;
267 err<<
"Cannot find vertices for this event.Continuing Without them ";
278 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
283 std::ostringstream err;
284 err<<
"cannot find blocks: (tag index)"
292 <<
"EGPFlow is starting..."<<std::endl;
295 assert( blocks.isValid() &&
"edm::Handle to blocks was null!");
296 std::ostringstream str;
299 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
303 std::list< reco::PFBlockRef > hcalBlockRefs;
304 std::list< reco::PFBlockRef > ecalBlockRefs;
305 std::list< reco::PFBlockRef > hoBlockRefs;
306 std::list< reco::PFBlockRef > otherBlockRefs;
308 for(
unsigned i=0;
i<blocks->size(); ++
i ) {
317 <<
"Found " << elements.
size()
318 <<
" PFBlockElements in block: " <<
i << std::endl;
320 bool singleEcalOrHcal =
false;
321 if( elements.
size() == 1 ){
322 switch( elements[0].
type() ) {
325 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
329 ecalBlockRefs.push_back( blockref );
330 singleEcalOrHcal =
true;
335 hcalBlockRefs.push_back( blockref );
336 singleEcalOrHcal =
true;
340 hoBlockRefs.push_back( blockref );
341 singleEcalOrHcal =
true;
348 if(!singleEcalOrHcal) {
349 otherBlockRefs.push_back( blockref );
360 for(
const auto& blockref : otherBlockRefs ) {
363 const auto&
elements = blockref->elements();
370 pfeg_->RunPFEG(blockref,active);
372 if(
pfeg_->getCandidates().size() ) {
375 <<
" elements produced "
376 <<
pfeg_->getCandidates().size()
377 <<
" e-g candidates!" << std::endl;
382 reco::PFCandidateCollection::iterator eginsertfrom =
384 std::move(
pfeg_->getCandidates().begin(),
385 pfeg_->getCandidates().end(),
388 const size_t egxsize =
egExtra_->size();
390 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
392 std::move(
pfeg_->getEGExtra().begin(),
393 pfeg_->getEGExtra().end(),
398 reco::SuperClusterCollection::iterator rscinsertfrom =
400 std::move(
pfeg_->getRefinedSCs().begin(),
401 pfeg_->getRefinedSCs().end(),
406 <<
"Running PFEGammaAlgo on all blocks produced = "
433 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
434 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
438 if (!pfClusterMapEBEE.count(*pfclus)) {
440 caloClustersEBEE->push_back(caloclus);
441 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
445 <<
"Found an EB/EE pfcluster matched to more than one supercluster!"
450 if (!pfClusterMapES.count(*pfclus)) {
452 caloClustersES->push_back(caloclus);
453 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
457 <<
"Found an ES pfcluster matched to more than one supercluster!"
468 for(
auto& sc : *sClusters_ ) {
477 sc.setClusters(clusters);
484 sc.setPreshowerClusters(psclusters);
493 iEvent.
put(sClusters_);
508 std::string err =
"PFAlgo: cannot open weight file '";
511 throw std::invalid_argument( err );
517 e(0, 0) = 0.0015 * 0.0015;
518 e(1, 1) = 0.0015 * 0.0015;
525 FILE * filePhotonConvID = fopen(cfg.
mvaweightfile.c_str(),
"r");
526 if (filePhotonConvID) {
527 fclose(filePhotonConvID);
530 std::string err =
"PFAlgo: cannot open weight file '";
533 throw std::invalid_argument( err );
561 int nVtx=primaryVertices->size();
567 for (
unsigned short i=0 ;
i<primaryVertices->size();++
i)
569 if(primaryVertices->at(
i).isValid()&&(!primaryVertices->at(
i).isFake()))
584 for (
auto &extra : extras){
585 for (
const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
589 std::vector<reco::TrackRef> OneLegConvVector;
590 OneLegConvVector.push_back(tkrefmva.first);
591 std::vector< float > OneLegMvaVector;
592 OneLegMvaVector.push_back(tkrefmva.second);
593 std::vector<reco::CaloClusterPtr> dummymatchingBC;
597 std::vector<math::XYZPointF>trackPositionAtEcalVec;
598 std::vector<math::XYZPointF>innPointVec;
599 std::vector<math::XYZVectorF>trackPinVec;
600 std::vector<math::XYZVectorF>trackPoutVec;
602 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
605 innPointVec.push_back(innPoint);
608 trackPinVec.push_back(trackPin);
611 trackPoutVec.push_back( trackPout );
613 float DCA = trk.
d0() ;
614 float mvaval = tkrefmva.second;
617 trackPositionAtEcalVec,
627 oneLegConversions.push_back(singleLegConvCandidate);
630 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
const GBRForest * ReaderGCEndCapHighr9_
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
const GBRForest * ReaderEcalRes_
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
const GBRForest * ReaderGCEndCapLowr9_
double coneTrackIsoForEgammaSC
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
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_
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
const GBRForest * ReaderLCEE_
std::string mvaWeightFileEleID
bool useEGammaSupercluster
unsigned int nTrackIsoForEgammaSC
T const * product() const
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
const GBRForest * ReaderGC_
edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
Particle reconstructed by the particle flow algorithm.
const GBRForest * ReaderLCEB_
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
const GBRForest * ReaderGCBarrel_
PFEGammaProducer(const edm::ParameterSet &)
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
std::string mvaweightfile
virtual void produce(edm::Event &, const edm::EventSetup &) override
double sumEtEcalIsoForEgammaSC_barrel
bool useCalibrationsFromDB_
std::auto_ptr< reco::ConversionCollection > singleLegConv_
std::auto_ptr< reco::SuperClusterCollection > sClusters_