CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 PFEGammaProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PFEGammaProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EEtoPSAssociation
eetopsSrc_
 
std::auto_ptr
< reco::PFCandidateCollection
egCandidates_
 
std::auto_ptr
< reco::PFCandidateEGammaExtraCollection
egExtra_
 
std::string esClustersCollection_
 
edm::EDGetTokenT
< reco::PFBlockCollection
inputTagBlocks_
 
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::auto_ptr
< reco::SuperClusterCollection
sClusters_
 
std::vector< double > setchi2Values_
 
std::auto_ptr
< reco::ConversionCollection
singleLegConv_
 
double sumEtEcalIsoForEgammaSC_barrel_
 
double sumEtEcalIsoForEgammaSC_endcap_
 
double sumPtTrackIsoForEgammaSC_barrel_
 
double sumPtTrackIsoForEgammaSC_endcap_
 
std::shared_ptr
< PFSCEnergyCalibration
thePFSCEnergyCalibration_
 
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::VertexCollection
vertices_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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)
explicit

Definition at line 45 of file PFEGammaProducer.cc.

References HLT_25ns14e33_v1_cff::algoType, PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections, assert(), HLT_25ns14e33_v1_cff::calibPFSCEle_barrel, HLT_25ns14e33_v1_cff::calibPFSCEle_endcap, HLT_25ns14e33_v1_cff::calibPFSCEle_Fbrem_barrel, HLT_25ns14e33_v1_cff::calibPFSCEle_Fbrem_endcap, PFEGammaAlgo::PFEGConfigInfo::coneEcalIsoForEgammaSC, PFEGammaAlgo::PFEGConfigInfo::coneTrackIsoForEgammaSC, ebeeClustersCollection_, eetopsSrc_, esClustersCollection_, contentValuesFiles::fullPath, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::iCfgCandConnector, inputTagBlocks_, LogDebug, PFEGammaAlgo::PFEGConfigInfo::mvaConvCut, PFEGammaAlgo::PFEGConfigInfo::mvaEleCut, PFEGammaAlgo::PFEGConfigInfo::mvaweightfile, PFEGammaAlgo::PFEGConfigInfo::mvaWeightFileEleID, 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, useCalibrationsFromDB_, PFEGammaAlgo::PFEGConfigInfo::useEGammaSupercluster, PFEGammaAlgo::PFEGConfigInfo::usePFSCEleCalib, PFEGammaAlgo::PFEGConfigInfo::useReg, useRegressionFromDB_, useVerticesForNeutral_, verbose_, vertices_, and PFEGammaAlgo::PFEGConfigInfo::X0_Map.

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

Definition at line 203 of file PFEGammaProducer.cc.

203 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 206 of file PFEGammaProducer.cc.

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

Definition at line 583 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 produce().

583  {
584 
586  for (auto &extra : extras){
587  for (const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
588  const reco::Track &trk = *tkrefmva.first;
589 
590  const reco::Vertex convVtx(trk.innerPosition(), error);
591  std::vector<reco::TrackRef> OneLegConvVector;
592  OneLegConvVector.push_back(tkrefmva.first);
593  std::vector< float > OneLegMvaVector;
594  OneLegMvaVector.push_back(tkrefmva.second);
595  std::vector<reco::CaloClusterPtr> dummymatchingBC;
597  scPtrVec.push_back(edm::refToPtr(extra.superClusterRef()));
598 
599  std::vector<math::XYZPointF>trackPositionAtEcalVec;
600  std::vector<math::XYZPointF>innPointVec;
601  std::vector<math::XYZVectorF>trackPinVec;
602  std::vector<math::XYZVectorF>trackPoutVec;
603  math::XYZPointF trackPositionAtEcal(trk.outerPosition().X(), trk.outerPosition().Y(), trk.outerPosition().Z());
604  trackPositionAtEcalVec.push_back(trackPositionAtEcal);
605 
606  math::XYZPointF innPoint(trk.innerPosition().X(), trk.innerPosition().Y(), trk.innerPosition().Z());
607  innPointVec.push_back(innPoint);
608 
609  math::XYZVectorF trackPin(trk.innerMomentum().X(), trk.innerMomentum().Y(), trk.innerMomentum().Z());
610  trackPinVec.push_back(trackPin);
611 
612  math::XYZVectorF trackPout(trk.outerMomentum().X(), trk.outerMomentum().Y(), trk.outerMomentum().Z());
613  trackPoutVec.push_back( trackPout );
614 
615  float DCA = trk.d0() ;
616  float mvaval = tkrefmva.second;
617  reco::Conversion singleLegConvCandidate(scPtrVec,
618  OneLegConvVector,
619  trackPositionAtEcalVec,
620  convVtx,
621  dummymatchingBC,
622  DCA,
623  innPointVec,
624  trackPinVec,
625  trackPoutVec,
626  mvaval,
628  singleLegConvCandidate.setOneLegMVA(OneLegMvaVector);
629  oneLegConversions.push_back(singleLegConvCandidate);
630 
631  reco::ConversionRef convref(convProd,oneLegConversions.size()-1);
632  extra.addSingleLegConversionRef(convref);
633 
634  }
635 
636  }
637 
638 }
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:550
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
ErrorD< N >::type type
Definition: Error.h:39
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
void PFEGammaProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 244 of file PFEGammaProducer.cc.

References assert(), gather_cfg::blocks, HLT_25ns14e33_v1_cff::clusters, createSingleLegConversions(), TauDecayModes::dec, ebeeClustersCollection_, reco::PFBlockElement::ECAL, eetopsSrc_, egCandidates_, egExtra_, asciidump::elements, esClustersCollection_, edm::EventID::event(), edm::hlt::Exception, newFWLiteAna::found, edm::Event::getByToken(), edm::Event::getRefBeforePut(), reco::PFBlockElement::HCAL, reco::PFBlockElement::HFEM, reco::PFBlockElement::HFHAD, reco::PFBlockElement::HO, i, edm::EventBase::id(), edm::EDGetTokenT< T >::index(), inputTagBlocks_, LOGDRESSED, eostools::move(), pfeg_, edm::Handle< T >::product(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::PtrVector< T >::push_back(), edm::Event::put(), edm::EventID::run(), reco::PFBlockElement::SC, sClusters_, reco::PFCandidate::setPFEGammaExtraRef(), setPFVertexParameters(), reco::PFCandidateEGammaExtra::setSuperClusterRef(), reco::PFCandidate::setSuperClusterRef(), singleLegConv_, edm::OwnVector< T, P >::size(), funct::true, useVerticesForNeutral_, HLT_25ns14e33_v1_cff::vertices, and vertices_.

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

Definition at line 503 of file PFEGammaProducer.cc.

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

Referenced by PFEGammaProducer().

503  {
504 
505  FILE * fileEleID = fopen(cfg.mvaWeightFileEleID.c_str(), "r");
506  if (fileEleID) {
507  fclose(fileEleID);
508  }
509  else {
510  std::string err = "PFAlgo: cannot open weight file '";
511  err += cfg.mvaWeightFileEleID;
512  err += "'";
513  throw std::invalid_argument( err );
514  }
515 
516  //for MVA pass PV if there is one in the collection otherwise pass a dummy
517  if(!useVerticesForNeutral_) { // create a dummy PV
519  e(0, 0) = 0.0015 * 0.0015;
520  e(1, 1) = 0.0015 * 0.0015;
521  e(2, 2) = 15. * 15.;
522  reco::Vertex::Point p(0, 0, 0);
523  primaryVertex_ = reco::Vertex(p, e, 0, 0, 0);
524  }
525  // pv=&dummy;
526  //if(! usePFPhotons_) return;
527  FILE * filePhotonConvID = fopen(cfg.mvaweightfile.c_str(), "r");
528  if (filePhotonConvID) {
529  fclose(filePhotonConvID);
530  }
531  else {
532  std::string err = "PFAlgo: cannot open weight file '";
533  err += cfg.mvaweightfile;
534  err += "'";
535  throw std::invalid_argument( err );
536  }
537  cfg.primaryVtx = &primaryVertex_;
538  pfeg_.reset(new PFEGammaAlgo(cfg));
539 }
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:124
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 553 of file PFEGammaProducer.cc.

References i, pfeg_, primaryVertex_, HLT_25ns14e33_v1_cff::useVertex, and useVerticesForNeutral_.

Referenced by produce().

554  {
556 
557  //Set the vertices for muon cleaning
558 // pfmu_->setInputsForCleaning(primaryVertices);
559 
560 
561  //Now find the primary vertex!
562  //bool primaryVertexFound = false;
563  int nVtx=primaryVertices->size();
564  pfeg_->setnPU(nVtx);
565 // if(usePFPhotons_){
566 // pfpho_->setnPU(nVtx);
567 // }
568  primaryVertex_ = primaryVertices->front();
569  for (unsigned short i=0 ;i<primaryVertices->size();++i)
570  {
571  if(primaryVertices->at(i).isValid()&&(!primaryVertices->at(i).isFake()))
572  {
574  //primaryVertexFound = true;
575  break;
576  }
577  }
578 
579  pfeg_->setPhotonPrimaryVtx(primaryVertex_ );
580 
581 }
int i
Definition: DBlmapReader.cc:9
reco::Vertex primaryVertex_
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection

Member Data Documentation

bool PFEGammaProducer::applyCrackCorrectionsElectrons_
private

Definition at line 107 of file PFEGammaProducer.h.

double PFEGammaProducer::coneEcalIsoForEgammaSC_
private

Definition at line 113 of file PFEGammaProducer.h.

double PFEGammaProducer::coneTrackIsoForEgammaSC_
private

Definition at line 116 of file PFEGammaProducer.h.

std::string PFEGammaProducer::ebeeClustersCollection_
private

Definition at line 135 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 70 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 121 of file PFEGammaProducer.h.

Referenced by produce().

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

Definition at line 122 of file PFEGammaProducer.h.

Referenced by produce().

std::string PFEGammaProducer::esClustersCollection_
private

Definition at line 136 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 69 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

double PFEGammaProducer::mvaEleCut_
private

Definition at line 104 of file PFEGammaProducer.h.

std::string PFEGammaProducer::mvaWeightFileEleID_
private

Variables for PFEGamma.

Definition at line 102 of file PFEGammaProducer.h.

unsigned int PFEGammaProducer::nTrackIsoForEgammaSC_
private

Definition at line 117 of file PFEGammaProducer.h.

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

the unfiltered electron collection

particle flow algorithm

Definition at line 133 of file PFEGammaProducer.h.

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

reco::Vertex PFEGammaProducer::primaryVertex_
private

Definition at line 119 of file PFEGammaProducer.h.

Referenced by setPFEGParameters(), and setPFVertexParameters().

const GBRForest* PFEGammaProducer::ReaderGC_
private

Definition at line 81 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderLC_
private

Definition at line 82 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderRes_
private

Definition at line 83 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

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

Definition at line 124 of file PFEGammaProducer.h.

Referenced by produce().

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

Definition at line 103 of file PFEGammaProducer.h.

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

Definition at line 123 of file PFEGammaProducer.h.

Referenced by produce().

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_barrel_
private

Definition at line 111 of file PFEGammaProducer.h.

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_endcap_
private

Definition at line 112 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_barrel_
private

Definition at line 114 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_endcap_
private

Definition at line 115 of file PFEGammaProducer.h.

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

Definition at line 99 of file PFEGammaProducer.h.

bool PFEGammaProducer::useCalibrationsFromDB_
private

Definition at line 97 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

bool PFEGammaProducer::useEGammaElectrons_
private

Definition at line 91 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGammaSupercluster_
private

Definition at line 110 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGElectrons_
private

Definition at line 109 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFElectrons_
private

Definition at line 105 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFPhotons_
private

Definition at line 106 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFSCEleCalib_
private

Definition at line 108 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePhotonReg_
private

Definition at line 79 of file PFEGammaProducer.h.

bool PFEGammaProducer::useRegressionFromDB_
private

Definition at line 80 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

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

verbose ?

Definition at line 76 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

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

Definition at line 71 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().