CMS 3D CMS Logo

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

#include <DoubleCollectionMerger.h>

Inheritance diagram for DoubleCollectionMerger< T1, T2, T3, T4 >:
edm::stream::EDProducer<>

Public Member Functions

 DoubleCollectionMerger (const edm::ParameterSet &)
 
 ~DoubleCollectionMerger () 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 BaseHit1
 
typedef T4 BaseHit2
 
typedef T1 MergeCollection1
 
typedef T3 MergeCollection2
 

Private Member Functions

void fill_output_obj (std::unique_ptr< MergeCollection1 > &output1, std::vector< edm::Handle< MergeCollection1 >> &inputCollections1)
 
void fill_output_obj (std::unique_ptr< MergeCollection2 > &output2, std::vector< edm::Handle< MergeCollection2 >> &inputCollections2)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection2 > &output, std::vector< edm::Handle< MergeCollection2 >> &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
 
template<>
void fill_output_obj (std::unique_ptr< MergeCollection2 > &output, std::vector< edm::Handle< MergeCollection2 >> &inputCollections)
 
void fill_output_obj_digiflag (std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
 
void fill_output_obj_digiflag (std::unique_ptr< MergeCollection2 > &output, std::vector< edm::Handle< MergeCollection2 >> &inputCollections)
 
void fill_output_obj_hcaldigi (std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
 
void fill_output_obj_hcaldigi (std::unique_ptr< MergeCollection2 > &output, std::vector< edm::Handle< MergeCollection2 >> &inputCollections)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection1 > > > inputs1_
 
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection2 > > > inputs2_
 

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, typename T3, typename T4>
class DoubleCollectionMerger< T1, T2, T3, T4 >

Author
Per Ahrens

Clean Up from Christian Winter & Sebastian Brommer, KIT

Definition at line 24 of file DoubleCollectionMerger.h.

Member Typedef Documentation

◆ BaseHit1

template<typename T1 , typename T2 , typename T3 , typename T4 >
typedef T2 DoubleCollectionMerger< T1, T2, T3, T4 >::BaseHit1
private

Definition at line 33 of file DoubleCollectionMerger.h.

◆ BaseHit2

template<typename T1 , typename T2 , typename T3 , typename T4 >
typedef T4 DoubleCollectionMerger< T1, T2, T3, T4 >::BaseHit2
private

Definition at line 35 of file DoubleCollectionMerger.h.

◆ MergeCollection1

template<typename T1 , typename T2 , typename T3 , typename T4 >
typedef T1 DoubleCollectionMerger< T1, T2, T3, T4 >::MergeCollection1
private

Definition at line 32 of file DoubleCollectionMerger.h.

◆ MergeCollection2

template<typename T1 , typename T2 , typename T3 , typename T4 >
typedef T3 DoubleCollectionMerger< T1, T2, T3, T4 >::MergeCollection2
private

Definition at line 34 of file DoubleCollectionMerger.h.

Constructor & Destructor Documentation

◆ DoubleCollectionMerger()

template<typename T1 , typename T2 , typename T3 , typename T4 >
DoubleCollectionMerger< T1, T2, T3, T4 >::DoubleCollectionMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 20 of file DoubleCollectionMerger.cc.

References edm::ParameterSet::getParameter().

20  {
21  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag>>("mergCollections");
22  for (auto const &inCollection : inCollections) {
23  inputs1_[inCollection.instance()].push_back(consumes<MergeCollection1>(inCollection));
24  inputs2_[inCollection.instance()].push_back(consumes<MergeCollection2>(inCollection));
25  }
26  for (const auto &toproduce : inputs1_) {
27  produces<MergeCollection1>(toproduce.first);
28  }
29  for (const auto &toproduce : inputs2_) {
30  produces<MergeCollection2>(toproduce.first);
31  }
32 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection2 > > > inputs2_
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection1 > > > inputs1_

◆ ~DoubleCollectionMerger()

template<typename T1 , typename T2 , typename T3 , typename T4 >
DoubleCollectionMerger< T1, T2, T3, T4 >::~DoubleCollectionMerger ( )
override

Definition at line 35 of file DoubleCollectionMerger.cc.

35  {
36  // nothing to be done yet...
37 }

Member Function Documentation

◆ fill_output_obj() [1/6]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj ( std::unique_ptr< MergeCollection1 > &  output1,
std::vector< edm::Handle< MergeCollection1 >> &  inputCollections1 
)
private

Definition at line 65 of file DoubleCollectionMerger.cc.

References cms::cuda::assert().

66  {
67  assert(0);
68 }
assert(be >=bs)

◆ fill_output_obj() [2/6]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj ( std::unique_ptr< MergeCollection2 > &  output2,
std::vector< edm::Handle< MergeCollection2 >> &  inputCollections2 
)
private

Definition at line 71 of file DoubleCollectionMerger.cc.

References cms::cuda::assert().

72  {
73  assert(0);
74 }
assert(be >=bs)

◆ fill_output_obj() [3/6]

template<>
void DoubleCollectionMerger< edm::SortedCollection< EESrFlag >, EESrFlag, edm::SortedCollection< EBSrFlag >, EBSrFlag >::fill_output_obj ( std::unique_ptr< MergeCollection1 > &  output,
std::vector< edm::Handle< MergeCollection1 >> &  inputCollections 
)
private

Definition at line 178 of file DoubleCollectionMerger.cc.

179  {
180  fill_output_obj_digiflag(output, inputCollections);
181 }
void fill_output_obj_digiflag(std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
Definition: output.py:1

◆ fill_output_obj() [4/6]

template<>
void DoubleCollectionMerger< edm::SortedCollection< EESrFlag >, EESrFlag, edm::SortedCollection< EBSrFlag >, EBSrFlag >::fill_output_obj ( std::unique_ptr< MergeCollection2 > &  output,
std::vector< edm::Handle< MergeCollection2 >> &  inputCollections 
)
private

Definition at line 185 of file DoubleCollectionMerger.cc.

186  {
187  fill_output_obj_digiflag(output, inputCollections);
188 }
void fill_output_obj_digiflag(std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
Definition: output.py:1

◆ fill_output_obj() [5/6]

template<>
void DoubleCollectionMerger< HBHEDigiCollection, HBHEDataFrame, HcalCalibDigiCollection, HcalCalibDataFrame >::fill_output_obj ( std::unique_ptr< MergeCollection1 > &  output,
std::vector< edm::Handle< MergeCollection1 >> &  inputCollections 
)
private

Definition at line 192 of file DoubleCollectionMerger.cc.

193  {
194  fill_output_obj_hcaldigi(output, inputCollections);
195 }
void fill_output_obj_hcaldigi(std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
Definition: output.py:1

◆ fill_output_obj() [6/6]

template<>
void DoubleCollectionMerger< HBHEDigiCollection, HBHEDataFrame, HcalCalibDigiCollection, HcalCalibDataFrame >::fill_output_obj ( std::unique_ptr< MergeCollection2 > &  output,
std::vector< edm::Handle< MergeCollection2 >> &  inputCollections 
)
private

Definition at line 199 of file DoubleCollectionMerger.cc.

200  {
201  fill_output_obj_hcaldigi(output, inputCollections);
202 }
void fill_output_obj_hcaldigi(std::unique_ptr< MergeCollection1 > &output, std::vector< edm::Handle< MergeCollection1 >> &inputCollections)
Definition: output.py:1

◆ fill_output_obj_digiflag() [1/2]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj_digiflag ( std::unique_ptr< MergeCollection1 > &  output,
std::vector< edm::Handle< MergeCollection1 >> &  inputCollections 
)
private

Definition at line 77 of file DoubleCollectionMerger.cc.

References valuemaptraslator_cfi::inputCollection, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, WZElectronSkims53X_cff::max, getGTfromDQMFile::obj, and or.

78  {
79  std::map<uint32_t, BaseHit1> output_map;
80 
81  // First merge the two collections again
82  for (auto const &inputCollection : inputCollections) {
83  for (typename MergeCollection1::const_iterator obj = inputCollection->begin(); obj != inputCollection->end();
84  ++obj) {
85  DetId detIdObject(obj->id().rawId());
86 
87  std::map<uint32_t, EESrFlag>::iterator it = output_map.find(detIdObject.rawId());
88  if (it == output_map.end()) {
89  BaseHit1 *akt_flag_obj = &output_map[detIdObject.rawId()];
90  const T2 &newSrFlag(*obj);
91  *akt_flag_obj = newSrFlag;
92  } else {
93  // re-determine flag
94  BaseHit1 preFlag = it->second;
95  BaseHit1 *akt_flag_obj = &output_map[detIdObject.rawId()];
96  T2 newSrFlag(*obj);
97 
98  newSrFlag.setValue(std::max(obj->value(), preFlag.value()));
99  if (preFlag.value() == 3 or obj->value() == 3)
100  newSrFlag.setValue(3);
101  if (preFlag.value() == 7 or obj->value() == 7)
102  newSrFlag.setValue(7);
103 
104  *akt_flag_obj = newSrFlag;
105  }
106  }
107  }
108 
109  // Now save it into the standard CMSSW format
110  for (typename std::map<uint32_t, BaseHit1>::const_iterator outFlags = output_map.begin();
111  outFlags != output_map.end();
112  ++outFlags) {
113  BaseHit1 currFlag = outFlags->second;
114  output->push_back(outFlags->second);
115  }
116  output->sort(); // Do a sort for this collection
117 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Definition: DetId.h:17
Definition: output.py:1

◆ fill_output_obj_digiflag() [2/2]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj_digiflag ( std::unique_ptr< MergeCollection2 > &  output,
std::vector< edm::Handle< MergeCollection2 >> &  inputCollections 
)
private

Definition at line 120 of file DoubleCollectionMerger.cc.

References valuemaptraslator_cfi::inputCollection, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, WZElectronSkims53X_cff::max, getGTfromDQMFile::obj, and or.

121  {
122  std::map<uint32_t, BaseHit2> output_map;
123 
124  // First merge the two collections again
125  for (auto const &inputCollection : inputCollections) {
126  for (typename MergeCollection2::const_iterator obj = inputCollection->begin(); obj != inputCollection->end();
127  ++obj) {
128  DetId detIdObject(obj->id().rawId());
129 
130  std::map<uint32_t, EBSrFlag>::iterator it = output_map.find(detIdObject.rawId());
131  if (it == output_map.end()) {
132  BaseHit2 *akt_flag_obj = &output_map[detIdObject.rawId()];
133  const T4 &newSrFlag(*obj);
134  *akt_flag_obj = newSrFlag;
135  } else {
136  // re-determine flag
137  BaseHit2 preFlag = it->second;
138  BaseHit2 *akt_flag_obj = &output_map[detIdObject.rawId()];
139  T4 newSrFlag(*obj);
140 
141  newSrFlag.setValue(std::max(obj->value(), preFlag.value()));
142  if (preFlag.value() == 3 or obj->value() == 3)
143  newSrFlag.setValue(3);
144  if (preFlag.value() == 7 or obj->value() == 7)
145  newSrFlag.setValue(7);
146 
147  *akt_flag_obj = newSrFlag;
148  }
149  }
150  }
151 
152  // Now save it into the standard CMSSW format
153  for (typename std::map<uint32_t, BaseHit2>::const_iterator outFlags = output_map.begin();
154  outFlags != output_map.end();
155  ++outFlags) {
156  BaseHit2 currFlag = outFlags->second;
157  output->push_back(outFlags->second);
158  }
159  output->sort(); // Do a sort for this collection
160 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Definition: DetId.h:17
Definition: output.py:1

◆ fill_output_obj_hcaldigi() [1/2]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj_hcaldigi ( std::unique_ptr< MergeCollection1 > &  output,
std::vector< edm::Handle< MergeCollection1 >> &  inputCollections 
)
private

Definition at line 163 of file DoubleCollectionMerger.cc.

164  {
165  // TODO: implement proper merging, only skeleton for the time-being
166  return;
167 }

◆ fill_output_obj_hcaldigi() [2/2]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void DoubleCollectionMerger< T1, T2, T3, T4 >::fill_output_obj_hcaldigi ( std::unique_ptr< MergeCollection2 > &  output,
std::vector< edm::Handle< MergeCollection2 >> &  inputCollections 
)
private

Definition at line 170 of file DoubleCollectionMerger.cc.

171  {
172  // TODO: implement proper merging, only skeleton for the time-being
173  return;
174 }

◆ produce()

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

Definition at line 40 of file DoubleCollectionMerger.cc.

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

40  {
41  for (auto input_ : inputs1_) {
42  std::unique_ptr<MergeCollection1> output(new MergeCollection1());
43  std::vector<edm::Handle<MergeCollection1>> inputCollections;
44  inputCollections.resize(input_.second.size());
45  for (unsigned id = 0; id < input_.second.size(); id++) {
46  iEvent.getByToken(input_.second[id], inputCollections[id]);
47  }
48  fill_output_obj(output, inputCollections);
49  iEvent.put(std::move(output), input_.first);
50  }
51 
52  for (auto input_ : inputs2_) {
53  std::unique_ptr<MergeCollection2> output(new MergeCollection2());
54  std::vector<edm::Handle<MergeCollection2>> inputCollections;
55  inputCollections.resize(input_.second.size());
56  for (unsigned id = 0; id < input_.second.size(); id++) {
57  iEvent.getByToken(input_.second[id], inputCollections[id]);
58  }
59  fill_output_obj(output, inputCollections);
60  iEvent.put(std::move(output), input_.first);
61  }
62 }
void fill_output_obj(std::unique_ptr< MergeCollection1 > &output1, std::vector< edm::Handle< MergeCollection1 >> &inputCollections1)
int iEvent
Definition: GenABIO.cc:224
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection2 > > > inputs2_
Definition: output.py:1
std::map< std::string, std::vector< edm::EDGetTokenT< MergeCollection1 > > > inputs1_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ inputs1_

template<typename T1 , typename T2 , typename T3 , typename T4 >
std::map<std::string, std::vector<edm::EDGetTokenT<MergeCollection1> > > DoubleCollectionMerger< T1, T2, T3, T4 >::inputs1_
private

Definition at line 36 of file DoubleCollectionMerger.h.

◆ inputs2_

template<typename T1 , typename T2 , typename T3 , typename T4 >
std::map<std::string, std::vector<edm::EDGetTokenT<MergeCollection2> > > DoubleCollectionMerger< T1, T2, T3, T4 >::inputs2_
private

Definition at line 37 of file DoubleCollectionMerger.h.