CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 addTriggerLists (const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) 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 (const AlCaRecoTriggerBits &bitsToWrite) const
 

Private Attributes

const std::vector
< edm::ParameterSet
alcarecoReplace_
 
const unsigned int firstRunIOV_
 
const int lastRunIOV_
 
const std::vector< std::string > listNamesRemove_
 
unsigned int nEventCalls_
 
const bool startEmpty_
 
const edm::ESGetToken
< AlCaRecoTriggerBits,
AlCaRecoTriggerBitsRcd
triggerBitsToken_
 
const std::vector
< edm::ParameterSet
triggerListsAdd_
 

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

82  nEventCalls_(0),
83  firstRunIOV_(cfg.getParameter<unsigned int>("firstRunIOV")),
84  lastRunIOV_(cfg.getParameter<int>("lastRunIOV")),
85  startEmpty_(cfg.getParameter<bool>("startEmpty")),
86  listNamesRemove_(cfg.getParameter<std::vector<std::string>>("listNamesRemove")),
87  triggerListsAdd_(cfg.getParameter<std::vector<edm::ParameterSet>>("triggerListsAdd")),
88  alcarecoReplace_(cfg.getParameter<std::vector<edm::ParameterSet>>("alcarecoToReplace")) {}
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > alcarecoReplace_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::vector< std::string > listNamesRemove_
AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate ( )
overridedefault

Member Function Documentation

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

Definition at line 170 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References AlCaRecoTriggerBits::compose(), Exception, alcazmumu_cfi::filter, AlCaRecoTriggerBits::m_alcarecoToTrig, mergeAndRegister::paths, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

171  {
172  TriggerMap &triggerMap = bits.m_alcarecoToTrig;
173 
174  // loop on PSets, each containing the key (filter name) and a vstring with triggers
175  for (std::vector<edm::ParameterSet>::const_iterator iSet = triggerListsAdd.begin(); iSet != triggerListsAdd.end();
176  ++iSet) {
177  const std::vector<std::string> paths(iSet->getParameter<std::vector<std::string>>("hltPaths"));
178  // We must avoid a map<string,vector<string> > in DB for performance reason,
179  // so we have to merge the paths into one string that will be decoded when needed:
180  const std::string mergedPaths = bits.compose(paths);
181 
182  const std::string filter(iSet->getParameter<std::string>("listName"));
183  if (triggerMap.find(filter) != triggerMap.end()) {
184  throw cms::Exception("BadConfig") << "List name '" << filter << "' already in map, either "
185  << "remove from 'triggerListsAdd' or "
186  << " add to 'listNamesRemove'.\n";
187  }
188  triggerMap[filter] = mergedPaths;
189  }
190 
191  return true;
192 }
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 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 91 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

91  {
92  if (nEventCalls_++ > 0) { // postfix increment!
93  edm::LogWarning("BadConfig") << "@SUB=analyze"
94  << "Writing to DB to be done only once, set\n"
95  << "'process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))'\n"
96  << " next time. But your writing is fine.)";
97  return;
98  }
99 
100  // create what to write - starting from empty or existing list
101  std::unique_ptr<AlCaRecoTriggerBits> bitsToWrite;
102  if (startEmpty_) {
103  bitsToWrite = std::make_unique<AlCaRecoTriggerBits>();
104  } else {
105  bitsToWrite = std::make_unique<AlCaRecoTriggerBits>(iSetup.getData(triggerBitsToken_));
106  }
107 
108  // remove some existing entries in map
109  this->removeKeysFromMap(listNamesRemove_, bitsToWrite->m_alcarecoToTrig);
110 
111  // now add new entries
112  this->addTriggerLists(triggerListsAdd_, *bitsToWrite);
113 
114  // now replace keys
115  this->replaceKeysFromMap(alcarecoReplace_, bitsToWrite->m_alcarecoToTrig);
116 
117  // finally write to DB
118  this->writeBitsToDB(*bitsToWrite);
119 }
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
bool addTriggerLists(const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< edm::ParameterSet > alcarecoReplace_
void writeBitsToDB(const AlCaRecoTriggerBits &bitsToWrite) const
bool removeKeysFromMap(const std::vector< std::string > &keys, TriggerMap &triggerMap) const
const std::vector< std::string > listNamesRemove_
Log< level::Warning, false > LogWarning
bool replaceKeysFromMap(const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const
void AlCaRecoTriggerBitsRcdUpdate::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 56 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

56  {
58  desc.setComment("Plugin to write payloads of type AlCaRecoTriggerBits");
59  desc.add<unsigned int>("firstRunIOV", 1);
60  desc.add<int>("lastRunIOV", -1);
61  desc.add<bool>("startEmpty", true);
62  desc.add<std::vector<std::string>>("listNamesRemove", {});
63 
64  edm::ParameterSetDescription desc_triggeListsToAdd;
65  desc_triggeListsToAdd.add<std::string>("listName");
66  desc_triggeListsToAdd.add<std::vector<std::string>>("hltPaths");
67  std::vector<edm::ParameterSet> default_triggerListsToAdd;
68  desc.addVPSet("triggerListsAdd", desc_triggeListsToAdd, default_triggerListsToAdd);
69 
70  edm::ParameterSetDescription desc_alcarecoToReplace;
71  desc_alcarecoToReplace.add<std::string>("oldKey");
72  desc_alcarecoToReplace.add<std::string>("newKey");
73  std::vector<edm::ParameterSet> default_alcarecoToReplace;
74  desc.addVPSet("alcarecoToReplace", desc_alcarecoToReplace, default_alcarecoToReplace);
75 
76  descriptions.addWithDefaultLabel(desc);
77 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap ( const std::vector< std::string > &  keys,
TriggerMap triggerMap 
) const
private

Definition at line 122 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References Exception.

Referenced by analyze().

123  {
124  for (std::vector<std::string>::const_iterator iKey = keys.begin(), endKey = keys.end(); iKey != endKey; ++iKey) {
125  if (triggerMap.find(*iKey) != triggerMap.end()) {
126  // remove
127  // edm::LogError("Temp") << "@SUB=removeKeysFromMap" << "Cannot yet remove '" << *iKey
128  // << "' from map.";
129  // FIXME: test next line@
130  triggerMap.erase(*iKey);
131  } else { // not in list ==> misconfiguartion!
132  throw cms::Exception("BadConfig") << "[AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap] "
133  << "Cannot remove key '" << *iKey << "' since not in "
134  << "list - typo in configuration?\n";
135  return false;
136  }
137  }
138  return true;
139 }
bool AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap ( const std::vector< edm::ParameterSet > &  alcarecoReplace,
TriggerMap triggerMap 
) const
private

Definition at line 142 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

143  {
144  std::vector<std::pair<std::string, std::string>> keyPairs;
145  keyPairs.reserve(alcarecoReplace.size());
146 
147  for (auto &iSet : alcarecoReplace) {
148  const std::string oldKey(iSet.getParameter<std::string>("oldKey"));
149  const std::string newKey(iSet.getParameter<std::string>("newKey"));
150  keyPairs.push_back(std::make_pair(oldKey, newKey));
151  }
152 
153  for (auto &iKey : keyPairs) {
154  if (triggerMap.find(iKey.first) != triggerMap.end()) {
155  std::string bitsToReplace = triggerMap[iKey.first];
156  triggerMap.erase(iKey.first);
157  triggerMap[iKey.second] = bitsToReplace;
158  } else { // not in list ==> misconfiguration!
159  edm::LogWarning("AlCaRecoTriggerBitsRcdUpdate")
160  << "[AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap] "
161  << "Cannot replace key '" << iKey.first << "with " << iKey.second << " since not in "
162  << "list - typo in configuration?\n";
163  return false;
164  }
165  }
166  return true;
167 }
Log< level::Warning, false > LogWarning
void AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB ( const AlCaRecoTriggerBits bitsToWrite) const
private

Definition at line 195 of file AlCaRecoTriggerBitsRcdUpdate.cc.

References Exception, firstRunIOV_, edm::Service< T >::isAvailable(), lastRunIOV_, and cond::service::PoolDBOutputService::writeOneIOV().

Referenced by analyze().

195  {
196  edm::LogInfo("") << "Uploading to the database...";
197 
199  if (!poolDbService.isAvailable()) {
200  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available.\n";
201  }
202 
203  poolDbService->writeOneIOV(bitsToWrite, firstRunIOV_, "AlCaRecoTriggerBitsRcd");
204 
205  edm::LogInfo("") << "...done for runs " << firstRunIOV_ << " to " << lastRunIOV_ << " (< 0 meaning infinity)!";
206 }
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo

Member Data Documentation

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

Definition at line 52 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

const unsigned int AlCaRecoTriggerBitsRcdUpdate::firstRunIOV_
private

Definition at line 47 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

const int AlCaRecoTriggerBitsRcdUpdate::lastRunIOV_
private

Definition at line 48 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by writeBitsToDB().

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

Definition at line 50 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

unsigned int AlCaRecoTriggerBitsRcdUpdate::nEventCalls_
private

Definition at line 46 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

const bool AlCaRecoTriggerBitsRcdUpdate::startEmpty_
private

Definition at line 49 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

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

Definition at line 45 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().

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

Definition at line 51 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Referenced by analyze().