CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauPiZeroUnembedder.cc
Go to the documentation of this file.
1 /*
2  * "Unembed" the pizeros in a reco::PFTau.
3  *
4  * This converts a collection of PFTaus which have their PiZeros stored
5  * as std::vector<RecoTauPiZeros>s to an output collection which has
6  * the PiZeros stored in a separate product, with the PiZeros stored as Refs
7  * within the tau. This will improve the de-serialization speed of the taus.
8  *
9  * Author: Evan K. Friis, UW Madison
10  *
11  */
12 
18 
20 
25 
27  public:
30  void produce(edm::Event& evt, const edm::EventSetup& es) override;
31  private:
34 };
35 
37  src_ = pset.getParameter<edm::InputTag>("src");
38  token = consumes<reco::CandidateView>(src_);
39  produces<reco::RecoTauPiZeroCollection>("pizeros");
40  produces<reco::PFTauCollection>();
41 }
43  std::auto_ptr<reco::RecoTauPiZeroCollection> piZerosOut(
45  std::auto_ptr<reco::PFTauCollection> tausOut(new reco::PFTauCollection);
46 
48  evt.getByToken(token, tauView);
49 
51  reco::tau::castView<reco::PFTauRefVector>(tauView);
52 
53  // Get the reference to the product of where the final pizeros will end up
54  reco::RecoTauPiZeroRefProd piZeroProd =
56 
57  for (size_t iTau = 0; iTau < taus.size(); ++iTau) {
58  // Make a copy
59  reco::PFTau myTau = *taus[iTau];
60  // The ref vectors that will be filled
61  reco::RecoTauPiZeroRefVector signalPiZeroRefs;
62  reco::RecoTauPiZeroRefVector isolationPiZeroRefs;
63 
64  // Copy the PiZeros into the new vector, while updating what refs they will
65  // have
66  const reco::RecoTauPiZeroCollection& signalPiZeros =
67  myTau.signalPiZeroCandidates();
68 
69  for (size_t iPiZero = 0; iPiZero < signalPiZeros.size(); ++iPiZero) {
70  piZerosOut->push_back(signalPiZeros[iPiZero]);
71  // Figure out what the ref for this pizero will be in the new coll.
72  signalPiZeroRefs.push_back(
73  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
74  }
75 
76  const reco::RecoTauPiZeroCollection& isolationPiZeroCandidates =
78  for (size_t iPiZero = 0; iPiZero < isolationPiZeroCandidates.size(); ++iPiZero) {
79  piZerosOut->push_back(isolationPiZeroCandidates[iPiZero]);
80  // Figure out what the ref for this pizero will be in the new coll.
81  isolationPiZeroRefs.push_back(
82  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
83  }
84 
85  myTau.setSignalPiZeroCandidatesRefs(signalPiZeroRefs);
86  myTau.setIsolationPiZeroCandidatesRefs(isolationPiZeroRefs);
87 
88  tausOut->push_back(myTau);
89  }
90 
91  evt.put(piZerosOut, "pizeros");
92  evt.put(tausOut);
93 }
94 
T getParameter(std::string const &) const
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< RecoTauPiZero > RecoTauPiZeroCollection
collection of RecoTauPiZero objects
RecoTauPiZeroUnembedder(const edm::ParameterSet &pset)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:91
void setIsolationPiZeroCandidatesRefs(const RecoTauPiZeroRefVector &)
Definition: PFTau.cc:110
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
const std::vector< RecoTauPiZero > & isolationPiZeroCandidates() const
Retrieve the association of isolation region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:114
void produce(edm::Event &evt, const edm::EventSetup &es) override
void setSignalPiZeroCandidatesRefs(const RecoTauPiZeroRefVector &)
Definition: PFTau.cc:106
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
edm::EDGetTokenT< reco::CandidateView > token