Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Concatenate.h
Go to the documentation of this file.
1 #ifndef UserCode_ICHiggsTauTau_Concatenate_h
2 #define UserCode_ICHiggsTauTau_Concatenate_h
3 
4 #include <vector>
5 #include <set>
6 #include <memory>
7 #include "FWCore/Framework/interface/EDProducer.h"
8 #include "FWCore/Framework/interface/Event.h"
9 #include "FWCore/Framework/interface/EventSetup.h"
10 #include "FWCore/ParameterSet/interface/ParameterSet.h"
11 #include "FWCore/Utilities/interface/InputTag.h"
12 #include "DataFormats/Common/interface/Handle.h"
14 
15 namespace ic {
16 
17 template <class T>
18 class Concatenate : public edm::EDProducer {
19  public:
20  explicit Concatenate(const edm::ParameterSet &);
21  ~Concatenate();
22 
23  private:
24  virtual void beginJob();
25  virtual void produce(edm::Event &, const edm::EventSetup &);
26  virtual void endJob();
27 
28  typedef std::vector<T> Vec;
29  typedef std::vector<edm::InputTag> VInputTag;
30 
31  std::vector<edm::InputTag> inputs_;
32 };
33 
34 // =============================
35 // Template class implementation
36 // =============================
37 template <class T>
38 Concatenate<T>::Concatenate(const edm::ParameterSet &config)
39  : inputs_(config.getParameter<VInputTag>("concatenate")) {
40  for(unsigned i = 0; i < inputs_.size(); ++i) {
41  consumes<Vec>(inputs_[i]);
42  }
43  produces<Vec>();
44 }
45 
46 template <class T>
48 
49 template <class T>
51 
52 template <class T>
53 void Concatenate<T>::endJob() {}
54 
55 template <class T>
56 void Concatenate<T>::produce(edm::Event &event,
57  const edm::EventSetup &setup) {
58  std::auto_ptr<Vec> product(new Vec());
59  for (unsigned i = 0; i < inputs_.size(); ++i) {
60  edm::Handle<Vec> vec;
61  event.getByLabel(inputs_[i], vec);
62  for (unsigned j = 0; j < vec->size(); ++j) {
63  product->push_back(vec->at(j));
64  }
65  }
66  event.put(product);
67 }
68 }
69 
70 #endif
Concatenate(const edm::ParameterSet &)
Definition: Concatenate.h:38
Definition: CaloJet.hh:9