source: trunk/MagicSoft/MarsOctober/mocttest/MHistosAdc.cc@ 499

Last change on this file since 499 was 447, checked in by harald, 24 years ago
Bringing the sources for the octobertest under CVS controll. (november, 3rd, 2000)
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1///////////////////////////////////////////////////////////////////////
2//
3// MHistosAdc
4//
5// This class contains a list of all ADC spektra histograms
6//
7///////////////////////////////////////////////////////////////////////
8
9#include "MHistosAdc.h"
10
11#include <iostream.h>
12
13#include <TH1.h>
14#include <TFile.h>
15
16ClassImp(MHistosAdc)
17
18MHistosAdc::MHistosAdc ()
19{
20 //
21 // default constructor
22 // creates an a list of histograms for all pixels and both gain channels
23 //
24
25 fHistHigh = new TObjArray(577);
26 fHistLow = new TObjArray(577);
27
28 //
29 // set the name and title of this object
30 //
31
32 fName = "MHistosAdc" ;
33 fTitle = "Container for ADC spectra histograms" ;
34
35 //
36 // loop over all Pixels and create two histograms
37 // one for the Low and one for the High gain
38 // connect all the histogram with the container fHist
39 //
40
41 Char_t tmp1[40];
42 Char_t tmp2[40];
43 TH1F *h1;
44
45 for ( Int_t i = 0 ; i < 577 ; i++)
46 {
47 sprintf ( tmp1, "high%d", i ) ;
48 sprintf ( tmp2, "high gain Pixel %d", i ) ;
49
50 h1 = new TH1F ( tmp1, tmp2, 256, 0., 255. ) ;
51
52 fHistHigh->Add( h1 ) ;
53
54 sprintf ( tmp1, "low %d", i ) ;
55 sprintf ( tmp2, "low gain Pixel %d", i ) ;
56
57 h1 = new TH1F ( tmp1, tmp2, 256, 0., 255. ) ;
58
59 fHistLow->Add( h1 ) ;
60
61 }
62}
63
64MHistosAdc::~MHistosAdc ()
65{
66
67 // default destructor
68 //
69 delete fHistHigh ;
70 delete fHistLow ;
71}
72
73void MHistosAdc::Print(Option_t *)
74{
75 for ( Int_t i = 0 ; i < 576 ; i++)
76 {
77 fHistHigh[i].Print() ;
78 }
79}
80
81void MHistosAdc::FillAdcHist ( Int_t iPix, UChar_t* data)
82{
83 // cout << " MHistosAdc::FillAdcHist " << endl ;
84
85 //
86 // fill all slices (contained in data) in the Histogram
87 // of iPix. If iPix > 10000 this is a low gain channel
88
89 //
90 // check which container list is needed
91 // for high or for low gain
92 //
93 if ( iPix < 10000 )
94 {
95 //
96 // loop over data
97 //
98 for (Int_t i=0; i< 15; i++ )
99 {
100 ((TH1F*) (fHistHigh->At(iPix)))->Fill( (Float_t) data[i]) ;
101 }
102 }
103 else
104 {
105 //
106 // loop over data
107 //
108 for (Int_t i=0; i< 15; i++ )
109 {
110 ((TH1F*) (fHistLow->At(iPix)))->Fill( (Float_t) data[i]) ;
111 }
112 }
113}
114
115void MHistosAdc::SaveHist ( char *name )
116{
117 //
118 // save all histogram in this class to a root file
119 //
120
121 TFile out( name, "recreate") ;
122
123 //
124 // loop over all pixels and write the files out
125 //
126
127 fHistLow->Write() ;
128 fHistHigh->Write() ;
129}
130
Note: See TracBrowser for help on using the repository browser.