CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
46  void produce(edm::Event&, const edm::EventSetup&) override;
47 
48  // ----------member data ---------------------------
49  bool doRefs_;
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
66  //now do what ever other initialization is needed
67  src_ = iConfig.getParameter<edm::InputTag>("src");
68  doRefs_ = iConfig.getParameter<bool>("doRefs");
69  token_ = consumes<l1t::JetBxCollection>(src_);
70 
71  //register your products
72  produces<vector<int>>("jetPt").setBranchAlias("jetPt");
73 
74  if (doRefs_) {
75  produces<l1t::JetRefVector>("l1tJetRef").setBranchAlias("l1tJetRef");
76  }
77 }
78 
79 //
80 // member functions
81 //
82 
83 // ------------ method called to produce the data ------------
85  using namespace edm;
86 
87  unique_ptr<vector<int>> jetMom(new vector<int>);
88  unique_ptr<l1t::JetRefVector> jetRef(new l1t::JetRefVector);
89 
90  // retrieve the tracks
92  iEvent.getByToken(token_, jets);
93  if (!jets.isValid())
94  return;
95 
96  const int size = jets->size();
97  jetMom->reserve(size);
98 
100 
101  for (iter = jets->begin(0); iter != jets->end(0); ++iter) {
102  jetMom->push_back(iter->pt());
103 
104  l1t::JetRef myref(jets, jets->key(iter));
105  jetRef->push_back(myref);
106 
107  } // end for
108 
109  iEvent.put(std::move(jetMom), "jetPt");
110 
111  if (doRefs_)
112  iEvent.put(std::move(jetRef), "l1tJetRef");
113 
114  return;
115 }
116 
117 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
119  //The following says we do not know what parameters are allowed so do no validation
120  // Please change this to state exactly what you do use, even if it is no parameters
122  desc.setUnknown();
123  descriptions.addDefault(desc);
124 }
125 
126 // declare this class as a framework plugin
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TestBXVectorRefProducer(const edm::ParameterSet &)
edm::EDGetTokenT< l1t::JetBxCollection > token_
HLT enums.
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511