CMS 3D CMS Logo

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

Public Member Functions

 AlCaRecoTriggerBitsRcdRead (const edm::ParameterSet &cfg)
 
void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
 ~AlCaRecoTriggerBitsRcdRead () 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

enum  OutputType { kText, kTwiki, kPython }
 

Private Member Functions

void printMap (edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const
 
OutputType stringToEnum (const std::string &outputType) const
 

Private Attributes

edm::RunNumber_t firstRun_
 
edm::RunNumber_t lastRun_
 
AlCaRecoTriggerBits lastTriggerBits_
 
std::unique_ptr< std::ofstream > output_
 
const OutputType outputType_
 
edm::ESWatcher< AlCaRecoTriggerBitsRcdwatcher_
 

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 read trigger bit mappings (AlCaRecoTriggerBits) from DB and put out as text. Several output formats can be configured via parameter 'outputType':

Where to put the text is decided by parameter 'rawFileName':

Definition at line 39 of file AlCaRecoTriggerBitsRcdRead.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 69 of file AlCaRecoTriggerBitsRcdRead.cc.

References MillePedeFileConverter_cfg::fileName, edm::ParameterSet::getUntrackedParameter(), kPython, kText, kTwiki, output_, outputType_, and AlCaHLTBitMon_QueryRunRegistry::string.

70  : outputType_(this->stringToEnum(cfg.getUntrackedParameter<std::string>("outputType"))), firstRun_(0), lastRun_(0) {
71  // edm::LogInfo("") << "@SUB=AlCaRecoTriggerBitsRcdRead"
72  // << cfg.getParameter<std::string>("@module_label");
73 
75  switch (outputType_) { // now append suffix
76  case kText:
77  fileName += ".txt";
78  break;
79  case kPython:
80  fileName += ".py";
81  break;
82  case kTwiki:
83  fileName += ".twiki";
84  break;
85  }
86  if (!fileName.empty()) {
87  output_.reset(new std::ofstream(fileName.c_str()));
88  if (!output_->good()) {
89  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
90  output_.reset();
91  }
92  }
93 }
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< std::ofstream > output_
OutputType stringToEnum(const std::string &outputType) const
AlCaRecoTriggerBitsRcdRead::~AlCaRecoTriggerBitsRcdRead ( )
inlineoverride

Definition at line 42 of file AlCaRecoTriggerBitsRcdRead.cc.

42 {}

Member Function Documentation

void AlCaRecoTriggerBitsRcdRead::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
inlineoverride

Definition at line 44 of file AlCaRecoTriggerBitsRcdRead.cc.

References beginRun(), endJob(), and writedatasetfile::run.

44 {}
void AlCaRecoTriggerBitsRcdRead::beginRun ( const edm::Run run,
const edm::EventSetup evtSetup 
)
override

Definition at line 113 of file AlCaRecoTriggerBitsRcdRead.cc.

References edm::ESWatcher< T >::check(), firstRun_, edm::EventSetup::get(), lastRun_, lastTriggerBits_, printMap(), edm::RunBase::run(), and watcher_.

Referenced by analyze().

113  {
114  if (watcher_.check(iSetup)) { // new IOV for this run
115  // Print last IOV - if there has already been one:
116  if (lastRun_ != 0)
118 
119  // Get AlCaRecoTriggerBits from EventSetup:
121  iSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
122  lastTriggerBits_ = *triggerBits; // copy for later use
123  firstRun_ = run.run(); // keep track where it started
124  }
125 
126  lastRun_ = run.run(); // keep track of last visited run
127 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > watcher_
RunNumber_t run() const
Definition: RunBase.h:40
void printMap(edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
void AlCaRecoTriggerBitsRcdRead::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 130 of file AlCaRecoTriggerBitsRcdRead.cc.

References firstRun_, lastRun_, lastTriggerBits_, and printMap().

Referenced by analyze().

130  {
131  // Print for very last IOV, not treated yet in beginRun(..):
133 }
void printMap(edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const
void AlCaRecoTriggerBitsRcdRead::printMap ( edm::RunNumber_t  firstRun,
edm::RunNumber_t  lastRun,
const AlCaRecoTriggerBits triggerMap 
) const
private

Definition at line 136 of file AlCaRecoTriggerBitsRcdRead.cc.

References AlCaRecoTriggerBits::decompose(), DEFINE_FWK_MODULE, mps_fire::i, kPython, kText, kTwiki, AlCaRecoTriggerBits::m_alcarecoToTrig, convertSQLitetoXML_cfg::output, output_, outputType_, and Skims_PA_cff::paths.

Referenced by beginRun(), and endJob().

138  {
139  // Get map of strings to concatenated list of names of HLT paths:
140  typedef std::map<std::string, std::string> TriggerMap;
141  const TriggerMap &triggerMap = triggerBits.m_alcarecoToTrig;
142 
143  // Collect output for given run numbers via ostringstream.
144  // Format depends on outputType_ configuration.
145  std::ostringstream output;
146  switch (outputType_) {
147  case kPython:
148  output << " triggerLists = cms.VPSet(\n";
149  [[fallthrough]];
150  case kText:
151  output << "#\n# AlCaRecoTriggerBits settings for IOV " << firstRun << "-" << lastRun << ":\n#\n";
152  break;
153  case kTwiki:
154  output << "---+++++ *IOV*: " << firstRun << "-" << lastRun << "\n"
155  << "| *TriggerBits list key* | *HLT paths* |\n";
156  break;
157  }
158 
159  // if (outputType_ == kPython) output << " triggerLists = cms.VPSet(\n";
160 
161  // loop over entries in map
162  for (TriggerMap::const_iterator i = triggerMap.begin(); i != triggerMap.end(); ++i) {
163  if (outputType_ == kPython && i != triggerMap.begin())
164  output << ",\n";
165 
166  switch (outputType_) {
167  case kPython:
168  output << " cms.PSet(listName = cms.string('" << i->first << "'),\n"
169  << " hltPaths = cms.vstring(";
170  break;
171  case kText:
172  output << "trigger list key: '" << i->first << "'\npaths:\n";
173  break;
174  case kTwiki:
175  output << "| '" << i->first << "' | ";
176  }
177  // We must avoid a map<string,vector<string> > in DB for performance reason,
178  // so the paths are mapped into one string separated by ';':
179  const std::vector<std::string> paths = triggerBits.decompose(i->second);
180  for (unsigned int iPath = 0; iPath < paths.size(); ++iPath) {
181  if (iPath != 0) {
182  output << ", "; // next path
183  switch (outputType_) {
184  case kPython: // only 2 per line
185  case kText: // only 4 per line
186  if (0 == (iPath % (outputType_ == kPython ? 2 : 4))) {
187  output << "\n";
188  if (outputType_ == kPython)
189  output << " ";
190  }
191  break;
192  case kTwiki: // Twiki will handle that
193  break;
194  }
195  }
196  output << "'" << paths[iPath] << "'";
197  }
198  switch (outputType_) {
199  case kPython:
200  output << ")\n )";
201  break;
202  case kText:
203  output << "\n#\n";
204  break;
205  case kTwiki:
206  output << " |\n";
207  }
208  }
209  if (outputType_ == kPython)
210  output << "\n ) # closing of VPSet triggerLists\n";
211 
212  // Final output - either message logger or output file:
213  if (output_.get())
214  *output_ << output.str();
215  else
216  edm::LogInfo("") << output.str();
217 }
std::map< std::string, std::string > m_alcarecoToTrig
std::unique_ptr< std::ofstream > output_
firstRun
Definition: dataset.py:940
AlCaRecoTriggerBitsRcdRead::OutputType AlCaRecoTriggerBitsRcdRead::stringToEnum ( const std::string &  outputType) const
private

Definition at line 96 of file AlCaRecoTriggerBitsRcdRead.cc.

References Exception, kPython, kText, and kTwiki.

96  {
97  if (outputTypeStr == "text")
98  return kText;
99  if (outputTypeStr == "twiki")
100  return kTwiki;
101  if (outputTypeStr == "python")
102  return kPython;
103  // if (outputTypeStr == "html") return kHtml;
104 
105  throw cms::Exception("BadConfig") << "AlCaRecoTriggerBitsRcdRead: "
106  << "outputType '" << outputTypeStr << "' not known,"
107  << " use 'text', 'twiki' or 'python'\n";
108 
109  return kTwiki; // never reached, to please compiler
110 }

Member Data Documentation

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::firstRun_
private

Definition at line 59 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::lastRun_
private

Definition at line 60 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

AlCaRecoTriggerBits AlCaRecoTriggerBitsRcdRead::lastTriggerBits_
private

Definition at line 61 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

std::unique_ptr<std::ofstream> AlCaRecoTriggerBitsRcdRead::output_
private

Definition at line 62 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

const OutputType AlCaRecoTriggerBitsRcdRead::outputType_
private

Definition at line 57 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

edm::ESWatcher<AlCaRecoTriggerBitsRcd> AlCaRecoTriggerBitsRcdRead::watcher_
private

Definition at line 58 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().