CMS 3D CMS Logo

CollectionMerger.cc
Go to the documentation of this file.
3 
6 
9 
13 
19 
22 
25 
32 
36 
37 // -------- Here Tracker Merger -----------
38 template <typename T1, typename T2>
39 void CollectionMerger<T1, T2>::fill_output_obj_tracker(std::unique_ptr<MergeCollection> &output,
40  std::vector<edm::Handle<MergeCollection> > &inputCollections,
41  bool print_pixel) {
42  std::map<uint32_t, std::vector<BaseHit> > output_map;
43  // First merge the collections with the help of the output map
44  for (auto const &inputCollection : inputCollections) {
45  for (typename MergeCollection::const_iterator clustSet = inputCollection->begin();
46  clustSet != inputCollection->end();
47  ++clustSet) {
48  DetId detIdObject(clustSet->detId());
49  for (typename edmNew::DetSet<BaseHit>::const_iterator clustIt = clustSet->begin(); clustIt != clustSet->end();
50  ++clustIt) {
51  output_map[detIdObject.rawId()].push_back(*clustIt);
52  }
53  }
54  }
55  // Now save it into the standard CMSSW format, with the standard Filler
56  for (typename std::map<uint32_t, std::vector<BaseHit> >::const_iterator outHits = output_map.begin();
57  outHits != output_map.end();
58  ++outHits) {
59  DetId detIdObject(outHits->first);
60  typename MergeCollection::FastFiller spc(*output, detIdObject);
61  for (const auto &Hit : outHits->second) {
62  spc.push_back(Hit);
63  }
64  }
65 }
66 
67 template <typename T1, typename T2>
68 void CollectionMerger<T1, T2>::fill_output_obj_calo(std::unique_ptr<MergeCollection> &output,
69  std::vector<edm::Handle<MergeCollection> > &inputCollections) {
70  std::map<uint32_t, BaseHit> output_map;
71  // First merge the two collections again
72  for (auto const &inputCollection : inputCollections) {
73  for (typename MergeCollection::const_iterator recHit = inputCollection->begin(); recHit != inputCollection->end();
74  ++recHit) {
75  DetId detIdObject(recHit->detid().rawId());
76  T2 *akt_calo_obj = &output_map[detIdObject.rawId()];
77  float new_energy = akt_calo_obj->energy() + recHit->energy();
78  T2 newRecHit(*recHit);
79  newRecHit.setEnergy(new_energy);
80  *akt_calo_obj = newRecHit;
81  }
82  }
83  // Now save it into the standard CMSSW format
84  for (typename std::map<uint32_t, BaseHit>::const_iterator outHits = output_map.begin(); outHits != output_map.end();
85  ++outHits) {
86  output->push_back(outHits->second);
87  }
88  output->sort(); //Do a sort for this collection
89 }
90 
91 // -------- Here Muon Chamber Merger -----------
92 template <typename T1, typename T2>
94  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
95  std::map<uint32_t, std::vector<BaseHit> > output_map;
96  // First merge the collections with the help of the output map
97  for (auto const &inputCollection : inputCollections) {
98  for (typename MergeCollection::const_iterator recHit = inputCollection->begin(); recHit != inputCollection->end();
99  ++recHit) {
100  DetId detIdObject(recHit->geographicalId());
101  output_map[detIdObject].push_back(*recHit);
102  }
103  }
104  // Now save it into the standard CMSSW format, with the standard Filler
105  for (typename std::map<uint32_t, std::vector<BaseHit> >::const_iterator outHits = output_map.begin();
106  outHits != output_map.end();
107  ++outHits) {
108  output->put((typename T1::id_iterator::value_type)outHits->first,
109  outHits->second.begin(),
110  outHits->second.end()); // The DTLayerId misses the automatic type cast
111  }
112 }
113 
114 // Here some overloaded functions, which are needed such that the right merger function is called for the indivudal Collections
115 template <typename T1, typename T2>
116 void CollectionMerger<T1, T2>::fill_output_obj(std::unique_ptr<MergeCollection> &output,
117  std::vector<edm::Handle<MergeCollection> > &inputCollections) {
118  assert(0); // CV: make sure general function never gets called;
119  // always use template specializations
120 }
121 
122 // Start with the Tracker collections
123 template <>
125  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
126  fill_output_obj_tracker(output, inputCollections, true);
127 }
128 
129 template <>
131  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
132  fill_output_obj_tracker(output, inputCollections);
133 }
134 
135 // Next are the Calo entries
136 template <>
138  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
139  fill_output_obj_calo(output, inputCollections);
140 }
141 
142 template <>
144  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
145  fill_output_obj_calo(output, inputCollections);
146 }
147 
148 template <>
150  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
151  fill_output_obj_calo(output, inputCollections);
152 }
153 
154 template <>
156  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
157  fill_output_obj_calo(output, inputCollections);
158 }
159 
160 template <>
162  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
163  fill_output_obj_calo(output, inputCollections);
164 }
165 
166 template <>
168  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
169  fill_output_obj_calo(output, inputCollections);
170 }
171 
172 // Here the Muon Chamber
173 template <>
175  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
176  fill_output_obj_muonchamber(output, inputCollections);
177 }
178 
179 template <>
181  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
182  fill_output_obj_muonchamber(output, inputCollections);
183 }
184 
185 template <>
187  std::unique_ptr<MergeCollection> &output, std::vector<edm::Handle<MergeCollection> > &inputCollections) {
188  fill_output_obj_muonchamber(output, inputCollections);
189 }
190 
193 
200 
CollectionMerger< edm::SortedCollection< HORecHit >, HORecHit > HORecHitColMerger
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CollectionMerger< edm::SortedCollection< CastorRecHit >, CastorRecHit > CastorRecHitColMerger
data_type const * const_iterator
Definition: DetSetNew.h:31
assert(be >=bs)
CollectionMerger< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > PixelColMerger
Definition: DetId.h:17
void fill_output_obj_muonchamber(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
CollectionMerger< edm::SortedCollection< ZDCRecHit >, ZDCRecHit > ZDCRecHitColMerger
Pixel cluster – collection of neighboring pixels above threshold.
void fill_output_obj(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
CollectionMerger< edmNew::DetSetVector< SiStripCluster >, SiStripCluster > StripColMerger
CollectionMerger< edm::RangeMap< DTLayerId, edm::OwnVector< DTRecHit1DPair > >, DTRecHit1DPair > DTRecHitColMerger
CollectionMerger< edm::RangeMap< CSCDetId, edm::OwnVector< CSCRecHit2D > >, CSCRecHit2D > CSCRecHitColMerger
CollectionMerger< edm::SortedCollection< HFRecHit >, HFRecHit > HFRecHitColMerger
CollectionMerger< edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit > >, RPCRecHit > RPCRecHitColMerger
void fill_output_obj_tracker(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections, bool print_pixel=false)
CollectionMerger< edm::SortedCollection< HBHERecHit >, HBHERecHit > HBHERecHitColMerger
CollectionMerger< edm::SortedCollection< EcalRecHit >, EcalRecHit > EcalRecHitColMerger