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;
46 primaryVertex_(
reco::Vertex()),
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>();
112 algo_config. mvaWeightFileEleID
116 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
141 iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
147 if(!useRegressionFromDB_) {
149 path_mvaWeightFileLCorr =
edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
151 path_mvaWeightFileGCorr =
edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
153 path_mvaWeightFileRes=
edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
155 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
157 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
159 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
161 LogDebug(
"PFEGammaProducer")<<
"Will set regressions from binary files " <<std::endl;
247 <<
" in run "<<iEvent.
id().
run()<<std::endl;
258 pfeg_->setEEtoPSAssociation(eetops);
265 std::ostringstream err;
266 err<<
"Cannot find vertices for this event.Continuing Without them ";
277 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
282 std::ostringstream err;
283 err<<
"cannot find blocks: (tag index)"
291 <<
"EGPFlow is starting..."<<std::endl;
294 assert( blocks.isValid() &&
"edm::Handle to blocks was null!");
295 std::ostringstream str;
298 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
302 std::list< reco::PFBlockRef > hcalBlockRefs;
303 std::list< reco::PFBlockRef > ecalBlockRefs;
304 std::list< reco::PFBlockRef > hoBlockRefs;
305 std::list< reco::PFBlockRef > otherBlockRefs;
307 for(
unsigned i=0;
i<blocks->size(); ++
i ) {
316 <<
"Found " << elements.
size()
317 <<
" PFBlockElements in block: " <<
i << std::endl;
319 bool singleEcalOrHcal =
false;
320 if( elements.
size() == 1 ){
321 switch( elements[0].
type() ) {
324 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
328 ecalBlockRefs.push_back( blockref );
329 singleEcalOrHcal =
true;
334 hcalBlockRefs.push_back( blockref );
335 singleEcalOrHcal =
true;
339 hoBlockRefs.push_back( blockref );
340 singleEcalOrHcal =
true;
347 if(!singleEcalOrHcal) {
348 otherBlockRefs.push_back( blockref );
359 for(
const auto& blockref : otherBlockRefs ) {
361 const auto&
elements = blockref->elements();
368 pfeg_->RunPFEG(blockref,active);
372 <<
" elements produced "
373 <<
pfeg_->getCandidates().size()
374 <<
" e-g candidates!" << std::endl;
378 reco::PFCandidateCollection::iterator eginsertfrom =
380 std::move(
pfeg_->getCandidates().begin(),
381 pfeg_->getCandidates().end(),
384 const size_t egxsize =
egExtra_->size();
386 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
388 std::move(
pfeg_->getEGExtra().begin(),
389 pfeg_->getEGExtra().end(),
394 reco::SuperClusterCollection::iterator rscinsertfrom =
396 std::move(
pfeg_->getRefinedSCs().begin(),
397 pfeg_->getRefinedSCs().end(),
402 <<
"Running PFEGammaAlgo on all blocks produced = "
412 size_t non_zero_sc_idx = 0;
423 if( rsc.
energy() != 0.0 ) {
437 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
438 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
442 if (!pfClusterMapEBEE.count(*pfclus)) {
444 caloClustersEBEE->push_back(caloclus);
445 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
449 <<
"Found an EB/EE pfcluster matched to more than one supercluster!"
450 << std::dec << std::endl;
454 if (!pfClusterMapES.count(*pfclus)) {
456 caloClustersES->push_back(caloclus);
457 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
461 <<
"Found an ES pfcluster matched to more than one supercluster!"
462 << std::dec << std::endl;
472 for(
auto& sc : *sClusters_ ) {
481 sc.setClusters(clusters);
488 sc.setPreshowerClusters(psclusters);
492 iEvent.
put(sClusters_);
506 std::string err =
"PFAlgo: cannot open weight file '";
509 throw std::invalid_argument( err );
515 e(0, 0) = 0.0015 * 0.0015;
516 e(1, 1) = 0.0015 * 0.0015;
523 FILE * filePhotonConvID = fopen(cfg.
mvaweightfile.c_str(),
"r");
524 if (filePhotonConvID) {
525 fclose(filePhotonConvID);
528 std::string err =
"PFAlgo: cannot open weight file '";
531 throw std::invalid_argument( err );
559 int nVtx=primaryVertices->size();
565 for (
unsigned short i=0 ;
i<primaryVertices->size();++
i)
567 if(primaryVertices->at(
i).isValid()&&(!primaryVertices->at(
i).isFake()))
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
const GBRForest * ReaderRes_
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
const GBRForest * ReaderGCEndCapHighr9_
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
const reco::Vertex * primaryVtx
double sumEtEcalIsoForEgammaSC_endcap
double sumPtTrackIsoForEgammaSC_barrel
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
const GBRForest * ReaderGCEndCapLowr9_
double coneTrackIsoForEgammaSC
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
double energy() const
cluster energy
std::string ebeeClustersCollection_
std::string esClustersCollection_
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
double coneEcalIsoForEgammaSC
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_
T const * product() const
edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
Particle reconstructed by the particle flow algorithm.
const GBRForest * ReaderLCEB_
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::SuperClusterCollection > sClusters_