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(EventPrincipal const& e, ModuleCallingContext const*) override;
31  virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&, ModuleCallingContext const*) override {}
32  virtual void writeRun(RunPrincipal const&, ModuleCallingContext 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  // Run 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
65  it != itEnd; ++it) {
66  LogAbsolute("AsciiOut") << it->processName() << " ";
67  }
68 
69  // ... collision id
70  LogAbsolute("AsciiOut") << '\n' << e.id() << '\n';
71 
72  // Loop over products, and write some output for each...
73 
74  std::vector<Provenance const*> provs;
75  e.getAllProvenance(provs);
76  for(std::vector<Provenance const*>::const_iterator i = provs.begin(),
77  iEnd = provs.end();
78  i != iEnd;
79  ++i) {
80  BranchDescription const& desc = (*i)->product();
81  if (selected(desc)) {
82  LogAbsolute("AsciiOut") << **i << '\n';
83  }
84  }
85  }
86 
87  void
90  desc.setComment("Outputs event information into text file.");
91  desc.addUntracked("prescale", 1U)
92  ->setComment("prescale factor");
93  desc.addUntracked("verbosity", 1U)
94  ->setComment("0: no output\n"
95  "1: event ID and timestamp only\n"
96  ">1: full output");
98  descriptions.add("asciiOutput", desc);
99  }
100 }
101 
collection_type::const_iterator const_iterator
const_iterator begin() const
void setComment(std::string const &value)
int i
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
EventID const & id() const
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Principal.cc:798
ProcessHistory const & processHistory() const
Definition: Principal.h:144
Timestamp const & time() const
void setComment(std::string const &value)
bool selected(BranchDescription const &desc) const
AsciiOutputModule(ParameterSet const &pset)
virtual void write(EventPrincipal const &e, ModuleCallingContext const *) override
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &, ModuleCallingContext const *) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc)
const_iterator end() const
TimeValue_t value() const
Definition: Timestamp.h:56
virtual void writeRun(RunPrincipal const &, ModuleCallingContext const *) override