33 #define docast(x,y) dynamic_cast<x>(y)
34 #define LOGVERB(x) edm::LogVerbatim(x)
35 #define LOGWARN(x) edm::LogWarning(x)
36 #define LOGERR(x) edm::LogError(x)
37 #define LOGDRESSED(x) edm::LogInfo(x)
39 #define docast(x,y) reinterpret_cast<x>(y)
40 #define LOGVERB(x) LogTrace(x)
41 #define LOGWARN(x) edm::LogWarning(x)
42 #define LOGERR(x) edm::LogError(x)
43 #define LOGDRESSED(x) LogDebug(x)
47 typedef std::list< reco::PFBlockRef >::iterator
IBR;
52 primaryVertex_(
reco::Vertex()),
53 ebeeClustersCollection_(
"EBEEClusters"),
54 esClustersCollection_(
"ESClusters") {
78 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
79 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
80 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
81 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
83 calibPFSCEle_barrel,calibPFSCEle_endcap ) );
88 iConfig.
getParameter<
bool>(
"produceEGCandsWithNoSuperCluster");
90 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_barrel");
92 iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_endcap");
96 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_barrel");
98 iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_endcap");
100 iConfig.
getParameter<
double>(
"coneTrackIsoForEgammaSC");
102 iConfig.
getParameter<
unsigned int>(
"nTrackIsoForEgammaSC");
106 produces<reco::PFCandidateCollection>();
107 produces<reco::PFCandidateEGammaExtraCollection>();
108 produces<reco::SuperClusterCollection>();
111 produces<reco::ConversionCollection>();
118 algo_config. mvaWeightFileEleID
122 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
139 iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
145 if(!useRegressionFromDB_) {
153 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
155 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
157 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
159 LogDebug(
"PFEGammaProducer")<<
"Will set regressions from binary files " <<std::endl;
247 <<
" in run "<<iEvent.
id().
run()<<std::endl;
258 pfeg_->setEEtoPSAssociation(eetops);
263 pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.
product());
267 pfeg_->setESChannelStatus(esChannelStatusHandle_.
product());
274 std::ostringstream err;
275 err<<
"Cannot find vertices for this event.Continuing Without them ";
286 LOGDRESSED(
"PFEGammaProducer")<<
"getting blocks"<<std::endl;
291 std::ostringstream err;
292 err<<
"cannot find blocks: (tag index)"
300 <<
"EGPFlow is starting..."<<std::endl;
303 assert( blocks.isValid() &&
"edm::Handle to blocks was null!");
304 std::ostringstream str;
307 LOGDRESSED(
"PFEGammaProducer") <<str.str()<<std::endl;
311 std::list< reco::PFBlockRef > hcalBlockRefs;
312 std::list< reco::PFBlockRef > ecalBlockRefs;
313 std::list< reco::PFBlockRef > hoBlockRefs;
314 std::list< reco::PFBlockRef > otherBlockRefs;
316 for(
unsigned i=0;
i<blocks->size(); ++
i ) {
325 <<
"Found " << elements.
size()
326 <<
" PFBlockElements in block: " <<
i << std::endl;
328 bool singleEcalOrHcal =
false;
329 if( elements.
size() == 1 ){
330 switch( elements[0].
type() ) {
333 <<
"PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
337 ecalBlockRefs.push_back( blockref );
338 singleEcalOrHcal =
true;
343 hcalBlockRefs.push_back( blockref );
344 singleEcalOrHcal =
true;
348 hoBlockRefs.push_back( blockref );
349 singleEcalOrHcal =
true;
356 if(!singleEcalOrHcal) {
357 otherBlockRefs.push_back( blockref );
368 for(
const auto& blockref : otherBlockRefs ) {
371 const auto&
elements = blockref->elements();
378 pfeg_->RunPFEG(globalCache(),blockref,active);
380 if(
pfeg_->getCandidates().size() ) {
383 <<
" elements produced "
384 <<
pfeg_->getCandidates().size()
385 <<
" e-g candidates!" << std::endl;
390 reco::PFCandidateCollection::iterator eginsertfrom =
393 pfeg_->getCandidates().end(),
396 const size_t egxsize =
egExtra_->size();
398 reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
401 pfeg_->getEGExtra().end(),
406 reco::SuperClusterCollection::iterator rscinsertfrom =
409 pfeg_->getRefinedSCs().end(),
414 <<
"Running PFEGammaAlgo on all blocks produced = "
441 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapEBEE;
442 std::map<edm::Ptr<reco::CaloCluster>,
unsigned int> pfClusterMapES;
446 if (!pfClusterMapEBEE.count(*pfclus)) {
448 caloClustersEBEE->push_back(caloclus);
449 pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
453 <<
"Found an EB/EE pfcluster matched to more than one supercluster!"
458 if (!pfClusterMapES.count(*pfclus)) {
460 caloClustersES->push_back(caloclus);
461 pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
465 <<
"Found an ES pfcluster matched to more than one supercluster!"
476 for(
auto& sc : *sClusters_ ) {
485 sc.setClusters(clusters);
492 sc.setPreshowerClusters(psclusters);
501 iEvent.
put(sClusters_);
516 std::string err =
"PFAlgo: cannot open weight file '";
519 throw std::invalid_argument( err );
525 e(0, 0) = 0.0015 * 0.0015;
526 e(1, 1) = 0.0015 * 0.0015;
533 FILE * filePhotonConvID = fopen(cfg.
mvaweightfile.c_str(),
"r");
534 if (filePhotonConvID) {
535 fclose(filePhotonConvID);
538 std::string err =
"PFAlgo: cannot open weight file '";
541 throw std::invalid_argument( err );
569 int nVtx=primaryVertices->size();
575 for (
unsigned short i=0 ;
i<primaryVertices->size();++
i)
577 if(primaryVertices->at(
i).isValid()&&(!primaryVertices->at(
i).isFake()))
592 for (
auto &extra : extras){
593 for (
const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
597 std::vector<reco::TrackRef> OneLegConvVector;
598 OneLegConvVector.push_back(tkrefmva.first);
599 std::vector< float > OneLegMvaVector;
600 OneLegMvaVector.push_back(tkrefmva.second);
601 std::vector<reco::CaloClusterPtr> dummymatchingBC;
605 std::vector<math::XYZPointF>trackPositionAtEcalVec;
606 std::vector<math::XYZPointF>innPointVec;
607 std::vector<math::XYZVectorF>trackPinVec;
608 std::vector<math::XYZVectorF>trackPoutVec;
610 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
613 innPointVec.push_back(innPoint);
616 trackPinVec.push_back(trackPin);
619 trackPoutVec.push_back( trackPout );
621 float DCA = trk.
d0() ;
622 float mvaval = tkrefmva.second;
625 trackPositionAtEcalVec,
635 oneLegConversions.push_back(singleLegConvCandidate);
638 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
tuple calibPFSCEle_Fbrem_endcap
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_
tuple calibPFSCEle_barrel
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
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
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()
tuple calibPFSCEle_Fbrem_barrel
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
T const * product() const
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
const GBRForest * ReaderGC_
std::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration
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
tuple calibPFSCEle_endcap
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
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_