source: trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc@ 674

Last change on this file since 674 was 656, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.9 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// //
3// MCT1ReadAscii //
4// //
5/////////////////////////////////////////////////////////////////////////////
6
7#include "MCT1ReadAscii.h"
8
9#include <fstream.h>
10
11#include "MLog.h"
12#include "MParList.h"
13#include "MCerPhotEvt.h"
14#include "MCT1Pedestals.h"
15
16ClassImp(MCT1ReadAscii)
17
18MCT1ReadAscii::MCT1ReadAscii(const char *fname,
19 const char *name,
20 const char *title)
21{
22 *fName = name ? name : "MCT1ReadAscii";
23 *fTitle = title ? title : "Task to loop over events in CT1 ascii file";
24
25 //
26 // remember file name for opening the file in the preprocessor
27 //
28 fFileName = fname;
29}
30
31Bool_t MCT1ReadAscii::PreProcess(MParList *pList)
32{
33 //
34 // Preprocessing
35 //
36
37 //
38 // open the input stream and check if it is really open (file exists?)
39 //
40 fIn = new ifstream(fFileName);
41 if (!(*fIn))
42 {
43 *fLog << "Error: MCT1ReadAscii::PreProcess: Cannot open file." << endl;
44 return kFALSE;
45 }
46
47 //
48 // look for the MCerPhotEvt class in the plist
49 //
50 fNphot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
51 if (!fNphot)
52 {
53 *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCerPhotEvt not found... creating." << endl;
54 fNphot = new MCerPhotEvt;
55 pList->AddToList(fNphot);
56 }
57
58 //
59 // look for the pedestal class in the plist
60 //
61 fPedest = (MCT1Pedestals*)pList->FindObject("MCT1Pedestals");
62 if (!fPedest)
63 {
64 *fLog << "MRawCT1Ascii::PreProcess - WARNING: MCT1Pedestals not found... creating." << endl;
65 fPedest = new MCT1Pedestals;
66 pList->AddToList(fPedest);
67 }
68
69 return kTRUE;
70}
71
72Bool_t MCT1ReadAscii::Process()
73{
74 //
75 // read in a dummy number (event number)
76 //
77 Int_t dummyI;
78 *fIn >> dummyI;
79
80 if (fIn->eof())
81 {
82 *fLog << "MRawCT1Ascii::Process - Error: EOF reached." << endl;
83 return kFALSE;
84 }
85
86 //
87 // if the first number is negativ this is a pedestal line:
88 // read in pedestals
89 //
90 if (dummyI < 0)
91 fPedest->AsciiRead(*fIn);
92
93 //
94 // five unsused numbers
95 //
96 *fIn >> dummyI;
97 *fIn >> dummyI;
98 *fIn >> dummyI;
99 *fIn >> dummyI;
100
101 //
102 // clear the list of cerphot-events
103 //
104 fNphot->Clear();
105
106 //
107 // read in the number of cerenkov photons and add the 'new' pixel
108 // too the list with it's id, number of photons and error
109 //
110 for (Int_t i = 0; i<127; i++ )
111 {
112 Float_t dummyF;
113
114 *fIn >> dummyF;
115
116 if (dummyF > 0.0)
117 fNphot->AddPixel(i, dummyF, (*fPedest)[i]);
118 }
119
120 return kTRUE;
121}
122
123Bool_t MCT1ReadAscii::PostProcess()
124{
125 //
126 // close and delete the input stream
127 //
128 delete fIn;
129
130 return kTRUE;
131}
132
Note: See TracBrowser for help on using the repository browser.