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 {
20  public:
21  // We do not take ownership of passed stream.
22  explicit AsciiOutputModule(ParameterSet const& pset);
23  virtual ~AsciiOutputModule();
24  static void fillDescriptions(ConfigurationDescriptions& descriptions);
25 
26  private:
27  virtual void write(EventPrincipal const& e);
29  virtual void writeRun(RunPrincipal const&){}
30  int prescale_;
32  int counter_;
33  };
34 
36  OutputModule(pset),
37  prescale_(pset.getUntrackedParameter<unsigned int>("prescale")),
38  verbosity_(pset.getUntrackedParameter<unsigned int>("verbosity")),
39  counter_(0) {
40  if (prescale_ == 0) prescale_ = 1;
41  }
42 
44  LogAbsolute("AsciiOut") << ">>> processed " << counter_ << " events" << std::endl;
45  }
46 
47  void
49 
50  if ((++counter_ % prescale_) != 0 || verbosity_ <= 0) return;
51 
52  // Run const& run = evt.getRun(); // this is still unused
53  LogAbsolute("AsciiOut")<< ">>> processing event # " << e.id() << " time " << e.time().value() << std::endl;
54 
55  if (verbosity_ <= 1) return;
56 
57  // Write out non-EDProduct contents...
58 
59  // ... list of process-names
61  it != itEnd; ++it) {
62  LogAbsolute("AsciiOut") << it->processName() << " ";
63  }
64 
65  // ... collision id
66  LogAbsolute("AsciiOut") << '\n' << e.id() << '\n';
67 
68  // Loop over products, and write some output for each...
69 
70  std::vector<Provenance const*> provs;
71  e.getAllProvenance(provs);
72  for(std::vector<Provenance const*>::const_iterator i = provs.begin(),
73  iEnd = provs.end();
74  i != iEnd;
75  ++i) {
76  BranchDescription const& desc = (*i)->product();
77  if (selected(desc)) {
78  LogAbsolute("AsciiOut") << **i << '\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 
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)
virtual void write(EventPrincipal const &e)
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:562
bool selected(BranchDescription const &desc) const
ProcessHistory const & processHistory() const
Definition: Principal.h:112
virtual void writeRun(RunPrincipal const &)
Timestamp const & time() const
void setComment(std::string const &value)
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &)
AsciiOutputModule(ParameterSet const &pset)
TimeValue_t value() const
Definition: Timestamp.cc:72
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc)
const_iterator end() const