CMS 3D CMS Logo

L1CondDBPayloadWriterExt.cc
Go to the documentation of this file.
2 
4 
9 
11  : m_writeL1TriggerKeyExt(iConfig.getParameter<bool>("writeL1TriggerKeyExt")),
12  m_writeConfigData(iConfig.getParameter<bool>("writeConfigData")),
13  m_overwriteKeys(iConfig.getParameter<bool>("overwriteKeys")),
14  m_logTransactions(iConfig.getParameter<bool>("logTransactions")),
15  m_newL1TriggerKeyListExt(iConfig.getParameter<bool>("newL1TriggerKeyListExt")) {
16  //now do what ever initialization is needed
17  key_token = esConsumes<L1TriggerKeyExt, L1TriggerKeyExtRcd>();
18 }
19 
21  // do anything here that needs to be done at desctruction time
22  // (e.g. close files, deallocate resources etc.)
23 }
24 
25 // ------------ method called to for each event ------------
27  using namespace edm;
28 
29  // Get L1TriggerKeyListExt and make a copy
30  L1TriggerKeyListExt oldKeyList;
31 
33  if (!m_writer.fillLastTriggerKeyList(oldKeyList)) {
34  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
35  }
36  }
37 
38  L1TriggerKeyListExt* keyList = nullptr;
39 
40  // Write L1TriggerKeyExt to ORCON with no IOV
43  // Before calling writePayload(), check if TSC key is already in
44  // L1TriggerKeyListExt. writePayload() will not catch this situation in
45  // the case of dummy configurations.
46  bool triggerKeyOK = true;
47  try {
48  // Get L1TriggerKeyExt
49  key = iSetup.get<L1TriggerKeyExtRcd>().get(key_token);
50  if (!m_overwriteKeys) {
51  triggerKeyOK = oldKeyList.token(key.tscKey()).empty();
52  }
53  } catch (l1t::DataAlreadyPresentException& ex) {
54  triggerKeyOK = false;
55  edm::LogVerbatim("L1-O2O") << ex.what();
56  }
57 
58  if (triggerKeyOK && m_writeL1TriggerKeyExt) {
59  edm::LogVerbatim("L1-O2O") << "Object key for L1TriggerKeyExtRcd@L1TriggerKeyExt: " << key.tscKey();
60  token = m_writer.writePayload(iSetup, "L1TriggerKeyExtRcd@L1TriggerKeyExt");
61  }
62 
63  // If L1TriggerKeyExt is invalid, then all configuration data is already in DB
64  bool throwException = false;
65 
66  if (!token.empty() || !m_writeL1TriggerKeyExt) {
67  // Record token in L1TriggerKeyListExt
69  keyList = new L1TriggerKeyListExt(oldKeyList);
70  if (!(keyList->addKey(key.tscKey(), token, m_overwriteKeys))) {
71  throw cond::Exception("L1CondDBPayloadWriter: TSC key " + key.tscKey() + " already in L1TriggerKeyListExt");
72  }
73  }
74 
75  if (m_writeConfigData) {
76  // Loop over record@type in L1TriggerKeyExt
77  L1TriggerKeyExt::RecordToKey::const_iterator it = key.recordToKeyMap().begin();
78  L1TriggerKeyExt::RecordToKey::const_iterator end = key.recordToKeyMap().end();
79 
80  for (; it != end; ++it) {
81  // Do nothing if object key is null.
82  if (it->second == L1TriggerKeyExt::kNullKey) {
83  edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: null object key for " << it->first
84  << "; skipping this record.";
85  } else {
86  // Check key is new before writing
87  if (oldKeyList.token(it->first, it->second).empty() || m_overwriteKeys) {
88  // Write data to ORCON with no IOV
89  if (!oldKeyList.token(it->first, it->second).empty()) {
90  edm::LogVerbatim("L1-O2O") << "*** Overwriting payload: object key for " << it->first << ": "
91  << it->second;
92  } else {
93  edm::LogVerbatim("L1-O2O") << "object key for " << it->first << ": " << it->second;
94  }
95 
96  try {
97  token = m_writer.writePayload(iSetup, it->first);
98  } catch (l1t::DataInvalidException& ex) {
99  edm::LogVerbatim("L1-O2O") << ex.what() << " Skipping to next record.";
100 
101  throwException = true;
102 
103  continue;
104  }
105 
106  if (!token.empty()) {
107  // Record token in L1TriggerKeyListExt
108  if (!keyList) {
109  keyList = new L1TriggerKeyListExt(oldKeyList);
110  }
111 
112  if (!(keyList->addKey(it->first, it->second, token, m_overwriteKeys))) {
113  // This should never happen because of the check
114  // above, but just in case....
115  throw cond::Exception("L1CondDBPayloadWriter: subsystem key " + it->second + " for " + it->first +
116  " already in L1TriggerKeyListExt");
117  }
118  }
119  } else {
120  edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: object key " << it->second << " for " << it->first
121  << " already in L1TriggerKeyListExt";
122  }
123  }
124  }
125  }
126  }
127 
128  if (keyList) {
129  // Write L1TriggerKeyListExt to ORCON
131  }
132 
133  if (throwException) {
134  throw l1t::DataInvalidException("Payload problem found.");
135  }
136 }
137 
138 // ------------ method called once each job just before starting event loop ------------
140 
141 // ------------ method called once each job just after ending the event loop ------------
143 
144 //define this as a plug-in
145 //DEFINE_FWK_MODULE(L1CondDBPayloadWriterExt);
electrons_cff.bool
bool
Definition: electrons_cff.py:366
L1TriggerKeyListExt
Definition: L1TriggerKeyListExt.h:10
MessageLogger.h
L1TriggerKeyExt::kNullKey
const static std::string kNullKey
Definition: L1TriggerKeyExt.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TriggerKeyExtRcd
Definition: L1TriggerKeyExtRcd.h:8
l1t::DataAlreadyPresentException
Definition: Exception.h:32
L1CondDBPayloadWriterExt::m_writer
l1t::DataWriterExt m_writer
Definition: L1CondDBPayloadWriterExt.h:31
cms::Exception::what
char const * what() const noexcept override
Definition: Exception.cc:103
l1t::DataInvalidException
Definition: Exception.h:51
L1TriggerKeyListExt::addKey
bool addKey(const std::string &tscKey, const std::string &payloadToken, bool overwriteKey=false)
Definition: L1TriggerKeyListExt.cc:28
L1TriggerKeyExtRcd.h
L1TriggerKeyExt.h
L1TriggerKeyListExtRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
L1CondDBPayloadWriterExt::endJob
void endJob() override
Definition: L1CondDBPayloadWriterExt.cc:142
mps_fire.end
end
Definition: mps_fire.py:242
L1TriggerKeyExt
Definition: L1TriggerKeyExt.h:23
l1t::DataWriterExt::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
Definition: DataWriterExt.cc:148
L1CondDBPayloadWriterExt::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1CondDBPayloadWriterExt.cc:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1CondDBPayloadWriterExt::m_newL1TriggerKeyListExt
bool m_newL1TriggerKeyListExt
Definition: L1CondDBPayloadWriterExt.h:49
edm::ParameterSet
Definition: ParameterSet.h:47
iEvent
int iEvent
Definition: GenABIO.cc:224
L1CondDBPayloadWriterExt::beginJob
void beginJob() override
Definition: L1CondDBPayloadWriterExt.cc:139
cond::Exception
persistency::Exception Exception
Definition: Exception.h:25
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
L1CondDBPayloadWriterExt::m_overwriteKeys
bool m_overwriteKeys
Definition: L1CondDBPayloadWriterExt.h:44
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
l1t::DataWriterExt::writePayload
std::string writePayload(const edm::EventSetup &setup, const std::string &recordType)
Definition: DataWriterExt.cc:15
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
L1TriggerKeyListExt.h
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
L1CondDBPayloadWriterExt::m_writeL1TriggerKeyExt
bool m_writeL1TriggerKeyExt
Definition: L1CondDBPayloadWriterExt.h:38
L1CondDBPayloadWriterExt.h
L1CondDBPayloadWriterExt::key_token
edm::ESGetToken< L1TriggerKeyExt, L1TriggerKeyExtRcd > key_token
Definition: L1CondDBPayloadWriterExt.h:35
L1CondDBPayloadWriterExt::L1CondDBPayloadWriterExt
L1CondDBPayloadWriterExt(const edm::ParameterSet &)
Definition: L1CondDBPayloadWriterExt.cc:10
L1CondDBPayloadWriterExt::m_logTransactions
bool m_logTransactions
Definition: L1CondDBPayloadWriterExt.h:46
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
L1CondDBPayloadWriterExt::m_writeConfigData
bool m_writeConfigData
Definition: L1CondDBPayloadWriterExt.h:41
l1t::DataWriterExt::writeKeyList
void writeKeyList(L1TriggerKeyListExt *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
Definition: DataWriterExt.cc:49
L1TriggerKeyListExt::token
std::string token(const std::string &tscKey) const
Definition: L1TriggerKeyListExt.cc:69
L1CondDBPayloadWriterExt::~L1CondDBPayloadWriterExt
~L1CondDBPayloadWriterExt() override
Definition: L1CondDBPayloadWriterExt.cc:20
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316