CMS 3D CMS Logo

AsciiOutputModule.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
4 #include <algorithm>
5 #include <iterator>
6 #include <ostream>
7 #include <iostream>
8 #include <string>
20 
21 namespace edm {
22 
23  class ModuleCallingContext;
24 
26  public:
27  // We do not take ownership of passed stream.
28  explicit AsciiOutputModule(ParameterSet const& pset);
29  ~AsciiOutputModule() override;
30  static void fillDescriptions(ConfigurationDescriptions& descriptions);
31 
32  private:
33  void write(EventForOutput const& e) override;
35  void writeRun(RunForOutput const&) override {}
36  int prescale_;
38  int counter_;
39  };
40 
42  : global::OutputModuleBase(pset),
43  global::OutputModule<>(pset),
44  prescale_(pset.getUntrackedParameter<unsigned int>("prescale")),
45  verbosity_(pset.getUntrackedParameter<unsigned int>("verbosity")),
46  counter_(0) {
47  if (prescale_ == 0)
48  prescale_ = 1;
49  }
50 
52  LogAbsolute("AsciiOut") << ">>> processed " << counter_ << " events" << std::endl;
53  }
54 
56  if ((++counter_ % prescale_) != 0 || verbosity_ <= 0)
57  return;
58 
59  // RunForOutput const& run = evt.getRun(); // this is still unused
60  LogAbsolute("AsciiOut") << ">>> processing event # " << e.id() << " time " << e.time().value() << std::endl;
61 
62  if (verbosity_ <= 1)
63  return;
64 
65  // Write out non-EDProduct contents...
66 
67  // ... list of process-names
68  for (auto const& process : e.processHistory()) {
69  LogAbsolute("AsciiOut") << process.processName() << " ";
70  }
71 
72  // ... collision id
73  LogAbsolute("AsciiOut") << '\n' << e.id() << '\n';
74 
75  // Loop over products, and write some output for each...
77  for (auto const& prod : reg->productList()) {
78  BranchDescription const& desc = prod.second;
79  if (selected(desc)) {
80  if (desc.isAlias()) {
81  LogAbsolute("AsciiOut") << "ModuleLabel " << desc.moduleLabel() << " is an alias for";
82  }
83 
84  auto const& prov = e.getProvenance(desc.originalBranchID());
85  LogAbsolute("AsciiOut") << prov;
86 
87  if (verbosity_ > 2) {
88  BranchDescription const& desc2 = prov.branchDescription();
89  std::string const& process = desc2.processName();
90  std::string const& label = desc2.moduleLabel();
91  ProcessHistory const& processHistory = e.processHistory();
92 
93  for (ProcessConfiguration const& pc : processHistory) {
94  if (pc.processName() == process) {
95  ParameterSetID const& psetID = pc.parameterSetID();
96  pset::Registry const* psetRegistry = pset::Registry::instance();
97  ParameterSet const* processPset = psetRegistry->getMapped(psetID);
98  if (processPset) {
99  if (desc.isAlias()) {
100  LogAbsolute("AsciiOut") << "Alias PSet\n" << processPset->getParameterSet(desc.moduleLabel());
101  }
102  LogAbsolute("AsciiOut") << processPset->getParameterSet(label) << "\n";
103  }
104  }
105  }
106  }
107  }
108  }
109  }
110 
113  desc.setComment("Outputs event information into text file.");
114  desc.addUntracked("prescale", 1U)->setComment("prescale factor");
115  desc.addUntracked("verbosity", 1U)
116  ->setComment(
117  "0: no output\n"
118  "1: event ID and timestamp only\n"
119  "2: provenance for each kept product\n"
120  ">2: PSet and provenance for each kept product");
121  OutputModule::fillDescription(desc);
122  descriptions.add("asciiOutput", desc);
123  }
124 } // namespace edm
125 
edm::AsciiOutputModule
Definition: AsciiOutputModule.cc:25
ConfigurationDescriptions.h
ConstProductRegistry.h
edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
edm::AsciiOutputModule::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: AsciiOutputModule.cc:111
MessageLogger.h
edm::global::OutputModule
Definition: OutputModule.h:28
edm::AsciiOutputModule::write
void write(EventForOutput const &e) override
Definition: AsciiOutputModule.cc:55
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EventForOutput.h
edm::AsciiOutputModule::writeRun
void writeRun(RunForOutput const &) override
Definition: AsciiOutputModule.cc:35
edm::LuminosityBlockForOutput
Definition: LuminosityBlockForOutput.h:40
edm::AsciiOutputModule::verbosity_
int verbosity_
Definition: AsciiOutputModule.cc:37
edm::RunForOutput
Definition: RunForOutput.h:39
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::BranchDescription::processName
std::string const & processName() const
Definition: BranchDescription.h:73
Service.h
Provenance.h
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
edm::Hash< ParameterSetType >
ParameterSetDescription.h
edm::AsciiOutputModule::prescale_
int prescale_
Definition: AsciiOutputModule.cc:36
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OutputModuleBase
edm::AsciiOutputModule::writeLuminosityBlock
void writeLuminosityBlock(LuminosityBlockForOutput const &) override
Definition: AsciiOutputModule.cc:34
edm::AsciiOutputModule::counter_
int counter_
Definition: AsciiOutputModule.cc:38
edm::ParameterSet
Definition: ParameterSet.h:47
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
edm::AsciiOutputModule::~AsciiOutputModule
~AsciiOutputModule() override
Definition: AsciiOutputModule.cc:51
OutputModule.h
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
Registry.h
edm::EventForOutput
Definition: EventForOutput.h:50
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition: BranchDescription.h:72
edm::BranchDescription
Definition: BranchDescription.h:32
edm::global::OutputModuleBase::selected
bool selected(BranchDescription const &desc) const
Definition: OutputModuleBase.cc:347
edm::ProcessHistory
Definition: ProcessHistory.h:13
ParameterSet.h
edm::pset::Registry::getMapped
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::ProcessConfiguration
Definition: ProcessConfiguration.h:14
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
edm::pset::Registry
Definition: Registry.h:26
edm::AsciiOutputModule::AsciiOutputModule
AsciiOutputModule(ParameterSet const &pset)
Definition: AsciiOutputModule.cc:41
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37