CMS 3D CMS Logo

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

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

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

Public Member Functions

 L1CondDBPayloadWriter (const edm::ParameterSet &)
 
 ~L1CondDBPayloadWriter () 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_logTransactions
 
bool m_newL1TriggerKeyList
 
bool m_overwriteKeys
 
bool m_writeConfigData
 
bool m_writeL1TriggerKey
 
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 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 40 of file L1CondDBPayloadWriter.h.

Constructor & Destructor Documentation

◆ L1CondDBPayloadWriter()

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

Definition at line 43 of file L1CondDBPayloadWriter.cc.

44  : m_writeL1TriggerKey(iConfig.getParameter<bool>("writeL1TriggerKey")),
45  m_writeConfigData(iConfig.getParameter<bool>("writeConfigData")),
46  m_overwriteKeys(iConfig.getParameter<bool>("overwriteKeys")),
47  m_logTransactions(iConfig.getParameter<bool>("logTransactions")),
48  m_newL1TriggerKeyList(iConfig.getParameter<bool>("newL1TriggerKeyList")),
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > l1TriggerKeyToken_

◆ ~L1CondDBPayloadWriter()

L1CondDBPayloadWriter::~L1CondDBPayloadWriter ( )
override

Definition at line 51 of file L1CondDBPayloadWriter.cc.

51  {
52  // do anything here that needs to be done at desctruction time
53  // (e.g. close files, deallocate resources etc.)
54 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 61 of file L1CondDBPayloadWriter.cc.

References L1TriggerKeyList::addKey(), relativeConstraints::empty, mps_fire::end, l1t::DataWriter::fillLastTriggerKeyList(), edm::EventSetup::getHandle(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, submitPVResolutionJobs::key, L1TriggerKey::kNullKey, l1TriggerKeyToken_, m_logTransactions, m_newL1TriggerKeyList, m_overwriteKeys, m_writeConfigData, m_writeL1TriggerKey, m_writer, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), L1TriggerKeyList::token(), unpackBuffers-CaloStage2::token, cms::Exception::what(), l1t::DataWriter::writeKeyList(), and l1t::DataWriter::writePayload().

61  {
62  using namespace edm;
63 
64  // Get L1TriggerKeyList and make a copy
65  L1TriggerKeyList oldKeyList;
66 
67  if (!m_newL1TriggerKeyList) {
68  if (!m_writer.fillLastTriggerKeyList(oldKeyList)) {
69  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
70  }
71  }
72 
73  L1TriggerKeyList* keyList = nullptr;
74 
75  // Write L1TriggerKey to ORCON with no IOV
78 
79  // Before calling writePayload(), check if TSC key is already in
80  // L1TriggerKeyList. writePayload() will not catch this situation in
81  // the case of dummy configurations.
82  bool triggerKeyOK = true;
83  try {
84  // Get L1TriggerKey
86 
87  if (!m_overwriteKeys) {
88  triggerKeyOK = oldKeyList.token(key->tscKey()).empty();
89  }
90  } catch (l1t::DataAlreadyPresentException& ex) {
91  triggerKeyOK = false;
92  edm::LogVerbatim("L1-O2O") << ex.what();
93  }
94 
95  if (triggerKeyOK && m_writeL1TriggerKey) {
96  edm::LogVerbatim("L1-O2O") << "Object key for L1TriggerKeyRcd@L1TriggerKey: " << key->tscKey();
97  token = m_writer.writePayload(iSetup, "L1TriggerKeyRcd@L1TriggerKey");
98  }
99 
100  // If L1TriggerKey is invalid, then all configuration data is already in DB
101  bool throwException = false;
102 
103  if (!token.empty() || !m_writeL1TriggerKey) {
104  // Record token in L1TriggerKeyList
105  if (m_writeL1TriggerKey) {
106  keyList = new L1TriggerKeyList(oldKeyList);
107  if (!(keyList->addKey(key->tscKey(), token, m_overwriteKeys))) {
108  throw cond::Exception("L1CondDBPayloadWriter: TSC key " + key->tscKey() + " already in L1TriggerKeyList");
109  }
110  }
111 
112  if (m_writeConfigData) {
113  // Loop over record@type in L1TriggerKey
114  L1TriggerKey::RecordToKey::const_iterator it = key->recordToKeyMap().begin();
115  L1TriggerKey::RecordToKey::const_iterator end = key->recordToKeyMap().end();
116 
117  for (; it != end; ++it) {
118  // Do nothing if object key is null.
119  if (it->second == L1TriggerKey::kNullKey) {
120  edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: null object key for " << it->first
121  << "; skipping this record.";
122  } else {
123  // Check key is new before writing
124  if (oldKeyList.token(it->first, it->second).empty() || m_overwriteKeys) {
125  // Write data to ORCON with no IOV
126  if (!oldKeyList.token(it->first, it->second).empty()) {
127  edm::LogVerbatim("L1-O2O") << "*** Overwriting payload: object key for " << it->first << ": "
128  << it->second;
129  } else {
130  edm::LogVerbatim("L1-O2O") << "object key for " << it->first << ": " << it->second;
131  }
132 
133  try {
134  token = m_writer.writePayload(iSetup, it->first);
135  } catch (l1t::DataInvalidException& ex) {
136  edm::LogVerbatim("L1-O2O") << ex.what() << " Skipping to next record.";
137 
138  throwException = true;
139 
140  continue;
141  }
142 
143  if (!token.empty()) {
144  // Record token in L1TriggerKeyList
145  if (!keyList) {
146  keyList = new L1TriggerKeyList(oldKeyList);
147  }
148 
149  if (!(keyList->addKey(it->first, it->second, token, m_overwriteKeys))) {
150  // This should never happen because of the check
151  // above, but just in case....
152  throw cond::Exception("L1CondDBPayloadWriter: subsystem key " + it->second + " for " + it->first +
153  " already in L1TriggerKeyList");
154  }
155  }
156  } else {
157  edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: object key " << it->second << " for " << it->first
158  << " already in L1TriggerKeyList";
159  }
160  }
161  }
162  }
163  }
164 
165  if (keyList) {
166  // Write L1TriggerKeyList to ORCON
168  }
169 
170  if (throwException) {
171  throw l1t::DataInvalidException("Payload problem found.");
172  }
173 }
persistency::Exception Exception
Definition: Exception.h:25
Log< level::Info, true > LogVerbatim
static const std::string kNullKey
Definition: L1TriggerKey.h:30
std::string token(const std::string &tscKey) const
Log< level::Error, false > LogError
std::string writePayload(const edm::EventSetup &setup, const std::string &recordType)
Definition: DataWriter.cc:15
key
prepare the HTCondor submission files and eventually submit them
void writeKeyList(L1TriggerKeyList *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
Definition: DataWriter.cc:49
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
HLT enums.
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > l1TriggerKeyToken_
char const * what() const noexcept override
Definition: Exception.cc:107
bool addKey(const std::string &tscKey, const std::string &payloadToken, bool overwriteKey=false)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ beginJob()

void L1CondDBPayloadWriter::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 176 of file L1CondDBPayloadWriter.cc.

176 {}

◆ endJob()

void L1CondDBPayloadWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 179 of file L1CondDBPayloadWriter.cc.

179 {}

Member Data Documentation

◆ l1TriggerKeyToken_

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

Definition at line 68 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_logTransactions

bool L1CondDBPayloadWriter::m_logTransactions
private

Definition at line 63 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_newL1TriggerKeyList

bool L1CondDBPayloadWriter::m_newL1TriggerKeyList
private

Definition at line 66 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_overwriteKeys

bool L1CondDBPayloadWriter::m_overwriteKeys
private

Definition at line 61 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_writeConfigData

bool L1CondDBPayloadWriter::m_writeConfigData
private

Definition at line 58 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_writeL1TriggerKey

bool L1CondDBPayloadWriter::m_writeL1TriggerKey
private

Definition at line 55 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

◆ m_writer

l1t::DataWriter L1CondDBPayloadWriter::m_writer
private

Definition at line 51 of file L1CondDBPayloadWriter.h.

Referenced by analyze().