HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoSimHeader.cxx
Go to the documentation of this file.
1 //
2 // File HarpoSimHeader.cxx
3 //
11 #include "HarpoSimHeader.h"
12 #include <cstdlib>
13 #include <cstdio>
14 #include <iostream>
15 #include <time.h>
16 
17 #define HARO_RUN_HEADER_LEN 20
18 
19 const char *timefmt = "R%Y.%m.%d-%T";
20 
21 ClassImp(HarpoSimHeader)
22 
24 {
25  fTime = 0;
26  fHeader = new char[(HARO_RUN_HEADER_LEN)+1];
27  fHeader[HARO_RUN_HEADER_LEN] = 0; // Zero termination for string
28  fHeader[0] = 0; // Zero string
29 }
30 
32 {
33  size_t nr;
34 
35  fTime = 0;
36  fHeader = new char[(HARO_RUN_HEADER_LEN)+1];
37  fHeader[HARO_RUN_HEADER_LEN] = 0; // Zero termination for string
38 
39  nr = std::fread(fHeader, HARO_RUN_HEADER_LEN, 1, fIn);
40  std::printf("nr %zi hdr %s\n",nr,fHeader);
41  if ( nr != 1 ) printf("Sim Header read error\n");
42  // ferror ? , feof ?
43 }
44 
45 
47  {
48  struct tm startTime;
49 
50  if ( strptime(fHeader,timefmt,&startTime) == (char *)NULL )
51  {
52  printf("HARPO Bad Header %s\n",fHeader);
53  return false;
54  };
55 
56  fTime = mktime(&startTime);
57  return true;
58  }
59 
61  {
62  std::cout << "--- HarpoSimHeader" << std::endl;
63  std::cout << "Start Time : " << fTime << std::endl;
64  // << "Dcc Header : " << fHeader << std::endl;
65  }
66 
A class hold HARPO run iformation.
const char * timefmt
A class hold HARPO run iformation.
#define HARO_RUN_HEADER_LEN