]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDA2.cxx
In MUONRecoCheck.C:
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDA2.cxx
CommitLineData
6a34dadb 1#include "AliPHOSDA2.h"
2#include "TString.h"
3
4ClassImp(AliPHOSDA2)
5
6//----------------------------------------------------------------
7AliPHOSDA2::AliPHOSDA2(int module) : TNamed(),
7708b003 8 fHistoFile(0),fFiredCells(0),fMod(module)
6a34dadb 9
10{
11 // Create AliPHOSDA2 ("Bad channels finder") object.
12 // module is the PHOS module number (0..4).
13 // Quality histogram names: module_iX_iZ_gain.
14 // Root file name: PHOS_ModuleX_BCM.root, where X - module number.
15
16 char name[128];
17 sprintf(name,"PHOS_Module%d_BCM",fMod);
18 SetName(name);
19
20 SetTitle("Detector Algorithm to check for PHOS channels quality");
21
22 char rootname[128];
23 sprintf(rootname,"%s.root",GetName());
24
25 fHistoFile = new TFile(rootname,"recreate"); // new file!
26
27 for(Int_t iX=0; iX<64; iX++) {
28 for(Int_t iZ=0; iZ<56; iZ++) {
29 for(Int_t iGain=0; iGain<2; iGain++) {
30 fHQuality[iX][iZ][iGain] = 0;
31 }
32 }
33 }
34
35 fMaps[0]=0;
36 fMaps[1]=0;
37
7708b003 38 fFiredCells = new TH1I("fFiredCells","Number of fired cells per event",100,0,1000);
39
6a34dadb 40}
41
c526b05d 42//----------------------------------------------------------------
43AliPHOSDA2::AliPHOSDA2(Int_t module, TObjArray* oldHistos) : TNamed(),
44 fHistoFile(0),fFiredCells(0),fMod(module)
45
46{
47 // Create AliPHOSDA2 ("Bad channels finder") object.
48 // module is the PHOS module number (0..4).
49 // Quality histogram names: module_iX_iZ_gain.
50 // Read histograms from array oldHistos (if any).
51 // Do not produce an output file!
52
53 char name[128];
54 sprintf(name,"PHOS_Module%d_BCM",fMod);
55 SetName(name);
56
57 SetTitle("Detector Algorithm to check for PHOS channels quality");
58
59 char hname[128];
60 TH1F* hist1=0;
61
62 for(Int_t iX=0; iX<64; iX++) {
63 for(Int_t iZ=0; iZ<56; iZ++) {
64 for(Int_t iGain=0; iGain<2; iGain++) {
65 sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain);
66 if(oldHistos)
67 hist1 = (TH1F*)oldHistos->FindObject(hname);
68 if(hist1) fHQuality[iX][iZ][iGain] = hist1;
69 else
70 fHQuality[iX][iZ][iGain] = 0;
71 }
72 }
73 }
74
75 fMaps[0]=0;
76 fMaps[1]=0;
77
78 fFiredCells = new TH1I("fFiredCells","Number of fired cells per event",100,0,1000);
79
80}
81
6a34dadb 82//-------------------------------------------------------------------
83AliPHOSDA2::AliPHOSDA2(const AliPHOSDA2& da) : TNamed(da),
7708b003 84 fHistoFile(0),fFiredCells(0),fMod(da.fMod)
6a34dadb 85{
86 // Copy constructor.
87
88 char hname[128];
89 TH1F* hist1=0;
90
91 for(Int_t iX=0; iX<64; iX++) {
92 for(Int_t iZ=0; iZ<56; iZ++) {
93 for(Int_t iGain=0; iGain<2; iGain++) {
94
95 sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain);
96 hist1 = (TH1F*)da.fHistoFile->Get(hname);
97 if(hist1) fHQuality[iX][iZ][iGain] = new TH1F(*hist1);
98 else
99 fHQuality[iX][iZ][iGain] = 0;
100 }
101 }
102 }
103
104 if(da.fMaps[0])
105 fMaps[0] = new TH2F(*da.fMaps[0]);
106 else
107 fMaps[0] = 0;
108
109 if(da.fMaps[1])
110 fMaps[1] = new TH2F(*da.fMaps[1]);
111 else
112 fMaps[1] = 0;
113
114 fHistoFile = new TFile(da.GetName(),"recreate");
7708b003 115 fFiredCells = new TH1I(*da.fFiredCells);
6a34dadb 116
117}
118
119//-------------------------------------------------------------------
120AliPHOSDA2& AliPHOSDA2::operator= (const AliPHOSDA2& da)
121{
122 //Assignment operator.
123
124 if(this != &da) {
125
126 TString oldname(fHistoFile->GetName());
127 TString newname(da.fHistoFile->GetName());
128
129 if(oldname != newname) {
130 delete fHistoFile;
131 fHistoFile = new TFile(da.fHistoFile->GetName(),"update");
132 }
133
134 fMod = da.fMod;
135
136 SetName(da.GetName());
137 SetTitle(da.GetTitle());
138
139 for(Int_t iX=0; iX<64; iX++) {
140 for(Int_t iZ=0; iZ<56; iZ++) {
141 for(Int_t iGain=0; iGain<2; iGain++) {
142 if (fHQuality[iX][iZ][iGain]) delete fHQuality[iX][iZ][iGain];
143 fHQuality[iX][iZ][iGain] = da.fHQuality[iX][iZ][iGain];
144 }
145 }
146 }
147
148 if(fMaps[0]) {
149 delete fMaps[0];
150 fMaps[0] = da.fMaps[0];
151 }
152
153 if(fMaps[1]) {
154 delete fMaps[1];
155 fMaps[1] = da.fMaps[1];
156 }
157
7708b003 158 if(fFiredCells) {
159 delete fFiredCells;
160 fFiredCells = da.fFiredCells;
161 }
162
6a34dadb 163 }
164
165 return *this;
166}
167
168
169//-------------------------------------------------------------------
170AliPHOSDA2::~AliPHOSDA2()
171{
172 // Destructor
173
174 UpdateHistoFile();
175 if(fHistoFile) delete fHistoFile;
176
177}
178
179//-------------------------------------------------------------------
180void AliPHOSDA2::FillQualityHistograms(Float_t quality[64][56][2])
181{
182 // Fills quality histograms.
183 // _By definition_, qood quality is 0<quality<1,
184 // all outside that is a bad quality.
185 // If no quality value read for particular channel,
186 // the correspondent array entry should be filled by zero.
187 // WARNING: this function should be called once per event!
188
189 char hname[128];
190 char htitl[128];
191
192 for(Int_t iX=0; iX<64; iX++) {
193 for (Int_t iZ=0; iZ<56; iZ++) {
194
195 for(Int_t iGain=0; iGain<2; iGain++) {
196 if(!quality[iX][iZ][iGain]) continue;
197
198 if(fHQuality[iX][iZ][iGain])
199 fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]);
200 else {
201 sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain);
202 sprintf(htitl,"Quality for crystal %d_%d_%d and gain %d",fMod,iX,iZ,iGain);
203 fHQuality[iX][iZ][iGain] = new TH1F(hname,htitl,100,1.e-6,10.);
204 fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]);
205 }
206 }
207
208 }
209 }
210
211}
212
7708b003 213//-------------------------------------------------------------------
214void AliPHOSDA2::FillFiredCellsHistogram(Int_t nCells)
215{
216 fFiredCells->Fill(nCells);
217}
218
6a34dadb 219//-------------------------------------------------------------------
220void AliPHOSDA2::UpdateHistoFile()
221{
222 // Write histograms to file
223
224 if(!fHistoFile) return;
225 if(!fHistoFile->IsOpen()) return;
226
227 char titl[128];
228
229 if(fMaps[0])
230 fMaps[0]->Reset();
231 else {
232 sprintf(titl,"Quality map for Low gain");
233 fMaps[0] = new TH2F("gmaplow", titl, 64,0.,64.,56,0.,56.);
234 }
235
236 if(fMaps[1])
237 fMaps[1]->Reset();
238 else {
239 sprintf(titl,"Quality map for High gain");
240 fMaps[1] = new TH2F("gmaphigh", titl, 64,0.,64.,56,0.,56.);
241 }
242
243 TH1F* hist1=0;
244
245 for(Int_t iX=0; iX<64; iX++) {
246 for(Int_t iZ=0; iZ<56; iZ++) {
247
248 for(Int_t iGain=0; iGain<2; iGain++) {
249 hist1 = fHQuality[iX][iZ][iGain];
250 if(hist1) {
251 hist1->Write(hist1->GetName(),TObject::kWriteDelete);
252 Double_t mean = hist1->GetMean();
0d4fe088 253 fMaps[iGain]->SetBinContent(iX+1,iZ+1,mean);
6a34dadb 254 }
255 }
256
257 }
258 }
259
260 fMaps[0]->Write(fMaps[0]->GetName(),TObject::kWriteDelete);
261 fMaps[1]->Write(fMaps[1]->GetName(),TObject::kWriteDelete);
262
7708b003 263 fFiredCells->Write();
264
6a34dadb 265}
266