CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TriggerKeyOnlineProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TriggerKeyOnlineProd
4 // Class: L1TriggerKeyOnlineProd
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Sun Mar 2 03:03:32 CET 2008
16 // $Id: L1TriggerKeyOnlineProd.cc,v 1.10 2008/10/13 01:49:48 wsun Exp $
17 //
18 //
19 
20 // system include files
21 
22 // user include files
24 
26 
28 
30 
31 //
32 // class declaration
33 //
34 
35 //
36 // constants, enums and typedefs
37 //
38 
39 //
40 // static data member definitions
41 //
42 
43 //
44 // constructors and destructor
45 //
47  : m_subsystemLabels(iConfig.getParameter<std::vector<std::string> >("subsystemLabels")) {
48  //the following line is needed to tell the framework what
49  // data is being produced
50  auto cc = setWhatProduced(this);
51 
52  //now do what ever other initialization is needed
53  l1TriggerKeyToken_ = cc.consumes(edm::ESInputTag("", "SubsystemKeysOnly"));
54  for (const auto& mlabel : m_subsystemLabels) {
55  l1TriggerKeyTokenVec_.emplace_back(cc.consumes(edm::ESInputTag("", mlabel)));
56  }
57 }
58 
60  // do anything here that needs to be done at desctruction time
61  // (e.g. close files, deallocate resources etc.)
62 }
63 
64 //
65 // member functions
66 //
67 
68 // ------------ method called to produce the data ------------
70  // Start with "SubsystemKeysOnly"
71  edm::ESHandle<L1TriggerKey> subsystemKeys;
72  try {
73  subsystemKeys = iRecord.getHandle(l1TriggerKeyToken_);
74  } catch (l1t::DataAlreadyPresentException& ex) {
75  throw ex;
76  }
77 
78  std::unique_ptr<L1TriggerKey> pL1TriggerKey = std::make_unique<L1TriggerKey>(*subsystemKeys);
79 
80  // Collate object keys
81  for (const auto& l1token : l1TriggerKeyTokenVec_) {
82  edm::ESHandle<L1TriggerKey> objectKeys;
83  try {
84  objectKeys = iRecord.getHandle(l1token);
85  } catch (l1t::DataAlreadyPresentException& ex) {
86  throw ex;
87  }
88 
89  pL1TriggerKey->add(objectKeys->recordToKeyMap());
90  }
91 
92  return pL1TriggerKey;
93 }
94 
95 //define this as a plug-in
96 //DEFINE_FWK_EVENTSETUP_MODULE(L1TriggerKeyOnlineProd);
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ESHandle< ProductT > getHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::vector< std::string > m_subsystemLabels
L1TriggerKeyOnlineProd(const edm::ParameterSet &)
ReturnType produce(const L1TriggerKeyRcd &)
std::unique_ptr< L1TriggerKey > ReturnType
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > l1TriggerKeyToken_
std::vector< edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > > l1TriggerKeyTokenVec_