CMS 3D CMS Logo

PATTauSignalCandidatesProducer.cc
Go to the documentation of this file.
7 #include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" //MB: can use CompositePtrCandidate, but dictionaries not defined
10 
12 public:
15 
16  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
17  void produce(edm::Event&, const edm::EventSetup&) override;
18 
19 private:
20  //--- configuration parameters
22  const bool storeLostTracks_;
23 };
24 
26  : tausToken_(consumes<pat::TauCollection>(cfg.getParameter<edm::InputTag>("src"))),
27  storeLostTracks_(cfg.getParameter<bool>("storeLostTracks")) {
28  produces<std::vector<reco::VertexCompositePtrCandidate>>();
29 }
30 
32  // Get the vector of taus
34  evt.getByToken(tausToken_, inputTaus);
35 
36  auto outputCands = std::make_unique<std::vector<reco::VertexCompositePtrCandidate>>();
37  outputCands->reserve(inputTaus->size() * 3); //avarage number of tau signal cands
38  for (size_t iTau = 0; iTau < inputTaus->size(); ++iTau) {
39  for (const auto& cand : (*inputTaus)[iTau].signalCands()) {
41  outCand.setStatus(iTau); //trick to store index of the mother tau to be used in NanoAOD
42  outCand.addDaughter(cand);
43  outputCands->push_back(outCand);
44  }
45  if (storeLostTracks_) {
46  for (const auto& cand : (*inputTaus)[iTau].signalLostTracks()) {
48  outCand.setStatus(iTau); //trick to store index of the mother tau to be used in NanoAOD
49  auto pdgId = cand->pdgId();
50  outCand.setPdgId(
51  pdgId + 10000 * ((pdgId >= 0) -
52  (pdgId < 0))); // increase abs(pdgId) by 10000 to distingish from "true" signal candidates
53  outCand.addDaughter(cand);
54  outputCands->push_back(outCand);
55  }
56  }
57  }
58 
59  evt.put(std::move(outputCands));
60 }
61 
63  // patTauDecayCandidatesProducer
65 
66  desc.add<edm::InputTag>("src", edm::InputTag("slimmedTaus"));
67  desc.add<bool>("storeLostTracks", true)
68  ->setComment("If true, lostTracks will be stored together with other candidates with pdgId=+-10211");
69 
70  descriptions.addWithDefaultLabel(desc);
71 }
72 
74 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< pat::TauCollection > tausToken_
std::vector< Tau > TauCollection
Definition: Tau.h:35
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Definition: HeavyIon.h:7
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
PATTauSignalCandidatesProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
HLT enums.
void addDaughter(const CandidatePtr &)
add a daughter via a reference
void setStatus(int status) final
set status word
void setPdgId(int pdgId) final
def move(src, dest)
Definition: eostools.py:511