CMS 3D CMS Logo

NanoAODBaseCrossCleaner.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PhysicsTools/NanoAOD
4 // Class: NanoAODBaseCrossCleaner
5 //
13 //
14 // Original Author: Andrea Rizzi
15 // Created: Mon, 28 Aug 2017 09:26:39 GMT
16 //
17 //
18 
21 
22 //
23 // constructors and destructor
24 //
26  name_(params.getParameter<std::string>("name") ),
27  doc_(params.getParameter<std::string>("doc") ),
28  jets_(consumes<edm::View<pat::Jet>>( params.getParameter<edm::InputTag>("jets") )),
29  muons_(consumes<edm::View<pat::Muon>>( params.getParameter<edm::InputTag>("muons") )),
30  electrons_(consumes<edm::View<pat::Electron>>( params.getParameter<edm::InputTag>("electrons") )),
31  taus_(consumes<edm::View<pat::Tau>>( params.getParameter<edm::InputTag>("taus") )),
32  photons_(consumes<edm::View<pat::Photon>>( params.getParameter<edm::InputTag>("photons") )),
33  jetSel_(params.getParameter<std::string>("jetSel") ),
34  muonSel_(params.getParameter<std::string>("muonSel") ),
35  electronSel_(params.getParameter<std::string>("electronSel") ),
36  tauSel_(params.getParameter<std::string>("tauSel") ),
37  photonSel_(params.getParameter<std::string>("photonSel") ),
38  jetName_(params.getParameter<std::string>("jetName") ),
39  muonName_(params.getParameter<std::string>("muonName") ),
40  electronName_(params.getParameter<std::string>("electronName") ),
41  tauName_(params.getParameter<std::string>("tauName") ),
42  photonName_(params.getParameter<std::string>("photonName") )
43 
44 {
45  produces<nanoaod::FlatTable>("jets");
46  produces<nanoaod::FlatTable>("muons");
47  produces<nanoaod::FlatTable>("electrons");
48  produces<nanoaod::FlatTable>("taus");
49  produces<nanoaod::FlatTable>("photons");
50 
51 }
52 
53 
55 {
56 
57  // do anything here that needs to be done at destruction time
58  // (e.g. close files, deallocate resources etc.)
59 
60 }
61 
62 
63 //
64 // member functions
65 //
66 
67 // ------------ method called to produce the data ------------
68 
69 
70 void
72 {
73  using namespace edm;
75  iEvent.getByToken(jets_, jetsIn);
76  std::vector<uint8_t> jets;
77  for (const auto & j: *jetsIn) {jets.push_back(jetSel_(j));}
78  auto jetsTable = std::make_unique<nanoaod::FlatTable>(jetsIn->size(),jetName_,false,true);
79 
81  iEvent.getByToken(muons_, muonsIn);
82  std::vector<uint8_t> muons;
83  for (const auto & m: *muonsIn) {muons.push_back(muonSel_(m));}
84  auto muonsTable = std::make_unique<nanoaod::FlatTable>(muonsIn->size(),muonName_,false,true);
85 
86 
88  iEvent.getByToken(electrons_, electronsIn);
89  std::vector<uint8_t> eles;
90  for (const auto & e: *electronsIn) {eles.push_back(electronSel_(e));}
91  auto electronsTable = std::make_unique<nanoaod::FlatTable>(electronsIn->size(),electronName_,false,true);
92 
94  iEvent.getByToken(taus_, tausIn);
95  std::vector<uint8_t> taus;
96  for (const auto & t: *tausIn) {taus.push_back(tauSel_(t));}
97  auto tausTable = std::make_unique<nanoaod::FlatTable>(tausIn->size(),tauName_,false,true);
98 
100  iEvent.getByToken(photons_, photonsIn);
101  std::vector<uint8_t> photons;
102  for (const auto & p: *photonsIn) {photons.push_back(photonSel_(p));}
103  auto photonsTable = std::make_unique<nanoaod::FlatTable>(photonsIn->size(),photonName_,false,true);
104 
105 
106  objectSelection(*jetsIn,*muonsIn,*electronsIn,*tausIn,*photonsIn,jets,muons,eles,taus,photons);
107 
108  muonsTable->addColumn<uint8_t>(name_,muons,doc_,nanoaod::FlatTable::UInt8Column);
109  jetsTable->addColumn<uint8_t>(name_,jets,doc_,nanoaod::FlatTable::UInt8Column);
110  electronsTable->addColumn<uint8_t>(name_,eles,doc_,nanoaod::FlatTable::UInt8Column);
111  tausTable->addColumn<uint8_t>(name_,taus,doc_,nanoaod::FlatTable::UInt8Column);
112  photonsTable->addColumn<uint8_t>(name_,photons,doc_,nanoaod::FlatTable::UInt8Column);
113 
114  iEvent.put(std::move(jetsTable),"jets");
115  iEvent.put(std::move(muonsTable),"muons");
116  iEvent.put(std::move(electronsTable),"electrons");
117  iEvent.put(std::move(tausTable),"taus");
118  iEvent.put(std::move(photonsTable),"photons");
119 
120 }
121 
122 // ------------ method called once each stream before processing any runs, lumis or events ------------
123 void
125 {
126 }
127 
128 // ------------ method called once each stream after processing all runs, lumis and events ------------
129 void
131 }
132 
133 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
134 void
136  //The following says we do not know what parameters are allowed so do no validation
137  // Please change this to state exactly what you do use, even if it is no parameters
139  desc.setUnknown();
140  descriptions.addDefault(desc);
141 }
142 
143 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
Definition: Photon.py:1
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
const StringCutObjectSelector< pat::Jet > jetSel_
Definition: HeavyIon.h:7
const StringCutObjectSelector< pat::Muon > muonSel_
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
Definition: Muon.py:1
Definition: Jet.py:1
vector< PseudoJet > jets
const StringCutObjectSelector< pat::Photon > photonSel_
void beginStream(edm::StreamID) override
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Tau.py:1
const StringCutObjectSelector< pat::Tau > tauSel_
HLT enums.
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const StringCutObjectSelector< pat::Electron > electronSel_
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
virtual void objectSelection(const edm::View< pat::Jet > &jets, const edm::View< pat::Muon > &muons, const edm::View< pat::Electron > &eles, const edm::View< pat::Tau > &taus, const edm::View< pat::Photon > &photons, std::vector< uint8_t > &jetBits, std::vector< uint8_t > &muonBits, std::vector< uint8_t > &eleBits, std::vector< uint8_t > &tauBits, std::vector< uint8_t > &photonBits)
def move(src, dest)
Definition: eostools.py:510
NanoAODBaseCrossCleaner(const edm::ParameterSet &)