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::EDProducer 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::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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 GBRForestReaderEcalRes_
 
const GBRForestReaderGC_
 
const GBRForestReaderGCBarrel_
 
const GBRForestReaderGCEndCapHighr9_
 
const GBRForestReaderGCEndCapLowr9_
 
const GBRForestReaderLC_
 
const GBRForestReaderLCEB_
 
const GBRForestReaderLCEE_
 
const GBRForestReaderRes_
 
std::auto_ptr
< reco::SuperClusterCollection
sClusters_
 
std::vector< double > setchi2Values_
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
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 PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections, PFEGammaAlgo::PFEGConfigInfo::coneEcalIsoForEgammaSC, PFEGammaAlgo::PFEGConfigInfo::coneTrackIsoForEgammaSC, ebeeClustersCollection_, eetopsSrc_, esClustersCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), 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>
77  thePFSCEnergyCalibration ( new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
78  calibPFSCEle_barrel,calibPFSCEle_endcap ));
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 
107  //PFElectrons Configuration
108  algo_config.mvaEleCut
109  = iConfig.getParameter<double>("pf_electron_mvaCut");
110 
111 
112  algo_config. mvaWeightFileEleID
113  = iConfig.getParameter<std::string>("pf_electronID_mvaWeightFile");
114 
115  algo_config.applyCrackCorrections
116  = iConfig.getParameter<bool>("pf_electronID_crackCorrection");
117 
118  std::string path_mvaWeightFileEleID;
119 
120  algo_config.mvaWeightFileEleID =
121  edm::FileInPath ( algo_config.mvaWeightFileEleID.c_str() ).fullPath();
122 
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<std::string>("pf_convID_mvaWeightFile");
135  algo_config.mvaConvCut = iConfig.getParameter<double>("pf_conv_mvaCut");
136  algo_config.mvaweightfile =
137  edm::FileInPath ( algo_config.mvaweightfile.c_str() ).fullPath();
138  algo_config.sumPtTrackIsoForPhoton =
139  iConfig.getParameter<double>("sumPtTrackIsoForPhoton");
140  algo_config.sumPtTrackIsoSlopeForPhoton =
141  iConfig.getParameter<double>("sumPtTrackIsoSlopeForPhoton");
142 
143  algo_config.X0_Map = iConfig.getParameter<std::string>("X0_Map");
144  algo_config.X0_Map =
145  edm::FileInPath( algo_config.X0_Map.c_str() ).fullPath();
146 
147  if(!useRegressionFromDB_) {
148  std::string mvaWeightFileLCorr=iConfig.getParameter<std::string>("pf_locC_mvaWeightFile");
149  path_mvaWeightFileLCorr = edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
150  std::string mvaWeightFileGCorr=iConfig.getParameter<std::string>("pf_GlobC_mvaWeightFile");
151  path_mvaWeightFileGCorr = edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
152  std::string mvaWeightFileRes=iConfig.getParameter<std::string>("pf_Res_mvaWeightFile");
153  path_mvaWeightFileRes=edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
154 
155  TFile *fgbr = new TFile(path_mvaWeightFileGCorr.c_str(),"READ");
156  ReaderGC_ =(const GBRForest*)fgbr->Get("GBRForest");
157  TFile *fgbr2 = new TFile(path_mvaWeightFileLCorr.c_str(),"READ");
158  ReaderLC_ = (const GBRForest*)fgbr2->Get("GBRForest");
159  TFile *fgbr3 = new TFile(path_mvaWeightFileRes.c_str(),"READ");
160  ReaderRes_ = (const GBRForest*)fgbr3->Get("GBRForest");
161  LogDebug("PFEGammaProducer")<<"Will set regressions from binary files " <<std::endl;
162  }
163 
164  edm::ParameterSet iCfgCandConnector
165  = iConfig.getParameter<edm::ParameterSet>("iCfgCandConnector");
166 
167 
168  // fToRead = iConfig.getUntrackedParameter<std::vector<std::string> >("toRead");
169 
171  = iConfig.getParameter<bool>("useCalibrationsFromDB");
172 
173  std::shared_ptr<PFEnergyCalibration> calibration(new PFEnergyCalibration());
174 
175  int algoType
176  = iConfig.getParameter<unsigned>("algoType");
177 
178  switch(algoType) {
179  case 0:
180  //pfAlgo_.reset( new PFAlgo);
181  break;
182  default:
183  assert(0);
184  }
185 
186  //PFEGamma
187  setPFEGParameters(algo_config);
188 
189  //MIKE: Vertex Parameters
190  vertices_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"));
191 
192  verbose_ =
193  iConfig.getUntrackedParameter<bool>("verbose",false);
194 
195 // bool debug_ =
196 // iConfig.getUntrackedParameter<bool>("debug",false);
197 
198 }
#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 ( )

Definition at line 202 of file PFEGammaProducer.cc.

202 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 205 of file PFEGammaProducer.cc.

References edm::EventSetup::get(), edm::ESHandle< class >::product(), ReaderEcalRes_, ReaderGCBarrel_, ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderLCEB_, ReaderLCEE_, and useRegressionFromDB_.

207 {
208 
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 }
const GBRForest * ReaderGCEndCapHighr9_
const GBRForest * ReaderEcalRes_
const GBRForest * ReaderGCEndCapLowr9_
const GBRForest * ReaderLCEE_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
const GBRForest * ReaderLCEB_
const GBRForest * ReaderGCBarrel_
void PFEGammaProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 241 of file PFEGammaProducer.cc.

References gather_cfg::blocks, ebeeClustersCollection_, reco::PFBlockElement::ECAL, eetopsSrc_, egCandidates_, egExtra_, asciidump::elements, reco::CaloCluster::energy(), 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, 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(), edm::OwnVector< T, P >::size(), funct::true, useVerticesForNeutral_, and vertices_.

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

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

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

References i, pfeg_, primaryVertex_, and useVerticesForNeutral_.

Referenced by produce().

550  {
551  useVerticesForNeutral_ = useVertex;
552 
553  //Set the vertices for muon cleaning
554 // pfmu_->setInputsForCleaning(primaryVertices);
555 
556 
557  //Now find the primary vertex!
558  //bool primaryVertexFound = false;
559  int nVtx=primaryVertices->size();
560  pfeg_->setnPU(nVtx);
561 // if(usePFPhotons_){
562 // pfpho_->setnPU(nVtx);
563 // }
564  primaryVertex_ = primaryVertices->front();
565  for (unsigned short i=0 ;i<primaryVertices->size();++i)
566  {
567  if(primaryVertices->at(i).isValid()&&(!primaryVertices->at(i).isFake()))
568  {
569  primaryVertex_ = primaryVertices->at(i);
570  //primaryVertexFound = true;
571  break;
572  }
573  }
574 
575  pfeg_->setPhotonPrimaryVtx(primaryVertex_ );
576 
577 }
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 104 of file PFEGammaProducer.h.

double PFEGammaProducer::coneEcalIsoForEgammaSC_
private

Definition at line 110 of file PFEGammaProducer.h.

double PFEGammaProducer::coneTrackIsoForEgammaSC_
private

Definition at line 113 of file PFEGammaProducer.h.

std::string PFEGammaProducer::ebeeClustersCollection_
private

Definition at line 131 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 67 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 118 of file PFEGammaProducer.h.

Referenced by produce().

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

Definition at line 119 of file PFEGammaProducer.h.

Referenced by produce().

std::string PFEGammaProducer::esClustersCollection_
private

Definition at line 132 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

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

Definition at line 66 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().

double PFEGammaProducer::mvaEleCut_
private

Definition at line 101 of file PFEGammaProducer.h.

std::string PFEGammaProducer::mvaWeightFileEleID_
private

Variables for PFEGamma.

Definition at line 99 of file PFEGammaProducer.h.

unsigned int PFEGammaProducer::nTrackIsoForEgammaSC_
private

Definition at line 114 of file PFEGammaProducer.h.

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

the unfiltered electron collection

particle flow algorithm

Definition at line 129 of file PFEGammaProducer.h.

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

reco::Vertex PFEGammaProducer::primaryVertex_
private

Definition at line 116 of file PFEGammaProducer.h.

Referenced by setPFEGParameters(), and setPFVertexParameters().

const GBRForest* PFEGammaProducer::ReaderEcalRes_
private

Definition at line 86 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderGC_
private

Definition at line 78 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderGCBarrel_
private

Definition at line 83 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderGCEndCapHighr9_
private

Definition at line 84 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderGCEndCapLowr9_
private

Definition at line 85 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderLC_
private

Definition at line 79 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

const GBRForest* PFEGammaProducer::ReaderLCEB_
private

Definition at line 81 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderLCEE_
private

Definition at line 82 of file PFEGammaProducer.h.

Referenced by beginRun().

const GBRForest* PFEGammaProducer::ReaderRes_
private

Definition at line 80 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

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

Definition at line 120 of file PFEGammaProducer.h.

Referenced by produce().

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

Definition at line 100 of file PFEGammaProducer.h.

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_barrel_
private

Definition at line 108 of file PFEGammaProducer.h.

double PFEGammaProducer::sumEtEcalIsoForEgammaSC_endcap_
private

Definition at line 109 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_barrel_
private

Definition at line 111 of file PFEGammaProducer.h.

double PFEGammaProducer::sumPtTrackIsoForEgammaSC_endcap_
private

Definition at line 112 of file PFEGammaProducer.h.

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

Definition at line 96 of file PFEGammaProducer.h.

bool PFEGammaProducer::useCalibrationsFromDB_
private

Definition at line 94 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

bool PFEGammaProducer::useEGammaElectrons_
private

Definition at line 88 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGammaSupercluster_
private

Definition at line 107 of file PFEGammaProducer.h.

bool PFEGammaProducer::useEGElectrons_
private

Definition at line 106 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFElectrons_
private

Definition at line 102 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFPhotons_
private

Definition at line 103 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePFSCEleCalib_
private

Definition at line 105 of file PFEGammaProducer.h.

bool PFEGammaProducer::usePhotonReg_
private

Definition at line 76 of file PFEGammaProducer.h.

bool PFEGammaProducer::useRegressionFromDB_
private

Definition at line 77 of file PFEGammaProducer.h.

Referenced by beginRun(), and PFEGammaProducer().

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

verbose ?

Definition at line 73 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer().

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

Definition at line 68 of file PFEGammaProducer.h.

Referenced by PFEGammaProducer(), and produce().