HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoReaderSim.cxx
Go to the documentation of this file.
1 //
2 // File HarpoReaderSim.cxx
3 //
10 #include "HarpoReaderSim.h"
11 #include "HarpoDetReader.h"
12 #include "HarpoConfig.h"
13 #include "HarpoRunHeader.h"
14 #include "HarpoEvent.h"
15 #include "HarpoTimeStamp.h"
16 
17 #include "HarpoDccReader.h"
18 #include "HarpoSimReader.h"
19 #include "HarpoFeminosHeader.h"
20 
21 #include <climits>
22 #include <cstdio>
23 #include <arpa/inet.h>
24 #include <cstdlib>
25 //#include <cstring>
26 #include <iostream>
27 
28 
29 ClassImp(HarpoReaderSim)
30 
31 
37 {
38  if(gHarpoDebug>0) Info("HarpoReaderSim()"," ");
39 
40  fMode = hSyncTime;
41 }
42 
44 
48 HarpoReaderSim::HarpoReaderSim(HarpoConfig *cfg) : HarpoReaderBase(cfg)
49  {
50  if(gHarpoDebug>0) Info("HarpoReaderSim(cfg)"," ");
51 
52  fMode = hSyncTime;
53  fRunHeader = new HarpoRunHeader(cfg);
54 
55 }
56 
58 {
59  if(gHarpoDebug>0) Info("~HarpoReaderSim()"," ");
60  // ??? Delete Det Constructors
61  // if ( fNewFile != NULL) {
62  // fNewFile->Close();
63  // }
64 }
65 
66 void HarpoReaderSim::SetDetFile(TString * /*name */,Int_t /* plane */)
67 {
68  // fInFile[plane] = name; //???
69 }
70 
71  void HarpoReaderSim::SetRootFile(TString *name)
72  {
73  //if(gHarpoDebug>0)
74  Info("Dummy SetRootFile","%s",name->Data());
75  }
76 
78 {
79  if(gHarpoDebug>1) Info("NextEvent"," ");
80  Bool_t res = true;
81  //ULong_t ndet;
82  //Long_t deltat;
83  //ULong_t ts[2],tso[2];
84 
85  res = res && fDetReader[SIMDET]->NextEvent();
86  if ( ! res ) return res; // No more event or errors
87 
88  fNevts++;
89  GetEvent();
90 
91  return res;
92 }
93 
95 {
96  if(gHarpoDebug>0) Info("GetEvent","event %ld",fNevts);
97  HarpoDetEvent *revt;
98  ULong_t ndet;
99 
100  /* if(fEvent==NULL) */ fEvent = new HarpoEvent();
101  /* if(fEventHeader==NULL) */ fEventHeader = new HarpoEventHeader();
102 
103  fEventHeader->SetEvtNo(fNevts); // Event header
105 
106  for(ndet=0;ndet<gkNDetectors;ndet++) {
107  if (fDetSet->isExist(ndet)) {
108  revt = ((HarpoSimReader*)fDetReader[SIMDET])->GetEvent(ndet);
109  fEvent->SetDetEvent(revt,ndet);
110  }
111  }
112 
113  return fEvent;
114 }
115 
118 {
119  if(gHarpoDebug>0) Info("GetRunHeader"," ");
120  return fRunHeader;
121 }
122 
124 
128 {
129  if(gHarpoDebug>0) Info("Init","Readout mode %d",mode);
130  Bool_t res = true;
131  fMode = mode;
132  fDetSet->print();
133 
134  std::cout << "Det is SIM " << fDetSet->isExist(SIMDET) << std::endl;
139  res = res && fDetReader[SIMDET]->Init();
140 
141  HarpoDetHeader *rawhdr;
142  // ULong_t ndet;
143 
145  // for(ndet=0;ndet<gkNDetectors;ndet++) {
146  // if (fDetSet->isSim()) {
147  // rawhdr = fDetReader[SIMDET]->GetDetHeader();
148  // fRunHeader->SetDetHeader(rawhdr,ndet);
149  // continue;
150  // }
151  // }
152 
153  // Save det mask
154  fDetSet->Set(SIMDET); // always set for simulation
155  fRunHeader->SetSimDataFlag(true);
157 
158  for(UInt_t ndet=0;ndet<gkNDetectors;ndet++) {
159  // std::cout << "DET : " << ndet << "/" << gkNDetectors << " => " << fDetSet->isExist(ndet)<< std::endl;
160  if (!fDetSet->isExist(ndet)) continue;
161  rawhdr = ((HarpoSimReader*)fDetReader[SIMDET])->GetDetHeader(ndet);
162  if(gHarpoDebug>0) {
163  std::cout << "Add Det Header "<< ndet << " " << rawhdr << std::endl;
164  rawhdr->print();
165  }
166  fRunHeader->SetDetHeader(rawhdr,ndet);
167  }
168  // std::cout << res << std::endl;
169  return res;
170 }
171 
172 Long_t HarpoReaderSim::Loop(Long_t maxevents)
173 {
174  Long_t cnt=0;
175  if(gHarpoDebug>0) Info("Loop", "maxevents = %ld",maxevents);
176 
177  while (NextEvent()) {
178  if(gHarpoDebug>1)
179  Info("Loop", "Get Event %ld",fNevts);
180  HarpoEvent* evt = GetEvent();
181  if(gHarpoDebug>1)
182  Info("Loop", "Process event %p",evt);
183 
184  // Pre
185  Int_t st = hAnaOK;
187 
188  for(Int_t i = 0; i<fNanalyses; i++)
189  {
191  st = fEvent->GetHeader()->GetEvAnaStatus();
192  if ( st < hAnaNextEvent ) break;
193  }
194 
195  if(gHarpoDebug>1)
196  Info("Loop", "Event processed");
197  // if (gHDetSet->isExist(SIMDET)){
198  // HarpoSimEvent *simEvt = (HarpoSimEvent *)(evt->GetDetEvent(SIMDET));
199  // Int_t nIonTr = simEvt->GetNtracks();
200  // }
201  evt->Delete();
202  if(gHarpoDebug>1)
203  Info("Loop", "Event Deleted");
204 
205  if (st == hAnaNextFile )
206  {
207  //how to go to next file ?
208  break;
209  }
210  else if (st == hAnaStop)
211  {
212  break;
213  }
214  else if (st <= hAnaAbort)
215  {
216  Error(__FUNCTION__,
217  "Fatal Analysis Error %d aborting prgram.\n",st);
218  std::abort();
219  }
220 
221  if (++cnt >= maxevents) break;
222  }
223  return cnt;
224 }
225 
226 Long_t HarpoReaderSim::Find(Long_t /* eventNo */ )
227 {
228  //todo Find
229  return true;
230 }
231 
233 {
234  //todo Skip
235 }
A class hold HARPO run iformation.
HarpoRunHeader * fRunHeader
virtual void print()
Definition: HarpoDetSet.cxx:43
virtual void print()
HarpoRunHeader * GetRunHeader()
Create RunHeader with links to all raw headers.
A virtual class store event data for un detector.
Definition: HarpoDetEvent.h:32
Long_t fRunNo
Number of readed events.
Int_t GetEvAnaStatus()
Get Event Analise status.
Long_t Loop(Long_t maxevents)
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
A class hold HARPO run iformation.
void SetEvAnaStatus(Int_t status)
Set Event Analise status.
virtual ~HarpoReaderSim()
HarpoEvent * GetEvent()
TString * GetInFile(Int_t idet)
Get Input file name for detector.
Definition: HarpoConfig.h:96
Stop Event Loop.
HarpoAnalyse * fAnalyse[30]
A class which read HARPO sim file from one SIM and creant Sim Events and Sim Headers for SIM Events o...
FullEvent Header not scecific to the detectors The class is ....
A base class for all top level HARPO readers.
Data from Keller temperuture and pressure sensors.
Definition: HarpoDet.h:22
void SetRunNo(Long_t nRun)
Find raw event by event number.
void SetHeader(HarpoEventHeader *data)
Definition: HarpoEvent.cxx:75
A class which read HARPO simulated events.
Close current input file continue with next file.
ULong_t GetMask()
Definition: HarpoDetSet.h:55
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
void SetDet(Long_t plane)
virtual void ProcessEvent(HarpoEvent *event)
Set pointer to new event for analyse, anlyse event , and delete.
stop event analysis, but write event
virtual Bool_t Init()=0
hReadMode fMode
virtual Bool_t NextEvent()=0
Bool_t Init(hReadMode mode=hSyncTime)
Init method : Open in/out files and check run header signature.
void SetDetFile(TString *name)
HarpoEventHeader * GetHeader()
Definition: HarpoEvent.cxx:80
A class store HARPO row event data and header. Provide access metods to the row event data...
Definition: HarpoEvent.h:29
void SetDetFile(TString *name, Int_t plane)
unsigned int res
Definition: Pmm2Status.h:428
Long_t Find(Long_t eventNo)
Abort program without saving the output or < -5.
void SetSimDataFlag(Bool_t flag=true)
HarpoEvent * fEvent
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
void SetEvtNo(Long_t rnum)
Set Event Number.
void SetDetEvent(HarpoDetEvent *event, ULong_t plane=XDCC)
Definition: HarpoEvent.cxx:85
void Set(ULong_t det)
Definition: HarpoDetSet.h:30
HarpoConfig * gHConfig
void SetDetHeader(HarpoDetHeader *hdr, UInt_t ndet=XDCC)
void SetDetMask(ULong_t mask)
hReadMode
A class which keeps track of the entire configuration of the analysis.
Definition: HarpoConfig.h:50
HarpoDetReader ** fDetReader
HarpoDetSet * fDetSet
HarpoEventHeader * fEventHeader
void SetRootFile(TString *name)