CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
AlCaRecoTriggerBitsRcdUpdate Class Reference
Inheritance diagram for AlCaRecoTriggerBitsRcdUpdate:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 AlCaRecoTriggerBitsRcdUpdate (const edm::ParameterSet &cfg)
 
void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
 ~AlCaRecoTriggerBitsRcdUpdate () override=default
 
- 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::map< std::string, std::string > TriggerMap
 

Private Member Functions

bool addPathsFromMap (const std::vector< edm::ParameterSet > &pathsToAdd, AlCaRecoTriggerBits &bits) const
 
bool addTriggerLists (const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
 
bool removeKeysFromMap (const std::vector< std::string > &keys, TriggerMap &triggerMap) const
 
bool removePathsFromMap (const std::vector< edm::ParameterSet > &pathsToRemove, AlCaRecoTriggerBits &bits) const
 
bool replaceKeysFromMap (const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
 
void writeBitsToDB (const AlCaRecoTriggerBits &bitsToWrite) const
 

Private Attributes

const std::vector< edm::ParameterSetalcarecoReplace_
 
const unsigned int firstRunIOV_
 
const int lastRunIOV_
 
const std::vector< std::string > listNamesRemove_
 
unsigned int nEventCalls_
 
const std::vector< edm::ParameterSetpathsToAdd_
 
const std::vector< edm::ParameterSetpathsToRemove_
 
const bool startEmpty_
 
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcdtriggerBitsToken_
 
const std::vector< edm::ParameterSettriggerListsAdd_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

Module to write trigger bit mappings (AlCaRecoTriggerBits) to DB. Can be configured to read an old one and update this by

Definition at line 32 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Member Typedef Documentation

◆ TriggerMap

typedef std::map<std::string, std::string> AlCaRecoTriggerBitsRcdUpdate::TriggerMap
private

Definition at line 41 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Constructor & Destructor Documentation

◆ AlCaRecoTriggerBitsRcdUpdate()

AlCaRecoTriggerBitsRcdUpdate::AlCaRecoTriggerBitsRcdUpdate ( const edm::ParameterSet cfg)
explicit

Definition at line 98 of file AlCaRecoTriggerBitsRcdUpdate.cc.

100  nEventCalls_(0),
101  firstRunIOV_(cfg.getParameter<unsigned int>("firstRunIOV")),
102  lastRunIOV_(cfg.getParameter<int>("lastRunIOV")),
103  startEmpty_(cfg.getParameter<bool>("startEmpty")),
104  listNamesRemove_(cfg.getParameter<std::vector<std::string>>("listNamesRemove")),
105  triggerListsAdd_(cfg.getParameter<std::vector<edm::ParameterSet>>("triggerListsAdd")),
106  alcarecoReplace_(cfg.getParameter<std::vector<edm::ParameterSet>>("alcarecoToReplace")),
107  pathsToAdd_(cfg.getParameter<std::vector<edm::ParameterSet>>("pathsToAdd")),
108  pathsToRemove_(cfg.getParameter<std::vector<edm::ParameterSet>>("pathsToRemove")) {}
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
const std::vector< edm::ParameterSet > pathsToRemove_
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > pathsToAdd_
const std::vector< edm::ParameterSet > alcarecoReplace_
const std::vector< std::string > listNamesRemove_

◆ ~AlCaRecoTriggerBitsRcdUpdate()

AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate ( )
overridedefault

Member Function Documentation

◆ addPathsFromMap()

bool AlCaRecoTriggerBitsRcdUpdate::addPathsFromMap ( const std::vector< edm::ParameterSet > &  pathsToAdd,
AlCaRecoTriggerBits bits 
) const
private

Definition at line 216 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References gpuClustering::pixelStatus::bits, filterCSVwithJSON::copy, Exception, ALCARECOTkAlBeamHalo_cff::filter, Skims_PA_cff::paths, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

217  {
218  TriggerMap &triggerMap = bits.m_alcarecoToTrig; //read from the condition tag
219 
220  // loop on PSets, each containing the key (filter name) and a vstring with triggers
221  for (const auto &iSet : pathsToAdd) {
222  const std::string filter(iSet.getParameter<std::string>("listName"));
223  std::string mergedPathsInKey;
224 
225  for (const auto &imap : triggerMap) {
226  if (imap.first == filter)
227  mergedPathsInKey = imap.second; //paths in the condition tag
228  }
229 
230  if (mergedPathsInKey.empty()) {
231  throw cms::Exception("BadConfig") << "List name '" << filter << "' not found in the map, "
232  << "if you want to add new key/paths, please use 'addTriggerLists'.\n";
233  }
234 
235  auto const &pathsInKey = bits.decompose(mergedPathsInKey);
236  auto const &paths = iSet.getParameter<std::vector<std::string>>("hltPaths"); //paths to add; from the configuration
237 
238  if (paths.empty()) { // nothing to add ==> misconfiguration!
239  throw cms::Exception("BadConfig") << "Didn't set any path to add!";
240  }
241 
242  std::set<std::string> pathsSet{pathsInKey.begin(), pathsInKey.end()};
243  std::copy(paths.begin(), paths.end(), std::inserter(pathsSet, pathsSet.end()));
244  std::vector<std::string> const newPathsInKey{pathsSet.begin(), pathsSet.end()};
245 
246  // We must avoid a map<string,vector<string> > in DB for performance reason,
247  // so we have to merge the paths into one string that will be decoded when needed:
248  triggerMap[filter] = bits.compose(newPathsInKey);
249  }
250 
251  return true;
252 }
constexpr uint32_t bits
Definition: gpuClustering.h:23
std::map< std::string, std::string > TriggerMap

◆ addTriggerLists()

bool AlCaRecoTriggerBitsRcdUpdate::addTriggerLists ( const std::vector< edm::ParameterSet > &  triggerListsAdd,
AlCaRecoTriggerBits bits 
) const
private

Definition at line 192 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References gpuClustering::pixelStatus::bits, Exception, ALCARECOTkAlBeamHalo_cff::filter, Skims_PA_cff::paths, AlCaHLTBitMon_QueryRunRegistry::string, and CreateSqliteForCondDB_cfg::triggerListsAdd.

Referenced by analyze().

193  {
194  TriggerMap &triggerMap = bits.m_alcarecoToTrig;
195 
196  // loop on PSets, each containing the key (filter name) and a vstring with triggers
197  for (const auto &iSet : triggerListsAdd) {
198  const std::vector<std::string> paths(iSet.getParameter<std::vector<std::string>>("hltPaths"));
199  // We must avoid a map<string,vector<string> > in DB for performance reason,
200  // so we have to merge the paths into one string that will be decoded when needed:
201  const std::string mergedPaths = bits.compose(paths);
202 
203  const std::string filter(iSet.getParameter<std::string>("listName"));
204  if (triggerMap.find(filter) != triggerMap.end()) {
205  throw cms::Exception("BadConfig") << "List name '" << filter << "' already in map, either "
206  << "remove from 'triggerListsAdd' or "
207  << " add to 'listNamesRemove'.\n";
208  }
209  triggerMap[filter] = mergedPaths;
210  }
211 
212  return true;
213 }
constexpr uint32_t bits
Definition: gpuClustering.h:23
std::map< std::string, std::string > TriggerMap

◆ analyze()

void AlCaRecoTriggerBitsRcdUpdate::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 111 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References addPathsFromMap(), addTriggerLists(), alcarecoReplace_, edm::EventSetup::getData(), listNamesRemove_, nEventCalls_, pathsToAdd_, pathsToRemove_, removeKeysFromMap(), removePathsFromMap(), replaceKeysFromMap(), startEmpty_, triggerBitsToken_, triggerListsAdd_, and writeBitsToDB().

111  {
112  if (nEventCalls_++ > 0) { // postfix increment!
113  edm::LogWarning("BadConfig") << "@SUB=analyze"
114  << "Writing to DB to be done only once, set\n"
115  << "'process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))'\n"
116  << " next time. But your writing is fine.)";
117  return;
118  }
119 
120  // create what to write - starting from empty or existing list
121  std::unique_ptr<AlCaRecoTriggerBits> bitsToWrite;
122  if (startEmpty_) {
123  bitsToWrite = std::make_unique<AlCaRecoTriggerBits>();
124  } else {
125  bitsToWrite = std::make_unique<AlCaRecoTriggerBits>(iSetup.getData(triggerBitsToken_));
126  }
127 
128  // remove some existing entries in map
129  this->removeKeysFromMap(listNamesRemove_, bitsToWrite->m_alcarecoToTrig);
130 
131  // now add new entries
132  this->addTriggerLists(triggerListsAdd_, *bitsToWrite);
133 
134  // now replace keys
135  this->replaceKeysFromMap(alcarecoReplace_, bitsToWrite->m_alcarecoToTrig);
136 
137  // add paths to the existing key
138  this->addPathsFromMap(pathsToAdd_, *bitsToWrite);
139 
140  // remove paths from the existing key
141  this->removePathsFromMap(pathsToRemove_, *bitsToWrite);
142 
143  // finally write to DB
144  this->writeBitsToDB(*bitsToWrite);
145 }
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
bool addTriggerLists(const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
bool addPathsFromMap(const std::vector< edm::ParameterSet > &pathsToAdd, AlCaRecoTriggerBits &bits) const
bool replaceKeysFromMap(const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
const std::vector< edm::ParameterSet > pathsToRemove_
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > pathsToAdd_
bool removePathsFromMap(const std::vector< edm::ParameterSet > &pathsToRemove, AlCaRecoTriggerBits &bits) const
const std::vector< edm::ParameterSet > alcarecoReplace_
bool removeKeysFromMap(const std::vector< std::string > &keys, TriggerMap &triggerMap) const
void writeBitsToDB(const AlCaRecoTriggerBits &bitsToWrite) const
const std::vector< std::string > listNamesRemove_
Log< level::Warning, false > LogWarning

◆ fillDescriptions()

void AlCaRecoTriggerBitsRcdUpdate::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 62 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

62  {
64  desc.setComment("Plugin to write payloads of type AlCaRecoTriggerBits");
65  desc.add<unsigned int>("firstRunIOV", 1);
66  desc.add<int>("lastRunIOV", -1);
67  desc.add<bool>("startEmpty", true);
68  desc.add<std::vector<std::string>>("listNamesRemove", {});
69 
70  edm::ParameterSetDescription desc_triggeListsToAdd;
71  desc_triggeListsToAdd.add<std::string>("listName");
72  desc_triggeListsToAdd.add<std::vector<std::string>>("hltPaths");
73  std::vector<edm::ParameterSet> default_triggerListsToAdd;
74  desc.addVPSet("triggerListsAdd", desc_triggeListsToAdd, default_triggerListsToAdd);
75 
76  edm::ParameterSetDescription desc_alcarecoToReplace;
77  desc_alcarecoToReplace.add<std::string>("oldKey");
78  desc_alcarecoToReplace.add<std::string>("newKey");
79  std::vector<edm::ParameterSet> default_alcarecoToReplace;
80  desc.addVPSet("alcarecoToReplace", desc_alcarecoToReplace, default_alcarecoToReplace);
81 
82  edm::ParameterSetDescription desc_pathsToAdd;
83  desc_pathsToAdd.add<std::string>("listName");
84  desc_pathsToAdd.add<std::vector<std::string>>("hltPaths");
85  std::vector<edm::ParameterSet> default_pathsToAdd;
86  desc.addVPSet("pathsToAdd", desc_pathsToAdd, default_pathsToAdd);
87 
88  edm::ParameterSetDescription desc_pathsToRemove;
89  desc_pathsToRemove.add<std::string>("listName");
90  desc_pathsToRemove.add<std::vector<std::string>>("hltPaths");
91  std::vector<edm::ParameterSet> default_pathsToRemove;
92  desc.addVPSet("pathsToRemove", desc_pathsToRemove, default_pathsToRemove);
93 
94  descriptions.addWithDefaultLabel(desc);
95 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ removeKeysFromMap()

bool AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap ( const std::vector< std::string > &  keys,
TriggerMap triggerMap 
) const
private

Definition at line 148 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References Exception, and relativeConstraints::keys.

Referenced by analyze().

149  {
150  for (std::vector<std::string>::const_iterator iKey = keys.begin(), endKey = keys.end(); iKey != endKey; ++iKey) {
151  if (triggerMap.find(*iKey) != triggerMap.end()) {
152  triggerMap.erase(*iKey);
153  } else { // not in list ==> misconfiguartion!
154  throw cms::Exception("BadConfig") << "[AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap] "
155  << "Cannot remove key '" << *iKey << "' since not in "
156  << "list - typo in configuration?\n";
157  return false;
158  }
159  }
160  return true;
161 }

◆ removePathsFromMap()

bool AlCaRecoTriggerBitsRcdUpdate::removePathsFromMap ( const std::vector< edm::ParameterSet > &  pathsToRemove,
AlCaRecoTriggerBits bits 
) const
private

Definition at line 255 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References gpuClustering::pixelStatus::bits, Exception, ALCARECOTkAlBeamHalo_cff::filter, castor_dqm_sourceclient_file_cfg::path, Skims_PA_cff::paths, MatrixUtil::remove(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

256  {
257  TriggerMap &triggerMap = bits.m_alcarecoToTrig; //read from the condition tag
258 
259  // loop on PSets, each containing the key (filter name) and a vstring with triggers
260  for (const auto &iSet : pathsToRemove) {
261  const std::string filter(iSet.getParameter<std::string>("listName"));
262  std::string mergedPathsInKey;
263 
264  for (const auto &imap : triggerMap) {
265  if (imap.first == filter)
266  mergedPathsInKey = imap.second; //paths in the condition tag
267  }
268 
269  if (mergedPathsInKey.empty()) {
270  throw cms::Exception("BadConfig") << "List name '" << filter << "' not found in the map";
271  }
272 
273  auto PathsInKey = bits.decompose(mergedPathsInKey);
274  auto const paths(
275  iSet.getParameter<std::vector<std::string>>("hltPaths")); //paths to remove; from the configuration
276 
277  if (paths.empty()) { // nothing to remove ==> misconfiguration!
278  throw cms::Exception("BadConfig") << "Didn't set any path to remove!";
279  }
280 
281  for (auto const &path : paths) {
282  PathsInKey.erase(std::remove(PathsInKey.begin(), PathsInKey.end(), path), PathsInKey.end());
283  }
284 
285  // We must avoid a map<string,vector<string> > in DB for performance reason,
286  // so we have to merge the paths into one string that will be decoded when needed:
287  triggerMap[filter] = bits.compose(PathsInKey);
288  }
289 
290  return true;
291 }
constexpr uint32_t bits
Definition: gpuClustering.h:23
std::map< std::string, std::string > TriggerMap
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223

◆ replaceKeysFromMap()

bool AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap ( const std::vector< edm::ParameterSet > &  alcarecoReplace,
TriggerMap triggerMap 
) const
private

Definition at line 164 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

165  {
166  std::vector<std::pair<std::string, std::string>> keyPairs;
167  keyPairs.reserve(alcarecoReplace.size());
168 
169  for (auto &iSet : alcarecoReplace) {
170  const std::string oldKey(iSet.getParameter<std::string>("oldKey"));
171  const std::string newKey(iSet.getParameter<std::string>("newKey"));
172  keyPairs.push_back(std::make_pair(oldKey, newKey));
173  }
174 
175  for (auto &iKey : keyPairs) {
176  if (triggerMap.find(iKey.first) != triggerMap.end()) {
177  std::string bitsToReplace = triggerMap[iKey.first];
178  triggerMap.erase(iKey.first);
179  triggerMap[iKey.second] = bitsToReplace;
180  } else { // not in list ==> misconfiguration!
181  edm::LogWarning("AlCaRecoTriggerBitsRcdUpdate")
182  << "[AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap] "
183  << "Cannot replace key '" << iKey.first << "with " << iKey.second << " since not in "
184  << "list - typo in configuration?\n";
185  return false;
186  }
187  }
188  return true;
189 }
Log< level::Warning, false > LogWarning

◆ writeBitsToDB()

void AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB ( const AlCaRecoTriggerBits bitsToWrite) const
private

Definition at line 294 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::commitTransaction(), cond::service::PoolDBOutputService::createNewIOV(), Exception, firstRunIOV_, cond::service::PoolDBOutputService::forceInit(), edm::Service< T >::isAvailable(), cond::TagInfo_t::lastInterval, lastRunIOV_, cond::Iov_t::payloadId, align_cfg::recordName, cond::service::PoolDBOutputService::session(), cond::service::PoolDBOutputService::startTransaction(), cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::tagInfo().

Referenced by analyze().

294  {
295  edm::LogInfo("AlCaRecoTriggerBitsRcdUpdate") << "Uploading to the database...";
296 
298  if (!poolDbService.isAvailable()) {
299  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available.\n";
300  }
301 
302  const std::string recordName("AlCaRecoTriggerBitsRcd");
303 
304  // when updating existing tag, compare payload hashs and skip appending new hash if it's same with last iov's
305  poolDbService->startTransaction();
306  auto newHash = poolDbService->session().storePayload(bitsToWrite);
307  cond::TagInfo_t tag_info;
308 
309  if (poolDbService->tagInfo(recordName, tag_info)) {
310  if (newHash != tag_info.lastInterval.payloadId) {
311  edm::LogInfo("AlCaRecoTriggerBitsRcdUpdate") << "## Appending to existing tag...";
312  poolDbService->forceInit();
313  poolDbService->appendSinceTime(newHash, firstRunIOV_, recordName);
314  } else {
315  edm::LogInfo("AlCaRecoTriggerBitsRcdUpdate") << "## Skipping update since hash is the same...";
316  }
317 
318  } else {
319  edm::LogInfo("AlCaRecoTriggerBitsRcdUpdate") << "## Creating new tag...";
320  poolDbService->forceInit();
321  poolDbService->createNewIOV(newHash, firstRunIOV_, recordName);
322  }
323  poolDbService->commitTransaction();
324 
325  edm::LogInfo("AlCaRecoTriggerBitsRcdUpdate")
326  << "...done for runs " << firstRunIOV_ << " to " << lastRunIOV_ << " (< 0 meaning infinity)!";
327 }
Iov_t lastInterval
Definition: Types.h:73
Hash payloadId
Definition: Types.h:55
Log< level::Info, false > LogInfo
bool appendSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
void createNewIOV(const std::string &firstPayloadId, cond::Time_t firstSinceTime, const std::string &recordName)
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
bool isAvailable() const
Definition: Service.h:40
bool tagInfo(const std::string &recordName, cond::TagInfo_t &result)
cond::persistency::Session session() const

Member Data Documentation

◆ alcarecoReplace_

const std::vector<edm::ParameterSet> AlCaRecoTriggerBitsRcdUpdate::alcarecoReplace_
private

Definition at line 56 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ firstRunIOV_

const unsigned int AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_
private

Definition at line 51 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

◆ lastRunIOV_

const int AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_
private

Definition at line 52 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

◆ listNamesRemove_

const std::vector<std::string> AlCaRecoTriggerBitsRcdUpdate::listNamesRemove_
private

Definition at line 54 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ nEventCalls_

unsigned int AlCaRecoTriggerBitsRcdUpdate::nEventCalls_
private

Definition at line 50 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ pathsToAdd_

const std::vector<edm::ParameterSet> AlCaRecoTriggerBitsRcdUpdate::pathsToAdd_
private

Definition at line 57 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ pathsToRemove_

const std::vector<edm::ParameterSet> AlCaRecoTriggerBitsRcdUpdate::pathsToRemove_
private

Definition at line 58 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ startEmpty_

const bool AlCaRecoTriggerBitsRcdUpdate::startEmpty_
private

Definition at line 53 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ triggerBitsToken_

const edm::ESGetToken<AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd> AlCaRecoTriggerBitsRcdUpdate::triggerBitsToken_
private

Definition at line 49 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ triggerListsAdd_

const std::vector<edm::ParameterSet> AlCaRecoTriggerBitsRcdUpdate::triggerListsAdd_
private

Definition at line 55 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().