CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PFEGammaProducer Class Reference

Producer for particle flow reconstructed particles (PFCandidates) More...

#include <PFEGammaProducer.h>

Inheritance diagram for PFEGammaProducer:
edm::stream::EDProducer< edm::GlobalCache< pfEGHelpers::HeavyObjectCache > >

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 PFEGammaProducer (const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PFEGammaProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< pfEGHelpers::HeavyObjectCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void globalEndJob (pfEGHelpers::HeavyObjectCache const *)
 
static std::unique_ptr< pfEGHelpers::HeavyObjectCacheinitializeGlobalCache (const edm::ParameterSet &conf)
 

Private Member Functions

void createSingleLegConversions (reco::PFCandidateEGammaExtraCollection &extras, reco::ConversionCollection &oneLegConversions, const edm::RefProd< reco::ConversionCollection > &convProd)
 
void setPFEGParameters (PFEGammaAlgo::PFEGConfigInfo &)
 
void setPFVertexParameters (bool useVertex, const reco::VertexCollection *primaryVertices)
 

Private Attributes

bool applyCrackCorrectionsElectrons_
 
double coneEcalIsoForEgammaSC_
 
double coneTrackIsoForEgammaSC_
 
std::string ebeeClustersCollection_
 
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociationeetopsSrc_
 
std::unique_ptr< reco::PFCandidateCollectionegCandidates_
 
std::unique_ptr< reco::PFCandidateEGammaExtraCollectionegExtra_
 
std::string esClustersCollection_
 
edm::EDGetTokenT< reco::PFBlockCollectioninputTagBlocks_
 
double mvaEleCut_
 
std::string mvaWeightFileEleID_
 Variables for PFEGamma. More...
 
unsigned int nTrackIsoForEgammaSC_
 
std::unique_ptr< PFEGammaAlgopfeg_
 the unfiltered electron collection More...
 
reco::Vertex primaryVertex_
 
const GBRForestReaderGC_
 
const GBRForestReaderLC_
 
const GBRForestReaderRes_
 
std::unique_ptr< reco::SuperClusterCollectionsClusters_
 
std::vector< double > setchi2Values_
 
std::unique_ptr< reco::ConversionCollectionsingleLegConv_
 
double sumEtEcalIsoForEgammaSC_barrel_
 
double sumEtEcalIsoForEgammaSC_endcap_
 
double sumPtTrackIsoForEgammaSC_barrel_
 
double sumPtTrackIsoForEgammaSC_endcap_
 
std::shared_ptr< PFSCEnergyCalibrationthePFSCEnergyCalibration_
 
bool useCalibrationsFromDB_
 
bool useEGammaElectrons_
 
bool useEGammaSupercluster_
 
bool useEGElectrons_
 
bool usePFElectrons_
 
bool usePFPhotons_
 
bool usePFSCEleCalib_
 
bool usePhotonReg_
 
bool useRegressionFromDB_
 
bool useVerticesForNeutral_
 
bool verbose_
 verbose ? More...
 
edm::EDGetTokenT< reco::VertexCollectionvertices_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< pfEGHelpers::HeavyObjectCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Producer for particle flow reconstructed particles (PFCandidates)

This producer makes use of PFAlgo, the particle flow algorithm.

Author
Colin Bernet
Date
July 2006

Definition at line 51 of file PFEGammaProducer.h.

Constructor & Destructor Documentation

PFEGammaProducer::PFEGammaProducer ( const edm::ParameterSet iConfig,
const pfEGHelpers::HeavyObjectCache  
)
explicit

Definition at line 50 of file PFEGammaProducer.cc.

References particleFlow_cfi::algoType, PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections, particleFlow_cfi::calibPFSCEle_barrel, particleFlow_cfi::calibPFSCEle_endcap, particleFlow_cfi::calibPFSCEle_Fbrem_barrel, particleFlow_cfi::calibPFSCEle_Fbrem_endcap, PFEGammaAlgo::PFEGConfigInfo::coneEcalIsoForEgammaSC, PFEGammaAlgo::PFEGConfigInfo::coneTrackIsoForEgammaSC, ebeeClustersCollection_, eetopsSrc_, esClustersCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), particleFlow_cfi::iCfgCandConnector, inputTagBlocks_, LogDebug, PFEGammaAlgo::PFEGConfigInfo::mvaConvCut, PFEGammaAlgo::PFEGConfigInfo::mvaEleCut, PFEGammaAlgo::PFEGConfigInfo::mvaweightfile, PFEGammaAlgo::PFEGConfigInfo::nTrackIsoForEgammaSC, PFEGammaAlgo::PFEGConfigInfo::produceEGCandsWithNoSuperCluster, ReaderGC_, ReaderLC_, ReaderRes_, setPFEGParameters(), AlCaHLTBitMon_QueryRunRegistry::string, PFEGammaAlgo::PFEGConfigInfo::sumEtEcalIsoForEgammaSC_barrel, PFEGammaAlgo::PFEGConfigInfo::sumEtEcalIsoForEgammaSC_endcap, PFEGammaAlgo::PFEGConfigInfo::sumPtTrackIsoForEgammaSC_barrel, PFEGammaAlgo::PFEGConfigInfo::sumPtTrackIsoForEgammaSC_endcap, PFEGammaAlgo::PFEGConfigInfo::sumPtTrackIsoForPhoton, PFEGammaAlgo::PFEGConfigInfo::sumPtTrackIsoSlopeForPhoton, PFEGammaAlgo::PFEGConfigInfo::thePFEnergyCalibration, PFEGammaAlgo::PFEGConfigInfo::thePFSCEnergyCalibration, useCalibrationsFromDB_, PFEGammaAlgo::PFEGConfigInfo::useEGammaSupercluster, PFEGammaAlgo::PFEGConfigInfo::usePFSCEleCalib, PFEGammaAlgo::PFEGConfigInfo::useReg, useRegressionFromDB_, useVerticesForNeutral_, verbose_, vertices_, and PFEGammaAlgo::PFEGConfigInfo::X0_Map.

51  :
53  ebeeClustersCollection_("EBEEClusters"),
54  esClustersCollection_("ESClusters") {
55 
56  PFEGammaAlgo::PFEGConfigInfo algo_config;
57 
59  = consumes<reco::PFBlockCollection>(iConfig.getParameter<edm::InputTag>("blocks"));
60 
61  eetopsSrc_ = consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<edm::InputTag>("EEtoPS_source"));
62 
63  algo_config.useReg
64  = iConfig.getParameter<bool>("usePhotonReg");
65 
67  = iConfig.getParameter<bool>("useVerticesForNeutral");
68 
70  = iConfig.getParameter<bool>("useRegressionFromDB");
71 
72 
73  std::vector<double> calibPFSCEle_Fbrem_barrel;
74  std::vector<double> calibPFSCEle_Fbrem_endcap;
75  std::vector<double> calibPFSCEle_barrel;
76  std::vector<double> calibPFSCEle_endcap;
77  algo_config.usePFSCEleCalib = iConfig.getParameter<bool>("usePFSCEleCalib");
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");
82  algo_config.thePFSCEnergyCalibration.reset( new PFSCEnergyCalibration( calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
84 
85  algo_config.useEGammaSupercluster =
86  iConfig.getParameter<bool>("useEGammaSupercluster");
87  algo_config.produceEGCandsWithNoSuperCluster =
88  iConfig.getParameter<bool>("produceEGCandsWithNoSuperCluster");
89  algo_config.sumEtEcalIsoForEgammaSC_barrel =
90  iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_barrel");
91  algo_config.sumEtEcalIsoForEgammaSC_endcap =
92  iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_endcap");
93  algo_config.coneEcalIsoForEgammaSC =
94  iConfig.getParameter<double>("coneEcalIsoForEgammaSC");
95  algo_config.sumPtTrackIsoForEgammaSC_barrel =
96  iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_barrel");
97  algo_config.sumPtTrackIsoForEgammaSC_endcap =
98  iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_endcap");
99  algo_config.coneTrackIsoForEgammaSC =
100  iConfig.getParameter<double>("coneTrackIsoForEgammaSC");
101  algo_config.nTrackIsoForEgammaSC =
102  iConfig.getParameter<unsigned int>("nTrackIsoForEgammaSC");
103 
104 
105  // register products
106  produces<reco::PFCandidateCollection>();
107  produces<reco::PFCandidateEGammaExtraCollection>();
108  produces<reco::SuperClusterCollection>();
109  produces<reco::CaloClusterCollection>(ebeeClustersCollection_);
110  produces<reco::CaloClusterCollection>(esClustersCollection_);
111  produces<reco::ConversionCollection>();
112 
113  //PFElectrons Configuration
114  algo_config.mvaEleCut
115  = iConfig.getParameter<double>("pf_electron_mvaCut");
116 
117 
118  algo_config. mvaWeightFileEleID
119  = iConfig.getParameter<edm::FileInPath>("pf_electronID_mvaWeightFile").fullPath();
120 
121  algo_config.applyCrackCorrections
122  = iConfig.getParameter<bool>("pf_electronID_crackCorrection");
123 
124  //PFPhoton Configuration
125 
126  std::string path_mvaWeightFileConvID;
127  std::string mvaWeightFileConvID;
128  std::string path_mvaWeightFileGCorr;
129  std::string path_mvaWeightFileLCorr;
130  std::string path_X0_Map;
131  std::string path_mvaWeightFileRes;
132 
133  algo_config.mvaweightfile =
134  iConfig.getParameter<edm::FileInPath>("pf_convID_mvaWeightFile").fullPath();
135  algo_config.mvaConvCut = iConfig.getParameter<double>("pf_conv_mvaCut");
136  algo_config.sumPtTrackIsoForPhoton =
137  iConfig.getParameter<double>("sumPtTrackIsoForPhoton");
138  algo_config.sumPtTrackIsoSlopeForPhoton =
139  iConfig.getParameter<double>("sumPtTrackIsoSlopeForPhoton");
140 
141  algo_config.X0_Map = iConfig.getParameter<std::string>("X0_Map");
142  algo_config.X0_Map =
143  edm::FileInPath( algo_config.X0_Map.c_str() ).fullPath();
144 
145  if(!useRegressionFromDB_) {
146  std::string mvaWeightFileLCorr=iConfig.getParameter<std::string>("pf_locC_mvaWeightFile");
147  path_mvaWeightFileLCorr = edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
148  std::string mvaWeightFileGCorr=iConfig.getParameter<std::string>("pf_GlobC_mvaWeightFile");
149  path_mvaWeightFileGCorr = edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
150  std::string mvaWeightFileRes=iConfig.getParameter<std::string>("pf_Res_mvaWeightFile");
151  path_mvaWeightFileRes=edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
152 
153  TFile *fgbr = new TFile(path_mvaWeightFileGCorr.c_str(),"READ");
154  ReaderGC_ =(const GBRForest*)fgbr->Get("GBRForest");
155  TFile *fgbr2 = new TFile(path_mvaWeightFileLCorr.c_str(),"READ");
156  ReaderLC_ = (const GBRForest*)fgbr2->Get("GBRForest");
157  TFile *fgbr3 = new TFile(path_mvaWeightFileRes.c_str(),"READ");
158  ReaderRes_ = (const GBRForest*)fgbr3->Get("GBRForest");
159  LogDebug("PFEGammaProducer")<<"Will set regressions from binary files " <<std::endl;
160  }
161 
163  = iConfig.getParameter<edm::ParameterSet>("iCfgCandConnector");
164 
165 
166  // fToRead = iConfig.getUntrackedParameter<std::vector<std::string> >("toRead");
167 
169  = iConfig.getParameter<bool>("useCalibrationsFromDB");
170 
171  algo_config.thePFEnergyCalibration.reset(new PFEnergyCalibration());
172 
173  int algoType
174  = iConfig.getParameter<unsigned>("algoType");
175 
176  switch(algoType) {
177  case 0:
178  //pfAlgo_.reset( new PFAlgo);
179  break;
180  default:
181  assert(0);
182  }
183 
184  //PFEGamma
185  setPFEGParameters(algo_config);
186 
187  //MIKE: Vertex Parameters
188  vertices_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"));
189 
190  verbose_ =
191  iConfig.getUntrackedParameter<bool>("verbose",false);
192 
193 // bool debug_ =
194 // iConfig.getUntrackedParameter<bool>("debug",false);
195 
196 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const GBRForest * ReaderRes_
edm::EDGetTokenT< reco::VertexCollection > vertices_
reco::Vertex primaryVertex_
std::string ebeeClustersCollection_
std::string esClustersCollection_
void setPFEGParameters(PFEGammaAlgo::PFEGConfigInfo &)
bool verbose_
verbose ?
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
const GBRForest * ReaderLC_
const GBRForest * ReaderGC_
edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
PFEGammaProducer::~PFEGammaProducer ( )
override

Definition at line 200 of file PFEGammaProducer.cc.

200 {}

Member Function Documentation

void PFEGammaProducer::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 203 of file PFEGammaProducer.cc.

Referenced by globalEndJob().

205 {
206 
207  /* // kept for historical reasons
208  if(useRegressionFromDB_) {
209 
210  edm::ESHandle<GBRForest> readerPFLCEB;
211  edm::ESHandle<GBRForest> readerPFLCEE;
212  edm::ESHandle<GBRForest> readerPFGCEB;
213  edm::ESHandle<GBRForest> readerPFGCEEHR9;
214  edm::ESHandle<GBRForest> readerPFGCEELR9;
215  edm::ESHandle<GBRForest> readerPFRes;
216  es.get<GBRWrapperRcd>().get("PFLCorrectionBar",readerPFLCEB);
217  ReaderLCEB_=readerPFLCEB.product();
218  es.get<GBRWrapperRcd>().get("PFLCorrectionEnd",readerPFLCEE);
219  ReaderLCEE_=readerPFLCEE.product();
220  es.get<GBRWrapperRcd>().get("PFGCorrectionBar",readerPFGCEB);
221  ReaderGCBarrel_=readerPFGCEB.product();
222  es.get<GBRWrapperRcd>().get("PFGCorrectionEndHighR9",readerPFGCEEHR9);
223  ReaderGCEndCapHighr9_=readerPFGCEEHR9.product();
224  es.get<GBRWrapperRcd>().get("PFGCorrectionEndLowR9",readerPFGCEELR9);
225  ReaderGCEndCapLowr9_=readerPFGCEELR9.product();
226  es.get<GBRWrapperRcd>().get("PFEcalResolution",readerPFRes);
227  ReaderEcalRes_=readerPFRes.product();
228 
229 
230  LogDebug("PFEGammaProducer")<<"setting regressions from DB "<<std::endl;
231 
232  }
233  */
234 
235  //pfAlgo_->setPFPhotonRegWeights(ReaderLC_, ReaderGC_, ReaderRes_);
236 
237 }
void PFEGammaProducer::createSingleLegConversions ( reco::PFCandidateEGammaExtraCollection extras,
reco::ConversionCollection oneLegConversions,
const edm::RefProd< reco::ConversionCollection > &  convProd 
)
private

Definition at line 590 of file PFEGammaProducer.cc.

References reco::TrackBase::d0(), relativeConstraints::error, reco::Track::innerMomentum(), reco::Track::innerPosition(), reco::Track::outerMomentum(), reco::Track::outerPosition(), reco::Conversion::pflow, edm::PtrVector< T >::push_back(), edm::refToPtr(), and reco::Conversion::setOneLegMVA().

Referenced by globalEndJob(), and produce().

590  {
591 
593  for (auto &extra : extras){
594  for (const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
595  const reco::Track &trk = *tkrefmva.first;
596 
597  const reco::Vertex convVtx(trk.innerPosition(), error);
598  std::vector<reco::TrackRef> OneLegConvVector;
599  OneLegConvVector.push_back(tkrefmva.first);
600  std::vector< float > OneLegMvaVector;
601  OneLegMvaVector.push_back(tkrefmva.second);
602  std::vector<reco::CaloClusterPtr> dummymatchingBC;
604  scPtrVec.push_back(edm::refToPtr(extra.superClusterRef()));
605 
606  std::vector<math::XYZPointF>trackPositionAtEcalVec;
607  std::vector<math::XYZPointF>innPointVec;
608  std::vector<math::XYZVectorF>trackPinVec;
609  std::vector<math::XYZVectorF>trackPoutVec;
610  math::XYZPointF trackPositionAtEcal(trk.outerPosition().X(), trk.outerPosition().Y(), trk.outerPosition().Z());
611  trackPositionAtEcalVec.push_back(trackPositionAtEcal);
612 
613  math::XYZPointF innPoint(trk.innerPosition().X(), trk.innerPosition().Y(), trk.innerPosition().Z());
614  innPointVec.push_back(innPoint);
615 
616  math::XYZVectorF trackPin(trk.innerMomentum().X(), trk.innerMomentum().Y(), trk.innerMomentum().Z());
617  trackPinVec.push_back(trackPin);
618 
619  math::XYZVectorF trackPout(trk.outerMomentum().X(), trk.outerMomentum().Y(), trk.outerMomentum().Z());
620  trackPoutVec.push_back( trackPout );
621 
622  float DCA = trk.d0() ;
623  float mvaval = tkrefmva.second;
624  reco::Conversion singleLegConvCandidate(scPtrVec,
625  OneLegConvVector,
626  trackPositionAtEcalVec,
627  convVtx,
628  dummymatchingBC,
629  DCA,
630  innPointVec,
631  trackPinVec,
632  trackPoutVec,
633  mvaval,
635  singleLegConvCandidate.setOneLegMVA(OneLegMvaVector);
636  oneLegConversions.push_back(singleLegConvCandidate);
637 
638  reco::ConversionRef convref(convProd,oneLegConversions.size()-1);
639  extra.addSingleLegConversionRef(convref);
640 
641  }
642 
643  }
644 
645 }
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:597
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
ErrorD< N >::type type
Definition: Error.h:33
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
static void PFEGammaProducer::globalEndJob ( pfEGHelpers::HeavyObjectCache const *  )
inlinestatic
static std::unique_ptr<pfEGHelpers::HeavyObjectCache> PFEGammaProducer::initializeGlobalCache ( const edm::ParameterSet conf)
inlinestatic

Definition at line 57 of file PFEGammaProducer.h.

57  {
58  return std::unique_ptr<pfEGHelpers::HeavyObjectCache>(new pfEGHelpers::HeavyObjectCache(conf));
59  }
void PFEGammaProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 241 of file PFEGammaProducer.cc.

References reco::CaloCluster::badHcalMarker, gather_cfg::blocks, fastPrimaryVertexProducer_cfi::clusters, createSingleLegConversions(), TauDecayModes::dec, ebeeClustersCollection_, reco::PFBlockElement::ECAL, eetopsSrc_, egCandidates_, egExtra_, allElectronIsolations_cfi::elements, esClustersCollection_, edm::EventID::event(), Exception, flags, runEdmFileComparison::found, edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), reco::PFBlockElement::HCAL, reco::PFBlockElement::HFEM, reco::PFBlockElement::HFHAD, reco::PFBlockElement::HO, mps_fire::i, edm::EventBase::id(), edm::EDGetTokenT< T >::index(), inputTagBlocks_, LOGDRESSED, eostools::move(), pfeg_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::PtrVector< T >::push_back(), edm::Event::put(), edm::EventID::run(), SimDataFormats::CaloAnalysis::sc, reco::PFBlockElement::SC, sClusters_, reco::PFCandidate::setPFEGammaExtraRef(), setPFVertexParameters(), reco::PFCandidateEGammaExtra::setSuperClusterRef(), reco::PFCandidate::setSuperClusterRef(), singleLegConv_, edm::OwnVector< T, P >::size(), str, funct::true, useVerticesForNeutral_, electrons_cff::vertices, and vertices_.

Referenced by globalEndJob().

242  {
243 
244  LOGDRESSED("PFEGammaProducer")
245  <<"START event: "
246  <<iEvent.id().event()
247  <<" in run "<<iEvent.id().run()<<std::endl;
248 
249 
250  // reset output collection
251  egCandidates_ = std::make_unique<reco::PFCandidateCollection>();
252  egExtra_ = std::make_unique<reco::PFCandidateEGammaExtraCollection>();
253  sClusters_ = std::make_unique<reco::SuperClusterCollection>();
254 
255  // Get the EE-PS associations
257  iEvent.getByToken(eetopsSrc_,eetops);
258  pfeg_->setEEtoPSAssociation(eetops);
259 
260  // preshower conditions
261  edm::ESHandle<ESEEIntercalibConstants> esEEInterCalibHandle_;
262  iSetup.get<ESEEIntercalibConstantsRcd>().get(esEEInterCalibHandle_);
263  pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.product());
264 
265  edm::ESHandle<ESChannelStatus> esChannelStatusHandle_;
266  iSetup.get<ESChannelStatusRcd>().get(esChannelStatusHandle_);
267  pfeg_->setESChannelStatus(esChannelStatusHandle_.product());
268 
269  // Get The vertices from the event
270  // and assign dynamic vertex parameters
272  bool gotVertices = iEvent.getByToken(vertices_,vertices);
273  if(!gotVertices) {
274  std::ostringstream err;
275  err<<"Cannot find vertices for this event.Continuing Without them ";
276  edm::LogError("PFEGammaProducer")<<err.str()<<std::endl;
277  }
278 
279  //Assign the PFAlgo Parameters
281 
282  // get the collection of blocks
283 
285 
286  LOGDRESSED("PFEGammaProducer")<<"getting blocks"<<std::endl;
287  bool found = iEvent.getByToken( inputTagBlocks_, blocks );
288 
289  if(!found ) {
290 
291  std::ostringstream err;
292  err<<"cannot find blocks: (tag index)"
293  << std::hex<< inputTagBlocks_.index() << std::dec;
294  edm::LogError("PFEGammaProducer")<<err.str()<<std::endl;
295 
296  throw cms::Exception( "MissingProduct", err.str());
297  }
298 
299  LOGDRESSED("PFEGammaProducer")
300  <<"EGPFlow is starting..."<<std::endl;
301 
302 #ifdef PFLOW_DEBUG
303  assert( blocks.isValid() && "edm::Handle to blocks was null!");
304  std::ostringstream str;
305  //str<<(*pfAlgo_)<<std::endl;
306  // cout << (*pfAlgo_) << std::endl;
307  LOGDRESSED("PFEGammaProducer") <<str.str()<<std::endl;
308 #endif
309 
310  // sort elements in three lists:
311  std::list< reco::PFBlockRef > hcalBlockRefs;
312  std::list< reco::PFBlockRef > ecalBlockRefs;
313  std::list< reco::PFBlockRef > hoBlockRefs;
314  std::list< reco::PFBlockRef > otherBlockRefs;
315 
316  for( unsigned i=0; i<blocks->size(); ++i ) {
317  // reco::PFBlockRef blockref( blockh,i );
318  //reco::PFBlockRef blockref = createBlockRef( *blocks, i);
319  reco::PFBlockRef blockref(blocks, i);
320 
322  elements = blockref->elements();
323 
324  LOGDRESSED("PFEGammaProducer")
325  << "Found " << elements.size()
326  << " PFBlockElements in block: " << i << std::endl;
327 
328  bool singleEcalOrHcal = false;
329  if( elements.size() == 1 ){
330  switch( elements[0].type() ) {
332  edm::LogError("PFEGammaProducer")
333  << "PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
337  ecalBlockRefs.push_back( blockref );
338  singleEcalOrHcal = true;
339  break;
343  if (elements[0].clusterRef()->flags() & reco::CaloCluster::badHcalMarker) continue;
344  hcalBlockRefs.push_back( blockref );
345  singleEcalOrHcal = true;
346  break;
348  // Single HO elements are likely to be noise. Not considered for now.
349  hoBlockRefs.push_back( blockref );
350  singleEcalOrHcal = true;
351  break;
352  default:
353  break;
354  }
355  }
356 
357  if(!singleEcalOrHcal) {
358  otherBlockRefs.push_back( blockref );
359  }
360  }//loop blocks
361 
362  // loop on blocks that are not single ecal, single ps1, single ps2 , or
363  // single hcal and produce unbiased collection of EGamma Candidates
364 
365  //printf("loop over blocks\n");
366  unsigned nblcks = 0;
367 
368  // this auto is a const reco::PFBlockRef&
369  for( const auto& blockref : otherBlockRefs ) {
370  ++nblcks;
371  // this auto is a: const edm::OwnVector< reco::PFBlockElement >&
372  const auto& elements = blockref->elements();
373  // make a copy of the link data, which will be edited.
374  //PFBlock::LinkData linkData = block.linkData();
375 
376  // keep track of the elements which are still active.
377  std::vector<bool> active( elements.size(), true );
378 
379  pfeg_->RunPFEG(globalCache(),blockref,active);
380 
381  if( !pfeg_->getCandidates().empty() ) {
382  LOGDRESSED("PFEGammaProducer")
383  << "Block with " << elements.size()
384  << " elements produced "
385  << pfeg_->getCandidates().size()
386  << " e-g candidates!" << std::endl;
387  }
388 
389  const size_t egsize = egCandidates_->size();
390  egCandidates_->resize(egsize + pfeg_->getCandidates().size());
391  reco::PFCandidateCollection::iterator eginsertfrom =
392  egCandidates_->begin() + egsize;
393  std::move(pfeg_->getCandidates().begin(),
394  pfeg_->getCandidates().end(),
395  eginsertfrom);
396 
397  const size_t egxsize = egExtra_->size();
398  egExtra_->resize(egxsize + pfeg_->getEGExtra().size());
399  reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
400  egExtra_->begin() + egxsize;
401  std::move(pfeg_->getEGExtra().begin(),
402  pfeg_->getEGExtra().end(),
403  egxinsertfrom);
404 
405  const size_t rscsize = sClusters_->size();
406  sClusters_->resize(rscsize + pfeg_->getRefinedSCs().size());
407  reco::SuperClusterCollection::iterator rscinsertfrom =
408  sClusters_->begin() + rscsize;
409  std::move(pfeg_->getRefinedSCs().begin(),
410  pfeg_->getRefinedSCs().end(),
411  rscinsertfrom);
412  }
413 
414  LOGDRESSED("PFEGammaProducer")
415  << "Running PFEGammaAlgo on all blocks produced = "
416  << egCandidates_->size() << " e-g candidates!"
417  << std::endl;
418 
421 
424 
425  //set the correct references to refined SC and EG extra using the refprods
426  for (unsigned int i=0; i < egCandidates_->size(); ++i) {
428  reco::PFCandidateEGammaExtra &xtra = egExtra_->at(i);
429 
430  reco::PFCandidateEGammaExtraRef extraref(egXtraProd,i);
431  reco::SuperClusterRef refinedSCRef(sClusterProd,i);
432 
433  xtra.setSuperClusterRef(refinedSCRef);
434  cand.setSuperClusterRef(refinedSCRef);
435  cand.setPFEGammaExtraRef(extraref);
436  }
437 
438  //build collections of output CaloClusters from the used PFClusters
439  auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
440  auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
441 
442  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapEBEE; //maps of pfclusters to caloclusters
443  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapES;
444 
445  for( const auto& sc : *sClusters_ ) {
446  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
447  if (!pfClusterMapEBEE.count(*pfclus)) {
448  reco::CaloCluster caloclus(**pfclus);
449  caloClustersEBEE->push_back(caloclus);
450  pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
451  }
452  else {
453  throw cms::Exception("PFEgammaProducer::produce")
454  << "Found an EB/EE pfcluster matched to more than one supercluster!"
455  << std::dec << std::endl;
456  }
457  }
458  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
459  if (!pfClusterMapES.count(*pfclus)) {
460  reco::CaloCluster caloclus(**pfclus);
461  caloClustersES->push_back(caloclus);
462  pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
463  }
464  else {
465  throw cms::Exception("PFEgammaProducer::produce")
466  << "Found an ES pfcluster matched to more than one supercluster!"
467  << std::dec << std::endl;
468  }
469  }
470  }
471 
472  //put calocluster output collections in event and get orphan handles to create ptrs
473  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEBEE = iEvent.put(std::move(caloClustersEBEE),ebeeClustersCollection_);
474  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleES = iEvent.put(std::move(caloClustersES),esClustersCollection_);
475 
476  //relink superclusters to output caloclusters
477  for( auto& sc : *sClusters_ ) {
478  edm::Ptr<reco::CaloCluster> seedptr(caloClusHandleEBEE,pfClusterMapEBEE[sc.seed()]);
479  sc.setSeed(seedptr);
480 
482  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
483  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleEBEE,pfClusterMapEBEE[*pfclus]);
484  clusters.push_back(clusptr);
485  }
486  sc.setClusters(clusters);
487 
488  reco::CaloClusterPtrVector psclusters;
489  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
490  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleES,pfClusterMapES[*pfclus]);
491  psclusters.push_back(clusptr);
492  }
493  sc.setPreshowerClusters(psclusters);
494  }
495 
496  //create and fill references to single leg conversions
498  singleLegConv_ = std::make_unique<reco::ConversionCollection>();
499  createSingleLegConversions(*egExtra_, *singleLegConv_, convProd);
500 
501  // release our demonspawn into the wild to cause havoc
502  iEvent.put(std::move(sClusters_));
503  iEvent.put(std::move(egExtra_));
504  iEvent.put(std::move(singleLegConv_));
505  iEvent.put(std::move(egCandidates_));
506 }
RunNumber_t run() const
Definition: EventID.h:39
type
Definition: HCALResponse.h:21
EventNumber_t event() const
Definition: EventID.h:41
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.
Definition: Event.h:137
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
std::unique_ptr< reco::PFCandidateEGammaExtraCollection > egExtra_
edm::EDGetTokenT< reco::VertexCollection > vertices_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
unsigned int index() const
Definition: EDGetToken.h:72
size_type size() const
Definition: OwnVector.h:264
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void setPFVertexParameters(bool useVertex, const reco::VertexCollection *primaryVertices)
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
std::string ebeeClustersCollection_
std::unique_ptr< reco::PFCandidateCollection > egCandidates_
std::unique_ptr< reco::ConversionCollection > singleLegConv_
std::string esClustersCollection_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:167
T const * product() const
Definition: Handle.h:81
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
edm::EventID id() const
Definition: EventBase.h:60
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
#define LOGDRESSED(x)
T get() const
Definition: EventSetup.h:63
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:650
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:629
#define str(s)
std::unique_ptr< reco::SuperClusterCollection > sClusters_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
void PFEGammaProducer::setPFEGParameters ( PFEGammaAlgo::PFEGConfigInfo cfg)
private

Definition at line 510 of file PFEGammaProducer.cc.

References MillePedeFileConverter_cfg::e, PFEGammaAlgo::PFEGConfigInfo::mvaweightfile, PFEGammaAlgo::PFEGConfigInfo::mvaWeightFileEleID, AlCaHLTBitMon_ParallelJobs::p, pfeg_, primaryVertex_, PFEGammaAlgo::PFEGConfigInfo::primaryVtx, AlCaHLTBitMon_QueryRunRegistry::string, and useVerticesForNeutral_.

Referenced by globalEndJob(), and PFEGammaProducer().

510  {
511 
512  FILE * fileEleID = fopen(cfg.mvaWeightFileEleID.c_str(), "r");
513  if (fileEleID) {
514  fclose(fileEleID);
515  }
516  else {
517  std::string err = "PFAlgo: cannot open weight file '";
518  err += cfg.mvaWeightFileEleID;
519  err += "'";
520  throw std::invalid_argument( err );
521  }
522 
523  //for MVA pass PV if there is one in the collection otherwise pass a dummy
524  if(!useVerticesForNeutral_) { // create a dummy PV
526  e(0, 0) = 0.0015 * 0.0015;
527  e(1, 1) = 0.0015 * 0.0015;
528  e(2, 2) = 15. * 15.;
529  reco::Vertex::Point p(0, 0, 0);
530  primaryVertex_ = reco::Vertex(p, e, 0, 0, 0);
531  }
532  // pv=&dummy;
533  //if(! usePFPhotons_) return;
534  FILE * filePhotonConvID = fopen(cfg.mvaweightfile.c_str(), "r");
535  if (filePhotonConvID) {
536  fclose(filePhotonConvID);
537  }
538  else {
539  std::string err = "PFAlgo: cannot open weight file '";
540  err += cfg.mvaweightfile;
541  err += "'";
542  throw std::invalid_argument( err );
543  }
544  cfg.primaryVtx = &primaryVertex_;
545  pfeg_.reset(new PFEGammaAlgo(cfg));
546 }
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:131
reco::Vertex primaryVertex_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
void PFEGammaProducer::setPFVertexParameters ( bool  useVertex,
const reco::VertexCollection primaryVertices 
)
private

Definition at line 560 of file PFEGammaProducer.cc.

References mps_fire::i, pfeg_, primaryVertex_, VerticesFromLeptons_cfi::useVertex, and useVerticesForNeutral_.

Referenced by globalEndJob(), and produce().

561  {
563 
564  //Set the vertices for muon cleaning
565 // pfmu_->setInputsForCleaning(primaryVertices);
566 
567 
568  //Now find the primary vertex!
569  //bool primaryVertexFound = false;
570  int nVtx=primaryVertices->size();
571  pfeg_->setnPU(nVtx);
572 // if(usePFPhotons_){
573 // pfpho_->setnPU(nVtx);
574 // }
575  primaryVertex_ = primaryVertices->front();
576  for (unsigned short i=0 ;i<primaryVertices->size();++i)
577  {
578  if(primaryVertices->at(i).isValid()&&(!primaryVertices->at(i).isFake()))
579  {
581  //primaryVertexFound = true;
582  break;
583  }
584  }
585 
586  pfeg_->setPhotonPrimaryVtx(primaryVertex_ );
587 
588 }
reco::Vertex primaryVertex_
primaryVertices
Definition: jets_cff.py:130
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection

Member Data Documentation

bool PFEGammaProducer::applyCrackCorrectionsElectrons_
private

Definition at line 115 of file PFEGammaProducer.h.

double PFEGammaProducer::coneEcalIsoForEgammaSC_
private

Definition at line 121 of file PFEGammaProducer.h.

double PFEGammaProducer::coneTrackIsoForEgammaSC_
private

Definition at line 124 of file PFEGammaProducer.h.

std::string PFEGammaProducer::ebeeClustersCollection_
private

Definition at line 143 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> PFEGammaProducer::eetopsSrc_
private

Definition at line 78 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

std::unique_ptr<reco::PFCandidateCollection> PFEGammaProducer::egCandidates_
private

Definition at line 129 of file PFEGammaProducer.h.

Referenced by produce().

std::unique_ptr<reco::PFCandidateEGammaExtraCollection> PFEGammaProducer::egExtra_
private

Definition at line 130 of file PFEGammaProducer.h.

Referenced by produce().

std::string PFEGammaProducer::esClustersCollection_
private

Definition at line 144 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

edm::EDGetTokenT<reco::PFBlockCollection> PFEGammaProducer::inputTagBlocks_
private

Definition at line 77 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

double PFEGammaProducer::mvaEleCut_
private

Definition at line 112 of file PFEGammaProducer.h.

std::string PFEGammaProducer::mvaWeightFileEleID_
private

Variables for PFEGamma.

Definition at line 110 of file PFEGammaProducer.h.

unsigned int PFEGammaProducer::nTrackIsoForEgammaSC_
private

Definition at line 125 of file PFEGammaProducer.h.

std::unique_ptr<PFEGammaAlgo> PFEGammaProducer::pfeg_
private

the unfiltered electron collection

particle flow algorithm

Definition at line 141 of file PFEGammaProducer.h.

Referenced by produce(), setPFEGParameters(), and setPFVertexParameters().

reco::Vertex PFEGammaProducer::primaryVertex_
private

Definition at line 127 of file PFEGammaProducer.h.

Referenced by setPFEGParameters(), and setPFVertexParameters().

const GBRForest* PFEGammaProducer::ReaderGC_
private

Definition at line 89 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderLC_
private

Definition at line 90 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderRes_
private

Definition at line 91 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

std::unique_ptr<reco::SuperClusterCollection> PFEGammaProducer::sClusters_
private

Definition at line 132 of file PFEGammaProducer.h.

Referenced by produce().

std::vector<double> PFEGammaProducer::setchi2Values_
private

Definition at line 111 of file PFEGammaProducer.h.

std::unique_ptr<reco::ConversionCollection> PFEGammaProducer::singleLegConv_
private

Definition at line 131 of file PFEGammaProducer.h.

Referenced by produce().

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_barrel_
private

Definition at line 119 of file PFEGammaProducer.h.

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_endcap_
private

Definition at line 120 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_barrel_
private

Definition at line 122 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_endcap_
private

Definition at line 123 of file PFEGammaProducer.h.

std::shared_ptr<PFSCEnergyCalibration> PFEGammaProducer::thePFSCEnergyCalibration_
private

Definition at line 107 of file PFEGammaProducer.h.

bool PFEGammaProducer::useCalibrationsFromDB_
private

Definition at line 105 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

bool PFEGammaProducer::useEGammaElectrons_
private

Definition at line 99 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGammaSupercluster_
private

Definition at line 118 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGElectrons_
private

Definition at line 117 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFElectrons_
private

Definition at line 113 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFPhotons_
private

Definition at line 114 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFSCEleCalib_
private

Definition at line 116 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePhotonReg_
private

Definition at line 87 of file PFEGammaProducer.h.

bool PFEGammaProducer::useRegressionFromDB_
private

Definition at line 88 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

bool PFEGammaProducer::useVerticesForNeutral_
private
bool PFEGammaProducer::verbose_
private

verbose ?

Definition at line 84 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

edm::EDGetTokenT<reco::VertexCollection> PFEGammaProducer::vertices_
private

Definition at line 79 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().