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 
54  reco::PFTauRefVector taus = reco::tau::castView<reco::PFTauRefVector>(tauView);
55 
56  // Get the reference to the product of where the final pizeros will end up
58 
59  for (size_t iTau = 0; iTau < taus.size(); ++iTau) {
60  // Make a copy
61  reco::PFTau myTau = *taus[iTau];
62  // The ref vectors that will be filled
63  reco::RecoTauPiZeroRefVector signalPiZeroRefs;
64  reco::RecoTauPiZeroRefVector isolationPiZeroRefs;
65 
66  // Copy the PiZeros into the new vector, while updating what refs they will
67  // have
68  const reco::RecoTauPiZeroCollection& signalPiZeros = myTau.signalPiZeroCandidates();
69 
70  for (size_t iPiZero = 0; iPiZero < signalPiZeros.size(); ++iPiZero) {
71  piZerosOut->push_back(signalPiZeros[iPiZero]);
72  // Figure out what the ref for this pizero will be in the new coll.
73  signalPiZeroRefs.push_back(reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size() - 1));
74  }
75 
76  const reco::RecoTauPiZeroCollection& isolationPiZeroCandidates = myTau.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(reco::RecoTauPiZeroRef(piZeroProd, piZerosOut->size() - 1));
81  }
82 
83  myTau.setSignalPiZeroCandidatesRefs(signalPiZeroRefs);
84  myTau.setIsolationPiZeroCandidatesRefs(isolationPiZeroRefs);
85 
86  tausOut->push_back(myTau);
87  }
88 
89  evt.put(std::move(piZerosOut), "pizeros");
90  evt.put(std::move(tausOut));
91 }
92 
94  // RecoTauPiZeroUnembedder
96  desc.add<edm::InputTag>("src", edm::InputTag("hpsPFTauProducerSansRefs"));
97  descriptions.add("RecoTauPiZeroUnembedder", desc);
98 }
99 
ConfigurationDescriptions.h
edm::RefProd
Definition: EDProductfwd.h:25
edm::Event::getRefBeforePut
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
PFTauFwd.h
RecoTauPiZeroUnembedder::~RecoTauPiZeroUnembedder
~RecoTauPiZeroUnembedder() override
Definition: RecoTauPiZeroUnembedder.cc:32
reco::PFTau::setIsolationPiZeroCandidatesRefs
void setIsolationPiZeroCandidatesRefs(RecoTauPiZeroRefVector)
Definition: PFTau.cc:270
edm::EDGetTokenT
Definition: EDGetToken.h:33
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
reco::PFTau
Definition: PFTau.h:36
edm::RefVector
Definition: EDProductfwd.h:27
RecoTauPiZeroUnembedder::RecoTauPiZeroUnembedder
RecoTauPiZeroUnembedder(const edm::ParameterSet &pset)
Definition: RecoTauPiZeroUnembedder.cc:41
edm::Handle
Definition: AssociativeIterator.h:50
RecoTauPiZero.h
edm::Ref
Definition: AssociativeIterator.h:58
reco::PFTau::isolationPiZeroCandidates
const std::vector< RecoTauPiZero > & isolationPiZeroCandidates() const
Retrieve the association of isolation region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:259
MakerMacros.h
reco::PFTau::signalPiZeroCandidates
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:240
RecoTauPiZeroUnembedder::src_
edm::InputTag src_
Definition: RecoTauPiZeroUnembedder.cc:37
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
RecoTauCommonUtilities.h
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
reco::RecoTauPiZeroCollection
std::vector< RecoTauPiZero > RecoTauPiZeroCollection
collection of RecoTauPiZero objects
Definition: RecoTauPiZeroFwd.h:9
Event.h
reco::PFTau::setSignalPiZeroCandidatesRefs
void setSignalPiZeroCandidatesRefs(RecoTauPiZeroRefVector)
Definition: PFTau.cc:255
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
RecoTauPiZeroUnembedder::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: RecoTauPiZeroUnembedder.cc:93
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
RecoTauPiZeroUnembedder::produce
void produce(edm::Event &evt, const edm::EventSetup &es) override
Definition: RecoTauPiZeroUnembedder.cc:47
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
RecoTauPiZeroUnembedder
Definition: RecoTauPiZeroUnembedder.cc:29
Frameworkfwd.h
PFTau.h
EventSetup.h
RecoTauPiZeroFwd.h
ParameterSet.h
edm::Event
Definition: Event.h:73
RecoTauPiZeroUnembedder::token
edm::EDGetTokenT< reco::CandidateView > token
Definition: RecoTauPiZeroUnembedder.cc:38
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27