CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 32 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 34 of file L1TEGMultiMerger.cc.

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

35  : instanceLabel_(conf.getParameter<std::string>("instance")) {
36  for (const auto& producer_tag : conf.getParameter<std::vector<edm::InputTag>>("pfProducers")) {
37  tokens_.push_back(
38  prod->consumes<T>(edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())));
39  }
40  // FIXME: move this outside
41  prod->produces<T>(instanceLabel_);
42  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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 75 of file L1TEGMultiMerger.cc.

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

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

75  {
76  out->insert(out->end(), in->begin(), in->end());
77  }

◆ 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 79 of file L1TEGMultiMerger.cc.

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

81  {
82  edm::Ref<BXVector<l1t::EGamma>>::key_type idx = 0;
83  for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) {
84  for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) {
85  out->push_back(bx, *egee_itr);
86  // 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
87  // no matter which BX we will insert next
88  refRemapper.oldRefs.push_back(bx, edm::Ref<BXVector<l1t::EGamma>>(in, idx++));
89  }
90  }
91  }

◆ produce()

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

Definition at line 44 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_.

44  {
46  auto out = std::make_unique<T>();
47  for (const auto& token : tokens_) {
48  iEvent.getByToken(token, handle);
49  populate(out, handle, refRemapper);
50  }
51  remapRefs(iEvent, out, refRemapper);
53  }
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 57 of file L1TEGMultiMerger.cc.

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

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

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

◆ 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