source: trunk/MagicSoft/MarsOctober/mocttest/MTdcSpect.cc@ 9223

Last change on this file since 9223 was 451, checked in by harald, 24 years ago
This files are neccessary for the TDC histos.
File size: 2.3 KB
Line 
1#include "MTdcSpect.h"
2
3#include <iostream.h>
4#include <stdlib.h>
5
6#include <TFile.h>
7
8#include "MRawEvt.h"
9#include "MParList.h"
10#include "MHistosTdc.h"
11
12
13////////////////////////////////////////////////////////////////////////
14//
15// MTdcSpect.h
16//
17// A Task to fill the raw Tdc values in the histograms to create
18// the Tdc raw spectra
19//
20
21ClassImp(MTdcSpect)
22
23MTdcSpect::MTdcSpect( char* treeName, char *rootfile)
24{
25 //
26 // default constructor
27 //
28 sprintf(fTreeName, "%s", treeName ) ;
29
30 sprintf(fOutFile, "%s", rootfile);
31}
32
33
34Bool_t MTdcSpect::PreProcess(MParList *pList)
35{
36 //
37 // Do the preprocessing for MTdcSpect
38 //
39 // Connects the event in MRawEvtBuf as the input for this task
40 // and the MHistosTdc container as the output
41 //
42
43 //
44 // first look for the input buffer MRawEvtBuf
45 //
46 fEvtBuf = (MObjBuffer*) pList->FindObject(fTreeName);
47 if (!fEvtBuf)
48 {
49 cout << "ERROR: MTdcSpect::PreProc(): " << fTreeName << " not found!" << endl;
50 exit(1);
51 }
52
53 //
54 // second connect the output container
55 //
56 fHists = (MHistosTdc*) pList->FindObject("MHistosTdc");
57
58 if (!fHists)
59 {
60 cout << "ERROR: MTdcSpect::PreProc(): MHistosTdc not found!" << endl;
61 exit(1);
62 }
63
64 return kTRUE ;
65}
66
67Bool_t MTdcSpect::Process()
68{
69 //
70 // fill the raw data values in the corresponding histograms
71 //
72
73 //
74 // loop over the pixels in the events
75 //
76
77 MRawEvt *fRawEvt = (MRawEvt*)(*fEvtBuf)();
78
79 for ( Int_t i=0 ; i< (Int_t) fRawEvt->GetMultPixel(); i++ )
80 {
81 fHists->FillTdcHist ( fRawEvt->GetPixelId(i),
82 fRawEvt->GetPixelData(i) );
83
84 }
85
86 return kTRUE ;
87}
88
89
90Bool_t MTdcSpect::PostProcess()
91{
92 //
93 // PostProessing
94 //
95 // after the loop over all events this routine is executed.
96 // Here the postprecessing is checking the contents of
97 // fOutFile.
98 // If it is "nooutput", nothing is done.
99 // Else the histograms in the MHistosTdc are written to a file.
100 //
101
102 if (strcmp (fOutFile, "nooutput"))
103 {
104 //
105 // write the histograms to File
106 //
107 cout << endl << "--> INFO: write the histograms to file: "
108 << fOutFile << endl ;
109
110 //
111 // call the containers save function
112 //
113
114 fHists->SaveHist(fOutFile);
115 }
116
117 return kTRUE;
118}
Note: See TracBrowser for help on using the repository browser.