CMS 3D CMS Logo

HLTCollectionProducer.h
Go to the documentation of this file.
1 #ifndef HLTCollectionProducer_h
2 #define HLTCollectionProducer_h
3 
4 //
5 // Package: HLTCollectionProducer
6 // Class: HLTCollectionProducer
7 //
14 //
15 // Original Author: Ian Tomalin
16 //
17 
18 #include <string>
19 #include <vector>
20 
21 // user include files
30 
31 //
32 // class declaration
33 //
34 
35 template <typename T>
37 
38  public:
40  ~HLTCollectionProducer() override;
41  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
42  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
43 
44  private:
47  const std::vector<int> triggerTypes_;
48 };
49 
50 
51 //
52 // constructors and destructor
53 //
54 template <typename T>
56  hltObjectTag_ ( iConfig.getParameter<edm::InputTag>("HLTObject") ),
57  hltObjectToken_(consumes<trigger::TriggerFilterObjectWithRefs>(hltObjectTag_)),
58  triggerTypes_ ( iConfig.getParameter<std::vector<int> >("TriggerTypes") )
59 {
60  produces< std::vector<T> >();
61 }
62 
63 template <typename T>
65 
66 template<typename T>
67 void
70  desc.add<edm::InputTag> ("HLTObject", edm::InputTag("TriggerFilterObjectWithRefs"));
71  std::vector<int> triggerTypes;
72  desc.add<std::vector<int> > ("TriggerTypes",triggerTypes);
73  descriptions.add(defaultModuleLabel<HLTCollectionProducer<T>>(), desc);
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to produce the data ------------
81 template <typename T>
82 void
84 {
85 
86  std::unique_ptr<std::vector<T> > collection ( new std::vector<T>() );
87 
88  // get hold of collection of TriggerFilterObjectsWithRefs
90  iEvent.getByToken(hltObjectToken_, hltObject);
91  std::vector<edm::Ref<std::vector<T> > > objectRefs;
92 
93  for (size_t t=0; t<triggerTypes_.size(); ++t) {
94  objectRefs.clear();
95  hltObject->getObjects( triggerTypes_[t], objectRefs );
96  for (size_t i = 0; i < objectRefs.size(); ++i) {
97  collection->push_back(*objectRefs[i]);
98  }
99  }
100 
101  iEvent.put(std::move(collection));
102 
103 }
104 
105 #endif // HLTCollectionProducer_h
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::string defaultModuleLabel()
HLTCollectionProducer(const edm::ParameterSet &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
const std::vector< int > triggerTypes_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > hltObjectToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const edm::InputTag hltObjectTag_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
def move(src, dest)
Definition: eostools.py:511