HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoDccHeader.cxx
Go to the documentation of this file.
1 //
2 // File HarpoDccHeader.cxx
3 //
11 #include "HarpoConfig.h"
12 #include "HarpoDccHeader.h"
13 #include "HarpoDccReader.h"
14 #include "HarpoPedMgr.h"
15 #include <cstdlib>
16 #include <cstdio>
17 #include <iostream>
18 #include <time.h>
19 
20 #define HARO_RUN_HEADER_LEN 20
21 
22 const char *timefmt = "R%Y.%m.%d-%T";
23 
24 ClassImp(HarpoDccHeader)
25 
27 {
28  fHeaderLen = HARO_RUN_HEADER_LEN;
29  fHeader = new char[(HARO_RUN_HEADER_LEN)+1];
30  fHeader[HARO_RUN_HEADER_LEN] = 0; // Zero termination for string
31  fHeader[0] = 0; // Zero string
32  peds = NULL;
33 }
34 
36 {
37  size_t nr;
38 
40  fHeader = new char[(HARO_RUN_HEADER_LEN)+1];
41  fHeader[HARO_RUN_HEADER_LEN] = 0; // Zero termination for string
42  peds = NULL;
43 
44  nr = std::fread(fHeader, HARO_RUN_HEADER_LEN, 1, fIn);
45  if ( nr != 1 ) printf("Dcc Header read error\n");
46 }
47 
48 
50  {
51  struct tm startTime;
52 
53  if ( strptime(fHeader,timefmt,&startTime) == (char *)NULL )
54  {
55  printf("HARPO Bad Header %s\n",fHeader);
56  return false;
57  };
58 
59  //This to make valgrin happy
60  startTime.tm_isdst = -1; /* Not set by strptime(); tells mktime()
61  to determine whether daylight saving time
62  is in effect */
63 
64  fTime = mktime(&startTime);
65 
67  HarpoPedMgr * pedmgr = gHConfig->GetHarpoPedMgr();
68  Long64_t run = gHConfig->GetRunNo();
69 
70  peds = pedmgr->Lookup(run,rdr->GetDet());
71 
72  return true;
73  }
74 
76  {
77  std::cout << "--- HarpoDccHeader" << std::endl
78  << "Start Time : " << fTime << std::endl
79  << "Dcc Header : " << fHeader << std::endl;
80  }
81 
A class hold HARPO run iformation.
A class which read HARPO dcc file from one DCC and creant Dcc Events and Dcc Headers for DCC Events o...
Long64_t GetRunNo()
Set Run Number.
Definition: HarpoConfig.h:127
A class hold HARPO run iformation.
HarpoPedestal * Lookup(Long_t run, Long_t detno)
! Serach pedestal and means for given plane
Definition: HarpoPedMgr.cxx:37
int fHeaderLen
Run Staring Time.
HarpoPedestal * peds
HarpoPedMgr * GetHarpoPedMgr()
Get pointer to Harpo Feminos pdestal manager.
Definition: HarpoConfig.h:163
const char * timefmt
#define HARO_RUN_HEADER_LEN
HarpoConfig * gHConfig
Int_t GetDet()
Define plane X or Y.