CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // user include files
26 
27 #include <typeinfo>
28 #include <string>
29 #include <vector>
30 
31 //
32 // class declaration
33 //
34 
35 template <typename T>
37 
38  public:
40  virtual ~HLTCollectionProducer();
41  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
42  virtual void produce(edm::Event&, const edm::EventSetup&);
43 
44  private:
46  std::vector<int> triggerTypes_;
47 };
48 
49 
50 //
51 // constructors and destructor
52 //
53 template <typename T>
55  hltObject_ ( iConfig.getParameter<edm::InputTag>("HLTObject") ),
56  triggerTypes_ ( iConfig.getParameter<std::vector<int> >("TriggerTypes") )
57 {
58  produces< std::vector<T> >();
59 }
60 
61 template <typename T>
63 
64 template<typename T>
65 void
68  desc.add<edm::InputTag> ("HLTObject", edm::InputTag("TriggerFilterObjectWithRefs"));
69  std::vector<int> triggerTypes;
70  desc.add<std::vector<int> > ("TriggerTypes",triggerTypes);
71  descriptions.add(std::string("hlt")+std::string(typeid(HLTCollectionProducer<T>).name()), desc);
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to produce the data ------------
79 template <typename T>
80 void
82 {
83 
84  std::auto_ptr<std::vector<T> > collection ( new std::vector<T>() );
85 
86  // get hold of collection of TriggerFilterObjectsWithRefs
88  iEvent.getByLabel(hltObject_, hltObject);
89  std::vector<edm::Ref<std::vector<T> > > objectRefs;
90 
91  for (size_t t=0; t<triggerTypes_.size(); ++t) {
92  objectRefs.clear();
93  hltObject->getObjects( triggerTypes_[t], objectRefs );
94  for (size_t i = 0; i < objectRefs.size(); ++i) {
95  collection->push_back(*objectRefs[i]);
96  }
97  }
98 
99  iEvent.put(collection);
100 
101 }
102 
103 #endif // HLTCollectionProducer_h
int i
Definition: DBlmapReader.cc:9
std::vector< int > triggerTypes_
HLTCollectionProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)