CMS 3D CMS Logo

CollectionMerger.h
Go to the documentation of this file.
1 
12 #ifndef TauAnalysis_MCEmbeddingTools_CollectionMerger_H
13 #define TauAnalysis_MCEmbeddingTools_CollectionMerger_H
14 
22 
26 
32 
33 //#include "TauAnalysis/MCEmbeddingTools/interface/embeddingAuxFunctions.h"
34 #include <string>
35 #include <iostream>
36 #include <map>
37 
38 template <typename T1, typename T2>
40 public:
41  explicit CollectionMerger(const edm::ParameterSet &);
42  ~CollectionMerger() override;
43 
44 private:
45  void produce(edm::Event &, const edm::EventSetup &) override;
46 
47  typedef T1 MergeCollection;
48  typedef T2 BaseHit;
49  std::map<std::string, std::vector<edm::EDGetTokenT<MergeCollection> > > inputs_;
50 
51  void fill_output_obj(std::unique_ptr<MergeCollection> &output,
52  std::vector<edm::Handle<MergeCollection> > &inputCollections);
53  void fill_output_obj_tracker(std::unique_ptr<MergeCollection> &output,
54  std::vector<edm::Handle<MergeCollection> > &inputCollections,
55  bool print_pixel = false);
56  void fill_output_obj_calo(std::unique_ptr<MergeCollection> &output,
57  std::vector<edm::Handle<MergeCollection> > &inputCollections);
58  void fill_output_obj_muonchamber(std::unique_ptr<MergeCollection> &output,
59  std::vector<edm::Handle<MergeCollection> > &inputCollections);
60 };
61 
62 template <typename T1, typename T2>
64  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("mergCollections");
65  for (auto const &inCollection : inCollections) {
66  inputs_[inCollection.instance()].push_back(consumes<MergeCollection>(inCollection));
67  }
68  for (const auto &toproduce : inputs_) {
69  // std::cout<<toproduce.first<<"\t"<<toproduce.second.size()<<std::endl;
70  produces<MergeCollection>(toproduce.first);
71  }
72 }
73 
74 template <typename T1, typename T2>
76  // nothing to be done yet...
77 }
78 
79 template <typename T1, typename T2>
81  for (auto input_ : inputs_) {
82  std::unique_ptr<MergeCollection> output(new MergeCollection());
83  std::vector<edm::Handle<MergeCollection> > inputCollections;
84  inputCollections.resize(input_.second.size());
85  for (unsigned id = 0; id < input_.second.size(); id++) {
86  iEvent.getByToken(input_.second[id], inputCollections[id]);
87  }
88  fill_output_obj(output, inputCollections);
89  iEvent.put(std::move(output), input_.first);
90  }
91 }
92 #endif
Handle.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
TrackDetectorAssociator.h
Muon.h
EDProducer.h
edm::Handle
Definition: AssociativeIterator.h:50
CollectionMerger::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CollectionMerger.h:80
CollectionMerger::inputs_
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection > > > inputs_
Definition: CollectionMerger.h:49
CollectionMerger
Definition: CollectionMerger.h:39
MakerMacros.h
CollectionMerger::~CollectionMerger
~CollectionMerger() override
Definition: CollectionMerger.h:75
CollectionMerger::fill_output_obj_muonchamber
void fill_output_obj_muonchamber(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
Definition: CollectionMerger.cc:93
CollectionMerger::fill_output_obj
void fill_output_obj(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
Definition: CollectionMerger.cc:116
EcalRecHit.h
CollectionMerger::fill_output_obj_tracker
void fill_output_obj_tracker(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections, bool print_pixel=false)
Definition: CollectionMerger.cc:39
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CollectionMerger::CollectionMerger
CollectionMerger(const edm::ParameterSet &)
Definition: CollectionMerger.h:63
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
OmniClusterRef.h
BaseTrackerRecHit.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
CollectionMerger::MergeCollection
T1 MergeCollection
Definition: CollectionMerger.h:47
TrackingComponentsRecord.h
SortedCollection.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CollectionMerger::BaseHit
T2 BaseHit
Definition: CollectionMerger.h:48
ParameterSet.h
edm::Event
Definition: Event.h:73
MuonEnergy.h
TrackAssociatorParameters.h
DetSetVectorNew.h
CollectionMerger::fill_output_obj_calo
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
Definition: CollectionMerger.cc:68