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 |
|
---|
17 | ClassImp(MReadCT1Ascii)
|
---|
18 |
|
---|
19 | MReadCT1Ascii::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 | // set the pedestals to default values
|
---|
31 |
|
---|
32 | for (Int_t i = 0; i<127; i++ )
|
---|
33 | {
|
---|
34 |
|
---|
35 | fPedest[i] = 1.5 ;
|
---|
36 | }
|
---|
37 |
|
---|
38 | }
|
---|
39 |
|
---|
40 | Bool_t MReadCT1Ascii::PreProcess(MParList *pList)
|
---|
41 | {
|
---|
42 | // Preprocessing
|
---|
43 |
|
---|
44 | // open the file cout << fFileName << endl ;
|
---|
45 |
|
---|
46 | fInputfile = fopen( fFileName, "r" ) ;
|
---|
47 |
|
---|
48 | if ( fInputfile == 0 )
|
---|
49 | return kFALSE ;
|
---|
50 |
|
---|
51 | // look for the MNphotEvent class in the plist
|
---|
52 |
|
---|
53 |
|
---|
54 | fNphot = (MNphotEvent*)pList->FindObject("MNphotEvent");
|
---|
55 |
|
---|
56 | if (!fNphot )
|
---|
57 | {
|
---|
58 | cout << "MRawCT1Ascii::PreProcess - WARNING: MNphotEvent not found... exit" << endl;
|
---|
59 | return kFALSE ;
|
---|
60 | }
|
---|
61 |
|
---|
62 | return kTRUE;
|
---|
63 | }
|
---|
64 |
|
---|
65 | Bool_t MReadCT1Ascii::Process()
|
---|
66 | {
|
---|
67 | fNphot->Clear() ;
|
---|
68 |
|
---|
69 | Int_t dummyI ;
|
---|
70 | Float_t dummyF ;
|
---|
71 |
|
---|
72 | // read in the first five numbers
|
---|
73 |
|
---|
74 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
75 | if ( feof ( fInputfile ) != 0 )
|
---|
76 | return kFALSE ;
|
---|
77 |
|
---|
78 | // if the first number is negativ this is the pedestal line
|
---|
79 |
|
---|
80 | if (dummyI < 0 )
|
---|
81 | ReadPedestal() ;
|
---|
82 |
|
---|
83 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
84 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
85 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
86 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
87 |
|
---|
88 | // read in the next 127 numbers as the pixels
|
---|
89 |
|
---|
90 | for (Int_t i = 0; i<127; i++ )
|
---|
91 | {
|
---|
92 | fscanf ( fInputfile, "%f", &dummyF ) ;
|
---|
93 |
|
---|
94 | if ( dummyF > 0.0 ) {
|
---|
95 | fNphot->AddPixel(i, dummyF, fPedest[i] ) ;
|
---|
96 | }
|
---|
97 |
|
---|
98 | }
|
---|
99 |
|
---|
100 | return kTRUE;
|
---|
101 | }
|
---|
102 |
|
---|
103 | Bool_t MReadCT1Ascii::PostProcess()
|
---|
104 | {
|
---|
105 | fclose( fInputfile ) ;
|
---|
106 | return kTRUE;
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 | void MReadCT1Ascii::ReadPedestal()
|
---|
111 | {
|
---|
112 | cout << " Read in the Pedestals " << endl ;
|
---|
113 | Int_t dummyI ;
|
---|
114 | Float_t dummyF ;
|
---|
115 |
|
---|
116 | // the next for values are for dummy
|
---|
117 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
118 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
119 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
120 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
121 |
|
---|
122 | // read in the next 127 numbers as the pedestals
|
---|
123 |
|
---|
124 | for (Int_t i = 0; i<127; i++ )
|
---|
125 | {
|
---|
126 | fscanf ( fInputfile, "%f", &dummyF ) ;
|
---|
127 |
|
---|
128 | if ( dummyF > 0.0 ) {
|
---|
129 | fPedest[i] = dummyF ;
|
---|
130 | }
|
---|
131 |
|
---|
132 | }
|
---|
133 |
|
---|
134 | fscanf ( fInputfile, "%d", &dummyI ) ;
|
---|
135 |
|
---|
136 |
|
---|
137 | }
|
---|
138 |
|
---|