Public Member Functions | |
AlCaRecoTriggerBitsRcdUpdate (const edm::ParameterSet &cfg) | |
virtual void | analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) |
~AlCaRecoTriggerBitsRcdUpdate () | |
Private Types | |
typedef std::map< std::string, std::string > | TriggerMap |
Private Member Functions | |
bool | addTriggerLists (const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const |
AlCaRecoTriggerBits * | createStartTriggerBits (bool startEmpty, const edm::EventSetup &evtSetup) const |
bool | removeKeysFromMap (const std::vector< std::string > &keys, TriggerMap &triggerMap) const |
void | writeBitsToDB (AlCaRecoTriggerBits *bitsToWrite) const |
Takes over memory uresponsibility for 'bitsToWrite'. | |
Private Attributes | |
const unsigned int | firstRunIOV_ |
const int | lastRunIOV_ |
const std::vector< std::string > | listNamesRemove_ |
unsigned int | nEventCalls_ |
const bool | startEmpty_ |
const std::vector < edm::ParameterSet > | triggerListsAdd_ |
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.
typedef std::map<std::string, std::string> AlCaRecoTriggerBitsRcdUpdate::TriggerMap [private] |
Definition at line 40 of file AlCaRecoTriggerBitsRcdUpdate.cc.
AlCaRecoTriggerBitsRcdUpdate::AlCaRecoTriggerBitsRcdUpdate | ( | const edm::ParameterSet & | cfg | ) | [explicit] |
Definition at line 60 of file AlCaRecoTriggerBitsRcdUpdate.cc.
: nEventCalls_(0), firstRunIOV_(cfg.getParameter<unsigned int>("firstRunIOV")), lastRunIOV_(cfg.getParameter<int>("lastRunIOV")), startEmpty_(cfg.getParameter<bool>("startEmpty")), listNamesRemove_(cfg.getParameter<std::vector<std::string> >("listNamesRemove")), triggerListsAdd_(cfg.getParameter<std::vector<edm::ParameterSet> >("triggerListsAdd")) { }
AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate | ( | ) | [inline] |
Definition at line 35 of file AlCaRecoTriggerBitsRcdUpdate.cc.
{}
bool AlCaRecoTriggerBitsRcdUpdate::addTriggerLists | ( | const std::vector< edm::ParameterSet > & | triggerListsAdd, |
AlCaRecoTriggerBits & | bits | ||
) | const [private] |
Definition at line 132 of file AlCaRecoTriggerBitsRcdUpdate.cc.
References AlCaRecoTriggerBits::compose(), Exception, align_tpl::filter, AlCaRecoTriggerBits::m_alcarecoToTrig, and EgammaValidation_cff::paths.
Referenced by analyze().
{ TriggerMap &triggerMap = bits.m_alcarecoToTrig; // loop on PSets, each containing the key (filter name) and a vstring with triggers for (std::vector<edm::ParameterSet>::const_iterator iSet = triggerListsAdd.begin(); iSet != triggerListsAdd.end(); ++iSet) { const std::vector<std::string> paths(iSet->getParameter<std::vector<std::string> >("hltPaths")); // We must avoid a map<string,vector<string> > in DB for performance reason, // so we have to merge the paths into one string that will be decoded when needed: const std::string mergedPaths = bits.compose(paths); const std::string filter(iSet->getParameter<std::string>("listName")); if (triggerMap.find(filter) != triggerMap.end()) { throw cms::Exception("BadConfig") << "List name '" << filter << "' already in map, either " << "remove from 'triggerListsAdd' or " << " add to 'listNamesRemove'.\n"; } triggerMap[filter] = mergedPaths; } return true; }
void AlCaRecoTriggerBitsRcdUpdate::analyze | ( | const edm::Event & | evt, |
const edm::EventSetup & | evtSetup | ||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 71 of file AlCaRecoTriggerBitsRcdUpdate.cc.
References addTriggerLists(), createStartTriggerBits(), listNamesRemove_, AlCaRecoTriggerBits::m_alcarecoToTrig, nEventCalls_, removeKeysFromMap(), startEmpty_, triggerListsAdd_, and writeBitsToDB().
{ if (nEventCalls_++ > 0) { // postfix increment! edm::LogWarning("BadConfig") << "@SUB=analyze" << "Writing to DB to be done only once, set\n" << "'process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))'\n" << " next time. But your writing is fine.)"; return; } // create what to write - starting from empty or existing list (auto_ptr?) AlCaRecoTriggerBits *bitsToWrite = this->createStartTriggerBits(startEmpty_, iSetup); // remove some existing entries in map this->removeKeysFromMap(listNamesRemove_, bitsToWrite->m_alcarecoToTrig); // now add new entries this->addTriggerLists(triggerListsAdd_, *bitsToWrite); // finally write to DB this->writeBitsToDB(bitsToWrite); }
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().
{ if (startEmpty) { return new AlCaRecoTriggerBits; } else { edm::ESHandle<AlCaRecoTriggerBits> triggerBits; evtSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits); return new AlCaRecoTriggerBits(*triggerBits); // copy old one } }
bool AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap | ( | const std::vector< std::string > & | keys, |
TriggerMap & | triggerMap | ||
) | const [private] |
Definition at line 110 of file AlCaRecoTriggerBitsRcdUpdate.cc.
References Exception.
Referenced by analyze().
{ for (std::vector<std::string>::const_iterator iKey = keys.begin(), endKey = keys.end(); iKey != endKey; ++iKey) { if (triggerMap.find(*iKey) != triggerMap.end()) { // remove // edm::LogError("Temp") << "@SUB=removeKeysFromMap" << "Cannot yet remove '" << *iKey // << "' from map."; // FIXME: test next line@ triggerMap.erase(*iKey); } else { // not in list ==> misconfiguartion! throw cms::Exception("BadConfig") << "[AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap] " << "Cannot remove key '" << *iKey << "' since not in " << "list - typo in configuration?\n"; return false; } } return true; }
void AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB | ( | AlCaRecoTriggerBits * | bitsToWrite | ) | const [private] |
Takes over memory uresponsibility for 'bitsToWrite'.
Definition at line 159 of file AlCaRecoTriggerBitsRcdUpdate.cc.
References Exception, firstRunIOV_, edm::Service< T >::isAvailable(), MergeJob_cfg::lastRun, lastRunIOV_, and ecalTPGAnalyzer_cfg::recordName.
Referenced by analyze().
{ edm::LogInfo("") << "Uploading to the database..."; edm::Service<cond::service::PoolDBOutputService> poolDbService; if (!poolDbService.isAvailable()) { throw cms::Exception("NotAvailable") << "PoolDBOutputService not available.\n"; } // ownership of bitsToWrite transferred // FIXME: Have to check that timetype is run number! How? const std::string recordName("AlCaRecoTriggerBitsRcd"); if (poolDbService->isNewTagRequest(recordName)) { // tag not yet existing // lastRunIOV_ = -1 means infinity: const cond::Time_t lastRun = (lastRunIOV_ < 0 ? poolDbService->endOfTime() : lastRunIOV_); poolDbService->createNewIOV(bitsToWrite, firstRunIOV_, lastRun, recordName); } else { // tag exists, can only append if (lastRunIOV_ >= 0) { throw cms::Exception("BadConfig") << "Tag already exists, can only append until infinity," << " but lastRunIOV = " << lastRunIOV_ << ".\n"; } poolDbService->appendSinceTime(bitsToWrite, firstRunIOV_, recordName); } edm::LogInfo("") << "...done for runs " << firstRunIOV_ << " to " << lastRunIOV_ << " (< 0 meaning infinity)!"; }
const unsigned int AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_ [private] |
Definition at line 49 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by writeBitsToDB().
const int AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_ [private] |
Definition at line 50 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by writeBitsToDB().
const std::vector<std::string> AlCaRecoTriggerBitsRcdUpdate::listNamesRemove_ [private] |
Definition at line 52 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by analyze().
unsigned int AlCaRecoTriggerBitsRcdUpdate::nEventCalls_ [private] |
Definition at line 48 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by analyze().
const bool AlCaRecoTriggerBitsRcdUpdate::startEmpty_ [private] |
Definition at line 51 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by analyze().
const std::vector<edm::ParameterSet> AlCaRecoTriggerBitsRcdUpdate::triggerListsAdd_ [private] |
Definition at line 53 of file AlCaRecoTriggerBitsRcdUpdate.cc.
Referenced by analyze().