CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
33 //#include "DataFormats/L1Trigger/interface/BXVector.h"
35 
36 //
37 // class declaration
38 //
39 
41  public:
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47  private:
48  virtual void beginStream(edm::StreamID) override;
49  virtual void produce(edm::Event&, const edm::EventSetup&) override;
50  virtual void endStream() override;
51 
52  //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
53  //virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
54  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
55  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
56 
57  // ----------member data ---------------------------
58  bool doRefs_;
61 };
62 
63 //
64 // constants, enums and typedefs
65 //
66 
67 
68 //
69 // static data member definitions
70 //
71 
72 //
73 // constructors and destructor
74 //
76 {
77 
78  //now do what ever other initialization is needed
79  src_ = iConfig.getParameter<edm::InputTag>( "src" );
80  doRefs_ = iConfig.getParameter<bool>("doRefs");
81  token_ = consumes<l1t::JetBxCollection>(src_);
82 
83  //register your products
84  produces<vector<int>>( "jetPt" ).setBranchAlias( "jetPt");
85 
86  if(doRefs_) {
87 
88  produces<l1t::JetRefVector>( "l1tJetRef" ).setBranchAlias( "l1tJetRef");
89 
90  }
91 
92 }
93 
94 
96 {
97 
98  // do anything here that needs to be done at destruction time
99  // (e.g. close files, deallocate resources etc.)
100 
101 }
102 
103 
104 //
105 // member functions
106 //
107 
108 // ------------ method called to produce the data ------------
109 void
111 {
112  using namespace edm;
113 
114  unique_ptr<vector<int>> jetMom ( new vector<int> );
115  unique_ptr<l1t::JetRefVector> jetRef ( new l1t::JetRefVector );
116 
117  // retrieve the tracks
119  iEvent.getByToken( token_, jets );
120  if(!jets.isValid()) return;
121 
122  const int size = jets->size();
123  jetMom->reserve( size );
124 
126 
127  for (iter = jets->begin(0); iter != jets->end(0); ++iter){
128 
129  jetMom->push_back(iter->pt());
130 
131  l1t::JetRef myref(jets, jets->key(iter ));
132  jetRef->push_back(myref);
133 
134 
135  } // end for
136 
137  iEvent.put(std::move(jetMom),"jetPt");
138 
139  if (doRefs_) iEvent.put(std::move(jetRef),"l1tJetRef");
140 
141  return;
142 
143 }
144 
145 // ------------ method called once each stream before processing any runs, lumis or events ------------
146 void
148 {
149 }
150 
151 // ------------ method called once each stream after processing all runs, lumis and events ------------
152 void
154 }
155 
156 // ------------ method called when starting to processes a run ------------
157 /*
158 void
159 TestBXVectorRefProducer::beginRun(edm::Run const&, edm::EventSetup const&)
160 {
161 }
162 */
163 
164 // ------------ method called when ending the processing of a run ------------
165 /*
166 void
167 TestBXVectorRefProducer::endRun(edm::Run const&, edm::EventSetup const&)
168 {
169 }
170 */
171 
172 // ------------ method called when starting to processes a luminosity block ------------
173 /*
174 void
175 TestBXVectorRefProducer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
176 {
177 }
178 */
179 
180 // ------------ method called when ending the processing of a luminosity block ------------
181 /*
182 void
183 TestBXVectorRefProducer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
184 {
185 }
186 */
187 
188 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
189 void
191  //The following says we do not know what parameters are allowed so do no validation
192  // Please change this to state exactly what you do use, even if it is no parameters
194  desc.setUnknown();
195  descriptions.addDefault(desc);
196 }
197 
198 //define this as a plug-in
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
vector< PseudoJet > jets
def move
Definition: eostools.py:510
virtual void beginStream(edm::StreamID) override
TestBXVectorRefProducer(const edm::ParameterSet &)
edm::EDGetTokenT< l1t::JetBxCollection > token_
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual void endStream() override
tuple size
Write out results.
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:20