| 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 |
|
|---|
| 31 | Bool_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 |
|
|---|
| 56 | Bool_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 |
|
|---|
| 90 | Bool_t MReadCT1Ascii::PostProcess()
|
|---|
| 91 | {
|
|---|
| 92 | fclose( fInputfile ) ;
|
|---|
| 93 | return kTRUE;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|