1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// -*- C++ -*-
//
// Package: HLTrigger/TestBXVectorRefProducer
// Class: TestBXVectorRefProducer
//
/**\class TestBXVectorRefProducer TestBXVectorRefProducer.cc HLTrigger/TestBXVectorRefProducer/plugins/TestBXVectorRefProducer.cc
Description: Simple testing producer to test storing of Ref<BXVector> (example of <l1t::JetRef>) in the Event.
Implementation:
Pick up the BXVector<l1t::Jet> from the event and try to store the Refs back into the Event.
*/
//
// Original Author: Vladimir Rekovic
// Created: Fri, 12 Feb 2016 09:56:04 GMT
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"
//#include "DataFormats/L1Trigger/interface/BXVector.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
//
// class declaration
//
class TestBXVectorRefProducer : public edm::stream::EDProducer<> {
public:
explicit TestBXVectorRefProducer(const edm::ParameterSet&);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
private:
void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------
bool doRefs_;
edm::InputTag src_;
edm::EDGetTokenT<l1t::JetBxCollection> token_;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
TestBXVectorRefProducer::TestBXVectorRefProducer(const edm::ParameterSet& iConfig) {
//now do what ever other initialization is needed
src_ = iConfig.getParameter<edm::InputTag>("src");
doRefs_ = iConfig.getParameter<bool>("doRefs");
token_ = consumes<l1t::JetBxCollection>(src_);
//register your products
produces<vector<int>>("jetPt").setBranchAlias("jetPt");
if (doRefs_) {
produces<l1t::JetRefVector>("l1tJetRef").setBranchAlias("l1tJetRef");
}
}
//
// member functions
//
// ------------ method called to produce the data ------------
void TestBXVectorRefProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
unique_ptr<vector<int>> jetMom(new vector<int>);
unique_ptr<l1t::JetRefVector> jetRef(new l1t::JetRefVector);
// retrieve the tracks
Handle<l1t::JetBxCollection> jets;
iEvent.getByToken(token_, jets);
if (!jets.isValid())
return;
const int size = jets->size();
jetMom->reserve(size);
l1t::JetBxCollection::const_iterator iter;
for (iter = jets->begin(0); iter != jets->end(0); ++iter) {
jetMom->push_back(iter->pt());
l1t::JetRef myref(jets, jets->key(iter));
jetRef->push_back(myref);
} // end for
iEvent.put(std::move(jetMom), "jetPt");
if (doRefs_)
iEvent.put(std::move(jetRef), "l1tJetRef");
return;
}
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void TestBXVectorRefProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}
// declare this class as a framework plugin
DEFINE_FWK_MODULE(TestBXVectorRefProducer);
|