1 | /////////////////////////////////////////////////////////////////////////////
|
---|
2 | // //
|
---|
3 | // MCT1ReadAscii //
|
---|
4 | // //
|
---|
5 | /////////////////////////////////////////////////////////////////////////////
|
---|
6 |
|
---|
7 | #include "MCT1ReadAscii.h"
|
---|
8 |
|
---|
9 | #include <fstream.h>
|
---|
10 |
|
---|
11 | #include "MLog.h"
|
---|
12 | #include "MLogManip.h"
|
---|
13 |
|
---|
14 | #include "MParList.h"
|
---|
15 | #include "MCerPhotEvt.h"
|
---|
16 | #include "MCT1Pedestals.h"
|
---|
17 |
|
---|
18 | ClassImp(MCT1ReadAscii)
|
---|
19 |
|
---|
20 | MCT1ReadAscii::MCT1ReadAscii(const char *fname,
|
---|
21 | const char *name,
|
---|
22 | const char *title)
|
---|
23 | {
|
---|
24 | *fName = name ? name : "MCT1ReadAscii";
|
---|
25 | *fTitle = title ? title : "Task to loop over events in CT1 ascii file";
|
---|
26 |
|
---|
27 | //
|
---|
28 | // remember file name for opening the file in the preprocessor
|
---|
29 | //
|
---|
30 | fFileName = fname;
|
---|
31 | }
|
---|
32 |
|
---|
33 | Bool_t MCT1ReadAscii::PreProcess(MParList *pList)
|
---|
34 | {
|
---|
35 | //
|
---|
36 | // Preprocessing
|
---|
37 | //
|
---|
38 |
|
---|
39 | //
|
---|
40 | // open the input stream and check if it is really open (file exists?)
|
---|
41 | //
|
---|
42 | fIn = new ifstream(fFileName);
|
---|
43 | if (!(*fIn))
|
---|
44 | {
|
---|
45 | *fLog << dbginf << "Cannot open file." << endl;
|
---|
46 | return kFALSE;
|
---|
47 | }
|
---|
48 |
|
---|
49 | //
|
---|
50 | // look for the MCerPhotEvt class in the plist
|
---|
51 | //
|
---|
52 | fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
|
---|
53 | if (!fNphot)
|
---|
54 | return kFALSE;
|
---|
55 |
|
---|
56 | //
|
---|
57 | // look for the pedestal class in the plist
|
---|
58 | //
|
---|
59 | fPedest = (MCT1Pedestals*)pList->FindCreateObj("MCT1Pedestals");
|
---|
60 | if (!fPedest)
|
---|
61 | return kFALSE;
|
---|
62 |
|
---|
63 | return kTRUE;
|
---|
64 | }
|
---|
65 |
|
---|
66 | Bool_t MCT1ReadAscii::Process()
|
---|
67 | {
|
---|
68 | //
|
---|
69 | // FIXME. This function should switch between reading pedestals and
|
---|
70 | // reading event data by the 'switch entry'.
|
---|
71 | // After reading it should set the InputStreamID correctly.
|
---|
72 | // ( should use MPedestalCam )
|
---|
73 | //
|
---|
74 |
|
---|
75 | //
|
---|
76 | // read in a dummy number (event number)
|
---|
77 | //
|
---|
78 | Int_t dummyI;
|
---|
79 | *fIn >> dummyI;
|
---|
80 |
|
---|
81 | //
|
---|
82 | // check if we are done
|
---|
83 | //
|
---|
84 | if (fIn->eof())
|
---|
85 | return kFALSE;
|
---|
86 |
|
---|
87 | //
|
---|
88 | // if the first number is negativ this is a pedestal line:
|
---|
89 | // read in pedestals
|
---|
90 | //
|
---|
91 | if (dummyI < 0)
|
---|
92 | fPedest->AsciiRead(*fIn);
|
---|
93 |
|
---|
94 | //
|
---|
95 | // five unsused numbers
|
---|
96 | //
|
---|
97 | *fIn >> dummyI; // ener
|
---|
98 | *fIn >> dummyI; // zenang
|
---|
99 | *fIn >> dummyI; // sec1
|
---|
100 | *fIn >> dummyI; // sec2
|
---|
101 |
|
---|
102 | //
|
---|
103 | // clear the list of cerphot-events
|
---|
104 | //
|
---|
105 | fNphot->Clear();
|
---|
106 |
|
---|
107 | //
|
---|
108 | // read in the number of cerenkov photons and add the 'new' pixel
|
---|
109 | // too the list with it's id, number of photons and error
|
---|
110 | //
|
---|
111 | for (Int_t i = 0; i<127; i++ )
|
---|
112 | {
|
---|
113 | Float_t nphot;
|
---|
114 |
|
---|
115 | *fIn >> nphot;
|
---|
116 |
|
---|
117 | if (nphot > 0.0)
|
---|
118 | fNphot->AddPixel(i, nphot, (*fPedest)[i]);
|
---|
119 | }
|
---|
120 |
|
---|
121 | return kTRUE;
|
---|
122 | }
|
---|
123 |
|
---|
124 | Bool_t MCT1ReadAscii::PostProcess()
|
---|
125 | {
|
---|
126 | //
|
---|
127 | // close and delete the input stream
|
---|
128 | //
|
---|
129 | delete fIn;
|
---|
130 |
|
---|
131 | return kTRUE;
|
---|
132 | }
|
---|
133 |
|
---|