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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

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

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

Definition at line 39 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Constructor & Destructor Documentation

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")) {}
T getParameter(std::string const &) const
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > alcarecoReplace_
const std::vector< std::string > listNamesRemove_
AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate ( )
inlineoverride

Definition at line 34 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References analyze().

34 {}

Member Function Documentation

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

Definition at line 156 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

Referenced by analyze().

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 }
std::map< std::string, std::string > m_alcarecoToTrig
std::map< std::string, std::string > TriggerMap
std::string compose(const std::vector< std::string > &paths) const
Compose several paths into one string :
void AlCaRecoTriggerBitsRcdUpdate::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
override

Definition at line 70 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

Referenced by ~AlCaRecoTriggerBitsRcdUpdate().

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 }
AlCaRecoTriggerBits * createStartTriggerBits(bool startEmpty, const edm::EventSetup &evtSetup) const
std::map< std::string, std::string > m_alcarecoToTrig
bool addTriggerLists(const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > alcarecoReplace_
bool removeKeysFromMap(const std::vector< std::string > &keys, TriggerMap &triggerMap) const
const std::vector< std::string > listNamesRemove_
void writeBitsToDB(AlCaRecoTriggerBits *bitsToWrite) const
Takes over memory uresponsibility for &#39;bitsToWrite&#39;.
bool replaceKeysFromMap(const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
AlCaRecoTriggerBits * AlCaRecoTriggerBitsRcdUpdate::createStartTriggerBits ( bool  startEmpty,
const edm::EventSetup evtSetup 
) const
private

Definition at line 97 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References edm::EventSetup::get().

Referenced by analyze().

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 }
T get() const
Definition: EventSetup.h:73
bool AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap ( const std::vector< std::string > &  keys,
TriggerMap triggerMap 
) const
private

Definition at line 108 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References Exception.

Referenced by analyze().

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 }
bool AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap ( const std::vector< edm::ParameterSet > &  alcarecoReplace,
TriggerMap triggerMap 
) const
private

Definition at line 128 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

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 }
void AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB ( AlCaRecoTriggerBits bitsToWrite) const
private

Takes over memory uresponsibility for 'bitsToWrite'.

Definition at line 181 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

Referenced by analyze().

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 }
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:40
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)

Member Data Documentation

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

Definition at line 53 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

const unsigned int AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_
private

Definition at line 48 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

const int AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_
private

Definition at line 49 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

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

Definition at line 51 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

unsigned int AlCaRecoTriggerBitsRcdUpdate::nEventCalls_
private

Definition at line 47 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

const bool AlCaRecoTriggerBitsRcdUpdate::startEmpty_
private

Definition at line 50 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

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

Definition at line 52 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().