CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TestBXVectorRefProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTrigger/TestBXVectorRefProducer
4 // Class: TestBXVectorRefProducer
5 //
13 //
14 // Original Author: Vladimir Rekovic
15 // Created: Fri, 12 Feb 2016 09:56:04 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
31 
32 //#include "DataFormats/L1Trigger/interface/BXVector.h"
34 
35 //
36 // class declaration
37 //
38 
40 public:
42  ~TestBXVectorRefProducer() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void beginStream(edm::StreamID) override;
48  void produce(edm::Event&, const edm::EventSetup&) override;
49  void endStream() override;
50 
51  //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
52  //virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
53  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
54  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
55 
56  // ----------member data ---------------------------
57  bool doRefs_;
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
74  //now do what ever other initialization is needed
75  src_ = iConfig.getParameter<edm::InputTag>("src");
76  doRefs_ = iConfig.getParameter<bool>("doRefs");
77  token_ = consumes<l1t::JetBxCollection>(src_);
78 
79  //register your products
80  produces<vector<int>>("jetPt").setBranchAlias("jetPt");
81 
82  if (doRefs_) {
83  produces<l1t::JetRefVector>("l1tJetRef").setBranchAlias("l1tJetRef");
84  }
85 }
86 
88  // do anything here that needs to be done at destruction time
89  // (e.g. close files, deallocate resources etc.)
90 }
91 
92 //
93 // member functions
94 //
95 
96 // ------------ method called to produce the data ------------
98  using namespace edm;
99 
100  unique_ptr<vector<int>> jetMom(new vector<int>);
101  unique_ptr<l1t::JetRefVector> jetRef(new l1t::JetRefVector);
102 
103  // retrieve the tracks
105  iEvent.getByToken(token_, jets);
106  if (!jets.isValid())
107  return;
108 
109  const int size = jets->size();
110  jetMom->reserve(size);
111 
113 
114  for (iter = jets->begin(0); iter != jets->end(0); ++iter) {
115  jetMom->push_back(iter->pt());
116 
117  l1t::JetRef myref(jets, jets->key(iter));
118  jetRef->push_back(myref);
119 
120  } // end for
121 
122  iEvent.put(std::move(jetMom), "jetPt");
123 
124  if (doRefs_)
125  iEvent.put(std::move(jetRef), "l1tJetRef");
126 
127  return;
128 }
129 
130 // ------------ method called once each stream before processing any runs, lumis or events ------------
132 
133 // ------------ method called once each stream after processing all runs, lumis and events ------------
135 
136 // ------------ method called when starting to processes a run ------------
137 /*
138 void
139 TestBXVectorRefProducer::beginRun(edm::Run const&, edm::EventSetup const&)
140 {
141 }
142 */
143 
144 // ------------ method called when ending the processing of a run ------------
145 /*
146 void
147 TestBXVectorRefProducer::endRun(edm::Run const&, edm::EventSetup const&)
148 {
149 }
150 */
151 
152 // ------------ method called when starting to processes a luminosity block ------------
153 /*
154 void
155 TestBXVectorRefProducer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
156 {
157 }
158 */
159 
160 // ------------ method called when ending the processing of a luminosity block ------------
161 /*
162 void
163 TestBXVectorRefProducer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
164 {
165 }
166 */
167 
168 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
170  //The following says we do not know what parameters are allowed so do no validation
171  // Please change this to state exactly what you do use, even if it is no parameters
173  desc.setUnknown();
174  descriptions.addDefault(desc);
175 }
176 
177 // declare this class as a framework plugin
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
vector< PseudoJet > jets
def move
Definition: eostools.py:511
void beginStream(edm::StreamID) override
TestBXVectorRefProducer(const edm::ParameterSet &)
edm::EDGetTokenT< l1t::JetBxCollection > token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
tuple size
Write out results.