CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1TEGMultiMerger::InstanceMerger< T > Class Template Reference

Public Member Functions

 InstanceMerger (L1TEGMultiMerger *prod, const edm::ParameterSet &conf)
 
void produce (edm::Event &iEvent, RefRemapper &refRemapper) const
 

Private Member Functions

template<class TT >
void populate (std::unique_ptr< TT > &out, const edm::Handle< TT > &in, RefRemapper &refRemapper) const
 
void populate (std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, RefRemapper &refRemapper) const
 
template<class TT >
void remapRefs (edm::Event &iEvent, std::unique_ptr< TT > &out, RefRemapper &refRemapper) const
 
void remapRefs (edm::Event &iEvent, std::unique_ptr< BXVector< l1t::EGamma >> &out, RefRemapper &refRemapper) const
 

Private Attributes

std::string instanceLabel_
 
std::vector< edm::EDGetTokenT< T > > tokens_
 

Detailed Description

template<class T>
class L1TEGMultiMerger::InstanceMerger< T >

Definition at line 29 of file L1TEGMultiMerger.cc.

Constructor & Destructor Documentation

◆ InstanceMerger()

template<class T >
L1TEGMultiMerger::InstanceMerger< T >::InstanceMerger ( L1TEGMultiMerger prod,
const edm::ParameterSet conf 
)
inline

Definition at line 31 of file L1TEGMultiMerger.cc.

References edm::ParameterSet::getParameter(), L1TEGMultiMerger::InstanceMerger< T >::instanceLabel_, dumpMFGeometry_cfg::prod, and L1TEGMultiMerger::InstanceMerger< T >::tokens_.

32  : instanceLabel_(conf.getParameter<std::string>("instance")) {
33  for (const auto& producer_tag : conf.getParameter<std::vector<edm::InputTag>>("pfProducers")) {
34  tokens_.push_back(
35  prod->consumes<T>(edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())));
36  }
37  // FIXME: move this outside
38  prod->produces<T>(instanceLabel_);
39  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< edm::EDGetTokenT< T > > tokens_
long double T

Member Function Documentation

◆ populate() [1/2]

template<class T >
template<class TT >
void L1TEGMultiMerger::InstanceMerger< T >::populate ( std::unique_ptr< TT > &  out,
const edm::Handle< TT > &  in,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 72 of file L1TEGMultiMerger.cc.

References recoMuon::in, and MillePedeFileConverter_cfg::out.

Referenced by L1TEGMultiMerger::InstanceMerger< T >::produce().

72  {
73  out->insert(out->end(), in->begin(), in->end());
74  }

◆ populate() [2/2]

template<class T >
void L1TEGMultiMerger::InstanceMerger< T >::populate ( std::unique_ptr< BXVector< l1t::EGamma >> &  out,
const edm::Handle< BXVector< l1t::EGamma >> &  in,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 76 of file L1TEGMultiMerger.cc.

References simKBmtfDigis_cfi::bx, heavyIonCSV_trainingSettings::idx, recoMuon::in, L1TEGMultiMerger::RefRemapper::oldRefs, MillePedeFileConverter_cfg::out, and BXVector< T >::push_back().

78  {
79  edm::Ref<BXVector<l1t::EGamma>>::key_type idx = 0;
80  for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) {
81  for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) {
82  out->push_back(bx, *egee_itr);
83  // this to ensure that the old ref and the new object have the same index in the BXVector collection so that we can still match them
84  // no matter which BX we will insert next
85  refRemapper.oldRefs.push_back(bx, edm::Ref<BXVector<l1t::EGamma>>(in, idx++));
86  }
87  }
88  }

◆ produce()

template<class T >
void L1TEGMultiMerger::InstanceMerger< T >::produce ( edm::Event iEvent,
RefRemapper refRemapper 
) const
inline

Definition at line 41 of file L1TEGMultiMerger.cc.

References patZpeak::handle, iEvent, L1TEGMultiMerger::InstanceMerger< T >::instanceLabel_, eostools::move(), MillePedeFileConverter_cfg::out, L1TEGMultiMerger::InstanceMerger< T >::populate(), L1TEGMultiMerger::InstanceMerger< T >::remapRefs(), unpackBuffers-CaloStage2::token, and L1TEGMultiMerger::InstanceMerger< T >::tokens_.

41  {
43  auto out = std::make_unique<T>();
44  for (const auto& token : tokens_) {
45  iEvent.getByToken(token, handle);
46  populate(out, handle, refRemapper);
47  }
48  remapRefs(iEvent, out, refRemapper);
50  }
void populate(std::unique_ptr< TT > &out, const edm::Handle< TT > &in, RefRemapper &refRemapper) const
int iEvent
Definition: GenABIO.cc:224
std::vector< edm::EDGetTokenT< T > > tokens_
void remapRefs(edm::Event &iEvent, std::unique_ptr< TT > &out, RefRemapper &refRemapper) const
def move(src, dest)
Definition: eostools.py:511

◆ remapRefs() [1/2]

template<class T >
template<class TT >
void L1TEGMultiMerger::InstanceMerger< T >::remapRefs ( edm::Event iEvent,
std::unique_ptr< TT > &  out,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 54 of file L1TEGMultiMerger.cc.

References L1TEGMultiMerger::RefRemapper::old2newRefMap, and MillePedeFileConverter_cfg::out.

Referenced by L1TEGMultiMerger::InstanceMerger< T >::produce().

54  {
55  for (auto& egobj : *out) {
56  auto newref = refRemapper.old2newRefMap.find(egobj.EGRef());
57  if (newref != refRemapper.old2newRefMap.end()) {
58  egobj.setEGRef(newref->second);
59  }
60  }
61  }

◆ remapRefs() [2/2]

template<class T >
void L1TEGMultiMerger::InstanceMerger< T >::remapRefs ( edm::Event iEvent,
std::unique_ptr< BXVector< l1t::EGamma >> &  out,
RefRemapper refRemapper 
) const
inlineprivate

Member Data Documentation

◆ instanceLabel_

template<class T >
std::string L1TEGMultiMerger::InstanceMerger< T >::instanceLabel_
private

◆ tokens_

template<class T >
std::vector<edm::EDGetTokenT<T> > L1TEGMultiMerger::InstanceMerger< T >::tokens_
private