source: trunk/MagicSoft/Mars/manalysis/MReadCT1Ascii.cc@ 596

Last change on this file since 596 was 596, checked in by harald, 24 years ago
Now the first version of the Camera eventdisplay is running. Run the macro "readCT1.C" to have a look.
File size: 2.1 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// //
3// MReadCT1Ascii //
4// //
5/////////////////////////////////////////////////////////////////////////////
6
7#include "MReadCT1Ascii.h"
8
9
10#include <stdio.h>
11#include <iostream.h>
12#include <fstream.h>
13
14#include "MParList.h"
15#include "MNphotEvent.h"
16
17ClassImp(MReadCT1Ascii)
18
19MReadCT1Ascii::MReadCT1Ascii(const char *fname,
20 const char *name,
21 const char *title)
22{
23 *fName = name ? name : "MReadCT1Ascii";
24 *fTitle = title ? title : "Task to loop over events in CT1 ascii file";
25
26 // open the input stream
27
28 fFileName = fname;
29}
30
31Bool_t MReadCT1Ascii::PreProcess(MParList *pList)
32{
33 // Preprocessing
34
35 // open the file cout << fFileName << endl ;
36
37 fInputfile = fopen( fFileName, "r" ) ;
38
39 if ( fInputfile == 0 )
40 return kFALSE ;
41
42 // look for the MNphotEvent class in the plist
43
44
45 fNphot = (MNphotEvent*)pList->FindObject("MNphotEvent");
46
47 if (!fNphot )
48 {
49 cout << "MRawCT1Ascii::PreProcess - WARNING: MNphotEvent not found... exit" << endl;
50 return kFALSE ;
51 }
52
53 return kTRUE;
54}
55
56Bool_t MReadCT1Ascii::Process()
57{
58 fNphot->Clear() ;
59
60 Int_t dummyI ;
61 Float_t dummyF ;
62
63 // read in the first five numbers
64
65 fscanf ( fInputfile, "%d", &dummyI ) ;
66 if ( feof ( fInputfile ) != 0 )
67 return kFALSE ;
68
69 fscanf ( fInputfile, "%d", &dummyI ) ;
70 fscanf ( fInputfile, "%d", &dummyI ) ;
71 fscanf ( fInputfile, "%d", &dummyI ) ;
72 fscanf ( fInputfile, "%d", &dummyI ) ;
73
74 // read in the next 127 numbers as the pixels
75
76 for (Int_t i = 0; i<127; i++ )
77 {
78 fscanf ( fInputfile, "%f", &dummyF ) ;
79
80
81 if ( dummyF > 0.0 ) {
82 fNphot->AddPixel(i, dummyF, sqrt(dummyF) ) ;
83 }
84
85 }
86
87 return kTRUE;
88}
89
90Bool_t MReadCT1Ascii::PostProcess()
91{
92 fclose( fInputfile ) ;
93 return kTRUE;
94}
95
Note: See TracBrowser for help on using the repository browser.