CMS 3D CMS Logo

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

Public Member Functions

 AlCaRecoTriggerBitsRcdUpdate (const edm::ParameterSet &cfg)
 
void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
 ~AlCaRecoTriggerBitsRcdUpdate () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

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

Private Member Functions

bool addTriggerLists (const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
 
AlCaRecoTriggerBitscreateStartTriggerBits (bool startEmpty, const edm::EventSetup &evtSetup) const
 
bool removeKeysFromMap (const std::vector< std::string > &keys, TriggerMap &triggerMap) const
 
bool replaceKeysFromMap (const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
 
void writeBitsToDB (AlCaRecoTriggerBits *bitsToWrite) const
 Takes over memory uresponsibility for 'bitsToWrite'. More...
 

Private Attributes

const std::vector< edm::ParameterSetalcarecoReplace_
 
const unsigned int firstRunIOV_
 
const int lastRunIOV_
 
const std::vector< std::string > listNamesRemove_
 
unsigned int nEventCalls_
 
const bool startEmpty_
 
const std::vector< edm::ParameterSettriggerListsAdd_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 31 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Member Typedef Documentation

◆ TriggerMap

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

Definition at line 39 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Constructor & Destructor Documentation

◆ AlCaRecoTriggerBitsRcdUpdate()

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

Definition at line 60 of file AlCaRecoTriggerBitsRcdUpdate.cc.

61  : nEventCalls_(0),
62  firstRunIOV_(cfg.getParameter<unsigned int>("firstRunIOV")),
63  lastRunIOV_(cfg.getParameter<int>("lastRunIOV")),
64  startEmpty_(cfg.getParameter<bool>("startEmpty")),
65  listNamesRemove_(cfg.getParameter<std::vector<std::string> >("listNamesRemove")),
66  triggerListsAdd_(cfg.getParameter<std::vector<edm::ParameterSet> >("triggerListsAdd")),
67  alcarecoReplace_(cfg.getParameter<std::vector<edm::ParameterSet> >("alcarecoToReplace")) {}

◆ ~AlCaRecoTriggerBitsRcdUpdate()

AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate ( )
inlineoverride

Definition at line 34 of file AlCaRecoTriggerBitsRcdUpdate.cc.

34 {}

Member Function Documentation

◆ addTriggerLists()

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

Definition at line 156 of file AlCaRecoTriggerBitsRcdUpdate.cc.

157  {
158  TriggerMap &triggerMap = bits.m_alcarecoToTrig;
159 
160  // loop on PSets, each containing the key (filter name) and a vstring with triggers
161  for (std::vector<edm::ParameterSet>::const_iterator iSet = triggerListsAdd.begin(); iSet != triggerListsAdd.end();
162  ++iSet) {
163  const std::vector<std::string> paths(iSet->getParameter<std::vector<std::string> >("hltPaths"));
164  // We must avoid a map<string,vector<string> > in DB for performance reason,
165  // so we have to merge the paths into one string that will be decoded when needed:
166  const std::string mergedPaths = bits.compose(paths);
167 
168  const std::string filter(iSet->getParameter<std::string>("listName"));
169  if (triggerMap.find(filter) != triggerMap.end()) {
170  throw cms::Exception("BadConfig") << "List name '" << filter << "' already in map, either "
171  << "remove from 'triggerListsAdd' or "
172  << " add to 'listNamesRemove'.\n";
173  }
174  triggerMap[filter] = mergedPaths;
175  }
176 
177  return true;
178 }

References AlCaRecoTriggerBits::compose(), Exception, ALCARECOTkAlBeamHalo_cff::filter, AlCaRecoTriggerBits::m_alcarecoToTrig, Skims_PA_cff::paths, AlCaHLTBitMon_QueryRunRegistry::string, and CreateSqliteForCondDB_cfg::triggerListsAdd.

Referenced by analyze().

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 70 of file AlCaRecoTriggerBitsRcdUpdate.cc.

70  {
71  if (nEventCalls_++ > 0) { // postfix increment!
72  edm::LogWarning("BadConfig") << "@SUB=analyze"
73  << "Writing to DB to be done only once, set\n"
74  << "'process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))'\n"
75  << " next time. But your writing is fine.)";
76  return;
77  }
78 
79  // create what to write - starting from empty or existing list (auto_ptr?)
80  AlCaRecoTriggerBits *bitsToWrite = this->createStartTriggerBits(startEmpty_, iSetup);
81 
82  // remove some existing entries in map
84 
85  // now add new entries
86  this->addTriggerLists(triggerListsAdd_, *bitsToWrite);
87 
88  // now replace keys
90 
91  // finally write to DB
92  this->writeBitsToDB(bitsToWrite);
93 }

References addTriggerLists(), alcarecoReplace_, createStartTriggerBits(), listNamesRemove_, AlCaRecoTriggerBits::m_alcarecoToTrig, nEventCalls_, removeKeysFromMap(), replaceKeysFromMap(), startEmpty_, triggerListsAdd_, and writeBitsToDB().

◆ createStartTriggerBits()

AlCaRecoTriggerBits * AlCaRecoTriggerBitsRcdUpdate::createStartTriggerBits ( bool  startEmpty,
const edm::EventSetup evtSetup 
) const
private

Definition at line 97 of file AlCaRecoTriggerBitsRcdUpdate.cc.

97  {
98  if (startEmpty) {
99  return new AlCaRecoTriggerBits;
100  } else {
102  evtSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
103  return new AlCaRecoTriggerBits(*triggerBits); // copy old one
104  }
105 }

References edm::EventSetup::get(), get, and CreateSqliteForCondDB_cfg::startEmpty.

Referenced by analyze().

◆ removeKeysFromMap()

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

Definition at line 108 of file AlCaRecoTriggerBitsRcdUpdate.cc.

109  {
110  for (std::vector<std::string>::const_iterator iKey = keys.begin(), endKey = keys.end(); iKey != endKey; ++iKey) {
111  if (triggerMap.find(*iKey) != triggerMap.end()) {
112  // remove
113  // edm::LogError("Temp") << "@SUB=removeKeysFromMap" << "Cannot yet remove '" << *iKey
114  // << "' from map.";
115  // FIXME: test next line@
116  triggerMap.erase(*iKey);
117  } else { // not in list ==> misconfiguartion!
118  throw cms::Exception("BadConfig") << "[AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap] "
119  << "Cannot remove key '" << *iKey << "' since not in "
120  << "list - typo in configuration?\n";
121  return false;
122  }
123  }
124  return true;
125 }

References Exception, and relativeConstraints::keys.

Referenced by analyze().

◆ replaceKeysFromMap()

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

Definition at line 128 of file AlCaRecoTriggerBitsRcdUpdate.cc.

129  {
130  std::vector<std::pair<std::string, std::string> > keyPairs;
131  keyPairs.reserve(alcarecoReplace.size());
132 
133  for (auto &iSet : alcarecoReplace) {
134  const std::string oldKey(iSet.getParameter<std::string>("oldKey"));
135  const std::string newKey(iSet.getParameter<std::string>("newKey"));
136  keyPairs.push_back(std::make_pair(oldKey, newKey));
137  }
138 
139  for (auto &iKey : keyPairs) {
140  if (triggerMap.find(iKey.first) != triggerMap.end()) {
141  std::string bitsToReplace = triggerMap[iKey.first];
142  triggerMap.erase(iKey.first);
143  triggerMap[iKey.second] = bitsToReplace;
144  } else { // not in list ==> misconfiguration!
145  edm::LogWarning("AlCaRecoTriggerBitsRcdUpdate")
146  << "[AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap] "
147  << "Cannot replace key '" << iKey.first << "with " << iKey.second << " since not in "
148  << "list - typo in configuration?\n";
149  return false;
150  }
151  }
152  return true;
153 }

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

◆ writeBitsToDB()

void AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB ( AlCaRecoTriggerBits bitsToWrite) const
private

Takes over memory uresponsibility for 'bitsToWrite'.

Definition at line 181 of file AlCaRecoTriggerBitsRcdUpdate.cc.

181  {
182  edm::LogInfo("") << "Uploading to the database...";
183 
185  if (!poolDbService.isAvailable()) {
186  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available.\n";
187  }
188 
189  // ownership of bitsToWrite transferred
190  // FIXME: Have to check that timetype is run number! How?
191  const std::string recordName("AlCaRecoTriggerBitsRcd");
192  if (poolDbService->isNewTagRequest(recordName)) { // tag not yet existing
193  // lastRunIOV_ = -1 means infinity:
194  const cond::Time_t lastRun = (lastRunIOV_ < 0 ? poolDbService->endOfTime() : lastRunIOV_);
195  poolDbService->createNewIOV(bitsToWrite, firstRunIOV_, lastRun, recordName);
196  } else { // tag exists, can only append
197  if (lastRunIOV_ >= 0) {
198  throw cms::Exception("BadConfig") << "Tag already exists, can only append until infinity,"
199  << " but lastRunIOV = " << lastRunIOV_ << ".\n";
200  }
201  poolDbService->appendSinceTime(bitsToWrite, firstRunIOV_, recordName);
202  }
203 
204  edm::LogInfo("") << "...done for runs " << firstRunIOV_ << " to " << lastRunIOV_ << " (< 0 meaning infinity)!";
205 }

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::endOfTime(), Exception, firstRunIOV_, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), BeamSpotPI::lastRun, lastRunIOV_, align_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

Member Data Documentation

◆ alcarecoReplace_

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

Definition at line 53 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ firstRunIOV_

const unsigned int AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_
private

Definition at line 48 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

◆ lastRunIOV_

const int AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_
private

Definition at line 49 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

◆ listNamesRemove_

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

Definition at line 51 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ nEventCalls_

unsigned int AlCaRecoTriggerBitsRcdUpdate::nEventCalls_
private

Definition at line 47 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ startEmpty_

const bool AlCaRecoTriggerBitsRcdUpdate::startEmpty_
private

Definition at line 50 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

◆ triggerListsAdd_

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

Definition at line 52 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

AlCaRecoTriggerBitsRcdUpdate::startEmpty_
const bool startEmpty_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:50
AlCaRecoTriggerBitsRcdUpdate::createStartTriggerBits
AlCaRecoTriggerBits * createStartTriggerBits(bool startEmpty, const edm::EventSetup &evtSetup) const
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:97
align_cfg.recordName
recordName
Definition: align_cfg.py:66
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:141
AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB
void writeBitsToDB(AlCaRecoTriggerBits *bitsToWrite) const
Takes over memory uresponsibility for 'bitsToWrite'.
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:181
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlCaRecoTriggerBitsRcdUpdate::alcarecoReplace_
const std::vector< edm::ParameterSet > alcarecoReplace_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:53
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap
bool removeKeysFromMap(const std::vector< std::string > &keys, TriggerMap &triggerMap) const
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:108
AlCaRecoTriggerBitsRcdUpdate::listNamesRemove_
const std::vector< std::string > listNamesRemove_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:51
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
edm::ESHandle
Definition: DTSurvey.h:22
CreateSqliteForCondDB_cfg.startEmpty
startEmpty
Definition: CreateSqliteForCondDB_cfg.py:89
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
AlCaRecoTriggerBits
Definition: AlCaRecoTriggerBits.h:9
AlCaRecoTriggerBitsRcdUpdate::nEventCalls_
unsigned int nEventCalls_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamSpotPI::lastRun
Definition: BeamSpotPayloadInspectorHelper.h:39
AlCaRecoTriggerBitsRcd
Definition: AlCaRecoTriggerBitsRcd.h:22
AlCaRecoTriggerBitsRcdUpdate::TriggerMap
std::map< std::string, std::string > TriggerMap
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:39
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
edm::Service< cond::service::PoolDBOutputService >
AlCaRecoTriggerBitsRcdUpdate::addTriggerLists
bool addTriggerLists(const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:156
get
#define get
looper.cfg
cfg
Definition: looper.py:297
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_
const unsigned int firstRunIOV_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:48
AlCaRecoTriggerBits::m_alcarecoToTrig
std::map< std::string, std::string > m_alcarecoToTrig
Definition: AlCaRecoTriggerBits.h:21
AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap
bool replaceKeysFromMap(const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:128
Exception
Definition: hltDiff.cc:246
AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_
const int lastRunIOV_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:49
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18
AlCaRecoTriggerBitsRcdUpdate::triggerListsAdd_
const std::vector< edm::ParameterSet > triggerListsAdd_
Definition: AlCaRecoTriggerBitsRcdUpdate.cc:52
AlCaRecoTriggerBits::compose
std::string compose(const std::vector< std::string > &paths) const
Compose several paths into one string :
Definition: AlCaRecoTriggerBits.cc:9
CreateSqliteForCondDB_cfg.triggerListsAdd
triggerListsAdd
Definition: CreateSqliteForCondDB_cfg.py:92