CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
AlCaRecoTriggerBitsRcdRead Class Reference
Inheritance diagram for AlCaRecoTriggerBitsRcdRead:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase 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
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
 ~AlCaRecoTriggerBitsRcdRead () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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_
 
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcdtriggerBitsToken_
 
edm::ESWatcher< AlCaRecoTriggerBitsRcdwatcher_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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

◆ OutputType

Constructor & Destructor Documentation

◆ AlCaRecoTriggerBitsRcdRead()

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

Definition at line 80 of file AlCaRecoTriggerBitsRcdRead.cc.

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

81  : triggerBitsToken_(esConsumes<edm::Transition::BeginRun>()),
82  outputType_(this->stringToEnum(cfg.getUntrackedParameter<std::string>("outputType"))),
83  firstRun_(0),
84  lastRun_(0) {
85  // edm::LogInfo("") << "@SUB=AlCaRecoTriggerBitsRcdRead"
86  // << cfg.getParameter<std::string>("@module_label");
87 
88  std::string fileName(cfg.getUntrackedParameter<std::string>("rawFileName"));
89  switch (outputType_) { // now append suffix
90  case kText:
91  fileName += ".txt";
92  break;
93  case kPython:
94  fileName += ".py";
95  break;
96  case kTwiki:
97  fileName += ".twiki";
98  break;
99  }
100  if (!fileName.empty()) {
101  output_ = std::make_unique<std::ofstream>(fileName.c_str());
102  if (!output_->good()) {
103  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
104  output_.reset();
105  }
106  }
107 }
Log< level::Error, false > LogError
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< std::ofstream > output_
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
OutputType stringToEnum(const std::string &outputType) const

◆ ~AlCaRecoTriggerBitsRcdRead()

AlCaRecoTriggerBitsRcdRead::~AlCaRecoTriggerBitsRcdRead ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 45 of file AlCaRecoTriggerBitsRcdRead.cc.

45 {}

◆ beginRun()

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

Definition at line 127 of file AlCaRecoTriggerBitsRcdRead.cc.

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

127  {
128  if (watcher_.check(iSetup)) { // new IOV for this run
129  edm::LogPrint("AlCaRecoTriggerBitsRcdRead") << "new IOV: " << firstRun_ << "-" << lastRun_;
130  // Print last IOV - if there has already been one:
131  if (lastRun_ != 0)
132  this->printMap(firstRun_, lastRun_, lastTriggerBits_);
133 
134  // Get AlCaRecoTriggerBits from EventSetup:
135  const auto &triggerBits = &iSetup.getData(triggerBitsToken_);
136  lastTriggerBits_ = *triggerBits; // copy for later use
137  firstRun_ = run.run(); // keep track where it started
138  }
139 
140  lastRun_ = run.run(); // keep track of last visited run
141 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > watcher_
Log< level::Warning, true > LogPrint
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void printMap(edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_

◆ endJob()

void AlCaRecoTriggerBitsRcdRead::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 144 of file AlCaRecoTriggerBitsRcdRead.cc.

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

144  {
145  // Print for very last IOV, not treated yet in beginRun(..):
147 }
void printMap(edm::RunNumber_t firstRun, edm::RunNumber_t lastRun, const AlCaRecoTriggerBits &triggerMap) const

◆ endRun()

void AlCaRecoTriggerBitsRcdRead::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverride

Definition at line 47 of file AlCaRecoTriggerBitsRcdRead.cc.

47 {}

◆ fillDescriptions()

void AlCaRecoTriggerBitsRcdRead::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 71 of file AlCaRecoTriggerBitsRcdRead.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

71  {
73  desc.setComment("Plugin to read payloads of type AlCaRecoTriggerBits");
74  desc.addUntracked<std::string>("rawFileName", "");
75  desc.addUntracked<std::string>("outputType", "twiki");
76  descriptions.addWithDefaultLabel(desc);
77 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ printMap()

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

Definition at line 150 of file AlCaRecoTriggerBitsRcdRead.cc.

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

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

◆ stringToEnum()

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

Definition at line 110 of file AlCaRecoTriggerBitsRcdRead.cc.

References Exception, kPython, kText, and kTwiki.

110  {
111  if (outputTypeStr == "text")
112  return kText;
113  if (outputTypeStr == "twiki")
114  return kTwiki;
115  if (outputTypeStr == "python")
116  return kPython;
117  // if (outputTypeStr == "html") return kHtml;
118 
119  throw cms::Exception("BadConfig") << "AlCaRecoTriggerBitsRcdRead: "
120  << "outputType '" << outputTypeStr << "' not known,"
121  << " use 'text', 'twiki' or 'python'\n";
122 
123  return kTwiki; // never reached, to please compiler
124 }

Member Data Documentation

◆ firstRun_

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::firstRun_
private

Definition at line 64 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ lastRun_

edm::RunNumber_t AlCaRecoTriggerBitsRcdRead::lastRun_
private

Definition at line 65 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ lastTriggerBits_

AlCaRecoTriggerBits AlCaRecoTriggerBitsRcdRead::lastTriggerBits_
private

Definition at line 66 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun(), and endJob().

◆ output_

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

Definition at line 67 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

◆ outputType_

const OutputType AlCaRecoTriggerBitsRcdRead::outputType_
private

Definition at line 62 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by AlCaRecoTriggerBitsRcdRead(), and printMap().

◆ triggerBitsToken_

const edm::ESGetToken<AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd> AlCaRecoTriggerBitsRcdRead::triggerBitsToken_
private

Definition at line 61 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().

◆ watcher_

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

Definition at line 63 of file AlCaRecoTriggerBitsRcdRead.cc.

Referenced by beginRun().