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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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.

References edm::ParameterSet::getParameter().

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 (const auto &toproduce : inputs_) {
69  // std::cout<<toproduce.first<<"\t"<<toproduce.second.size()<<std::endl;
70  produces<MergeCollection>(toproduce.first);
71  }
72 }
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection > > > inputs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

◆ ~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.

References cms::cuda::assert().

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

◆ 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.

References convertSQLitetoXML_cfg::output.

125  {
126  fill_output_obj_tracker(output, inputCollections, true);
127 }
void fill_output_obj_tracker(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections, bool print_pixel=false)

◆ 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.

References convertSQLitetoXML_cfg::output.

131  {
132  fill_output_obj_tracker(output, inputCollections);
133 }
void fill_output_obj_tracker(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections, bool print_pixel=false)

◆ 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.

References convertSQLitetoXML_cfg::output.

138  {
139  fill_output_obj_calo(output, inputCollections);
140 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

144  {
145  fill_output_obj_calo(output, inputCollections);
146 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

150  {
151  fill_output_obj_calo(output, inputCollections);
152 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

156  {
157  fill_output_obj_calo(output, inputCollections);
158 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

162  {
163  fill_output_obj_calo(output, inputCollections);
164 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

168  {
169  fill_output_obj_calo(output, inputCollections);
170 }
void fill_output_obj_calo(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

175  {
176  fill_output_obj_muonchamber(output, inputCollections);
177 }
void fill_output_obj_muonchamber(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

181  {
182  fill_output_obj_muonchamber(output, inputCollections);
183 }
void fill_output_obj_muonchamber(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

References convertSQLitetoXML_cfg::output.

187  {
188  fill_output_obj_muonchamber(output, inputCollections);
189 }
void fill_output_obj_muonchamber(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)

◆ 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.

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

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 }
Definition: DetId.h:17

◆ 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.

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

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 }
Definition: DetId.h:17

◆ 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.

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

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 }
data_type const * const_iterator
Definition: DetSetNew.h:31
Definition: DetId.h:17

◆ 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.

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

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 }
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection > > > inputs_
int iEvent
Definition: GenABIO.cc:224
void fill_output_obj(std::unique_ptr< MergeCollection > &output, std::vector< edm::Handle< MergeCollection > > &inputCollections)
def move(src, dest)
Definition: eostools.py:511

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.