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)
 
virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &evtSetup) override
 
virtual void endJob () override
 
 ~AlCaRecoTriggerBitsRcdRead ()
 
- 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 ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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 & itemsToGetFromEvent () 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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::auto_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 &)
 
- 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 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 40 of file AlCaRecoTriggerBitsRcdRead.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 72 of file AlCaRecoTriggerBitsRcdRead.cc.

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

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

Definition at line 43 of file AlCaRecoTriggerBitsRcdRead.cc.

43 {}

Member Function Documentation

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

Definition at line 45 of file AlCaRecoTriggerBitsRcdRead.cc.

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

45 {}
void AlCaRecoTriggerBitsRcdRead::beginRun ( const edm::Run run,
const edm::EventSetup evtSetup 
)
overridevirtual

Definition at line 112 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:
117 
118  // Get AlCaRecoTriggerBits from EventSetup:
120  iSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
121  lastTriggerBits_ = *triggerBits; // copy for later use
122  firstRun_ = run.run(); // keep track where it started
123  }
124 
125  lastRun_ = run.run(); // keep track of last visited run
126 }
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:57
void AlCaRecoTriggerBitsRcdRead::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 129 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_, and outputType_.

Referenced by beginRun(), and endJob().

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

Definition at line 97 of file AlCaRecoTriggerBitsRcdRead.cc.

References Exception, kPython, kText, and kTwiki.

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

Member Data Documentation

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::firstRun_
private

Definition at line 62 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::lastRun_
private

Definition at line 63 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

AlCaRecoTriggerBits AlCaRecoTriggerBitsRcdRead::lastTriggerBits_
private

Definition at line 64 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

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

Definition at line 65 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

const OutputType AlCaRecoTriggerBitsRcdRead::outputType_
private

Definition at line 60 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

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

Definition at line 61 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().