CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
17 
18 namespace edm {
19 
20  class ModuleCallingContext;
21 
23  public:
24  // We do not take ownership of passed stream.
25  explicit AsciiOutputModule(ParameterSet const& pset);
26  virtual ~AsciiOutputModule();
27  static void fillDescriptions(ConfigurationDescriptions& descriptions);
28 
29  private:
30  virtual void write(EventForOutput const& e) override;
31  virtual void writeLuminosityBlock(LuminosityBlockForOutput const&) override {}
32  virtual void writeRun(RunForOutput const&) override {}
33  int prescale_;
35  int counter_;
36  };
37 
39  global::OutputModuleBase(pset),
40  global::OutputModule<>(pset),
41  prescale_(pset.getUntrackedParameter<unsigned int>("prescale")),
42  verbosity_(pset.getUntrackedParameter<unsigned int>("verbosity")),
43  counter_(0) {
44  if (prescale_ == 0) prescale_ = 1;
45  }
46 
48  LogAbsolute("AsciiOut") << ">>> processed " << counter_ << " events" << std::endl;
49  }
50 
51  void
53 
54  if ((++counter_ % prescale_) != 0 || verbosity_ <= 0) return;
55 
56  // RunForOutput const& run = evt.getRun(); // this is still unused
57  LogAbsolute("AsciiOut")<< ">>> processing event # " << e.id() << " time " << e.time().value() << std::endl;
58 
59  if (verbosity_ <= 1) return;
60 
61  // Write out non-EDProduct contents...
62 
63  // ... list of process-names
64  for (auto const& process : e.processHistory()) {
65  LogAbsolute("AsciiOut") << process.processName() << " ";
66  }
67 
68  // ... collision id
69  LogAbsolute("AsciiOut") << '\n' << e.id() << '\n';
70 
71  // Loop over products, and write some output for each...
72 
73  std::vector<Provenance const*> provs;
74  e.getAllProvenance(provs);
75  for(auto const& prov : provs) {
76  BranchDescription const& desc = prov->branchDescription();
77  if (selected(desc)) {
78  LogAbsolute("AsciiOut") << *prov << '\n';
79  }
80  }
81  }
82 
83  void
86  desc.setComment("Outputs event information into text file.");
87  desc.addUntracked("prescale", 1U)
88  ->setComment("prescale factor");
89  desc.addUntracked("verbosity", 1U)
90  ->setComment("0: no output\n"
91  "1: event ID and timestamp only\n"
92  ">1: full output");
94  descriptions.add("asciiOutput", desc);
95  }
96 }
97 
void setComment(std::string const &value)
virtual ProcessHistory const & processHistory() const
EventID const & id() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void setComment(std::string const &value)
virtual void writeLuminosityBlock(LuminosityBlockForOutput const &) override
bool selected(BranchDescription const &desc) const
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
Timestamp const & time() const
AsciiOutputModule(ParameterSet const &pset)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void write(EventForOutput const &e) override
virtual void writeRun(RunForOutput const &) override
tuple process
Definition: LaserDQM_cfg.py:3
void getAllProvenance(std::vector< Provenance const * > &provenances) const
TimeValue_t value() const
Definition: Timestamp.h:56