CMS 3D CMS Logo

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

#include <PuppiProducer.h>

Inheritance diagram for PuppiProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef edm::View< reco::CandidateCandidateView
 
typedef math::XYZTLorentzVector LorentzVector
 
typedef std::vector< LorentzVectorLorentzVectorCollection
 
typedef std::vector< pat::PackedCandidatePackedOutputCollection
 
typedef std::vector< reco::PFCandidatePFInputCollection
 
typedef std::vector< reco::PFCandidatePFOutputCollection
 
typedef edm::View< reco::PFCandidatePFView
 
typedef reco::VertexCollection VertexCollection
 
- 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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 PuppiProducer (const edm::ParameterSet &)
 
 ~PuppiProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool fClonePackedCands
 
float fDZCut
 
std::unique_ptr< PackedOutputCollectionfPackedPuppiCandidates
 
std::string fPFName
 
float fPtMax
 
std::unique_ptr< PFOutputCollectionfPuppiCandidates
 
std::unique_ptr< PuppiContainerfPuppiContainer
 
bool fPuppiDiagnostics
 
bool fPuppiForLeptons
 
std::string fPuppiName
 
std::string fPVName
 
std::vector< RecoObjfRecoObjCollection
 
bool fUseDZ
 
bool fUseExistingWeights
 
bool fUseWeightsNoLep
 
int fVtxNdofCut
 
double fVtxZCut
 
edm::EDGetTokenT< CandidateViewtokenPFCandidates_
 
edm::EDGetTokenT< VertexCollectiontokenVertices_
 

Additional Inherited Members

- 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

Definition at line 19 of file PuppiProducer.h.

Member Typedef Documentation

Definition at line 29 of file PuppiProducer.h.

Definition at line 26 of file PuppiProducer.h.

Definition at line 27 of file PuppiProducer.h.

Definition at line 32 of file PuppiProducer.h.

Definition at line 30 of file PuppiProducer.h.

Definition at line 31 of file PuppiProducer.h.

Definition at line 33 of file PuppiProducer.h.

Definition at line 28 of file PuppiProducer.h.

Constructor & Destructor Documentation

PuppiProducer::PuppiProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 31 of file PuppiProducer.cc.

References fClonePackedCands, fDZCut, fPtMax, fPuppiContainer, fPuppiDiagnostics, fPuppiForLeptons, fUseDZ, fUseExistingWeights, fUseWeightsNoLep, fVtxNdofCut, fVtxZCut, edm::ParameterSet::getParameter(), tokenPFCandidates_, and tokenVertices_.

31  {
32  fPuppiDiagnostics = iConfig.getParameter<bool>("puppiDiagnostics");
33  fPuppiForLeptons = iConfig.getParameter<bool>("puppiForLeptons");
34  fUseDZ = iConfig.getParameter<bool>("UseDeltaZCut");
35  fDZCut = iConfig.getParameter<double>("DeltaZCut");
36  fPtMax = iConfig.getParameter<double>("PtMaxNeutrals");
37  fUseExistingWeights = iConfig.getParameter<bool>("useExistingWeights");
38  fUseWeightsNoLep = iConfig.getParameter<bool>("useWeightsNoLep");
39  fClonePackedCands = iConfig.getParameter<bool>("clonePackedCands");
40  fVtxNdofCut = iConfig.getParameter<int>("vtxNdofCut");
41  fVtxZCut = iConfig.getParameter<double>("vtxZCut");
42  fPuppiContainer = std::unique_ptr<PuppiContainer> ( new PuppiContainer(iConfig) );
43 
45  = consumes<CandidateView>(iConfig.getParameter<edm::InputTag>("candName"));
47  = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexName"));
48 
49 
50  produces<edm::ValueMap<float> > ();
51  produces<edm::ValueMap<LorentzVector> > ();
52  produces< edm::ValueMap<reco::CandidatePtr> >();
53 
55  produces<pat::PackedCandidateCollection>();
56  else
57  produces<reco::PFCandidateCollection>();
58 
59  if (fPuppiDiagnostics){
60  produces<double> ("PuppiNAlgos");
61  produces<std::vector<double>> ("PuppiRawAlphas");
62  produces<std::vector<double>> ("PuppiAlphas");
63  produces<std::vector<double>> ("PuppiAlphasMed");
64  produces<std::vector<double>> ("PuppiAlphasRms");
65  }
66 }
T getParameter(std::string const &) const
bool fUseWeightsNoLep
Definition: PuppiProducer.h:51
bool fPuppiDiagnostics
Definition: PuppiProducer.h:45
std::unique_ptr< PuppiContainer > fPuppiContainer
Definition: PuppiProducer.h:55
edm::EDGetTokenT< VertexCollection > tokenVertices_
Definition: PuppiProducer.h:41
bool fClonePackedCands
Definition: PuppiProducer.h:52
bool fPuppiForLeptons
Definition: PuppiProducer.h:46
bool fUseExistingWeights
Definition: PuppiProducer.h:50
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
Definition: PuppiProducer.h:40
PuppiProducer::~PuppiProducer ( )
override

Definition at line 68 of file PuppiProducer.cc.

68  {
69 }

Member Function Documentation

void PuppiProducer::beginJob ( void  )
privatevirtual

Definition at line 322 of file PuppiProducer.cc.

322  {
323 }
void PuppiProducer::endJob ( void  )
privatevirtual

Definition at line 325 of file PuppiProducer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

325  {
326 }
void PuppiProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 328 of file PuppiProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

328  {
329  //The following says we do not know what parameters are allowed so do no validation
330  // Please change this to state exactly what you do use, even if it is no parameters
332  desc.setUnknown();
333  descriptions.addDefault(desc);
334 }
void addDefault(ParameterSetDescription const &psetDescription)
void PuppiProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 71 of file PuppiProducer.cc.

References funct::abs(), edm::View< T >::begin(), RecoObj::charge, RecoObj::d0, pat::PackedCandidate::dxy(), RecoObj::dZ, pat::PackedCandidate::dz(), edm::View< T >::end(), pat::PackedCandidate::energy(), RecoObj::eta, Exception, fClonePackedCands, fDZCut, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, fPackedPuppiCandidates, fPuppiCandidates, fPuppiContainer, fPuppiDiagnostics, fPuppiForLeptons, fRecoObjCollection, pat::PackedCandidate::fromPV(), fUseDZ, fUseExistingWeights, fUseWeightsNoLep, fVtxNdofCut, fVtxZCut, edm::Event::getByToken(), reco::PFCandidate::gsfTrackRef(), mps_fire::i, RecoObj::id, triggerObjects_cff::id, edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), edm::errors::LogicError, RecoObj::m, eostools::move(), reco::LeafCandidate::p4(), RecoObj::phi, edm::Handle< T >::product(), RecoObj::pt, pat::PackedCandidate::puppiWeight(), pat::PackedCandidate::puppiWeightNoLep(), edm::Event::put(), pat::PackedCandidate::PVLoose, pat::PackedCandidate::PVTight, pat::PackedCandidate::PVUsedInFit, pat::PackedCandidate::px(), pat::PackedCandidate::py(), pat::PackedCandidate::pz(), RecoObj::rapidity, edm::View< T >::size(), tokenPFCandidates_, tokenVertices_, reco::PFCandidate::trackRef(), reco::PFCandidate::translatePdgIdToType(), heppy_batch::val, MuonErrorMatrixValues_cff::values, and pat::PackedCandidate::vertexRef().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

71  {
72 
73  // Get PFCandidate Collection
74  edm::Handle<CandidateView> hPFProduct;
75  iEvent.getByToken(tokenPFCandidates_,hPFProduct);
76  const CandidateView *pfCol = hPFProduct.product();
77 
78  // Get vertex collection w/PV as the first entry?
80  iEvent.getByToken(tokenVertices_,hVertexProduct);
81  const reco::VertexCollection *pvCol = hVertexProduct.product();
82 
83  int npv = 0;
84  const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
85  for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
86  if (!vtxIter->isFake() && vtxIter->ndof()>=fVtxNdofCut && std::abs(vtxIter->z())<=fVtxZCut)
87  npv++;
88  }
89 
90  //Fill the reco objects
91  fRecoObjCollection.clear();
92  for(CandidateView::const_iterator itPF = pfCol->begin(); itPF!=pfCol->end(); itPF++) {
93  // std::cout << "itPF->pdgId() = " << itPF->pdgId() << std::endl;
94  RecoObj pReco;
95  pReco.pt = itPF->pt();
96  pReco.eta = itPF->eta();
97  pReco.phi = itPF->phi();
98  pReco.m = itPF->mass();
99  pReco.rapidity = itPF->rapidity();
100  pReco.charge = itPF->charge();
101  const reco::Vertex *closestVtx = nullptr;
102  double pDZ = -9999;
103  double pD0 = -9999;
104  int pVtxId = -9999;
105  bool lFirst = true;
106  const pat::PackedCandidate *lPack = dynamic_cast<const pat::PackedCandidate*>(&(*itPF));
107  if(lPack == nullptr ) {
108 
109  const reco::PFCandidate *pPF = dynamic_cast<const reco::PFCandidate*>(&(*itPF));
110  double curdz = 9999;
111  int closestVtxForUnassociateds = -9999;
112  for(reco::VertexCollection::const_iterator iV = pvCol->begin(); iV!=pvCol->end(); ++iV) {
113  if(lFirst) {
114  if ( pPF->trackRef().isNonnull() ) pDZ = pPF->trackRef() ->dz(iV->position());
115  else if ( pPF->gsfTrackRef().isNonnull() ) pDZ = pPF->gsfTrackRef()->dz(iV->position());
116  if ( pPF->trackRef().isNonnull() ) pD0 = pPF->trackRef() ->d0();
117  else if ( pPF->gsfTrackRef().isNonnull() ) pD0 = pPF->gsfTrackRef()->d0();
118  lFirst = false;
119  if(pDZ > -9999) pVtxId = 0;
120  }
121  if(iV->trackWeight(pPF->trackRef())>0) {
122  closestVtx = &(*iV);
123  break;
124  }
125  // in case it's unassocciated, keep more info
126  double tmpdz = 99999;
127  if ( pPF->trackRef().isNonnull() ) tmpdz = pPF->trackRef() ->dz(iV->position());
128  else if ( pPF->gsfTrackRef().isNonnull() ) tmpdz = pPF->gsfTrackRef()->dz(iV->position());
129  if (std::abs(tmpdz) < curdz){
130  curdz = std::abs(tmpdz);
131  closestVtxForUnassociateds = pVtxId;
132  }
133  pVtxId++;
134 
135  }
136  int tmpFromPV = 0;
137  // mocking the miniAOD definitions
138  if (closestVtx != nullptr && std::abs(pReco.charge) > 0 && pVtxId > 0) tmpFromPV = 0;
139  if (closestVtx != nullptr && std::abs(pReco.charge) > 0 && pVtxId == 0) tmpFromPV = 3;
140  if (closestVtx == nullptr && std::abs(pReco.charge) > 0 && closestVtxForUnassociateds == 0) tmpFromPV = 2;
141  if (closestVtx == nullptr && std::abs(pReco.charge) > 0 && closestVtxForUnassociateds != 0) tmpFromPV = 1;
142  pReco.dZ = pDZ;
143  pReco.d0 = pD0;
144  pReco.id = 0;
145  if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
146  else{
147  if (tmpFromPV == 0){ pReco.id = 2; } // 0 is associated to PU vertex
148  if (tmpFromPV == 3){ pReco.id = 1; }
149  if (tmpFromPV == 1 || tmpFromPV == 2){
150  pReco.id = 0;
151  if (!fPuppiForLeptons && fUseDZ && (std::abs(pDZ) < fDZCut)) pReco.id = 1;
152  if (!fPuppiForLeptons && fUseDZ && (std::abs(pDZ) > fDZCut)) pReco.id = 2;
153  if (fPuppiForLeptons && tmpFromPV == 1) pReco.id = 2;
154  if (fPuppiForLeptons && tmpFromPV == 2) pReco.id = 1;
155  }
156  }
157  }
158  else if(lPack->vertexRef().isNonnull() ) {
159  pDZ = lPack->dz();
160  pD0 = lPack->dxy();
161  pReco.dZ = pDZ;
162  pReco.d0 = pD0;
163 
164  pReco.id = 0;
165  if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
166  if (std::abs(pReco.charge) > 0){
167  if (lPack->fromPV() == 0){ pReco.id = 2; } // 0 is associated to PU vertex
168  if (lPack->fromPV() == (pat::PackedCandidate::PVUsedInFit)){ pReco.id = 1; }
169  if (lPack->fromPV() == (pat::PackedCandidate::PVTight) || lPack->fromPV() == (pat::PackedCandidate::PVLoose)){
170  pReco.id = 0;
171  if (!fPuppiForLeptons && fUseDZ && (std::abs(pDZ) < fDZCut)) pReco.id = 1;
172  if (!fPuppiForLeptons && fUseDZ && (std::abs(pDZ) > fDZCut)) pReco.id = 2;
173  if (fPuppiForLeptons && lPack->fromPV() == (pat::PackedCandidate::PVLoose)) pReco.id = 2;
174  if (fPuppiForLeptons && lPack->fromPV() == (pat::PackedCandidate::PVTight)) pReco.id = 1;
175  }
176  }
177  }
178 
179  fRecoObjCollection.push_back(pReco);
180 
181  }
182 
183  fPuppiContainer->initialize(fRecoObjCollection);
184  fPuppiContainer->setNPV( npv );
185 
186  std::vector<double> lWeights;
187  std::vector<fastjet::PseudoJet> lCandidates;
188  if (!fUseExistingWeights){
189  //Compute the weights and get the particles
190  lWeights = fPuppiContainer->puppiWeights();
191  lCandidates = fPuppiContainer->puppiParticles();
192  }
193  else{
194  //Use the existing weights
195  int lPackCtr = 0;
196  for(CandidateView::const_iterator itPF = pfCol->begin(); itPF!=pfCol->end(); itPF++) {
197  const pat::PackedCandidate *lPack = dynamic_cast<const pat::PackedCandidate*>(&(*itPF));
198  float curpupweight = -1.;
199  if(lPack == nullptr ) {
200  // throw error
201  throw edm::Exception(edm::errors::LogicError,"PuppiProducer: cannot get weights since inputs are not PackedCandidates");
202  }
203  else{
204  if (fUseWeightsNoLep){ curpupweight = lPack->puppiWeightNoLep(); }
205  else{ curpupweight = lPack->puppiWeight(); }
206  }
207  lWeights.push_back(curpupweight);
208  fastjet::PseudoJet curjet( curpupweight*lPack->px(), curpupweight*lPack->py(), curpupweight*lPack->pz(), curpupweight*lPack->energy());
209  curjet.set_user_index(lPackCtr);
210  lCandidates.push_back(curjet);
211  lPackCtr++;
212  }
213  }
214 
215  //Fill it into the event
216  std::unique_ptr<edm::ValueMap<float> > lPupOut(new edm::ValueMap<float>());
217  edm::ValueMap<float>::Filler lPupFiller(*lPupOut);
218  lPupFiller.insert(hPFProduct,lWeights.begin(),lWeights.end());
219  lPupFiller.fill();
220 
221  // This is a dummy to access the "translate" method which is a
222  // non-static member function even though it doesn't need to be.
223  // Will fix in the future.
224  static const reco::PFCandidate dummySinceTranslateIsNotStatic;
225 
226  // Fill a new PF/Packed Candidate Collection and write out the ValueMap of the new p4s.
227  // Since the size of the ValueMap must be equal to the input collection, we need
228  // to search the "puppi" particles to find a match for each input. If none is found,
229  // the input is set to have a four-vector of 0,0,0,0
232  std::unique_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
233  LorentzVectorCollection puppiP4s;
234  std::vector<reco::CandidatePtr> values(hPFProduct->size());
235 
236  for ( auto i0 = hPFProduct->begin(),
237  i0begin = hPFProduct->begin(),
238  i0end = hPFProduct->end(); i0 != i0end; ++i0 ) {
239  std::unique_ptr<pat::PackedCandidate> pCand;
240  std::unique_ptr<reco::PFCandidate> pfCand;
242  const pat::PackedCandidate *cand = dynamic_cast<const pat::PackedCandidate*>(&(*i0));
243  if(!cand)
244  throw edm::Exception(edm::errors::LogicError,"PuppiProducer: inputs are not PackedCandidates");
245  pCand.reset( new pat::PackedCandidate(*cand) );
246  } else {
247  auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(i0->pdgId());
248  const reco::PFCandidate *cand = dynamic_cast<const reco::PFCandidate*>(&(*i0));
249  pfCand.reset( new reco::PFCandidate( cand ? *cand : reco::PFCandidate(i0->charge(), i0->p4(), id) ) );
250  }
251  LorentzVector pVec = i0->p4();
252  int val = i0 - i0begin;
253 
254  // Find the Puppi particle matched to the input collection using the "user_index" of the object.
255  auto puppiMatched = find_if( lCandidates.begin(), lCandidates.end(), [&val]( fastjet::PseudoJet const & i ){ return i.user_index() == val; } );
256  if ( puppiMatched != lCandidates.end() ) {
257  pVec.SetPxPyPzE(puppiMatched->px(),puppiMatched->py(),puppiMatched->pz(),puppiMatched->E());
258  } else {
259  pVec.SetPxPyPzE( 0, 0, 0, 0);
260  }
261  puppiP4s.push_back( pVec );
262 
264  pCand->setP4(pVec);
265  pCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
266  fPackedPuppiCandidates->push_back(*pCand);
267  } else {
268  pfCand->setP4(pVec);
269  pfCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
270  fPuppiCandidates->push_back(*pfCand);
271  }
272  }
273 
274  //Compute the modified p4s
275  edm::ValueMap<LorentzVector>::Filler p4PupFiller(*p4PupOut);
276  p4PupFiller.insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
277  p4PupFiller.fill();
278 
279  iEvent.put(std::move(lPupOut));
280  iEvent.put(std::move(p4PupOut));
283  for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
284  reco::CandidatePtr pkref( oh, ic );
285  values[ic] = pkref;
286  }
287  } else {
289  for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
290  reco::CandidatePtr pkref( oh, ic );
291  values[ic] = pkref;
292  }
293  }
294  std::unique_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
296  filler.insert(hPFProduct, values.begin(), values.end());
297  filler.fill();
298  iEvent.put(std::move(pfMap_p));
299 
300 
303 
304  // all the different alphas per particle
305  // THE alpha per particle
306  std::unique_ptr<std::vector<double> > theAlphas(new std::vector<double>(fPuppiContainer->puppiAlphas()));
307  std::unique_ptr<std::vector<double> > theAlphasMed(new std::vector<double>(fPuppiContainer->puppiAlphasMed()));
308  std::unique_ptr<std::vector<double> > theAlphasRms(new std::vector<double>(fPuppiContainer->puppiAlphasRMS()));
309  std::unique_ptr<std::vector<double> > alphas(new std::vector<double>(fPuppiContainer->puppiRawAlphas()));
310  std::unique_ptr<double> nalgos(new double(fPuppiContainer->puppiNAlgos()));
311 
312  iEvent.put(std::move(alphas),"PuppiRawAlphas");
313  iEvent.put(std::move(nalgos),"PuppiNAlgos");
314  iEvent.put(std::move(theAlphas),"PuppiAlphas");
315  iEvent.put(std::move(theAlphasMed),"PuppiAlphasMed");
316  iEvent.put(std::move(theAlphasRms),"PuppiAlphasRms");
317  }
318 
319 }
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
double px() const override
x coordinate of momentum vector
float puppiWeightNoLep() const
Weight from full PUPPI.
float d0
Definition: RecoObj.h:28
bool fUseWeightsNoLep
Definition: PuppiProducer.h:51
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< reco::PFCandidate > PFOutputCollection
Definition: PuppiProducer.h:31
Definition: RecoObj.h:4
bool fPuppiDiagnostics
Definition: PuppiProducer.h:45
std::vector< pat::PackedCandidate > PackedOutputCollection
Definition: PuppiProducer.h:32
std::vector< RecoObj > fRecoObjCollection
Definition: PuppiProducer.h:56
size_type size() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
Definition: PuppiProducer.h:55
int charge
Definition: RecoObj.h:29
double pz() const override
z coordinate of momentum vector
edm::EDGetTokenT< VertexCollection > tokenVertices_
Definition: PuppiProducer.h:41
float dZ
Definition: RecoObj.h:27
double py() const override
y coordinate of momentum vector
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
float rapidity
Definition: RecoObj.h:17
float pt
Definition: RecoObj.h:17
const_iterator begin() const
int id
Definition: RecoObj.h:18
float phi
Definition: RecoObj.h:17
const PVAssoc fromPV(size_t ipv=0) const
std::unique_ptr< PackedOutputCollection > fPackedPuppiCandidates
Definition: PuppiProducer.h:58
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool fClonePackedCands
Definition: PuppiProducer.h:52
double energy() const override
energy
math::XYZTLorentzVector LorentzVector
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::View< reco::Candidate > CandidateView
Definition: PuppiProducer.h:29
bool fPuppiForLeptons
Definition: PuppiProducer.h:46
std::vector< LorentzVector > LorentzVectorCollection
float m
Definition: RecoObj.h:17
T const * product() const
Definition: Handle.h:81
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:233
float eta
Definition: RecoObj.h:17
bool fUseExistingWeights
Definition: PuppiProducer.h:50
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:480
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
Definition: PuppiProducer.h:40
const_iterator end() const
virtual float dxy() const
dxy with respect to the PV ref
std::unique_ptr< PFOutputCollection > fPuppiCandidates
Definition: PuppiProducer.h:57
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

bool PuppiProducer::fClonePackedCands
private

Definition at line 52 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

float PuppiProducer::fDZCut
private

Definition at line 48 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

std::unique_ptr< PackedOutputCollection > PuppiProducer::fPackedPuppiCandidates
private

Definition at line 58 of file PuppiProducer.h.

Referenced by produce().

std::string PuppiProducer::fPFName
private

Definition at line 43 of file PuppiProducer.h.

float PuppiProducer::fPtMax
private

Definition at line 49 of file PuppiProducer.h.

Referenced by PuppiProducer().

std::unique_ptr< PFOutputCollection > PuppiProducer::fPuppiCandidates
private

Definition at line 57 of file PuppiProducer.h.

Referenced by produce().

std::unique_ptr<PuppiContainer> PuppiProducer::fPuppiContainer
private

Definition at line 55 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fPuppiDiagnostics
private

Definition at line 45 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fPuppiForLeptons
private

Definition at line 46 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

std::string PuppiProducer::fPuppiName
private

Definition at line 42 of file PuppiProducer.h.

std::string PuppiProducer::fPVName
private

Definition at line 44 of file PuppiProducer.h.

std::vector<RecoObj> PuppiProducer::fRecoObjCollection
private

Definition at line 56 of file PuppiProducer.h.

Referenced by produce().

bool PuppiProducer::fUseDZ
private

Definition at line 47 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fUseExistingWeights
private

Definition at line 50 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fUseWeightsNoLep
private

Definition at line 51 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

int PuppiProducer::fVtxNdofCut
private

Definition at line 53 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

double PuppiProducer::fVtxZCut
private

Definition at line 54 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

edm::EDGetTokenT< CandidateView > PuppiProducer::tokenPFCandidates_
private

Definition at line 40 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

edm::EDGetTokenT< VertexCollection > PuppiProducer::tokenVertices_
private

Definition at line 41 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().