1 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include "Riostream.h"
12 #include "AliITSgeomTGeo.h"
13 #include "AliITSGainSSDv2.h"
14 #include "AliITSBadChannelsSSDv2.h"
15 #include "AliITSNoiseSSDv2.h"
16 #include "AliITSPedestalSSDv2.h"
17 #include "AliITSGainSSD.h"
18 #include "AliITSBadChannelsSSD.h"
19 #include "AliITSNoiseSSD.h"
20 #include "AliITSPedestalSSD.h"
21 #include "AliCDBManager.h"
22 #include "AliCDBEntry.h"
29 //====================================================================//
30 void Noise(AliCDBManager * man);
31 void Pedestal(AliCDBManager * man);
32 void BadChannelMap(AliCDBManager * man);
33 void GainCalibration(AliCDBManager * man);
34 void ReadOldSSDPedestal(TObjArray *array, AliITSPedestalSSDv2 *pedestalSSD);
35 void ReadOldSSDNoise(TObjArray *array, AliITSNoiseSSDv2 *noiseSSD);
36 void ReadOldSSDBadChannels(TObjArray *array, AliITSBadChannelsSSDv2 *badChannelsSSD);
37 void ReadOldSSDGain(TObjArray *array, AliITSGainSSDv2 *gainSSD);
38 void drawNoiseDistributions(Int_t runNumber);
39 void drawPedestalDistributions(Int_t runNumber);
40 //====================================================================//
42 //_____________________________________________________________________//
43 void readSSDOCDBEntry(const char* type = "alien", Int_t runNumber = 0) {
44 //This macro allows to visualize the bad channels in the OCDB
45 //The type can be either "local" or "alien" (where the OCDB file comes from)
46 //The run nmber is the pedestal one
47 gStyle->SetPalette(1,0);
50 AliCDBManager * man = AliCDBManager::Instance();
52 if(gType == "alien") {
53 //man->SetDefaultStorage("alien://folder=/alice/data/2009/Reference/");
54 man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB/");
56 else if(gType == "local")
57 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
59 cout<<"Allowed types: local or alien!!!"<<endl;
63 man->SetRun(runNumber);
71 //_____________________________________________________________________//
72 void drawNoiseDistributions(Int_t runNumber) {
73 //Draws the noise distributions for each side and layer
74 TString filename = "noiseDistributionsSSD."; filename += runNumber;
76 TFile *f = TFile::Open(filename.Data());
77 TH1F *gHistNoisePSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistNoisePSideLayer5"));
78 TH1F *gHistNoiseNSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistNoiseNSideLayer5"));
79 TH1F *gHistNoisePSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistNoisePSideLayer6"));
80 TH1F *gHistNoiseNSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistNoiseNSideLayer6"));
82 TCanvas *c1 = new TCanvas("c1","Noise distribution (P-side, Layer 5)",
84 c1->SetFillColor(10); c1->SetHighLightColor(10); c1->SetLogy();
85 gHistNoisePSideLayer5->SetStats(kFALSE); gHistNoisePSideLayer5->Draw();
87 TCanvas *c2 = new TCanvas("c2","Noise distribution (N-side, Layer 5)",
89 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->SetLogy();
90 gHistNoiseNSideLayer5->SetStats(kFALSE); gHistNoiseNSideLayer5->Draw();
92 TCanvas *c3 = new TCanvas("c3","Noise distribution (P-side, Layer 6)",
94 c3->SetFillColor(10); c3->SetHighLightColor(10); c3->SetLogy();
95 gHistNoisePSideLayer6->SetStats(kFALSE); gHistNoisePSideLayer6->Draw();
97 TCanvas *c4 = new TCanvas("c4","Noise distribution (N-side, Layer 6)",
99 c4->SetFillColor(10); c4->SetHighLightColor(10); c4->SetLogy();
100 gHistNoiseNSideLayer6->SetStats(kFALSE); gHistNoiseNSideLayer6->Draw();
103 //_____________________________________________________________________//
104 void drawPedestalDistributions(Int_t runNumber) {
105 //Draws the pedestal distributions for each side and layer
106 TString filename = "pedestalDistributionsSSD."; filename += runNumber;
108 TFile *f = TFile::Open(filename.Data());
109 TH1F *gHistPedestalPSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistPedestalPSideLayer5"));
110 TH1F *gHistPedestalNSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistPedestalNSideLayer5"));
111 TH1F *gHistPedestalPSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistPedestalPSideLayer6"));
112 TH1F *gHistPedestalNSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistPedestalNSideLayer6"));
114 TCanvas *c1 = new TCanvas("c1","Pedestal distribution (P-side, Layer 5)",
116 c1->SetFillColor(10); c1->SetHighLightColor(10); c1->SetLogy();
117 gHistPedestalPSideLayer5->SetStats(kFALSE); gHistPedestalPSideLayer5->Draw();
119 TCanvas *c2 = new TCanvas("c2","Pedestal distribution (N-side, Layer 5)",
121 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->SetLogy();
122 gHistPedestalNSideLayer5->SetStats(kFALSE); gHistPedestalNSideLayer5->Draw();
124 TCanvas *c3 = new TCanvas("c3","Pedestal distribution (P-side, Layer 6)",
126 c3->SetFillColor(10); c3->SetHighLightColor(10); c3->SetLogy();
127 gHistPedestalPSideLayer6->SetStats(kFALSE); gHistPedestalPSideLayer6->Draw();
129 TCanvas *c4 = new TCanvas("c4","Pedestal distribution (N-side, Layer 6)",
131 c4->SetFillColor(10); c4->SetHighLightColor(10); c4->SetLogy();
132 gHistPedestalNSideLayer6->SetStats(kFALSE); gHistPedestalNSideLayer6->Draw();
135 //_____________________________________________________________________//
136 void Pedestal(AliCDBManager * man) {
137 //Reads the noise OCDB file
138 const Int_t fgkSSDMODULES = 1698;
139 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
140 static const Int_t fgkDefaultNStripsSSD = 768;
142 Int_t runNumber = man->GetRun();
144 //pedestal histograms
145 TH1F *gHistPedestalPSideLayer5 = new TH1F("gHistPedestalPSideLayer5",
146 "Pedestal values (P-side, Layer5); ADC counts; Entries;",
148 TH1F *gHistPedestalNSideLayer5 = new TH1F("gHistPedestalNSideLayer5",
149 "Pedestal values (N-side, Layer5); ADC counts; Entries;",
151 TH1F *gHistPedestalPSideLayer6 = new TH1F("gHistPedestalPSideLayer6",
152 "Pedestal values (P-side, Layer6); ADC counts; Entries;",
154 TH1F *gHistPedestalNSideLayer6 = new TH1F("gHistPedestalNSideLayer6",
155 "Pedestal values (N-side, Layer6); ADC counts; Entries;",
158 Int_t fLayer = 0,fLadder = 0, fModule = 0;
160 AliITSPedestalSSDv2 *pedestalSSD = new AliITSPedestalSSDv2();
161 AliCDBEntry *entryPedestalSSD = man->Get("ITS/Ref/PedestalSSD");
162 TObject *empty = (TObject *)entryPedestalSSD->GetObject();
163 TString objectname = empty->GetName();
164 if(objectname=="TObjArray") {
165 TObjArray *pedestalSSDOld = (TObjArray *)entryPedestalSSD->GetObject();
166 ReadOldSSDPedestal(pedestalSSDOld, pedestalSSD);
168 else if(objectname=="AliITSPedestalSSDv2") {
169 cout<<"Reading the new format of the calibration file..."<<endl;
170 pedestalSSD = (AliITSPedestalSSDv2 *)entryPedestalSSD->GetObject();
173 Double_t pedestal = 0.0;
174 for (Int_t i = 0; i < fgkSSDMODULES; i++) {
175 AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule);
176 //cout<<"Pedestal for module: "<<i+500<<" - Layer: "<<fLayer<<endl;
177 for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
178 pedestal = pedestalSSD->GetPedestalP(i,j);
179 //Printf("Pedestal value: %lf",pedestal);
181 gHistPedestalPSideLayer5->Fill(pedestal);
183 gHistPedestalPSideLayer6->Fill(pedestal);
185 pedestal = pedestalSSD->GetPedestalN(i,j);
187 gHistPedestalNSideLayer5->Fill(pedestal);
189 gHistPedestalNSideLayer6->Fill(pedestal);
193 TString output = "pedestalDistributionsSSD."; output += runNumber;
195 TFile *f = TFile::Open(output.Data(),"recreate");
196 gHistPedestalPSideLayer5->Write();
197 gHistPedestalNSideLayer5->Write();
198 gHistPedestalPSideLayer6->Write();
199 gHistPedestalNSideLayer6->Write();
203 //_____________________________________________________________________//
204 void Noise(AliCDBManager * man) {
205 //Reads the noise OCDB file
206 const Int_t fgkSSDMODULES = 1698;
207 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
208 static const Int_t fgkDefaultNStripsSSD = 768;
210 Int_t runNumber = man->GetRun();
213 TH1F *gHistNoisePSideLayer5 = new TH1F("gHistNoisePSideLayer5",
214 "Noise values (P-side, Layer5); ADC counts; Entries;",
216 TH1F *gHistNoiseNSideLayer5 = new TH1F("gHistNoiseNSideLayer5",
217 "Noise values (N-side, Layer5); ADC counts; Entries;",
219 TH1F *gHistNoisePSideLayer6 = new TH1F("gHistNoisePSideLayer6",
220 "Noise values (P-side, Layer6); ADC counts; Entries;",
222 TH1F *gHistNoiseNSideLayer6 = new TH1F("gHistNoiseNSideLayer6",
223 "Noise values (N-side, Layer6); ADC counts; Entries;",
226 Int_t fLayer = 0,fLadder = 0, fModule = 0;
227 Int_t fHistCounter = 0;
229 TObjArray *array = new TObjArray();
230 TH1D *hNoiseModule[fgkSSDMODULES];
231 for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
232 AliITSgeomTGeo::GetModuleId(i,fLayer,fLadder,fModule);
233 fTitle = "SSD_Noise_Layer"; fTitle += fLayer;
234 fTitle += "_Ladder"; fTitle += fLadder;
235 fTitle += "_Module"; fTitle += fModule;
237 hNoiseModule[fHistCounter] = new TH1D(fTitle.Data(),fTitle.Data(),1540,0,1540);
238 hNoiseModule[fHistCounter]->GetXaxis()->SetTitleColor(1);
239 hNoiseModule[fHistCounter]->GetXaxis()->SetTitle("Strip number");
240 hNoiseModule[fHistCounter]->GetYaxis()->SetTitle("Noise");
241 array->AddLast(hNoiseModule[fHistCounter]);
245 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
246 AliCDBEntry *entryNoiseSSD = man->Get("ITS/Calib/NoiseSSD");
247 TObject *empty = (TObject *)entryNoiseSSD->GetObject();
248 TString objectname = empty->GetName();
249 if(objectname=="TObjArray") {
250 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
251 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
253 else if(objectname=="AliITSNoiseSSDv2") {
254 cout<<"Reading the new format of the calibration file..."<<endl;
255 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
258 Double_t noise = 0.0;
259 for (Int_t i = 0; i < fgkSSDMODULES; i++) {
260 AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule);
261 //cout<<"Noise for module: "<<i+500<<" - Layer: "<<fLayer<<endl;
262 for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
263 noise = noiseSSD->GetNoiseP(i,j);
264 hNoiseModule[i]->SetBinContent(j+1,noise);
266 gHistNoisePSideLayer5->Fill(noise);
268 gHistNoisePSideLayer6->Fill(noise);
270 noise = noiseSSD->GetNoiseN(i,j);
271 hNoiseModule[i]->SetBinContent(fgkSSDSTRIPSPERMODULE-j,noise);
273 gHistNoiseNSideLayer5->Fill(noise);
275 gHistNoiseNSideLayer6->Fill(noise);
279 TString output1 = "noiseSSD."; output1 += runNumber; output1 += ".root";
280 TFile *f1 = TFile::Open(output1.Data(),"recreate");
284 TString output2 = "noiseDistributionsSSD."; output2 += runNumber;
286 TFile *f2 = TFile::Open(output2.Data(),"recreate");
287 gHistNoisePSideLayer5->Write();
288 gHistNoiseNSideLayer5->Write();
289 gHistNoisePSideLayer6->Write();
290 gHistNoiseNSideLayer6->Write();
294 //_____________________________________________________________________//
295 void BadChannelMap(AliCDBManager * man) {
296 const Int_t fgkSSDMODULES = 1698;
297 static const Int_t fgkDefaultNStripsSSD = 768;
299 //_____________________________________________________________________________//
300 TH2F *fHistPSideBadChannelMapLayer5 = new TH2F("fHistPSideBadChannelMapLayer5",
301 "Layer 5;N_{module};N_{ladder}",
304 fHistPSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
305 fHistPSideBadChannelMapLayer5->GetZaxis()->SetRangeUser(0.,100.);
306 fHistPSideBadChannelMapLayer5->SetStats(kFALSE);
307 fHistPSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
308 fHistPSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
309 fHistPSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
310 fHistPSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
311 fHistPSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
312 fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
313 fHistPSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
314 TH2F *fHistNSideBadChannelMapLayer5 = new TH2F("fHistNSideBadChannelMapLayer5",
315 "Layer 5;N_{module};N_{ladder}",
318 fHistNSideBadChannelMapLayer5->GetXaxis()->SetTitleColor(1);
319 fHistNSideBadChannelMapLayer5->GetZaxis()->SetRangeUser(0.,100.);
320 fHistNSideBadChannelMapLayer5->SetStats(kFALSE);
321 fHistNSideBadChannelMapLayer5->GetYaxis()->SetTitleOffset(1.8);
322 fHistNSideBadChannelMapLayer5->GetXaxis()->SetNdivisions(22);
323 fHistNSideBadChannelMapLayer5->GetYaxis()->SetNdivisions(34);
324 fHistNSideBadChannelMapLayer5->GetXaxis()->SetLabelSize(0.03);
325 fHistNSideBadChannelMapLayer5->GetYaxis()->SetLabelSize(0.03);
326 fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitleOffset(1.6);
327 fHistNSideBadChannelMapLayer5->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
329 TH2F *fHistPSideBadChannelMapLayer6 = new TH2F("fHistPSideBadChannelMapLayer6",
330 "Layer 6;N_{module};N_{ladder}",
333 fHistPSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
334 fHistPSideBadChannelMapLayer6->GetZaxis()->SetRangeUser(0.,100.);
335 fHistPSideBadChannelMapLayer6->SetStats(kFALSE);
336 fHistPSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
337 fHistPSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
338 fHistPSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
339 fHistPSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
340 fHistPSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
341 fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
342 fHistPSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (p-side)[%]");
343 TH2F *fHistNSideBadChannelMapLayer6 = new TH2F("fHistNSideBadChannelMapLayer6",
344 "Layer 6;N_{module};N_{ladder}",
347 fHistNSideBadChannelMapLayer6->GetXaxis()->SetTitleColor(1);
348 fHistNSideBadChannelMapLayer6->GetZaxis()->SetRangeUser(0.,100.);
349 fHistNSideBadChannelMapLayer6->SetStats(kFALSE);
350 fHistNSideBadChannelMapLayer6->GetYaxis()->SetTitleOffset(1.8);
351 fHistNSideBadChannelMapLayer6->GetXaxis()->SetNdivisions(25);
352 fHistNSideBadChannelMapLayer6->GetYaxis()->SetNdivisions(38);
353 fHistNSideBadChannelMapLayer6->GetXaxis()->SetLabelSize(0.03);
354 fHistNSideBadChannelMapLayer6->GetYaxis()->SetLabelSize(0.03);
355 fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitleOffset(1.6);
356 fHistNSideBadChannelMapLayer6->GetZaxis()->SetTitle("Bad channels (n-side)[%]");
357 //_____________________________________________________________________________//
359 //_____________________________________________________________________________//
360 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
361 AliCDBEntry *entryBadChannelsSSD = man->Get("ITS/Calib/BadChannelsSSD");
362 TObject *empty = (TObject *)entryBadChannelsSSD->GetObject();
363 TString objectname = empty->GetName();
364 if(objectname=="TObjArray") {
365 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
366 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
368 else if(objectname=="AliITSBadChannelsSSDv2") {
369 cout<<"Reading the new format of the calibration file..."<<endl;
370 badChannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
372 //_____________________________________________________________________________//
374 //_____________________________________________________________________________//
375 Int_t nPSideChannelsTotal = 0, nNSideChannelsTotal = 0;
376 Int_t nBadPSideChannelsTotal = 0, nBadNSideChannelsTotal = 0;
377 Int_t nBadPSideChannels = 0, nBadNSideChannels = 0;
378 Int_t layer = 0, ladder = 0, module = 0;
379 Int_t nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
380 Int_t nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
381 //_____________________________________________________________________________//
383 for(Int_t i = 0; i < fgkSSDMODULES; i++) {
384 //for(Int_t i = 0; i < 1; i++) {
385 AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
386 nBadPSideChannels = 0, nBadNSideChannels = 0;
387 nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
388 nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
390 Int_t badChannel = 0;
391 for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
392 badChannel = (Int_t)(badChannelsSSD->GetBadChannelP(i,j));
393 //cout<<"Module: "<<i+500<< " Strip: "<<j<<" - "<<badChannel<<endl;
394 if(badChannel != 0) {
396 nPSideChannelsLayer5 += 1;
398 nPSideChannelsLayer6 += 1;
399 nBadPSideChannels += 1;
401 badChannel = (Int_t)(badChannelsSSD->GetBadChannelN(i,j));
402 //cout<<"Module: "<<i+500<< " Strip: "<<fgkDefaultNStripsSSD+j+1<<" - "<<badChannel<<endl;
403 if(badChannel != 0) {
405 nNSideChannelsLayer5 += 1;
407 nNSideChannelsLayer6 += 1;
408 nBadNSideChannels += 1;
412 if(nPSideChannelsLayer5 > 0)
413 fHistPSideBadChannelMapLayer5->Fill(module,499+ladder,
414 100.*nPSideChannelsLayer5/fgkDefaultNStripsSSD);
415 else fHistPSideBadChannelMapLayer5->Fill(module,499+ladder,0.0001);
416 if(nNSideChannelsLayer5 > 0)
417 fHistNSideBadChannelMapLayer5->Fill(module,499+ladder,
418 100.*nNSideChannelsLayer5/fgkDefaultNStripsSSD);
419 else fHistNSideBadChannelMapLayer5->Fill(module,499+ladder,0.0001);
422 if(nPSideChannelsLayer6 > 0)
423 fHistPSideBadChannelMapLayer6->Fill(module,599+ladder,
424 100.*nPSideChannelsLayer6/fgkDefaultNStripsSSD);
425 else fHistPSideBadChannelMapLayer6->Fill(module,599+ladder,0.0001);
426 if(nNSideChannelsLayer6 > 0)
427 fHistNSideBadChannelMapLayer6->Fill(module,599+ladder,
428 100.*nNSideChannelsLayer6/fgkDefaultNStripsSSD);
429 else fHistNSideBadChannelMapLayer6->Fill(module,599+ladder,0.0001);
432 nBadPSideChannelsTotal += nBadPSideChannels;
433 nBadNSideChannelsTotal += nBadNSideChannels;
434 nPSideChannelsTotal += fgkDefaultNStripsSSD;
435 nNSideChannelsTotal += fgkDefaultNStripsSSD;
438 cout<<"================================="<<endl;
439 cout<<"Bad p-Side channels: "<<100.*nBadPSideChannelsTotal/nPSideChannelsTotal<<endl;
440 cout<<"Bad n-Side channels: "<<100.*nBadNSideChannelsTotal/nNSideChannelsTotal<<endl;
441 cout<<"================================="<<endl;
443 TCanvas *cBadChannel = new TCanvas("cBadChannel",
444 "Bad channel list",0,0,900,900);
445 cBadChannel->SetHighLightColor(10); cBadChannel->SetFillColor(10);
446 cBadChannel->Divide(2,2);
448 cBadChannel->cd(1)->SetBottomMargin(.2);
449 cBadChannel->cd(1)->SetLeftMargin(.15);
450 cBadChannel->cd(1)->SetRightMargin(.2);
451 cBadChannel->cd(1)->SetGridx(); cBadChannel->cd(1)->SetGridy();
452 cBadChannel->cd(1); fHistPSideBadChannelMapLayer5->Draw("colz");
453 cBadChannel->cd(2)->SetBottomMargin(.2);
454 cBadChannel->cd(2)->SetLeftMargin(.15);
455 cBadChannel->cd(2)->SetRightMargin(.2);
456 cBadChannel->cd(2)->SetGridx(); cBadChannel->cd(2)->SetGridy();
457 cBadChannel->cd(2); fHistPSideBadChannelMapLayer6->Draw("colz");
458 cBadChannel->cd(3)->SetBottomMargin(.2);
459 cBadChannel->cd(3)->SetLeftMargin(.15);
460 cBadChannel->cd(3)->SetRightMargin(.2);
461 cBadChannel->cd(3)->SetGridx(); cBadChannel->cd(3)->SetGridy();
462 cBadChannel->cd(3); fHistNSideBadChannelMapLayer5->Draw("colz");
463 cBadChannel->cd(4)->SetBottomMargin(.2);
464 cBadChannel->cd(4)->SetLeftMargin(.15);
465 cBadChannel->cd(4)->SetRightMargin(.2);
466 cBadChannel->cd(4)->SetGridx(); cBadChannel->cd(4)->SetGridy();
467 cBadChannel->cd(4); fHistNSideBadChannelMapLayer6->Draw("colz");
468 cBadChannel->SaveAs("Run-BadChannels.gif");
470 TFile *fOutput = new TFile("badChannelsSSD.root","recreate");
471 fHistPSideBadChannelMapLayer5->Write();
472 fHistNSideBadChannelMapLayer5->Write();
473 fHistPSideBadChannelMapLayer6->Write();
474 fHistNSideBadChannelMapLayer6->Write();
478 //_____________________________________________________________________//
479 void GainCalibration(AliCDBManager * man) {
480 const Int_t fgkSSDMODULES = 1698;
481 static const Int_t fgkDefaultNStripsSSD = 768;
483 TH2F *fHistGainMapLayer5 = new TH2F("fHistGainMapLayer5",
484 "Layer 5;N_{strip};N_{module}",
487 fHistGainMapLayer5->GetXaxis()->SetTitleColor(1);
488 fHistGainMapLayer5->SetStats(kFALSE);
489 fHistGainMapLayer5->GetYaxis()->SetTitleOffset(1.8);
490 TH2F *fHistGainMapLayer6 = new TH2F("fHistGainMapLayer6",
491 "Layer 6;N_{strip};N_{module}",
494 fHistGainMapLayer6->GetXaxis()->SetTitleColor(1);
495 fHistGainMapLayer6->SetStats(kFALSE);
496 fHistGainMapLayer6->GetYaxis()->SetTitleOffset(1.8);
498 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
499 AliCDBEntry *entryGainSSD = man->Get("ITS/Calib/GainSSD");
500 TObject *empty = (TObject *)entryGainSSD->GetObject();
501 TString objectname = empty->GetName();
502 if(objectname=="Gain") {
503 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
504 ReadOldSSDGain(gainSSDOld, gainSSD);
506 else if(objectname=="AliITSGainSSDv2") {
507 cout<<"Reading the new format of the calibration file..."<<endl;
508 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
511 Int_t layer = 0, ladder = 0, module = 0;
513 for (Int_t i = 0; i < fgkSSDMODULES; i++) {
514 //for (Int_t i = 0; i < 1; i++) {
515 AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
516 for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
517 gain = gainSSD->GetGainP(i,j);
518 //cout<<"GainP: "<<gain<<endl;
520 fHistGainMapLayer5->Fill(j,i+500,gain);
522 fHistGainMapLayer6->Fill(j,i+500,gain);
524 gain = gainSSD->GetGainN(i,j);
525 //cout<<"GainN: "<<gain<<endl;
527 fHistGainMapLayer5->Fill(fgkDefaultNStripsSSD+j,i+500,gain);
529 fHistGainMapLayer6->Fill(fgkDefaultNStripsSSD+j,i+500,gain);
533 TCanvas *cGain = new TCanvas("cGain","Gain calibration map",0,300,600,300);
534 cGain->SetHighLightColor(10); cGain->SetFillColor(10); cGain->Divide(2,1);
536 cGain->cd(1)->SetBottomMargin(.2); cGain->cd(1)->SetLeftMargin(.15);
537 cGain->cd(1); fHistGainMapLayer5->Draw("colz");
538 cGain->cd(2)->SetBottomMargin(.2); cGain->cd(2)->SetLeftMargin(.15);
539 cGain->cd(2); fHistGainMapLayer6->Draw("colz");
542 //_____________________________________________________________________//
543 void ReadOldSSDNoise(TObjArray *array,
544 AliITSNoiseSSDv2 *noiseSSD) {
545 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
546 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
548 Int_t fNMod = array->GetEntries();
549 cout<<"Converting old calibration object for noise..."<<endl;
552 Double_t noise = 0.0;
553 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
554 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
555 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
556 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
557 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
558 noiseSSD->AddNoiseP(iModule,iStrip,noise);
559 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
560 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
565 //_____________________________________________________________________//
566 void ReadOldSSDPedestal(TObjArray *array,
567 AliITSPedestalSSDv2 *pedestalSSD) {
568 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
569 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
571 Int_t fNMod = array->GetEntries();
572 cout<<"Converting old calibration object for pedestal..."<<endl;
575 Double_t pedestal = 0.0;
576 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
577 AliITSPedestalSSD *pedestalModule = (AliITSPedestalSSD*) (array->At(iModule));
578 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
579 pedestal = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? pedestalModule->GetPedestalP(iStrip) : pedestalModule->GetPedestalN(1535 - iStrip);
580 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
581 pedestalSSD->AddPedestalP(iModule,iStrip,pedestal);
582 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
583 pedestalSSD->AddPedestalN(iModule,1535 - iStrip,pedestal);
588 //_____________________________________________________________________//
589 void ReadOldSSDBadChannels(TObjArray *array,
590 AliITSBadChannelsSSDv2 *badChannelsSSD) {
591 Int_t fNMod = array->GetEntries();
592 cout<<"Converting old calibration object for bad channels..."<<endl;
593 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
594 //for (Int_t iModule = 0; iModule < 1; iModule++) {
595 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
596 TArrayI arrayPSide = bad->GetBadPChannelsList();
597 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
598 badChannelsSSD->AddBadChannelP(iModule,
600 (Char_t)arrayPSide.At(iPCounter));
602 TArrayI arrayNSide = bad->GetBadNChannelsList();
603 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
604 badChannelsSSD->AddBadChannelN(iModule,
606 (Char_t)arrayNSide.At(iNCounter));
611 //_____________________________________________________________________//
612 void ReadOldSSDGain(TObjArray *array,
613 AliITSGainSSDv2 *gainSSD) {
614 Int_t fNMod = array->GetEntries();
615 cout<<"Converting old calibration object for gain..."<<endl;
618 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
619 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
620 TArrayF arrayPSide = gainModule->GetGainP();
621 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
622 gainSSD->AddGainP(iModule,
624 arrayPSide.At(iPCounter));
625 TArrayF arrayNSide = gainModule->GetGainN();
626 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
627 gainSSD->AddGainN(iModule,
629 arrayNSide.At(iNCounter));