source: trunk/MagicSoft/MarsOctober/mocttest/MHistosTdc.cc@ 3354

Last change on this file since 3354 was 451, checked in by harald, 24 years ago
This files are neccessary for the TDC histos.
File size: 2.5 KB
Line 
1///////////////////////////////////////////////////////////////////////
2//
3// MHistosTdc
4//
5// This class contains a list of all Tdc spektra histograms
6//
7///////////////////////////////////////////////////////////////////////
8
9#include "MHistosTdc.h"
10
11#include <iostream.h>
12
13#include <TH1.h>
14#include <TFile.h>
15
16ClassImp(MHistosTdc)
17
18MHistosTdc::MHistosTdc ()
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 = "MHistosTdc" ;
33 fTitle = "Container for Tdc 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, 15, -0.5, 14.5 ) ;
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, 15, -0.5, 14.5 ) ;
58
59 fHistLow->Add( h1 ) ;
60
61 }
62}
63
64MHistosTdc::~MHistosTdc ()
65{
66
67 // default destructor
68 //
69 delete fHistHigh ;
70 delete fHistLow ;
71}
72
73void MHistosTdc::Print(Option_t *)
74{
75 for ( Int_t i = 0 ; i < 576 ; i++)
76 {
77 fHistHigh[i].Print() ;
78 }
79}
80
81void MHistosTdc::FillTdcHist ( Int_t iPix, UChar_t* data)
82{
83 // cout << " MHistosTdc::FillTdcHist " << 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) i, (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) i, (Float_t) data[i]) ;
111 }
112 }
113}
114
115void MHistosTdc::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.