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  OutputModule(pset),
40  prescale_(pset.getUntrackedParameter<unsigned int>("prescale")),
41  verbosity_(pset.getUntrackedParameter<unsigned int>("verbosity")),
42  counter_(0) {
43  if (prescale_ == 0) prescale_ = 1;
44  }
45 
47  LogAbsolute("AsciiOut") << ">>> processed " << counter_ << " events" << std::endl;
48  }
49 
50  void
52 
53  if ((++counter_ % prescale_) != 0 || verbosity_ <= 0) return;
54 
55  // Run const& run = evt.getRun(); // this is still unused
56  LogAbsolute("AsciiOut")<< ">>> processing event # " << e.id() << " time " << e.time().value() << std::endl;
57 
58  if (verbosity_ <= 1) return;
59 
60  // Write out non-EDProduct contents...
61 
62  // ... list of process-names
64  it != itEnd; ++it) {
65  LogAbsolute("AsciiOut") << it->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(std::vector<Provenance const*>::const_iterator i = provs.begin(),
76  iEnd = provs.end();
77  i != iEnd;
78  ++i) {
79  BranchDescription const& desc = (*i)->product();
80  if (selected(desc)) {
81  LogAbsolute("AsciiOut") << **i << '\n';
82  }
83  }
84  }
85 
86  void
89  desc.setComment("Outputs event information into text file.");
90  desc.addUntracked("prescale", 1U)
91  ->setComment("prescale factor");
92  desc.addUntracked("verbosity", 1U)
93  ->setComment("0: no output\n"
94  "1: event ID and timestamp only\n"
95  ">1: full output");
97  descriptions.add("asciiOutput", desc);
98  }
99 }
100 
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:759
bool selected(BranchDescription const &desc) const
ProcessHistory const & processHistory() const
Definition: Principal.h:139
Timestamp const & time() const
void setComment(std::string const &value)
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