[1173] | 1 | /* ---------------------------------------------------------------------------
|
---|
| 2 | ** This software is in the public domain, furnished "as is", without technical
|
---|
| 3 | ** support, and with no warranty, express or implied, as to its usefulness for
|
---|
| 4 | ** any purpose.
|
---|
| 5 | **
|
---|
| 6 | ** A library for HEP events storage and processing based on Google's ProtocolBuffers
|
---|
| 7 | **
|
---|
| 8 | ** Author: S.Chekanov (ANL). chekanov@anl.gov
|
---|
| 9 | ** Copyright 2012
|
---|
| 10 | ** -------------------------------------------------------------------------*/
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | #ifndef ProMCBook_H
|
---|
| 14 | #define ProMCBook_H
|
---|
| 15 |
|
---|
| 16 | #include <string>
|
---|
| 17 | #include <iostream>
|
---|
| 18 | #include <fstream>
|
---|
| 19 | #include <iomanip>
|
---|
| 20 | #include "zipios++/zipios-config.h"
|
---|
| 21 | #include "zipios++/meta-iostreams.h"
|
---|
| 22 | #include "zipios++/zipoutputstream.h"
|
---|
| 23 | #include "zipios++/zipfile.h"
|
---|
| 24 | #include "zipios++/zipinputstream.h"
|
---|
| 25 | #include <ctime>
|
---|
| 26 | #include <iostream>
|
---|
| 27 | #include <fstream>
|
---|
| 28 | #include <exception>
|
---|
| 29 | #include "ProMC.pb.h"
|
---|
| 30 | #include "ProMCHeader.pb.h"
|
---|
| 31 | #include "ProMCStat.pb.h"
|
---|
| 32 | #include "ProMCDescription.pb.h"
|
---|
| 33 |
|
---|
| 34 | using namespace promc;
|
---|
| 35 | using namespace std;
|
---|
| 36 | using namespace zipios ;
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | using std::cerr ;
|
---|
| 41 | using std::cout ;
|
---|
| 42 | using std::endl ;
|
---|
| 43 | using std::ios ;
|
---|
| 44 | using std::string ;
|
---|
| 45 | using std::exception ;
|
---|
| 46 | using std::istream;
|
---|
| 47 | using std::ofstream;
|
---|
| 48 | using std::ifstream;
|
---|
| 49 | using std::setw;
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | class ProMCBook{
|
---|
| 53 | public:
|
---|
| 54 |
|
---|
| 55 | ProMCBook();
|
---|
| 56 | ~ProMCBook();
|
---|
| 57 | ProMCBook(const char* filename, const char * option);
|
---|
| 58 | void open(const char* filename, const char * option);
|
---|
| 59 | ProMCEvent get();
|
---|
| 60 | ProMCEvent event(long idx);
|
---|
| 61 | int next();
|
---|
| 62 | int getTimestamp() { return timestamp; };
|
---|
| 63 | int getVersion() { return version; };
|
---|
| 64 | string getDescription() { return description; };
|
---|
| 65 | void setDescription(int events, string s);
|
---|
| 66 | int getEvents() { return nev; };
|
---|
| 67 | int getEventsRequested() { return requested_nev; };
|
---|
| 68 | ProMCHeader getHeader();
|
---|
| 69 | void setHeader(ProMCHeader h);
|
---|
| 70 | void setStatistics(ProMCStat h);
|
---|
| 71 | void close();
|
---|
| 72 | void write(ProMCEvent e ); // write histogram if any
|
---|
| 73 | void clear();
|
---|
| 74 | unsigned int size(); // all size
|
---|
| 75 | static const int current_version=2;
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | private:
|
---|
| 79 |
|
---|
| 80 | int timestamp;
|
---|
| 81 | int version;
|
---|
| 82 | string description;
|
---|
| 83 | ProMCStat hStat;
|
---|
| 84 | unsigned long nev;
|
---|
| 85 | unsigned long requested_nev;
|
---|
| 86 | ZipOutputStream *outzip;
|
---|
| 87 | ZipInputStream *inpzip;
|
---|
| 88 | bool isToWrite;
|
---|
| 89 | ZipFile *zfile;
|
---|
| 90 |
|
---|
| 91 | };
|
---|
| 92 |
|
---|
| 93 | #endif
|
---|