CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

AlCaRecoTriggerBitsRcdRead Class Reference

Inheritance diagram for AlCaRecoTriggerBitsRcdRead:
edm::EDAnalyzer

List of all members.

Public Member Functions

 AlCaRecoTriggerBitsRcdRead (const edm::ParameterSet &cfg)
virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
virtual void beginRun (const edm::Run &run, const edm::EventSetup &evtSetup)
virtual void endJob ()
 ~AlCaRecoTriggerBitsRcdRead ()

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
< AlCaRecoTriggerBitsRcd
watcher_

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

Enumerator:
kText 
kTwiki 
kPython 

Definition at line 52 of file AlCaRecoTriggerBitsRcdRead.cc.

{kText, kTwiki, kPython}; //kHtml};

Constructor & Destructor Documentation

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

Definition at line 72 of file AlCaRecoTriggerBitsRcdRead.cc.

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

  : outputType_(this->stringToEnum(cfg.getUntrackedParameter<std::string>("outputType"))),
    firstRun_(0), lastRun_(0)
{
  //   edm::LogInfo("") << "@SUB=AlCaRecoTriggerBitsRcdRead" 
  //               << cfg.getParameter<std::string>("@module_label");

  std::string fileName(cfg.getUntrackedParameter<std::string>("rawFileName"));
  switch (outputType_) { // now append suffix
  case kText:   fileName += ".txt";   break;
  case kPython: fileName += ".py";    break;
  case kTwiki:  fileName += ".twiki"; break;
  }
  if (fileName.size()) {
    output_.reset(new std::ofstream(fileName.c_str()));
    if (!output_->good()) {
      edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
      output_.reset();
    }
  }

}
AlCaRecoTriggerBitsRcdRead::~AlCaRecoTriggerBitsRcdRead ( ) [inline]

Definition at line 43 of file AlCaRecoTriggerBitsRcdRead.cc.

{}

Member Function Documentation

virtual void AlCaRecoTriggerBitsRcdRead::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 45 of file AlCaRecoTriggerBitsRcdRead.cc.

{}
void AlCaRecoTriggerBitsRcdRead::beginRun ( const edm::Run run,
const edm::EventSetup evtSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

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_.

{
  if (watcher_.check(iSetup)) { // new IOV for this run
    // Print last IOV - if there has already been one:
    if (lastRun_ != 0) this->printMap(firstRun_, lastRun_, lastTriggerBits_);
  
    // Get AlCaRecoTriggerBits from EventSetup:
    edm::ESHandle<AlCaRecoTriggerBits> triggerBits;
    iSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
    lastTriggerBits_ = *triggerBits; // copy for later use
    firstRun_ = run.run();           // keep track where it started
  }

  lastRun_ = run.run(); // keep track of last visited run
}
void AlCaRecoTriggerBitsRcdRead::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 129 of file AlCaRecoTriggerBitsRcdRead.cc.

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

{
  // Print for very last IOV, not treated yet in beginRun(..):
  this->printMap(firstRun_, lastRun_, lastTriggerBits_);
}
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(), i, kPython, kText, kTwiki, AlCaRecoTriggerBits::m_alcarecoToTrig, convertSQLitetoXML_cfg::output, output_, outputType_, and EgammaValidation_cff::paths.

Referenced by beginRun(), and endJob().

{
  // Get map of strings to concatenated list of names of HLT paths:
  typedef std::map<std::string, std::string> TriggerMap;
  const TriggerMap &triggerMap = triggerBits.m_alcarecoToTrig;

  // Collect output for given run numbers via ostringstream.
  // Format depends on outputType_ configuration.
  std::ostringstream output;
  switch (outputType_) {
  case kPython:
    output << "  triggerLists = cms.VPSet(\n";
    // no 'break;'!
  case kText:
    output << "#\n# AlCaRecoTriggerBits settings for IOV "
           << firstRun << "-" << lastRun << ":\n#\n";
    break;
  case kTwiki:
    output << "---+++++ *IOV*: " << firstRun << "-" << lastRun << "\n"
           << "| *TriggerBits list key* | *HLT paths* |\n";
    break;
  }

  //  if (outputType_ == kPython) output << "  triggerLists = cms.VPSet(\n";

  // loop over entries in map
  for (TriggerMap::const_iterator i = triggerMap.begin(); i != triggerMap.end(); ++i) {

    if (outputType_ == kPython && i != triggerMap.begin()) output << ",\n";

    switch (outputType_) {
    case kPython:
      output << "      cms.PSet(listName = cms.string('" << i->first << "'),\n"
             << "               hltPaths = cms.vstring(";
      break;
    case kText:
      output << "trigger list key: '" << i->first << "'\npaths:\n";
      break;
    case kTwiki:
      output << "| '" << i->first << "' | ";
    }
    // We must avoid a map<string,vector<string> > in DB for performance reason,
    // so the paths are mapped into one string separated by ';':
    const std::vector<std::string> paths = triggerBits.decompose(i->second);
    for (unsigned int iPath = 0; iPath < paths.size(); ++iPath) {
      if (iPath != 0) {
        output << ", "; // next path
        switch (outputType_) {
        case kPython: // only 2 per line
        case kText:   // only 4 per line
          if (0 == (iPath % (outputType_ == kPython ? 2 : 4))) {
            output << "\n";
            if (outputType_ == kPython) output << "                                      ";
          }
          break;
        case kTwiki: // Twiki will handle that
          break;
        }
      }
      output << "'" << paths[iPath] << "'";
    }
    switch (outputType_) {
    case kPython:
      output << ")\n              )";
      break;
    case kText:
      output << "\n#\n";
      break;
    case kTwiki:
      output << " |\n";
    }
  }
  if (outputType_ == kPython) output << "\n      ) # closing of VPSet triggerLists\n"; 
  
  // Final output - either message logger or output file:
  if (output_.get()) *output_ << output.str();
  else edm::LogInfo("") << output.str();
}
AlCaRecoTriggerBitsRcdRead::OutputType AlCaRecoTriggerBitsRcdRead::stringToEnum ( const std::string &  outputType) const [private]

Definition at line 97 of file AlCaRecoTriggerBitsRcdRead.cc.

References Exception, kPython, kText, and kTwiki.

{
  if (outputTypeStr == "text") return kText;
  if (outputTypeStr == "twiki") return kTwiki;
  if (outputTypeStr == "python") return kPython;
  // if (outputTypeStr == "html") return kHtml;

  throw cms::Exception("BadConfig") << "AlCaRecoTriggerBitsRcdRead: "
                                    << "outputType '" << outputTypeStr << "' not known,"
                                    << " use 'text', 'twiki' or 'python'\n";

  return kTwiki; // never reached, to please compiler
}

Member Data Documentation

Definition at line 62 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

Definition at line 63 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

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

Definition at line 60 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

Definition at line 61 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().