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 |
|
---|
16 | ClassImp(MHistosAdc)
|
---|
17 |
|
---|
18 | MHistosAdc::MHistosAdc (const char *name, const char *title)
|
---|
19 | {
|
---|
20 | //
|
---|
21 | // default constructor
|
---|
22 | // creates an a list of histograms for all pixels and both gain channels
|
---|
23 | //
|
---|
24 |
|
---|
25 | //
|
---|
26 | // set the name and title of this object
|
---|
27 | //
|
---|
28 |
|
---|
29 | *fName = name ? name : "MHistosAdc" ;
|
---|
30 | *fTitle = title ? title : "Container for ADC spectra histograms" ;
|
---|
31 |
|
---|
32 | //
|
---|
33 | // loop over all Pixels and create two histograms
|
---|
34 | // one for the Low and one for the High gain
|
---|
35 | // connect all the histogram with the container fHist
|
---|
36 | //
|
---|
37 | fHistHi = new TObjArray(577);
|
---|
38 | fHistLo = new TObjArray(577);
|
---|
39 |
|
---|
40 | Char_t tmp1[40];
|
---|
41 | Char_t tmp2[40];
|
---|
42 |
|
---|
43 | for ( Int_t i = 0 ; i < 577 ; i++)
|
---|
44 | {
|
---|
45 | sprintf ( tmp1, "high%d", i ) ;
|
---|
46 | sprintf ( tmp2, "high gain Pixel %d", i ) ;
|
---|
47 |
|
---|
48 | fHistHi->Add( new TH1F ( tmp1, tmp2, 256, 0., 255. ) ) ;
|
---|
49 |
|
---|
50 | sprintf ( tmp1, "low %d", i ) ;
|
---|
51 | sprintf ( tmp2, "low gain Pixel %d", i ) ;
|
---|
52 |
|
---|
53 | fHistLo->Add( new TH1F ( tmp1, tmp2, 256, 0., 255. ) ) ;
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | MHistosAdc::~MHistosAdc ()
|
---|
58 | {
|
---|
59 |
|
---|
60 | // default destructor
|
---|
61 | //
|
---|
62 | delete fHistHi ;
|
---|
63 | delete fHistLo ;
|
---|
64 | }
|
---|
65 |
|
---|
66 | void MHistosAdc::Print(Option_t *)
|
---|
67 | {
|
---|
68 | for ( Int_t i = 0 ; i < 576 ; i++)
|
---|
69 | {
|
---|
70 | fHistHi[i].Print() ;
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | void MHistosAdc::FillAdcHistHi ( Int_t iPix, Byte_t data)
|
---|
75 | {
|
---|
76 | //
|
---|
77 |
|
---|
78 | GetHistHi(iPix)->Fill( (Float_t) data ) ;
|
---|
79 | }
|
---|
80 |
|
---|
81 | void MHistosAdc::FillAdcHistLo ( Int_t iPix, Byte_t data)
|
---|
82 | {
|
---|
83 | //
|
---|
84 |
|
---|
85 | GetHistLo(iPix)->Fill( (Float_t) data ) ;
|
---|
86 | }
|
---|
87 |
|
---|
88 | void MHistosAdc::SaveHist ( char *name )
|
---|
89 | {
|
---|
90 | //
|
---|
91 | // save all histogram in this class to a root file
|
---|
92 | //
|
---|
93 |
|
---|
94 | //
|
---|
95 | // FIXME: Don't open a file and write to this file!
|
---|
96 | // just Fill the current container (or the two histograms
|
---|
97 | // to an open file. The user must choose a file before.
|
---|
98 | //
|
---|
99 | TFile out( name, "recreate") ;
|
---|
100 |
|
---|
101 | //
|
---|
102 | // loop over all pixels and write the files out
|
---|
103 | //
|
---|
104 |
|
---|
105 | fHistLo->Write() ;
|
---|
106 | fHistHi->Write() ;
|
---|
107 | }
|
---|
108 |
|
---|