test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
 ~AlCaRecoTriggerBitsRcdUpdate ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
void writeBitsToDB (AlCaRecoTriggerBits *bitsToWrite) const
 Takes over memory uresponsibility for 'bitsToWrite'. More...
 

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_
 

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 &)
 
- 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 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 32 of file AlCaRecoTriggerBitsRcdUpdate.cc.

Member Typedef Documentation

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

Definition at line 40 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 {
68 }
T getParameter(std::string const &) const
const std::vector< edm::ParameterSet > triggerListsAdd_
const std::vector< std::string > listNamesRemove_
AlCaRecoTriggerBitsRcdUpdate::~AlCaRecoTriggerBitsRcdUpdate ( )
inline

Definition at line 35 of file AlCaRecoTriggerBitsRcdUpdate.cc.

35 {}

Member Function Documentation

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, alcazmumu_cfi::filter, AlCaRecoTriggerBits::m_alcarecoToTrig, mergeAndRegister::paths, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

134 {
135  TriggerMap &triggerMap = bits.m_alcarecoToTrig;
136 
137  // loop on PSets, each containing the key (filter name) and a vstring with triggers
138  for (std::vector<edm::ParameterSet>::const_iterator iSet = triggerListsAdd.begin();
139  iSet != triggerListsAdd.end(); ++iSet) {
140 
141  const std::vector<std::string> paths(iSet->getParameter<std::vector<std::string> >("hltPaths"));
142  // We must avoid a map<string,vector<string> > in DB for performance reason,
143  // so we have to merge the paths into one string that will be decoded when needed:
144  const std::string mergedPaths = bits.compose(paths);
145 
146  const std::string filter(iSet->getParameter<std::string>("listName"));
147  if (triggerMap.find(filter) != triggerMap.end()) {
148  throw cms::Exception("BadConfig") << "List name '" << filter << "' already in map, either "
149  << "remove from 'triggerListsAdd' or "
150  << " add to 'listNamesRemove'.\n";
151  }
152  triggerMap[filter] = mergedPaths;
153  }
154 
155  return true;
156 }
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::EDAnalyzer.

Definition at line 71 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

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

99 {
100  if (startEmpty) {
101  return new AlCaRecoTriggerBits;
102  } else {
104  evtSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
105  return new AlCaRecoTriggerBits(*triggerBits); // copy old one
106  }
107 }
const T & get() const
Definition: EventSetup.h:56
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().

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

Takes over memory uresponsibility for 'bitsToWrite'.

Definition at line 159 of file AlCaRecoTriggerBitsRcdUpdate.cc.

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

Referenced by analyze().

160 {
161  edm::LogInfo("") << "Uploading to the database...";
162 
164  if (!poolDbService.isAvailable()) {
165  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available.\n";
166  }
167 
168  // ownership of bitsToWrite transferred
169  // FIXME: Have to check that timetype is run number! How?
170  const std::string recordName("AlCaRecoTriggerBitsRcd");
171  if (poolDbService->isNewTagRequest(recordName)) { // tag not yet existing
172  // lastRunIOV_ = -1 means infinity:
173  const cond::Time_t lastRun = (lastRunIOV_ < 0 ? poolDbService->endOfTime() : lastRunIOV_);
174  poolDbService->createNewIOV(bitsToWrite, firstRunIOV_, lastRun, recordName);
175  } else { // tag exists, can only append
176  if (lastRunIOV_ >= 0) {
177  throw cms::Exception("BadConfig") << "Tag already exists, can only append until infinity,"
178  << " but lastRunIOV = " << lastRunIOV_ << ".\n";
179  }
180  poolDbService->appendSinceTime(bitsToWrite, firstRunIOV_, recordName);
181  }
182 
183  edm::LogInfo("") << "...done for runs " << firstRunIOV_ << " to " << lastRunIOV_
184  << " (< 0 meaning infinity)!";
185 }
tuple recordName
Definition: align_cfg.py:66
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
unsigned long long Time_t
Definition: Time.h:16
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)

Member Data Documentation

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().