Rivet  3.1.3
ReaderCompressedAscii.hh
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC3_READERCOMPRESSEDASCII_H
7 #define HEPMC3_READERCOMPRESSEDASCII_H
8 #include "Rivet/Tools/RivetHepMC.hh"
18 #include "HepMC3/Reader.h"
19 #include "HepMC3/GenEvent.h"
20 #include <string>
21 #include <fstream>
22 #include <istream>
23 
24 namespace Rivet {
25 
26 
27 class ReaderCompressedAscii : public HepMC3::Reader {
28 
29 public:
30 
31  typedef HepMC3::GenParticlePtr GenParticlePtr;
32  typedef HepMC3::GenVertexPtr GenVertexPtr;
33 
34 public:
35 
38  ReaderCompressedAscii(const std::string& filename);
39 
41  ReaderCompressedAscii(std::istream &);
42 
44  ~ReaderCompressedAscii();
45 
49  bool read_event(GenEvent& evt);
50 
52  bool failed() {
53  return !(*m_stream);
54  }
55 
57  void close();
58 
59 private:
60 
62  std::string unescape(const std::string& s);
63 
65 
66 
71  std::pair<int,int> parse_event_information();
72 
76  bool parse_weight_values();
77 
81  bool parse_precision();
82 
86  bool parse_vertex_information();
87 
91  bool parse_particle_information();
92 
96  bool parse_attribute();
97 
101  bool parse_run_attribute();
102 
107  bool parse_weight_names();
108 
113  bool parse_tool();
114 
120  bool read_position(GenVertexPtr v = GenVertexPtr());
121 
126  bool read_momentum(GenParticlePtr p);
127 
129 
130 
131 private:
132 
133  std::ifstream m_file;
134  std::istream* m_stream;
135 
136  std::istringstream is;
137 
138  GenEvent * m_evt;
139 
140  double m_precision_phi;
141  double m_precision_eta;
142  double m_precision_e;
143  double m_precision_m;
144  bool m_using_integers;
145 
146  map<long,long> m_masses;
147 
149  vector<GenParticlePtr> m_particles;
151  vector<int> m_ppvx;
153  map<int,GenVertexPtr> m_vertices;
155  map<int, std::vector<int> > m_vpin;
156 
158  std::map< std::string, shared_ptr<HepMC3::Attribute> > m_global_attributes;
159 
160 };
161 
162 
163 } // namespace HepMC3
164 
165 #endif
Definition: MC_Cent_pPb.hh:10