CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CollectionMerger< T1, T2 > Class Template Reference

#include <CollectionMerger.h>

Inheritance diagram for CollectionMerger< T1, T2 >:
edm::stream::EDProducer<>

Public Member Functions

 CollectionMerger (const edm::ParameterSet &)
 
 ~CollectionMerger () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef T2 BaseHit
 
typedef T1 MergeCollection
 

Private Member Functions

void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
template<>
void fill_output_obj (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)
 
void fill_output_obj_muonchamber (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
 
void fill_output_obj_tracker (std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections, bool print_pixel=false)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection > > > inputs_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

template<typename T1, typename T2>
class CollectionMerger< T1, T2 >

Author
Stefan Wayand; Christian Veelken, LLR

Definition at line 39 of file CollectionMerger.h.

Member Typedef Documentation

◆ BaseHit

template<typename T1 , typename T2 >
typedef T2 CollectionMerger< T1, T2 >::BaseHit
private

Definition at line 48 of file CollectionMerger.h.

◆ MergeCollection

template<typename T1 , typename T2 >
typedef T1 CollectionMerger< T1, T2 >::MergeCollection
private

Definition at line 47 of file CollectionMerger.h.

Constructor & Destructor Documentation

◆ CollectionMerger()

template<typename T1 , typename T2 >
CollectionMerger< T1, T2 >::CollectionMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 63 of file CollectionMerger.h.

63  {
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 (auto toproduce : inputs_) {
69  // std::cout<<toproduce.first<<"\t"<<toproduce.second.size()<<std::endl;
70  produces<MergeCollection>(toproduce.first);
71  }
72 }

References edm::ParameterSet::getParameter().

◆ ~CollectionMerger()

template<typename T1 , typename T2 >
CollectionMerger< T1, T2 >::~CollectionMerger ( )
override

Definition at line 75 of file CollectionMerger.h.

75  {
76  // nothing to be done yet...
77 }

Member Function Documentation

◆ fill_output_obj() [1/12]

template<typename T1 , typename T2 >
void CollectionMerger< T1, T2 >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 116 of file CollectionMerger.cc.

117  {
118  assert(0); // CV: make sure general function never gets called;
119  // always use template specializations
120 }

References cms::cuda::assert().

◆ fill_output_obj() [2/12]

template<>
void CollectionMerger< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 124 of file CollectionMerger.cc.

125  {
126  fill_output_obj_tracker(output, inputCollections, true);
127 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [3/12]

template<>
void CollectionMerger< edmNew::DetSetVector< SiStripCluster >, SiStripCluster >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 130 of file CollectionMerger.cc.

131  {
132  fill_output_obj_tracker(output, inputCollections);
133 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [4/12]

template<>
void CollectionMerger< edm::SortedCollection< EcalRecHit >, EcalRecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 137 of file CollectionMerger.cc.

138  {
139  fill_output_obj_calo(output, inputCollections);
140 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [5/12]

template<>
void CollectionMerger< edm::SortedCollection< HBHERecHit >, HBHERecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 143 of file CollectionMerger.cc.

144  {
145  fill_output_obj_calo(output, inputCollections);
146 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [6/12]

template<>
void CollectionMerger< edm::SortedCollection< HFRecHit >, HFRecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 149 of file CollectionMerger.cc.

150  {
151  fill_output_obj_calo(output, inputCollections);
152 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [7/12]

template<>
void CollectionMerger< edm::SortedCollection< HORecHit >, HORecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 155 of file CollectionMerger.cc.

156  {
157  fill_output_obj_calo(output, inputCollections);
158 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [8/12]

template<>
void CollectionMerger< edm::SortedCollection< CastorRecHit >, CastorRecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 161 of file CollectionMerger.cc.

162  {
163  fill_output_obj_calo(output, inputCollections);
164 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [9/12]

template<>
void CollectionMerger< edm::SortedCollection< ZDCRecHit >, ZDCRecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 167 of file CollectionMerger.cc.

168  {
169  fill_output_obj_calo(output, inputCollections);
170 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [10/12]

template<>
void CollectionMerger< edm::RangeMap< DTLayerId, edm::OwnVector< DTRecHit1DPair > >, DTRecHit1DPair >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 174 of file CollectionMerger.cc.

175  {
176  fill_output_obj_muonchamber(output, inputCollections);
177 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [11/12]

template<>
void CollectionMerger< edm::RangeMap< CSCDetId, edm::OwnVector< CSCRecHit2D > >, CSCRecHit2D >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 180 of file CollectionMerger.cc.

181  {
182  fill_output_obj_muonchamber(output, inputCollections);
183 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj() [12/12]

template<>
void CollectionMerger< edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit > >, RPCRecHit >::fill_output_obj ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 186 of file CollectionMerger.cc.

187  {
188  fill_output_obj_muonchamber(output, inputCollections);
189 }

References convertSQLitetoXML_cfg::output.

◆ fill_output_obj_calo()

template<typename T1 , typename T2 >
void CollectionMerger< T1, T2 >::fill_output_obj_calo ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 68 of file CollectionMerger.cc.

69  {
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 }

References PDWG_EXOHSCP_cff::inputCollection, convertSQLitetoXML_cfg::output, and rpcPointValidation_cfi::recHit.

◆ fill_output_obj_muonchamber()

template<typename T1 , typename T2 >
void CollectionMerger< T1, T2 >::fill_output_obj_muonchamber ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections 
)
private

Definition at line 93 of file CollectionMerger.cc.

94  {
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 }

References PDWG_EXOHSCP_cff::inputCollection, genParticles_cff::map, convertSQLitetoXML_cfg::output, and rpcPointValidation_cfi::recHit.

◆ fill_output_obj_tracker()

template<typename T1 , typename T2 >
void CollectionMerger< T1, T2 >::fill_output_obj_tracker ( std::unique_ptr< MergeCollection > &  output,
std::vector< edm::Handle< MergeCollection > > &  inputCollections,
bool  print_pixel = false 
)
private

Definition at line 39 of file CollectionMerger.cc.

41  {
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 }

References PDWG_EXOHSCP_cff::inputCollection, genParticles_cff::map, and convertSQLitetoXML_cfg::output.

◆ produce()

template<typename T1 , typename T2 >
void CollectionMerger< T1, T2 >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 80 of file CollectionMerger.h.

80  {
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 }

References iEvent, eostools::move(), and convertSQLitetoXML_cfg::output.

Member Data Documentation

◆ inputs_

template<typename T1 , typename T2 >
std::map<std::string, std::vector<edm::EDGetTokenT<MergeCollection> > > CollectionMerger< T1, T2 >::inputs_
private

Definition at line 49 of file CollectionMerger.h.

Hit
Definition: HitCollection.h:12
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
cms::cuda::assert
assert(be >=bs)
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
CollectionMerger::inputs_
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection > > > inputs_
Definition: CollectionMerger.h:49
DetId
Definition: DetId.h:17
PDWG_EXOHSCP_cff.inputCollection
inputCollection
Definition: PDWG_EXOHSCP_cff.py:56
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
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
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
CollectionMerger::MergeCollection
T1 MergeCollection
Definition: CollectionMerger.h:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
genParticles_cff.map
map
Definition: genParticles_cff.py:11
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
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31