CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1CondDBIOVWriter Class Reference

#include <CondTools/L1Trigger/interface/L1CondDBIOVWriter.h>

Inheritance diagram for L1CondDBIOVWriter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1CondDBIOVWriter (const edm::ParameterSet &)
 
 ~L1CondDBIOVWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcdl1TriggerKeyToken_
 
bool m_forceUpdate
 
bool m_ignoreTriggerKey
 
bool m_logKeys
 
bool m_logTransactions
 
std::vector< std::string > m_recordTypes
 
std::string m_tscKey
 
l1t::DataWriter m_writer
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 39 of file L1CondDBIOVWriter.h.

Constructor & Destructor Documentation

◆ L1CondDBIOVWriter()

L1CondDBIOVWriter::L1CondDBIOVWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 49 of file L1CondDBIOVWriter.cc.

References edm::EDConsumerBase::esConsumes(), edm::ParameterSet::getParameter(), l1TriggerKeyToken_, m_recordTypes, AlCaHarvesting_cff::record, and AlCaHLTBitMon_QueryRunRegistry::string.

50  : m_tscKey(iConfig.getParameter<std::string>("tscKey")),
51  m_ignoreTriggerKey(iConfig.getParameter<bool>("ignoreTriggerKey")),
52  m_logKeys(iConfig.getParameter<bool>("logKeys")),
53  m_logTransactions(iConfig.getParameter<bool>("logTransactions")),
54  m_forceUpdate(iConfig.getParameter<bool>("forceUpdate")) {
55  //now do what ever initialization is needed
56  typedef std::vector<edm::ParameterSet> ToSave;
57  ToSave toSave = iConfig.getParameter<ToSave>("toPut");
58  for (ToSave::const_iterator it = toSave.begin(); it != toSave.end(); it++) {
59  std::string record = it->getParameter<std::string>("record");
60  std::string type = it->getParameter<std::string>("type");
61  m_recordTypes.push_back(record + "@" + type);
62  }
64 }
std::vector< std::string > m_recordTypes
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > l1TriggerKeyToken_

◆ ~L1CondDBIOVWriter()

L1CondDBIOVWriter::~L1CondDBIOVWriter ( )
override

Definition at line 66 of file L1CondDBIOVWriter.cc.

66  {
67  // do anything here that needs to be done at desctruction time
68  // (e.g. close files, deallocate resources etc.)
69 }

Member Function Documentation

◆ analyze()

void L1CondDBIOVWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 76 of file L1CondDBIOVWriter.cc.

References mps_fire::end, l1t::DataWriter::fillLastTriggerKeyList(), edm::EventSetup::getHandle(), iEvent, crabWrapper::key, L1TriggerKey::kNullKey, l1TriggerKeyToken_, dqm-mbProfile::log, m_forceUpdate, m_ignoreTriggerKey, m_logKeys, m_logTransactions, m_recordTypes, m_tscKey, m_writer, l1t::DataWriter::readObject(), align_cfg::recordName, python.rootplot.root2matplotlib::replace(), writedatasetfile::run, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), L1TriggerKeyList::token(), and l1t::DataWriter::updateIOV().

76  {
77  using namespace edm;
78 
79  // Get L1TriggerKeyList
80  L1TriggerKeyList keyList;
81  l1t::DataWriter dataWriter;
82  if (!dataWriter.fillLastTriggerKeyList(keyList)) {
83  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
84  }
85 
86  unsigned long long run = iEvent.id().run();
87 
88  L1TriggerKey::RecordToKey recordTypeToKeyMap;
89 
90  bool triggerKeyIOVUpdated = true;
91 
92  // Start log string, convert run number into string
93  std::stringstream ss;
94  ss << run;
95  std::string log = "KEYLOG runNumber=" + ss.str();
96  bool logRecords = true;
97 
98  if (!m_ignoreTriggerKey) {
99  if (!m_tscKey.empty()) {
100  edm::LogVerbatim("L1-O2O") << "Object key for L1TriggerKey@L1TriggerKeyRcd: " << m_tscKey;
101 
102  // Use TSC key and L1TriggerKeyList to find next run's
103  // L1TriggerKey token
104  std::string keyToken = keyList.token(m_tscKey);
105 
106  // Update IOV sequence for this token with since-time = new run
107  triggerKeyIOVUpdated = m_writer.updateIOV("L1TriggerKeyRcd", keyToken, run, m_logTransactions);
108 
109  // Read current L1TriggerKey directly from ORCON using token
111  m_writer.readObject(keyToken, key);
112 
113  recordTypeToKeyMap = key.recordToKeyMap();
114 
115  // Replace spaces in key with ?s. Do reverse substitution when
116  // making L1TriggerKey.
117  std::string tmpKey = m_tscKey;
118  replace(tmpKey.begin(), tmpKey.end(), ' ', '?');
119  log += " tscKey=" + tmpKey;
120  logRecords = false;
121  } else {
122  // For use with Run Settings, no corresponding L1TrigerKey in
123  // ORCON.
124 
125  // Get L1TriggerKey from EventSetup
126  auto esKey = iSetup.getHandle(l1TriggerKeyToken_);
127  recordTypeToKeyMap = esKey->recordToKeyMap();
128  }
129  } else {
130  std::vector<std::string>::const_iterator recordTypeItr = m_recordTypes.begin();
131  std::vector<std::string>::const_iterator recordTypeEnd = m_recordTypes.end();
132 
133  for (; recordTypeItr != recordTypeEnd; ++recordTypeItr) {
134  recordTypeToKeyMap.insert(std::make_pair(*recordTypeItr, m_tscKey));
135  }
136  }
137 
138  // If L1TriggerKey IOV was already up to date, then so are all its
139  // sub-records.
140  bool throwException = false;
141 
142  if (triggerKeyIOVUpdated || m_forceUpdate) {
143  // Loop over record@type in L1TriggerKey
144  L1TriggerKey::RecordToKey::const_iterator itr = recordTypeToKeyMap.begin();
145  L1TriggerKey::RecordToKey::const_iterator end = recordTypeToKeyMap.end();
146 
147  for (; itr != end; ++itr) {
148  std::string recordType = itr->first;
149  std::string objectKey = itr->second;
150 
151  std::string recordName(recordType, 0, recordType.find_first_of('@'));
152 
153  if (logRecords) {
154  // Replace spaces in key with ?s. Do reverse substitution when
155  // making L1TriggerKey.
156  std::string tmpKey = objectKey;
157  replace(tmpKey.begin(), tmpKey.end(), ' ', '?');
158  log += " " + recordName + "Key=" + tmpKey;
159  }
160 
161  // Do nothing if object key is null.
162  if (objectKey == L1TriggerKey::kNullKey) {
163  edm::LogVerbatim("L1-O2O") << "L1CondDBIOVWriter: null object key for " << recordType
164  << "; skipping this record.";
165  } else {
166  // Find payload token
167  edm::LogVerbatim("L1-O2O") << "Object key for " << recordType << ": " << objectKey;
168 
169  std::string payloadToken = keyList.token(recordType, objectKey);
170  if (payloadToken.empty()) {
171  edm::LogVerbatim("L1-O2O") << "L1CondDBIOVWriter: empty payload token for " + recordType + ", key " +
172  objectKey;
173 
174  throwException = true;
175  } else {
177  }
178  }
179  }
180  }
181 
182  if (m_logKeys) {
183  edm::LogVerbatim("L1-O2O") << log;
184  }
185 
186  if (throwException) {
187  throw cond::Exception("L1CondDBIOVWriter: empty payload tokens");
188  }
189 }
persistency::Exception Exception
Definition: Exception.h:25
Log< level::Info, true > LogVerbatim
l1t::DataWriter m_writer
std::vector< std::string > m_recordTypes
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:25
static const std::string kNullKey
Definition: L1TriggerKey.h:30
def replace(string, replacements)
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > l1TriggerKeyToken_
std::string token(const std::string &tscKey) const
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriter.h:72
HLT enums.
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriter.cc:72
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ beginJob()

void L1CondDBIOVWriter::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 192 of file L1CondDBIOVWriter.cc.

192 {}

◆ endJob()

void L1CondDBIOVWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 195 of file L1CondDBIOVWriter.cc.

195 {}

Member Data Documentation

◆ l1TriggerKeyToken_

edm::ESGetToken<L1TriggerKey, L1TriggerKeyRcd> L1CondDBIOVWriter::l1TriggerKeyToken_
private

Definition at line 70 of file L1CondDBIOVWriter.h.

Referenced by analyze(), and L1CondDBIOVWriter().

◆ m_forceUpdate

bool L1CondDBIOVWriter::m_forceUpdate
private

Definition at line 68 of file L1CondDBIOVWriter.h.

Referenced by analyze().

◆ m_ignoreTriggerKey

bool L1CondDBIOVWriter::m_ignoreTriggerKey
private

Definition at line 62 of file L1CondDBIOVWriter.h.

Referenced by analyze().

◆ m_logKeys

bool L1CondDBIOVWriter::m_logKeys
private

Definition at line 64 of file L1CondDBIOVWriter.h.

Referenced by analyze().

◆ m_logTransactions

bool L1CondDBIOVWriter::m_logTransactions
private

Definition at line 66 of file L1CondDBIOVWriter.h.

Referenced by analyze().

◆ m_recordTypes

std::vector<std::string> L1CondDBIOVWriter::m_recordTypes
private

Definition at line 55 of file L1CondDBIOVWriter.h.

Referenced by analyze(), and L1CondDBIOVWriter().

◆ m_tscKey

std::string L1CondDBIOVWriter::m_tscKey
private

Definition at line 51 of file L1CondDBIOVWriter.h.

Referenced by analyze().

◆ m_writer

l1t::DataWriter L1CondDBIOVWriter::m_writer
private

Definition at line 50 of file L1CondDBIOVWriter.h.

Referenced by analyze().