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 
Hit
Definition: HitCollection.h:12
EcalRecHit
Definition: EcalRecHit.h:15
StripColMerger
CollectionMerger< edmNew::DetSetVector< SiStripCluster >, SiStripCluster > StripColMerger
Definition: CollectionMerger.cc:24
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
DTLayerId.h
HORecHit
Definition: HORecHit.h:11
RPCRecHitColMerger
CollectionMerger< edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit > >, RPCRecHit > RPCRecHitColMerger
Definition: CollectionMerger.cc:35
PixelColMerger
CollectionMerger< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > PixelColMerger
Definition: CollectionMerger.cc:23
ZDCRecHit.h
HBHERecHit
Definition: HBHERecHit.h:13
SiPixelCluster.h
cms::cuda::assert
assert(be >=bs)
ZDCRecHitColMerger
CollectionMerger< edm::SortedCollection< ZDCRecHit >, ZDCRecHit > ZDCRecHitColMerger
Definition: CollectionMerger.cc:31
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
RangeMap.h
edm::Handle
Definition: AssociativeIterator.h:50
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
CSCDetId.h
CollectionMerger
Definition: CollectionMerger.h:39
DetId
Definition: DetId.h:17
MakerMacros.h
HFRecHit
Definition: HFRecHit.h:11
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CastorRecHit
Definition: CastorRecHit.h:7
RPCRecHit
Definition: RPCRecHit.h:14
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
DTRecHit1DPair
Definition: DTRecHit1DPair.h:26
HORecHitColMerger
CollectionMerger< edm::SortedCollection< HORecHit >, HORecHit > HORecHitColMerger
Definition: CollectionMerger.cc:29
EcalRecHit.h
RPCDetId.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
CSCRecHit2D
Definition: CSCRecHit2D.h:18
SiStripCluster.h
HLT_FULL_cff.inputCollection
inputCollection
Definition: HLT_FULL_cff.py:11707
HFRecHitColMerger
CollectionMerger< edm::SortedCollection< HFRecHit >, HFRecHit > HFRecHitColMerger
Definition: CollectionMerger.cc:28
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DTRecHit1DPair.h
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
CastorRecHitColMerger
CollectionMerger< edm::SortedCollection< CastorRecHit >, CastorRecHit > CastorRecHitColMerger
Definition: CollectionMerger.cc:30
DTRecHitColMerger
CollectionMerger< edm::RangeMap< DTLayerId, edm::OwnVector< DTRecHit1DPair > >, DTRecHit1DPair > DTRecHitColMerger
Definition: CollectionMerger.cc:33
DTSLRecCluster.h
CSCRecHitColMerger
CollectionMerger< edm::RangeMap< CSCDetId, edm::OwnVector< CSCRecHit2D > >, CSCRecHit2D > CSCRecHitColMerger
Definition: CollectionMerger.cc:34
SortedCollection.h
RPCRecHit.h
ZDCRecHit
Definition: ZDCRecHit.h:11
CSCRecHit2D.h
HBHERecHitColMerger
CollectionMerger< edm::SortedCollection< HBHERecHit >, HBHERecHit > HBHERecHitColMerger
Definition: CollectionMerger.cc:27
genParticles_cff.map
map
Definition: genParticles_cff.py:11
OwnVector.h
SiStripCluster
Definition: SiStripCluster.h:8
CollectionMerger.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
EcalRecHitColMerger
CollectionMerger< edm::SortedCollection< EcalRecHit >, EcalRecHit > EcalRecHitColMerger
Definition: CollectionMerger.cc:26
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31