CMS 3D CMS Logo

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  auto piZerosOut = std::make_unique<reco::RecoTauPiZeroCollection>();
44  auto tausOut = std::make_unique<reco::PFTauCollection>();
45 
47  evt.getByToken(token, tauView);
48 
50  reco::tau::castView<reco::PFTauRefVector>(tauView);
51 
52  // Get the reference to the product of where the final pizeros will end up
53  reco::RecoTauPiZeroRefProd piZeroProd =
55 
56  for (size_t iTau = 0; iTau < taus.size(); ++iTau) {
57  // Make a copy
58  reco::PFTau myTau = *taus[iTau];
59  // The ref vectors that will be filled
60  reco::RecoTauPiZeroRefVector signalPiZeroRefs;
61  reco::RecoTauPiZeroRefVector isolationPiZeroRefs;
62 
63  // Copy the PiZeros into the new vector, while updating what refs they will
64  // have
65  const reco::RecoTauPiZeroCollection& signalPiZeros =
66  myTau.signalPiZeroCandidates();
67 
68  for (size_t iPiZero = 0; iPiZero < signalPiZeros.size(); ++iPiZero) {
69  piZerosOut->push_back(signalPiZeros[iPiZero]);
70  // Figure out what the ref for this pizero will be in the new coll.
71  signalPiZeroRefs.push_back(
72  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
73  }
74 
75  const reco::RecoTauPiZeroCollection& isolationPiZeroCandidates =
77  for (size_t iPiZero = 0; iPiZero < isolationPiZeroCandidates.size(); ++iPiZero) {
78  piZerosOut->push_back(isolationPiZeroCandidates[iPiZero]);
79  // Figure out what the ref for this pizero will be in the new coll.
80  isolationPiZeroRefs.push_back(
81  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
82  }
83 
84  myTau.setSignalPiZeroCandidatesRefs(signalPiZeroRefs);
85  myTau.setIsolationPiZeroCandidatesRefs(isolationPiZeroRefs);
86 
87  tausOut->push_back(myTau);
88  }
89 
90  evt.put(std::move(piZerosOut), "pizeros");
91  evt.put(std::move(tausOut));
92 }
93 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< RecoTauPiZero > RecoTauPiZeroCollection
collection of RecoTauPiZero objects
RecoTauPiZeroUnembedder(const edm::ParameterSet &pset)
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:127
RefProd< PROD > getRefBeforePut()
Definition: Event.h:167
const std::vector< RecoTauPiZero > & isolationPiZeroCandidates() const
Retrieve the association of isolation region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:146
void produce(edm::Event &evt, const edm::EventSetup &es) override
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
void setIsolationPiZeroCandidatesRefs(RecoTauPiZeroRefVector)
Definition: PFTau.cc:157
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::CandidateView > token
void setSignalPiZeroCandidatesRefs(RecoTauPiZeroRefVector)
Definition: PFTau.cc:142