HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hrootwriter.cxx
Go to the documentation of this file.
1 //
2 // Demo code for harpo root tree writing
3 //
4 
5 #include <stdlib.h>
6 #include <stdio.h>
7 
8 #include "TDirectory.h"
9 #include "HarpoConfig.h"
10 #include "HarpoReader.h"
11 //#include "HarpoReaderRoot.h"
12 #include "HarpoRunHeader.h"
13 
14 #include "HarpoAnalyseWriter.h"
15 
16 int main(int argc, char **argv)
17 {
18  Long_t processed = -1; // Processed events counter , negative on error
19 
20  HarpoRunHeader *hdr;
21  //HarpoEvent *hevent;
22 
23  HarpoConfig *cfg = new HarpoConfig(argc,argv);
24  cfg->Init();
25 
26  cfg->print();
27 
28  // printf ("Before Reader Init ...\n");
29  // gDirectory->pwd();
30 
31  HarpoReader *rdr = new HarpoReader( cfg );
32  //HarpoReaderRoot *rdr = new HarpoReaderRoot( cfg );
33  // hNoCMPTime, // Read without timeshump comparision
34  // hFirstTime, // return only plane which smaller time stamp
35  // hSyncTime // skip plane event with smaller timeshatp, return only
36 
37 //if ( rdr->Init(hNoCMPTime) ) {
38 //if ( rdr->Init(hFirstTime) ) {
39  if ( rdr->Init(hSyncTime) ) {
40  hdr = rdr->GetRunHeader();
41  hdr->print();
42  }
43  else
44  {
45  printf ("Int ERROR exiting ...\n");
46  return 1;
47  }
48 
50 
51  // printf ("Before Set Header ...\n");
52  // gDirectory->pwd();
53 
54  hana->SetRunHeader(hdr);
55  // printf ("Before Reader Init ...\n");
56  // gDirectory->pwd();
57  hana->Init(); // if errors ???
58  // printf ("After Reader Init ...\n");
59  // gDirectory->pwd();
60 
61 
62  rdr->SetAnalyseFunction(hana);
63 
64  //if ( rdr->NextEvent() ) printf("\n Next Event OK\n");
65  processed = rdr->LoopAll();
66 
67  hana->Save();
68  delete hana;
69  delete rdr;
70  delete cfg;
71  printf("\n Done processed Events %li\n",processed);
72  return 0;
73 }
74 
75 
76 
void Save(char *mode=NULL)
Bool_t Init(hReadMode mode=hSyncTime)
Definition: HarpoReader.h:73
A class hold HARPO run iformation.
A class which instantiate the real top level reader.
Definition: HarpoReader.h:33
Long_t LoopAll()
Read errors.
Definition: HarpoReader.h:79
void Init()
Definition: HarpoConfig.h:63
void SetAnalyseFunction(HarpoAnalyse *func, Int_t i=0)
Definition: HarpoReader.h:51
int main(int argc, char **argv)
Definition: hrootwriter.cxx:16
A class which write harpo events to ROOT Tree.
void print() const
Read config file in libconfig format.
HarpoRunHeader * GetRunHeader()
Definition: HarpoReader.h:70
void SetRunHeader(HarpoRunHeader *hdr)
Definition: HarpoAnalyse.h:60
A class which keeps track of the entire configuration of the analysis.
Definition: HarpoConfig.h:50