]>
Commit | Line | Data |
---|---|---|
55ec1be0 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////////// | |
17 | // Class AliPHOSCpvDA1 accumulates histograms with amplitudes per CPV channel. | |
18 | // It is intended to run at DAQ or HLT computers. | |
19 | // Author: Boris Polishchuk, 25 January 2008. | |
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | #include "AliPHOSCpvDA1.h" | |
23 | #include "TString.h" | |
24 | ||
25 | ClassImp(AliPHOSCpvDA1) | |
26 | ||
27 | //---------------------------------------------------------------- | |
28 | AliPHOSCpvDA1::AliPHOSCpvDA1(int module) : TNamed(), | |
29 | fHistoFile(0),fMod(module) | |
30 | ||
31 | { | |
32 | // Create DA1 ("Calibration DA") object. | |
33 | // module is the CPV module number (0..4). | |
34 | // Checks existence of histograms which might have been left | |
35 | // from the previous runs to continue their filling. | |
36 | // Histogram names: module_iX_iZ. | |
37 | // Root file name: CPV_ModuleX_Calib.root, where X - module number. | |
38 | ||
39 | char name[128]; | |
6ba1dd81 | 40 | TString sname="CPV_Module%d_Calib"; |
41 | snprintf(name,sname.Length(),sname.Data(),fMod); | |
55ec1be0 | 42 | SetName(name); |
43 | ||
44 | char title[128]; | |
6ba1dd81 | 45 | TString stitle="Calibration Detector Algorithm for CPV module %d"; |
46 | snprintf(title,stitle.Length(),stitle.Data(),fMod); | |
55ec1be0 | 47 | SetTitle(title); |
48 | ||
49 | char rootname[128]; | |
6ba1dd81 | 50 | TString srootname="%s.root"; |
51 | snprintf(rootname,srootname.Length(),srootname.Data(),GetName()); | |
55ec1be0 | 52 | |
53 | fHistoFile = new TFile(rootname,"update"); | |
54 | ||
55 | char hname[128]; | |
56 | TH1F* hist1=0; | |
6ba1dd81 | 57 | TString shname="%d_%d_%d"; |
55ec1be0 | 58 | |
59 | for(Int_t iX=0; iX<128; iX++) { | |
60 | for(Int_t iZ=0; iZ<56; iZ++) { | |
6ba1dd81 | 61 | snprintf(hname,shname.Length(),shname.Data(),fMod,iX,iZ); |
55ec1be0 | 62 | hist1 = (TH1F*)fHistoFile->Get(hname); |
63 | if(hist1) fCharge[iX][iZ] = hist1; | |
64 | else | |
65 | fCharge[iX][iZ] = 0; | |
66 | } | |
67 | } | |
68 | ||
69 | } | |
70 | ||
71 | //------------------------------------------------------------------- | |
72 | AliPHOSCpvDA1::AliPHOSCpvDA1(const AliPHOSCpvDA1& da) : TNamed(da), | |
73 | fHistoFile(0),fMod(da.fMod) | |
74 | { | |
75 | // Copy constructor. | |
76 | ||
77 | fHistoFile = new TFile(da.GetName(),"update"); | |
78 | ||
79 | char hname[128]; | |
80 | TH1F* hist1=0; | |
81 | ||
82 | for(Int_t iX=0; iX<128; iX++) { | |
83 | for(Int_t iZ=0; iZ<56; iZ++) { | |
84 | ||
14895588 | 85 | snprintf(hname,128,"%d_%d_%d",fMod,iX,iZ); |
55ec1be0 | 86 | hist1 = (TH1F*)da.fHistoFile->Get(hname); |
87 | if(hist1) fCharge[iX][iZ] = new TH1F(*hist1); | |
88 | else | |
89 | fCharge[iX][iZ] = 0; | |
90 | } | |
91 | } | |
92 | ||
93 | } | |
94 | ||
95 | //------------------------------------------------------------------- | |
96 | AliPHOSCpvDA1& AliPHOSCpvDA1::operator= (const AliPHOSCpvDA1& da) | |
97 | { | |
98 | //Assignment operator. | |
99 | ||
100 | if(this != &da) { | |
101 | ||
102 | TString oldname(fHistoFile->GetName()); | |
103 | TString newname(da.fHistoFile->GetName()); | |
104 | ||
105 | if(oldname != newname) { | |
106 | delete fHistoFile; | |
107 | fHistoFile = new TFile(da.fHistoFile->GetName(),"update"); | |
108 | } | |
109 | ||
110 | fMod = da.fMod; | |
111 | ||
112 | SetName(da.GetName()); | |
113 | SetTitle(da.GetTitle()); | |
114 | ||
115 | for(Int_t iX=0; iX<128; iX++) { | |
116 | for(Int_t iZ=0; iZ<56; iZ++) { | |
117 | ||
118 | if(fCharge[iX][iZ]) delete fCharge[iX][iZ]; | |
119 | fCharge[iX][iZ] = da.fCharge[iX][iZ]; | |
120 | } | |
121 | } | |
122 | ||
123 | } | |
124 | ||
125 | return *this; | |
126 | } | |
127 | ||
128 | ||
129 | //------------------------------------------------------------------- | |
130 | AliPHOSCpvDA1::~AliPHOSCpvDA1() | |
131 | { | |
132 | // Destructor | |
133 | ||
134 | UpdateHistoFile(); | |
135 | if(fHistoFile) delete fHistoFile; | |
136 | ||
137 | } | |
138 | ||
139 | //------------------------------------------------------------------- | |
140 | void AliPHOSCpvDA1::FillHistograms(Float_t e[128][56]) | |
141 | { | |
142 | // Fill charge deposit histograms of one event. | |
143 | // Charge data is encoded as e[X][Z], | |
144 | // where X(0..127) and Z(0..55) - pad position in the CPV module, | |
145 | // Charge in ADC counts. | |
146 | // If no charge read for particular channel, | |
147 | // the correspondent array entry should be filled by zero. | |
148 | // WARNING: this function should be called once per event! | |
149 | ||
150 | char hname[128]; | |
151 | char htitl[128]; | |
152 | ||
153 | for(Int_t iX=0; iX<128; iX++) { | |
154 | for (Int_t iZ=0; iZ<56; iZ++) { | |
155 | ||
156 | if(!e[iX][iZ]) continue; | |
157 | ||
158 | if(fCharge[iX][iZ]) | |
159 | fCharge[iX][iZ]->Fill(e[iX][iZ]); | |
160 | else { | |
14895588 | 161 | snprintf(hname,128,"%d_%d_%d",fMod,iX,iZ); |
162 | snprintf(htitl,128,"Charge deposited on the pad %d_%d_%d",fMod,iX,iZ); | |
55ec1be0 | 163 | fCharge[iX][iZ] = new TH1F(hname,htitl,1024,0.,1024.); |
164 | fCharge[iX][iZ]->Fill(e[iX][iZ]); | |
165 | } | |
166 | ||
167 | } | |
168 | } | |
169 | ||
170 | } | |
171 | ||
172 | //------------------------------------------------------------------- | |
173 | void AliPHOSCpvDA1::UpdateHistoFile() | |
174 | { | |
175 | // Write histograms to file | |
176 | ||
177 | if(!fHistoFile) return; | |
178 | if(!fHistoFile->IsOpen()) return; | |
179 | ||
180 | TH1F* hist1=0; | |
181 | ||
182 | for(Int_t iX=0; iX<128; iX++) { | |
183 | for(Int_t iZ=0; iZ<56; iZ++) { | |
184 | ||
185 | hist1 = fCharge[iX][iZ]; | |
186 | if(hist1) hist1->Write(hist1->GetName(),TObject::kWriteDelete); | |
187 | } | |
188 | } | |
189 | ||
190 | } | |
191 |