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

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 Member Functions

 PuppiProducer (const edm::ParameterSet &)
 
 ~PuppiProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::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
 
double fDZCutForChargedFromPUVtxs
 
double fEtaMaxCharged
 
double fEtaMinUseDZ
 
uint fNumOfPUVtxsForCharged
 
std::unique_ptr< PackedOutputCollectionfPackedPuppiCandidates
 
std::string fPFName
 
double fPtMaxCharged
 
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 fUseFromPVLooseTight
 
bool fUseWeightsNoLep
 
int fVtxNdofCut
 
double fVtxZCut
 
edm::EDGetTokenT< CandidateViewtokenPFCandidates_
 
edm::EDGetTokenT< VertexCollectiontokenVertices_
 

Detailed Description

Definition at line 23 of file PuppiProducer.h.

Member Typedef Documentation

Definition at line 33 of file PuppiProducer.h.

Definition at line 30 of file PuppiProducer.h.

Definition at line 31 of file PuppiProducer.h.

Definition at line 36 of file PuppiProducer.h.

Definition at line 34 of file PuppiProducer.h.

Definition at line 35 of file PuppiProducer.h.

Definition at line 37 of file PuppiProducer.h.

Definition at line 32 of file PuppiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file PuppiProducer.cc.

References fClonePackedCands, fDZCut, fDZCutForChargedFromPUVtxs, fEtaMaxCharged, fEtaMinUseDZ, fNumOfPUVtxsForCharged, fPtMaxCharged, fPuppiContainer, fPuppiDiagnostics, fPuppiForLeptons, fUseDZ, fUseExistingWeights, fUseFromPVLooseTight, fUseWeightsNoLep, fVtxNdofCut, fVtxZCut, edm::ParameterSet::getParameter(), tokenPFCandidates_, tokenVertices_, and parallelization::uint().

25  {
26  fPuppiDiagnostics = iConfig.getParameter<bool>("puppiDiagnostics");
27  fPuppiForLeptons = iConfig.getParameter<bool>("puppiForLeptons");
28  fUseFromPVLooseTight = iConfig.getParameter<bool>("UseFromPVLooseTight");
29  fUseDZ = iConfig.getParameter<bool>("UseDeltaZCut");
30  fDZCut = iConfig.getParameter<double>("DeltaZCut");
31  fEtaMinUseDZ = iConfig.getParameter<double>("EtaMinUseDeltaZ");
32  fPtMaxCharged = iConfig.getParameter<double>("PtMaxCharged");
33  fEtaMaxCharged = iConfig.getParameter<double>("EtaMaxCharged");
34  fNumOfPUVtxsForCharged = iConfig.getParameter<uint>("NumOfPUVtxsForCharged");
35  fDZCutForChargedFromPUVtxs = iConfig.getParameter<double>("DeltaZCutForChargedFromPUVtxs");
36  fUseExistingWeights = iConfig.getParameter<bool>("useExistingWeights");
37  fUseWeightsNoLep = iConfig.getParameter<bool>("useWeightsNoLep");
38  fClonePackedCands = iConfig.getParameter<bool>("clonePackedCands");
39  fVtxNdofCut = iConfig.getParameter<int>("vtxNdofCut");
40  fVtxZCut = iConfig.getParameter<double>("vtxZCut");
41  fPuppiContainer = std::unique_ptr<PuppiContainer> ( new PuppiContainer(iConfig) );
42 
44  = consumes<CandidateView>(iConfig.getParameter<edm::InputTag>("candName"));
46  = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexName"));
47 
48 
49  produces<edm::ValueMap<float> > ();
50  produces<edm::ValueMap<LorentzVector> > ();
51  produces< edm::ValueMap<reco::CandidatePtr> >();
52 
54  produces<pat::PackedCandidateCollection>();
55  else
56  produces<reco::PFCandidateCollection>();
57 
58  if (fPuppiDiagnostics){
59  produces<double> ("PuppiNAlgos");
60  produces<std::vector<double>> ("PuppiRawAlphas");
61  produces<std::vector<double>> ("PuppiAlphas");
62  produces<std::vector<double>> ("PuppiAlphasMed");
63  produces<std::vector<double>> ("PuppiAlphasRms");
64  }
65 }
T getParameter(std::string const &) const
bool fUseFromPVLooseTight
Definition: PuppiProducer.h:51
double fDZCutForChargedFromPUVtxs
Definition: PuppiProducer.h:58
bool fUseWeightsNoLep
Definition: PuppiProducer.h:60
bool fPuppiDiagnostics
Definition: PuppiProducer.h:49
double fEtaMaxCharged
Definition: PuppiProducer.h:56
std::unique_ptr< PuppiContainer > fPuppiContainer
Definition: PuppiProducer.h:64
edm::EDGetTokenT< VertexCollection > tokenVertices_
Definition: PuppiProducer.h:45
bool fClonePackedCands
Definition: PuppiProducer.h:61
bool fPuppiForLeptons
Definition: PuppiProducer.h:50
double fPtMaxCharged
Definition: PuppiProducer.h:55
def uint(string)
uint fNumOfPUVtxsForCharged
Definition: PuppiProducer.h:57
bool fUseExistingWeights
Definition: PuppiProducer.h:59
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
Definition: PuppiProducer.h:44
double fEtaMinUseDZ
Definition: PuppiProducer.h:54
PuppiProducer::~PuppiProducer ( )
override

Definition at line 67 of file PuppiProducer.cc.

67  {
68 }

Member Function Documentation

void PuppiProducer::beginJob ( void  )
privatevirtual

Definition at line 370 of file PuppiProducer.cc.

370  {
371 }
void PuppiProducer::endJob ( void  )
privatevirtual

Definition at line 373 of file PuppiProducer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

373  {
374 }
void PuppiProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 376 of file PuppiProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, PuppiAlgo::fillDescriptionsPuppiAlgo(), and parallelization::uint().

376  {
378  desc.add<bool>("puppiDiagnostics", false);
379  desc.add<bool>("puppiForLeptons", false);
380  desc.add<bool>("UseFromPVLooseTight", false);
381  desc.add<bool>("UseDeltaZCut", true);
382  desc.add<double>("DeltaZCut", 0.3);
383  desc.add<double>("EtaMinUseDeltaZ", 0.);
384  desc.add<double>("PtMaxCharged", 0.);
385  desc.add<double>("EtaMaxCharged", 99999.);
386  desc.add<double>("PtMaxNeutrals", 200.);
387  desc.add<double>("PtMaxNeutralsStartSlope", 0.);
388  desc.add<uint>("NumOfPUVtxsForCharged", 0);
389  desc.add<double>("DeltaZCutForChargedFromPUVtxs", 0.2);
390  desc.add<bool>("useExistingWeights", false);
391  desc.add<bool>("useWeightsNoLep", false);
392  desc.add<bool>("clonePackedCands", false);
393  desc.add<int>("vtxNdofCut", 4);
394  desc.add<double>("vtxZCut", 24);
395  desc.add<edm::InputTag>("candName", edm::InputTag("particleFlow"));
396  desc.add<edm::InputTag>("vertexName", edm::InputTag("offlinePrimaryVertices"));
397  desc.add<bool>("applyCHS", true);
398  desc.add<bool>("invertPuppi", false);
399  desc.add<bool>("useExp", false);
400  desc.add<double>("MinPuppiWeight", .01);
401 
403 
404  descriptions.add("PuppiProducer", desc);
405 }
static void fillDescriptionsPuppiAlgo(edm::ParameterSetDescription &desc)
Definition: PuppiAlgo.cc:216
ParameterDescriptionBase * add(U const &iLabel, T const &value)
def uint(string)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PuppiProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 70 of file PuppiProducer.cc.

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

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

70  {
71 
72  // Get PFCandidate Collection
73  edm::Handle<CandidateView> hPFProduct;
74  iEvent.getByToken(tokenPFCandidates_,hPFProduct);
75  const CandidateView *pfCol = hPFProduct.product();
76 
77  // Get vertex collection w/PV as the first entry?
79  iEvent.getByToken(tokenVertices_,hVertexProduct);
80  const reco::VertexCollection *pvCol = hVertexProduct.product();
81 
82  int npv = 0;
83  const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
84  for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
85  if (!vtxIter->isFake() && vtxIter->ndof()>=fVtxNdofCut && std::abs(vtxIter->z())<=fVtxZCut)
86  npv++;
87  }
88 
89  //Fill the reco objects
90  fRecoObjCollection.clear();
91  fRecoObjCollection.reserve(pfCol->size());
92  for(auto const& aPF : *pfCol) {
93  RecoObj pReco;
94  pReco.pt = aPF.pt();
95  pReco.eta = aPF.eta();
96  pReco.phi = aPF.phi();
97  pReco.m = aPF.mass();
98  pReco.rapidity = aPF.rapidity();
99  pReco.charge = aPF.charge();
100  const reco::Vertex *closestVtx = nullptr;
101  double pDZ = -9999;
102  double pD0 = -9999;
103  uint pVtxId = 0;
104  const pat::PackedCandidate *lPack = dynamic_cast<const pat::PackedCandidate*>(&aPF);
105  if(lPack == nullptr ) {
106 
107  const reco::PFCandidate *pPF = dynamic_cast<const reco::PFCandidate*>(&aPF);
108  double curdz = 9999;
109  int closestVtxForUnassociateds = -9999;
110  const reco::TrackRef aTrackRef = pPF->trackRef();
111  bool lFirst = true;
112  for(auto const& aV : *pvCol) {
113  if(lFirst) {
114  if ( aTrackRef.isNonnull()) {
115  pDZ = aTrackRef->dz(aV.position());
116  pD0 = aTrackRef->d0();
117  } else if (pPF->gsfTrackRef().isNonnull()) {
118  pDZ = pPF->gsfTrackRef()->dz(aV.position());
119  pD0 = pPF->gsfTrackRef()->d0();
120  }
121  lFirst = false;
122  if(pDZ > -9999) pVtxId = 0;
123  }
124  if(aTrackRef.isNonnull() && aV.trackWeight(pPF->trackRef())>0) {
125  closestVtx = &aV;
126  break;
127  }
128  // in case it's unassocciated, keep more info
129  double tmpdz = 99999;
130  if ( aTrackRef.isNonnull() ) tmpdz = aTrackRef ->dz(aV.position());
131  else if ( pPF->gsfTrackRef().isNonnull() ) tmpdz = pPF->gsfTrackRef()->dz(aV.position());
132  if (std::abs(tmpdz) < curdz){
133  curdz = std::abs(tmpdz);
134  closestVtxForUnassociateds = pVtxId;
135  }
136  pVtxId++;
137 
138  }
139  int tmpFromPV = 0;
140  // mocking the miniAOD definitions
141  if (std::abs(pReco.charge) > 0){
142  if (closestVtx != nullptr && pVtxId > 0) tmpFromPV = 0;
143  if (closestVtx != nullptr && pVtxId == 0) tmpFromPV = 3;
144  if (closestVtx == nullptr && closestVtxForUnassociateds == 0) tmpFromPV = 2;
145  if (closestVtx == nullptr && closestVtxForUnassociateds != 0) tmpFromPV = 1;
146  }
147  pReco.dZ = pDZ;
148  pReco.d0 = pD0;
149  pReco.id = 0;
150  if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
151  else{
152  if (tmpFromPV == 0) {
153  pReco.id = 2;
154  if (fNumOfPUVtxsForCharged > 0 and (pVtxId <= fNumOfPUVtxsForCharged) and
156  pReco.id = 1;
157  } else if (tmpFromPV == 3){ pReco.id = 1; }
158  else if (tmpFromPV == 1 || tmpFromPV == 2){
159  pReco.id = 0;
160  if ((fPtMaxCharged > 0) and (pReco.pt > fPtMaxCharged))
161  pReco.id = 1;
162  else if (std::abs(pReco.eta) > fEtaMaxCharged)
163  pReco.id = 1;
164  else if ((fUseDZ) && (std::abs(pReco.eta) >= fEtaMinUseDZ))
165  pReco.id = (std::abs(pDZ) < fDZCut) ? 1 : 2;
166  else if (fUseFromPVLooseTight && tmpFromPV == 1)
167  pReco.id = 2;
168  else if (fUseFromPVLooseTight && tmpFromPV == 2)
169  pReco.id = 1;
170  }
171  }
172  }
173  else if(lPack->vertexRef().isNonnull() ) {
174  pDZ = lPack->dz();
175  pD0 = lPack->dxy();
176  pReco.dZ = pDZ;
177  pReco.d0 = pD0;
178 
179  pReco.id = 0;
180  if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
181  if (std::abs(pReco.charge) > 0){
182  if (lPack->fromPV() == 0){
183  pReco.id = 2;
185  for (size_t puVtx_idx = 1; puVtx_idx <= fNumOfPUVtxsForCharged && puVtx_idx < pvCol->size();
186  ++puVtx_idx) {
187  if (lPack->fromPV(puVtx_idx) >= 2) {
188  pReco.id = 1;
189  break;
190  }
191  }
192  }
193  } else if (lPack->fromPV() == (pat::PackedCandidate::PVUsedInFit)){ pReco.id = 1; }
194  else if (lPack->fromPV() == (pat::PackedCandidate::PVTight) || lPack->fromPV() == (pat::PackedCandidate::PVLoose)){
195  pReco.id = 0;
196  if ((fPtMaxCharged > 0) and (pReco.pt > fPtMaxCharged))
197  pReco.id = 1;
198  else if (std::abs(pReco.eta) > fEtaMaxCharged)
199  pReco.id = 1;
200  else if ((fUseDZ) && (std::abs(pReco.eta) >= fEtaMinUseDZ))
201  pReco.id = (std::abs(pDZ) < fDZCut) ? 1 : 2;
203  pReco.id = 2;
205  pReco.id = 1;
206  }
207  }
208  }
209 
210  fRecoObjCollection.push_back(pReco);
211 
212  }
213 
214  fPuppiContainer->initialize(fRecoObjCollection);
215  fPuppiContainer->setNPV( npv );
216 
217  std::vector<double> lWeights;
218  std::vector<PuppiCandidate> lCandidates;
219  if (!fUseExistingWeights){
220  //Compute the weights and get the particles
221  lWeights = fPuppiContainer->puppiWeights();
222  lCandidates = fPuppiContainer->puppiParticles();
223  }
224  else{
225  //Use the existing weights
226  int lPackCtr = 0;
227  for(auto const& aPF : *pfCol) {
228  const pat::PackedCandidate *lPack = dynamic_cast<const pat::PackedCandidate*>(&aPF);
229  float curpupweight = -1.;
230  if(lPack == nullptr ) {
231  // throw error
232  throw edm::Exception(edm::errors::LogicError,"PuppiProducer: cannot get weights since inputs are not PackedCandidates");
233  }
234  else{
235  if (fUseWeightsNoLep){ curpupweight = lPack->puppiWeightNoLep(); }
236  else{ curpupweight = lPack->puppiWeight(); }
237  }
238  lWeights.push_back(curpupweight);
239  PuppiCandidate curjet;
240  curjet.px = curpupweight*lPack->px();
241  curjet.py = curpupweight*lPack->py();
242  curjet.pz = curpupweight*lPack->pz();
243  curjet.e = curpupweight*lPack->energy();
244  curjet.pt = curpupweight*lPack->pt();
245  curjet.eta = lPack->eta();
246  curjet.rapidity = lPack->rapidity();
247  curjet.phi = lPack->phi();
248  curjet.m = curpupweight*lPack->mass();
249  lCandidates.push_back(curjet);
250  lPackCtr++;
251  }
252  }
253 
254  //Fill it into the event
255  std::unique_ptr<edm::ValueMap<float> > lPupOut(new edm::ValueMap<float>());
256  edm::ValueMap<float>::Filler lPupFiller(*lPupOut);
257  lPupFiller.insert(hPFProduct,lWeights.begin(),lWeights.end());
258  lPupFiller.fill();
259 
260  // This is a dummy to access the "translate" method which is a
261  // non-static member function even though it doesn't need to be.
262  // Will fix in the future.
263  static const reco::PFCandidate dummySinceTranslateIsNotStatic;
264 
265  // Fill a new PF/Packed Candidate Collection and write out the ValueMap of the new p4s.
266  // Since the size of the ValueMap must be equal to the input collection, we need
267  // to search the "puppi" particles to find a match for each input. If none is found,
268  // the input is set to have a four-vector of 0,0,0,0
271  std::unique_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
272  LorentzVectorCollection puppiP4s;
273  std::vector<reco::CandidatePtr> values(hPFProduct->size());
274 
275  int val = -1;
276  for ( auto const& aCand : *hPFProduct) {
277  val++;
278  std::unique_ptr<pat::PackedCandidate> pCand;
279  std::unique_ptr<reco::PFCandidate> pfCand;
281  const pat::PackedCandidate *cand = dynamic_cast<const pat::PackedCandidate*>(&aCand);
282  if(!cand)
283  throw edm::Exception(edm::errors::LogicError,"PuppiProducer: inputs are not PackedCandidates");
284  pCand.reset( new pat::PackedCandidate(*cand) );
285  } else {
286  auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(aCand.pdgId());
287  const reco::PFCandidate *cand = dynamic_cast<const reco::PFCandidate*>(&aCand);
288  pfCand.reset( new reco::PFCandidate( cand ? *cand : reco::PFCandidate(aCand.charge(), aCand.p4(), id) ) );
289  }
290  LorentzVector pVec;
291 
292  //get an index to a pup in lCandidates: either fUseExistingWeights with no skips or get from fPuppiContainer
293  int iPuppiMatched = fUseExistingWeights ? val : fPuppiContainer->recoToPup()[val];
294  if ( iPuppiMatched >= 0 ) {
295  auto const& puppiMatched = lCandidates[iPuppiMatched];
296  pVec.SetPxPyPzE(puppiMatched.px,puppiMatched.py,puppiMatched.pz,puppiMatched.e);
298  if(fPuppiForLeptons)
299  pCand->setPuppiWeight(pCand->puppiWeight(),lWeights[val]);
300  else
301  pCand->setPuppiWeight(lWeights[val],pCand->puppiWeightNoLep());
302  }
303  } else {
304  pVec.SetPxPyPzE( 0, 0, 0, 0);
306  pCand->setPuppiWeight(0,0);
307  }
308  }
309  puppiP4s.push_back( pVec );
310 
312  pCand->setP4(pVec);
313  pCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
314  fPackedPuppiCandidates->push_back(*pCand);
315  } else {
316  pfCand->setP4(pVec);
317  pfCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
318  fPuppiCandidates->push_back(*pfCand);
319  }
320  }
321 
322  //Compute the modified p4s
323  edm::ValueMap<LorentzVector>::Filler p4PupFiller(*p4PupOut);
324  p4PupFiller.insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
325  p4PupFiller.fill();
326 
327  iEvent.put(std::move(lPupOut));
328  iEvent.put(std::move(p4PupOut));
331  for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
332  reco::CandidatePtr pkref( oh, ic );
333  values[ic] = pkref;
334  }
335  } else {
337  for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
338  reco::CandidatePtr pkref( oh, ic );
339  values[ic] = pkref;
340  }
341  }
342  std::unique_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
344  filler.insert(hPFProduct, values.begin(), values.end());
345  filler.fill();
346  iEvent.put(std::move(pfMap_p));
347 
348 
351 
352  // all the different alphas per particle
353  // THE alpha per particle
354  std::unique_ptr<std::vector<double> > theAlphas(new std::vector<double>(fPuppiContainer->puppiAlphas()));
355  std::unique_ptr<std::vector<double> > theAlphasMed(new std::vector<double>(fPuppiContainer->puppiAlphasMed()));
356  std::unique_ptr<std::vector<double> > theAlphasRms(new std::vector<double>(fPuppiContainer->puppiAlphasRMS()));
357  std::unique_ptr<std::vector<double> > alphas(new std::vector<double>(fPuppiContainer->puppiRawAlphas()));
358  std::unique_ptr<double> nalgos(new double(fPuppiContainer->puppiNAlgos()));
359 
360  iEvent.put(std::move(alphas),"PuppiRawAlphas");
361  iEvent.put(std::move(nalgos),"PuppiNAlgos");
362  iEvent.put(std::move(theAlphas),"PuppiAlphas");
363  iEvent.put(std::move(theAlphasMed),"PuppiAlphasMed");
364  iEvent.put(std::move(theAlphasRms),"PuppiAlphasRms");
365  }
366 
367 }
float puppiWeight() const
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
bool fUseFromPVLooseTight
Definition: PuppiProducer.h:51
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double px() const override
x coordinate of momentum vector
float puppiWeightNoLep() const
Weight from full PUPPI.
float d0
Definition: RecoObj.h:28
double fDZCutForChargedFromPUVtxs
Definition: PuppiProducer.h:58
bool fUseWeightsNoLep
Definition: PuppiProducer.h:60
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< reco::PFCandidate > PFOutputCollection
Definition: PuppiProducer.h:35
Definition: RecoObj.h:4
bool fPuppiDiagnostics
Definition: PuppiProducer.h:49
std::vector< pat::PackedCandidate > PackedOutputCollection
Definition: PuppiProducer.h:36
std::vector< RecoObj > fRecoObjCollection
Definition: PuppiProducer.h:65
size_type size() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const reco::VertexRef vertexRef() const
double fEtaMaxCharged
Definition: PuppiProducer.h:56
std::unique_ptr< PuppiContainer > fPuppiContainer
Definition: PuppiProducer.h:64
int charge
Definition: RecoObj.h:29
double pz() const override
z coordinate of momentum vector
edm::EDGetTokenT< VertexCollection > tokenVertices_
Definition: PuppiProducer.h:45
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
int id
Definition: RecoObj.h:18
double rapidity() const override
rapidity
float phi
Definition: RecoObj.h:17
const PVAssoc fromPV(size_t ipv=0) const
std::unique_ptr< PackedOutputCollection > fPackedPuppiCandidates
Definition: PuppiProducer.h:67
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool fClonePackedCands
Definition: PuppiProducer.h:61
double energy() const override
energy
math::XYZTLorentzVector LorentzVector
double pt() const override
transverse momentum
edm::View< reco::Candidate > CandidateView
Definition: PuppiProducer.h:33
bool fPuppiForLeptons
Definition: PuppiProducer.h:50
std::vector< LorentzVector > LorentzVectorCollection
double eta() const override
momentum pseudorapidity
double phi() const override
momentum azimuthal angle
float m
Definition: RecoObj.h:17
T const * product() const
Definition: Handle.h:74
double fPtMaxCharged
Definition: PuppiProducer.h:55
def uint(string)
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:233
float eta
Definition: RecoObj.h:17
uint fNumOfPUVtxsForCharged
Definition: PuppiProducer.h:57
bool fUseExistingWeights
Definition: PuppiProducer.h:59
double mass() const override
mass
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:480
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
Definition: PuppiProducer.h:44
virtual float dxy() const
dxy with respect to the PV ref
std::unique_ptr< PFOutputCollection > fPuppiCandidates
Definition: PuppiProducer.h:66
def move(src, dest)
Definition: eostools.py:511
double fEtaMinUseDZ
Definition: PuppiProducer.h:54

Member Data Documentation

bool PuppiProducer::fClonePackedCands
private

Definition at line 61 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

float PuppiProducer::fDZCut
private

Definition at line 53 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

double PuppiProducer::fDZCutForChargedFromPUVtxs
private

Definition at line 58 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

double PuppiProducer::fEtaMaxCharged
private

Definition at line 56 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

double PuppiProducer::fEtaMinUseDZ
private

Definition at line 54 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

uint PuppiProducer::fNumOfPUVtxsForCharged
private

Definition at line 57 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

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

Definition at line 67 of file PuppiProducer.h.

Referenced by produce().

std::string PuppiProducer::fPFName
private

Definition at line 47 of file PuppiProducer.h.

double PuppiProducer::fPtMaxCharged
private

Definition at line 55 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

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

Definition at line 66 of file PuppiProducer.h.

Referenced by produce().

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

Definition at line 64 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fPuppiDiagnostics
private

Definition at line 49 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fPuppiForLeptons
private

Definition at line 50 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

std::string PuppiProducer::fPuppiName
private

Definition at line 46 of file PuppiProducer.h.

std::string PuppiProducer::fPVName
private

Definition at line 48 of file PuppiProducer.h.

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

Definition at line 65 of file PuppiProducer.h.

Referenced by produce().

bool PuppiProducer::fUseDZ
private

Definition at line 52 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fUseExistingWeights
private

Definition at line 59 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fUseFromPVLooseTight
private

Definition at line 51 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

bool PuppiProducer::fUseWeightsNoLep
private

Definition at line 60 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

int PuppiProducer::fVtxNdofCut
private

Definition at line 62 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

double PuppiProducer::fVtxZCut
private

Definition at line 63 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

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

Definition at line 44 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().

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

Definition at line 45 of file PuppiProducer.h.

Referenced by produce(), and PuppiProducer().