]>
Commit | Line | Data |
---|---|---|
6a34dadb | 1 | #include "AliPHOSDA2.h" |
2 | #include "TString.h" | |
3 | ||
4 | ClassImp(AliPHOSDA2) | |
5 | ||
6 | //---------------------------------------------------------------- | |
7 | AliPHOSDA2::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 | ||
42 | //------------------------------------------------------------------- | |
43 | AliPHOSDA2::AliPHOSDA2(const AliPHOSDA2& da) : TNamed(da), | |
7708b003 | 44 | fHistoFile(0),fFiredCells(0),fMod(da.fMod) |
6a34dadb | 45 | { |
46 | // Copy constructor. | |
47 | ||
48 | char hname[128]; | |
49 | TH1F* hist1=0; | |
50 | ||
51 | for(Int_t iX=0; iX<64; iX++) { | |
52 | for(Int_t iZ=0; iZ<56; iZ++) { | |
53 | for(Int_t iGain=0; iGain<2; iGain++) { | |
54 | ||
55 | sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain); | |
56 | hist1 = (TH1F*)da.fHistoFile->Get(hname); | |
57 | if(hist1) fHQuality[iX][iZ][iGain] = new TH1F(*hist1); | |
58 | else | |
59 | fHQuality[iX][iZ][iGain] = 0; | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | if(da.fMaps[0]) | |
65 | fMaps[0] = new TH2F(*da.fMaps[0]); | |
66 | else | |
67 | fMaps[0] = 0; | |
68 | ||
69 | if(da.fMaps[1]) | |
70 | fMaps[1] = new TH2F(*da.fMaps[1]); | |
71 | else | |
72 | fMaps[1] = 0; | |
73 | ||
74 | fHistoFile = new TFile(da.GetName(),"recreate"); | |
7708b003 | 75 | fFiredCells = new TH1I(*da.fFiredCells); |
6a34dadb | 76 | |
77 | } | |
78 | ||
79 | //------------------------------------------------------------------- | |
80 | AliPHOSDA2& AliPHOSDA2::operator= (const AliPHOSDA2& da) | |
81 | { | |
82 | //Assignment operator. | |
83 | ||
84 | if(this != &da) { | |
85 | ||
86 | TString oldname(fHistoFile->GetName()); | |
87 | TString newname(da.fHistoFile->GetName()); | |
88 | ||
89 | if(oldname != newname) { | |
90 | delete fHistoFile; | |
91 | fHistoFile = new TFile(da.fHistoFile->GetName(),"update"); | |
92 | } | |
93 | ||
94 | fMod = da.fMod; | |
95 | ||
96 | SetName(da.GetName()); | |
97 | SetTitle(da.GetTitle()); | |
98 | ||
99 | for(Int_t iX=0; iX<64; iX++) { | |
100 | for(Int_t iZ=0; iZ<56; iZ++) { | |
101 | for(Int_t iGain=0; iGain<2; iGain++) { | |
102 | if (fHQuality[iX][iZ][iGain]) delete fHQuality[iX][iZ][iGain]; | |
103 | fHQuality[iX][iZ][iGain] = da.fHQuality[iX][iZ][iGain]; | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | if(fMaps[0]) { | |
109 | delete fMaps[0]; | |
110 | fMaps[0] = da.fMaps[0]; | |
111 | } | |
112 | ||
113 | if(fMaps[1]) { | |
114 | delete fMaps[1]; | |
115 | fMaps[1] = da.fMaps[1]; | |
116 | } | |
117 | ||
7708b003 | 118 | if(fFiredCells) { |
119 | delete fFiredCells; | |
120 | fFiredCells = da.fFiredCells; | |
121 | } | |
122 | ||
6a34dadb | 123 | } |
124 | ||
125 | return *this; | |
126 | } | |
127 | ||
128 | ||
129 | //------------------------------------------------------------------- | |
130 | AliPHOSDA2::~AliPHOSDA2() | |
131 | { | |
132 | // Destructor | |
133 | ||
134 | UpdateHistoFile(); | |
135 | if(fHistoFile) delete fHistoFile; | |
136 | ||
137 | } | |
138 | ||
139 | //------------------------------------------------------------------- | |
140 | void AliPHOSDA2::FillQualityHistograms(Float_t quality[64][56][2]) | |
141 | { | |
142 | // Fills quality histograms. | |
143 | // _By definition_, qood quality is 0<quality<1, | |
144 | // all outside that is a bad quality. | |
145 | // If no quality value read for particular channel, | |
146 | // the correspondent array entry should be filled by zero. | |
147 | // WARNING: this function should be called once per event! | |
148 | ||
149 | char hname[128]; | |
150 | char htitl[128]; | |
151 | ||
152 | for(Int_t iX=0; iX<64; iX++) { | |
153 | for (Int_t iZ=0; iZ<56; iZ++) { | |
154 | ||
155 | for(Int_t iGain=0; iGain<2; iGain++) { | |
156 | if(!quality[iX][iZ][iGain]) continue; | |
157 | ||
158 | if(fHQuality[iX][iZ][iGain]) | |
159 | fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]); | |
160 | else { | |
161 | sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain); | |
162 | sprintf(htitl,"Quality for crystal %d_%d_%d and gain %d",fMod,iX,iZ,iGain); | |
163 | fHQuality[iX][iZ][iGain] = new TH1F(hname,htitl,100,1.e-6,10.); | |
164 | fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]); | |
165 | } | |
166 | } | |
167 | ||
168 | } | |
169 | } | |
170 | ||
171 | } | |
172 | ||
7708b003 | 173 | //------------------------------------------------------------------- |
174 | void AliPHOSDA2::FillFiredCellsHistogram(Int_t nCells) | |
175 | { | |
176 | fFiredCells->Fill(nCells); | |
177 | } | |
178 | ||
6a34dadb | 179 | //------------------------------------------------------------------- |
180 | void AliPHOSDA2::UpdateHistoFile() | |
181 | { | |
182 | // Write histograms to file | |
183 | ||
184 | if(!fHistoFile) return; | |
185 | if(!fHistoFile->IsOpen()) return; | |
186 | ||
187 | char titl[128]; | |
188 | ||
189 | if(fMaps[0]) | |
190 | fMaps[0]->Reset(); | |
191 | else { | |
192 | sprintf(titl,"Quality map for Low gain"); | |
193 | fMaps[0] = new TH2F("gmaplow", titl, 64,0.,64.,56,0.,56.); | |
194 | } | |
195 | ||
196 | if(fMaps[1]) | |
197 | fMaps[1]->Reset(); | |
198 | else { | |
199 | sprintf(titl,"Quality map for High gain"); | |
200 | fMaps[1] = new TH2F("gmaphigh", titl, 64,0.,64.,56,0.,56.); | |
201 | } | |
202 | ||
203 | TH1F* hist1=0; | |
204 | ||
205 | for(Int_t iX=0; iX<64; iX++) { | |
206 | for(Int_t iZ=0; iZ<56; iZ++) { | |
207 | ||
208 | for(Int_t iGain=0; iGain<2; iGain++) { | |
209 | hist1 = fHQuality[iX][iZ][iGain]; | |
210 | if(hist1) { | |
211 | hist1->Write(hist1->GetName(),TObject::kWriteDelete); | |
212 | Double_t mean = hist1->GetMean(); | |
0d4fe088 | 213 | fMaps[iGain]->SetBinContent(iX+1,iZ+1,mean); |
6a34dadb | 214 | } |
215 | } | |
216 | ||
217 | } | |
218 | } | |
219 | ||
220 | fMaps[0]->Write(fMaps[0]->GetName(),TObject::kWriteDelete); | |
221 | fMaps[1]->Write(fMaps[1]->GetName(),TObject::kWriteDelete); | |
222 | ||
7708b003 | 223 | fFiredCells->Write(); |
224 | ||
6a34dadb | 225 | } |
226 |