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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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 41 of file AlCaRecoTriggerBitsRcdRead.cc.

Member Enumeration Documentation

◆ OutputType

Enumerator
kText 
kTwiki 
kPython 

Definition at line 52 of file AlCaRecoTriggerBitsRcdRead.cc.

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

Constructor & Destructor Documentation

◆ AlCaRecoTriggerBitsRcdRead()

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

Definition at line 71 of file AlCaRecoTriggerBitsRcdRead.cc.

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

References looper::cfg, MillePedeFileConverter_cfg::fileName, kPython, kText, kTwiki, output_, outputType_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~AlCaRecoTriggerBitsRcdRead()

AlCaRecoTriggerBitsRcdRead::~AlCaRecoTriggerBitsRcdRead ( )
inlineoverride

Definition at line 44 of file AlCaRecoTriggerBitsRcdRead.cc.

44 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 46 of file AlCaRecoTriggerBitsRcdRead.cc.

46 {}

◆ beginRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 115 of file AlCaRecoTriggerBitsRcdRead.cc.

115  {
116  if (watcher_.check(iSetup)) { // new IOV for this run
117  // Print last IOV - if there has already been one:
118  if (lastRun_ != 0)
120 
121  // Get AlCaRecoTriggerBits from EventSetup:
123  iSetup.get<AlCaRecoTriggerBitsRcd>().get(triggerBits);
124  lastTriggerBits_ = *triggerBits; // copy for later use
125  firstRun_ = run.run(); // keep track where it started
126  }
127 
128  lastRun_ = run.run(); // keep track of last visited run
129 }

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

◆ endJob()

void AlCaRecoTriggerBitsRcdRead::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 132 of file AlCaRecoTriggerBitsRcdRead.cc.

132  {
133  // Print for very last IOV, not treated yet in beginRun(..):
135 }

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

◆ printMap()

void AlCaRecoTriggerBitsRcdRead::printMap ( edm::RunNumber_t  firstRun,
edm::RunNumber_t  lastRun,
const AlCaRecoTriggerBits triggerMap 
) const
private

Definition at line 138 of file AlCaRecoTriggerBitsRcdRead.cc.

140  {
141  // Get map of strings to concatenated list of names of HLT paths:
142  typedef std::map<std::string, std::string> TriggerMap;
143  const TriggerMap &triggerMap = triggerBits.m_alcarecoToTrig;
144 
145  // Collect output for given run numbers via ostringstream.
146  // Format depends on outputType_ configuration.
147  std::ostringstream output;
148  switch (outputType_) {
149  case kPython:
150  output << " triggerLists = cms.VPSet(\n";
151  [[fallthrough]];
152  case kText:
153  output << "#\n# AlCaRecoTriggerBits settings for IOV " << 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  if (outputType_ == kPython && i != triggerMap.begin())
166  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)
191  output << " ";
192  }
193  break;
194  case kTwiki: // Twiki will handle that
195  break;
196  }
197  }
198  output << "'" << paths[iPath] << "'";
199  }
200  switch (outputType_) {
201  case kPython:
202  output << ")\n )";
203  break;
204  case kText:
205  output << "\n#\n";
206  break;
207  case kTwiki:
208  output << " |\n";
209  }
210  }
211  if (outputType_ == kPython)
212  output << "\n ) # closing of VPSet triggerLists\n";
213 
214  // Final output - either message logger or output file:
215  if (output_.get())
216  *output_ << output.str();
217  else
218  edm::LogInfo("") << output.str();
219 }

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

Referenced by beginRun(), and endJob().

◆ stringToEnum()

AlCaRecoTriggerBitsRcdRead::OutputType AlCaRecoTriggerBitsRcdRead::stringToEnum ( const std::string &  outputType) const
private

Definition at line 98 of file AlCaRecoTriggerBitsRcdRead.cc.

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

References Exception, kPython, kText, and kTwiki.

Member Data Documentation

◆ firstRun_

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::firstRun_
private

Definition at line 61 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ lastRun_

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::lastRun_
private

Definition at line 62 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ lastTriggerBits_

AlCaRecoTriggerBits AlCaRecoTriggerBitsRcdRead::lastTriggerBits_
private

Definition at line 63 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ output_

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

Definition at line 64 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

◆ outputType_

const OutputType AlCaRecoTriggerBitsRcdRead::outputType_
private

Definition at line 59 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

◆ watcher_

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

Definition at line 60 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
dataset.firstRun
firstRun
Definition: dataset.py:940
mps_fire.i
i
Definition: mps_fire.py:428
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
AlCaRecoTriggerBitsRcdRead::firstRun_
edm::RunNumber_t firstRun_
Definition: AlCaRecoTriggerBitsRcdRead.cc:61
AlCaRecoTriggerBitsRcdRead::lastRun_
edm::RunNumber_t lastRun_
Definition: AlCaRecoTriggerBitsRcdRead.cc:62
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
AlCaRecoTriggerBitsRcdRead::printMap
void printMap(edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const
Definition: AlCaRecoTriggerBitsRcdRead.cc:138
AlCaRecoTriggerBitsRcdRead::lastTriggerBits_
AlCaRecoTriggerBits lastTriggerBits_
Definition: AlCaRecoTriggerBitsRcdRead.cc:63
edm::ESHandle
Definition: DTSurvey.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamSpotPI::lastRun
Definition: BeamSpotPayloadInspectorHelper.h:39
AlCaRecoTriggerBitsRcd
Definition: AlCaRecoTriggerBitsRcd.h:22
AlCaRecoTriggerBitsRcdRead::output_
std::unique_ptr< std::ofstream > output_
Definition: AlCaRecoTriggerBitsRcdRead.cc:64
AlCaRecoTriggerBitsRcdRead::kText
Definition: AlCaRecoTriggerBitsRcdRead.cc:52
AlCaRecoTriggerBitsRcdRead::kPython
Definition: AlCaRecoTriggerBitsRcdRead.cc:52
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaRecoTriggerBitsRcdRead::kTwiki
Definition: AlCaRecoTriggerBitsRcdRead.cc:52
get
#define get
looper.cfg
cfg
Definition: looper.py:297
AlCaRecoTriggerBitsRcdRead::outputType_
const OutputType outputType_
Definition: AlCaRecoTriggerBitsRcdRead.cc:59
AlCaRecoTriggerBitsRcdRead::stringToEnum
OutputType stringToEnum(const std::string &outputType) const
Definition: AlCaRecoTriggerBitsRcdRead.cc:98
writedatasetfile.run
run
Definition: writedatasetfile.py:27
AlCaRecoTriggerBits::m_alcarecoToTrig
std::map< std::string, std::string > m_alcarecoToTrig
Definition: AlCaRecoTriggerBits.h:21
Exception
Definition: hltDiff.cc:246
AlCaRecoTriggerBitsRcdRead::watcher_
edm::ESWatcher< AlCaRecoTriggerBitsRcd > watcher_
Definition: AlCaRecoTriggerBitsRcdRead.cc:60
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18