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 
21 
23 
28 
30  public:
33  void produce(edm::Event& evt, const edm::EventSetup& es) override;
34  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
35 
36  private:
39 };
40 
42  src_ = pset.getParameter<edm::InputTag>("src");
43  token = consumes<reco::CandidateView>(src_);
44  produces<reco::RecoTauPiZeroCollection>("pizeros");
45  produces<reco::PFTauCollection>();
46 }
48  auto piZerosOut = std::make_unique<reco::RecoTauPiZeroCollection>();
49  auto tausOut = std::make_unique<reco::PFTauCollection>();
50 
52  evt.getByToken(token, tauView);
53 
55  reco::tau::castView<reco::PFTauRefVector>(tauView);
56 
57  // Get the reference to the product of where the final pizeros will end up
58  reco::RecoTauPiZeroRefProd piZeroProd =
60 
61  for (size_t iTau = 0; iTau < taus.size(); ++iTau) {
62  // Make a copy
63  reco::PFTau myTau = *taus[iTau];
64  // The ref vectors that will be filled
65  reco::RecoTauPiZeroRefVector signalPiZeroRefs;
66  reco::RecoTauPiZeroRefVector isolationPiZeroRefs;
67 
68  // Copy the PiZeros into the new vector, while updating what refs they will
69  // have
70  const reco::RecoTauPiZeroCollection& signalPiZeros =
71  myTau.signalPiZeroCandidates();
72 
73  for (size_t iPiZero = 0; iPiZero < signalPiZeros.size(); ++iPiZero) {
74  piZerosOut->push_back(signalPiZeros[iPiZero]);
75  // Figure out what the ref for this pizero will be in the new coll.
76  signalPiZeroRefs.push_back(
77  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
78  }
79 
80  const reco::RecoTauPiZeroCollection& isolationPiZeroCandidates =
82  for (size_t iPiZero = 0; iPiZero < isolationPiZeroCandidates.size(); ++iPiZero) {
83  piZerosOut->push_back(isolationPiZeroCandidates[iPiZero]);
84  // Figure out what the ref for this pizero will be in the new coll.
85  isolationPiZeroRefs.push_back(
86  reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size()-1));
87  }
88 
89  myTau.setSignalPiZeroCandidatesRefs(signalPiZeroRefs);
90  myTau.setIsolationPiZeroCandidatesRefs(isolationPiZeroRefs);
91 
92  tausOut->push_back(myTau);
93  }
94 
95  evt.put(std::move(piZerosOut), "pizeros");
96  evt.put(std::move(tausOut));
97 }
98 
99 void
101  // RecoTauPiZeroUnembedder
103  desc.add<edm::InputTag>("src", edm::InputTag("hpsPFTauProducerSansRefs"));
104  descriptions.add("RecoTauPiZeroUnembedder", desc);
105 }
106 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< RecoTauPiZero > RecoTauPiZeroCollection
collection of RecoTauPiZero objects
RecoTauPiZeroUnembedder(const edm::ParameterSet &pset)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:230
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
const std::vector< RecoTauPiZero > & isolationPiZeroCandidates() const
Retrieve the association of isolation region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:249
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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:260
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::CandidateView > token
void setSignalPiZeroCandidatesRefs(RecoTauPiZeroRefVector)
Definition: PFTau.cc:245