source: trunk/MagicSoft/MarsOctober/mocttest/MCalcPed1.cc@ 6937

Last change on this file since 6937 was 452, checked in by harald, 24 years ago
Further improvements in the layout of some guiclasses. Know the fundament for calculating the pedestals is created with the first implementation of the classes MPixPedest and MPedest. A first task for calculating the pedestals is set up (MCalcPed1).
File size: 2.9 KB
Line 
1#include "MCalcPed1.h"
2
3#include <stdlib.h>
4
5#include <TROOT.h>
6#include <TApplication.h>
7#include <TSystem.h>
8#include <TGClient.h>
9#include <TGFileDialog.h>
10#include <TVirtualX.h>
11
12#include "MRawEvt.h"
13#include "MParList.h"
14#include "MHistosAdc.h"
15
16
17////////////////////////////////////////////////////////////////////////
18//
19// MGShowSpect.h
20//
21// A Gui Task to show the raw ADC values in the histograms
22//
23
24ClassImp(MCalcPed1)
25
26
27Bool_t MCalcPed1::PreProcess(MParList *pList)
28{
29 //
30 // Do the preprocessing for MCalcPed1
31 //
32 // Connects Histogramms in the MHistosAdc container as the input
33 // and the MPedest class in the list for output
34 //
35
36 fHists = (MHistosAdc*) pList->FindObject("MHistosAdc");
37
38 if (!fHists)
39 {
40 cout << "ERROR: MCalcPed1::PreProc(): MHistosAdc not found!" << endl;
41 exit(1);
42 }
43
44 fPedData = (MPedest*) pList->FindObject("MPedest");
45
46 if (!fPedData)
47 {
48 cout << "ERROR: MCalcPed1::PreProc(): MPedest not found!" << endl;
49 exit(1);
50 }
51
52 return (kTRUE) ;
53}
54
55
56Bool_t MCalcPed1::PostProcess()
57{
58 // just start the gui for displaying the adc spectra
59
60
61 // loop over the high gain histograms and do a fit to them to get
62 // the pedestal datas
63
64 // define the function to fit
65
66 TH1F *histofit ;
67 TF1 *gausfit = new TF1 ("gausfit", "gaus", 0., 100. ) ;
68
69 TObjArray *histList ;
70
71 Int_t iEnt ;
72
73 // all for the high gains
74
75 histList = fHists->GetHighList() ;
76 for ( Int_t i=0; i< fHists->GetHighEntries() ; i++ ) {
77
78 // select the histogram
79 histofit = (TH1F*) histList->At(i) ;
80 iEnt = histofit->GetEntries() ;
81
82 if ( iEnt > 1. ) {
83 histofit->Fit("gausfit", "RQN" ) ;
84 fPedData->SetAllHigh(i,
85 gausfit->GetParameter(1), gausfit->GetParameter(1)/sqrt(iEnt-1.) ,
86 gausfit->GetParameter(2), gausfit->GetParameter(2)/sqrt(2. * iEnt ) ) ;
87 }
88 else {
89 fPedData->SetAllHigh(i, -1., -1., -1., -1. ) ;
90 }
91 }
92
93 // all for the low gains
94
95 histList = fHists->GetLowList() ;
96 for ( Int_t i=0; i< fHists->GetLowEntries() ; i++ ) {
97
98 histofit = (TH1F*) histList->At(i) ;
99 iEnt = histofit->GetEntries() ;
100
101 if ( iEnt > 1. ) {
102 histofit->Fit("gausfit", "RQN" ) ;
103
104 fPedData->SetAllLow(i,
105 gausfit->GetParameter(1), gausfit->GetParameter(1)/sqrt(iEnt-1.) ,
106 gausfit->GetParameter(2), gausfit->GetParameter(2)/sqrt(2. * iEnt ) ) ;
107 }
108 else {
109 fPedData->SetAllLow(i, -1., -1., -1., -1. ) ;
110 }
111 }
112
113
114
115 // fPedData->Print() ;
116
117
118 if (strcmp (fFileOut, "nooutput"))
119 {
120 //
121 // write the histograms to File
122 //
123 cout << endl << "--> INFO: write the histograms to file: "
124 << fFileOut << endl ;
125
126
127 TFile out( fFileOut, "recreate") ;
128
129 //
130 // write the pedestal container to file
131 //
132
133 fPedData->Write() ;
134
135 out.Close() ;
136 }
137
138
139 return (kTRUE) ;
140}
141
142
143
144
145
146
147
148
149
150
Note: See TracBrowser for help on using the repository browser.