Double check if SM is running added. Some redundant output removed from SM
[u/mrichter/AliRoot.git] / ITS / correlateOCDBforSSD.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include "TString.h"
3 #include "TH1.h"
4 #include "TH2.h"
5 #include "TFile.h"
6 #include "TObjArray.h"
7 #include "TObject.h"
8 #include "TCanvas.h"
9 #include "TStyle.h"
10 #include "Riostream.h"
11
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"
23 #endif
24
25
26 //====================================================================//
27 void Noise(AliCDBManager * man);
28 void Pedestal(AliCDBManager * man);
29 void GainCalibration(AliCDBManager * man);
30 void ReadOldSSDPedestal(TObjArray *array, AliITSPedestalSSDv2 *pedestalSSD);
31 void ReadOldSSDNoise(TObjArray *array, AliITSNoiseSSDv2 *noiseSSD);
32 void ReadOldSSDBadChannels(TObjArray *array, AliITSBadChannelsSSDv2 *badChannelsSSD);
33 void ReadOldSSDGain(TObjArray *array, AliITSGainSSDv2 *gainSSD);
34 void drawNoiseDistributions(Int_t runNumber);
35 void drawPedestalDistributions(Int_t runNumber);
36 //====================================================================//
37
38 //_____________________________________________________________________//
39 void correlateOCDBforSSD(const char* type = "alien", Int_t runNumber = 0) {
40   //This macro allows to read the pedestal values from the reference 
41   //directory and correlate them with the bad channel list.
42   //It also allows to correlate the noise values in the OCDB with 
43   //the bad channel list.
44   TString gType = type;
45   
46   AliCDBManager *man1 = AliCDBManager::Instance();
47   
48   if(gType == "alien") {
49     man1->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB/");
50     man1->SetSpecificStorage("ITS/Ref/PedestalSSD",
51                              "alien://folder=/alice/data/2009/Reference/");
52   }
53   else if(gType == "local") {
54     man1->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
55     man1->SetSpecificStorage("ITS/Ref/PedestalSSD",
56                              "local://$ALICE_ROOT/");
57   }
58   else {
59     cout<<"Allowed types: local or alien!!!"<<endl;
60     abort();
61   }
62   
63   man1->SetRun(runNumber);
64     
65   Pedestal(man1);
66   Noise(man1);
67 }
68
69 //_____________________________________________________________________//
70 void drawNoiseDistributions(Int_t runNumber) {
71   //Draws the noise distributions for each side and layer
72   TString filename = "noiseDistributionsSSD."; filename += runNumber;
73   filename += ".root";
74   TFile *f = TFile::Open(filename.Data());
75   TH1F *gHistNoisePSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistNoisePSideLayer5"));
76   TH1F *gHistNoiseNSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistNoiseNSideLayer5"));
77   TH1F *gHistNoisePSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistNoisePSideLayer6"));
78   TH1F *gHistNoiseNSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistNoiseNSideLayer6"));
79
80   TCanvas *c1 = new TCanvas("c1","Noise distribution (P-side, Layer 5)",
81                             0,0,400,400);
82   c1->SetFillColor(10); c1->SetHighLightColor(10); c1->SetLogy();
83   gHistNoisePSideLayer5->SetStats(kFALSE); 
84   gHistNoisePSideLayer5->GetXaxis()->SetRangeUser(0.0,20.);
85   gHistNoisePSideLayer5->Draw();
86   c1->SaveAs("Noise-PSide-Layer5.eps");
87
88   TCanvas *c2 = new TCanvas("c2","Noise distribution (N-side, Layer 5)",
89                             400,0,400,400);
90   c2->SetFillColor(10); c2->SetHighLightColor(10); c2->SetLogy();
91   gHistNoiseNSideLayer5->SetStats(kFALSE); 
92   gHistNoiseNSideLayer5->GetXaxis()->SetRangeUser(0.0,20.);
93   gHistNoiseNSideLayer5->Draw();
94   c2->SaveAs("Noise-NSide-Layer5.eps");
95
96   TCanvas *c3 = new TCanvas("c3","Noise distribution (P-side, Layer 6)",
97                             0,400,400,400);
98   c3->SetFillColor(10); c3->SetHighLightColor(10); c3->SetLogy();
99   gHistNoisePSideLayer6->SetStats(kFALSE); 
100   gHistNoisePSideLayer6->GetXaxis()->SetRangeUser(0.0,20.);
101   gHistNoisePSideLayer6->Draw();
102   c3->SaveAs("Noise-PSide-Layer6.eps");
103
104   TCanvas *c4 = new TCanvas("c4","Noise distribution (N-side, Layer 6)",
105                             400,400,400,400);
106   c4->SetFillColor(10); c4->SetHighLightColor(10); c4->SetLogy();
107   gHistNoiseNSideLayer6->SetStats(kFALSE); 
108   gHistNoiseNSideLayer6->GetXaxis()->SetRangeUser(0.0,20.);
109   gHistNoiseNSideLayer6->Draw();
110   c4->SaveAs("Noise-NSide-Layer6.eps");
111 }
112
113 //_____________________________________________________________________//
114 void drawPedestalDistributions(Int_t runNumber) {
115   //Draws the pedestal distributions for each side and layer
116   TString filename = "pedestalDistributionsSSD."; filename += runNumber;
117   filename += ".root";
118   TFile *f = TFile::Open(filename.Data());
119   TH1F *gHistPedestalPSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistPedestalPSideLayer5"));
120   TH1F *gHistPedestalNSideLayer5 = dynamic_cast<TH1F *>(f->Get("gHistPedestalNSideLayer5"));
121   TH1F *gHistPedestalPSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistPedestalPSideLayer6"));
122   TH1F *gHistPedestalNSideLayer6 = dynamic_cast<TH1F *>(f->Get("gHistPedestalNSideLayer6"));
123
124   TCanvas *c1 = new TCanvas("c1","Pedestal distribution (P-side, Layer 5)",
125                             0,0,400,400);
126   c1->SetFillColor(10); c1->SetHighLightColor(10); c1->SetLogy();
127   gHistPedestalPSideLayer5->SetStats(kFALSE); gHistPedestalPSideLayer5->Draw();
128   c1->SaveAs("Pedestal-PSide-Layer5.eps");
129
130   TCanvas *c2 = new TCanvas("c2","Pedestal distribution (N-side, Layer 5)",
131                             400,0,400,400);
132   c2->SetFillColor(10); c2->SetHighLightColor(10); c2->SetLogy();
133   gHistPedestalNSideLayer5->SetStats(kFALSE); gHistPedestalNSideLayer5->Draw();
134   c2->SaveAs("Pedestal-NSide-Layer5.eps");
135   
136   TCanvas *c3 = new TCanvas("c3","Pedestal distribution (P-side, Layer 6)",
137                             0,400,400,400);
138   c3->SetFillColor(10); c3->SetHighLightColor(10); c3->SetLogy();
139   gHistPedestalPSideLayer6->SetStats(kFALSE); gHistPedestalPSideLayer6->Draw();
140   c3->SaveAs("Pedestal-PSide-Layer6.eps");
141
142   TCanvas *c4 = new TCanvas("c4","Pedestal distribution (N-side, Layer 6)",
143                             400,400,400,400);
144   c4->SetFillColor(10); c4->SetHighLightColor(10); c4->SetLogy();
145   gHistPedestalNSideLayer6->SetStats(kFALSE); gHistPedestalNSideLayer6->Draw();
146   c4->SaveAs("Pedestal-NSide-Layer6.eps");
147 }
148
149 //_____________________________________________________________________//
150 void Pedestal(AliCDBManager * man) {
151   //Reads the noise OCDB file
152   const Int_t fgkSSDMODULES = 1698;
153   static const Int_t fgkDefaultNStripsSSD = 768;
154
155   Int_t runNumber = man->GetRun();
156
157   //=========================================================//
158   //pedestal histograms
159   TH1F *gHistPedestalPSideLayer5 = new TH1F("gHistPedestalPSideLayer5",
160                                             "Pedestal values (P-side, Layer5); ADC counts; Entries;",
161                                             1000,-500,500);
162   TH1F *gHistPedestalNSideLayer5 = new TH1F("gHistPedestalNSideLayer5",
163                                             "Pedestal values (N-side, Layer5); ADC counts; Entries;",
164                                             1000,-500,500);
165   TH1F *gHistPedestalPSideLayer6 = new TH1F("gHistPedestalPSideLayer6",
166                                             "Pedestal values (P-side, Layer6); ADC counts; Entries;",
167                                             1000,-500,500);
168   TH1F *gHistPedestalNSideLayer6 = new TH1F("gHistPedestalNSideLayer6",
169                                             "Pedestal values (N-side, Layer6); ADC counts; Entries;",
170                                             1000,-500,500);
171
172   //=========================================================//
173   Int_t fLayer = 0,fLadder = 0, fModule = 0;
174   
175   //=========================================================//
176   AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
177   AliCDBEntry *entryBadChannelsSSD = man->Get("ITS/Calib/BadChannelsSSD");
178   TObject *emptyBadChannel = (TObject *)entryBadChannelsSSD->GetObject();
179   TString objectnameBadChannel = emptyBadChannel->GetName();
180   if(objectnameBadChannel=="TObjArray") {
181     TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
182     ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
183   }
184   else if(objectnameBadChannel=="AliITSBadChannelsSSDv2") {
185     cout<<"Reading the new format of the calibration file..."<<endl;
186     badChannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
187   }
188
189   //=========================================================//
190   AliITSPedestalSSDv2 *pedestalSSD = new AliITSPedestalSSDv2();
191   AliCDBEntry *entryPedestalSSD = man->Get("ITS/Ref/PedestalSSD");
192   TObject *emptyPedestal = (TObject *)entryPedestalSSD->GetObject();
193   TString objectnamePedestal = emptyPedestal->GetName();
194   if(objectnamePedestal=="TObjArray") {
195     TObjArray *pedestalSSDOld = (TObjArray *)entryPedestalSSD->GetObject();
196     ReadOldSSDPedestal(pedestalSSDOld, pedestalSSD);
197   }
198   else if(objectnamePedestal=="AliITSPedestalSSDv2") {
199     cout<<"Reading the new format of the calibration file..."<<endl;
200     pedestalSSD = (AliITSPedestalSSDv2 *)entryPedestalSSD->GetObject();
201   }
202
203   Double_t pedestalPSide = 0.0, pedestalNSide = 0.0;
204   Int_t badChannelPSide = 0, badChannelNSide = 0;
205   for (Int_t i = 0; i < fgkSSDMODULES; i++) {
206     AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule);      
207     //cout<<"Pedestal for module: "<<i+500<<" - Layer: "<<fLayer<<endl;
208     for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
209       badChannelPSide = (Int_t)(badChannelsSSD->GetBadChannelP(i,j));
210       pedestalPSide = pedestalSSD->GetPedestalP(i,j);
211       if(badChannelPSide == 0) {
212         //Printf("Pedestal value: %lf",pedestal);
213         if(fLayer == 5) 
214           gHistPedestalPSideLayer5->Fill(pedestalPSide);
215         if(fLayer == 6) 
216           gHistPedestalPSideLayer6->Fill(pedestalPSide);
217       }
218       
219       badChannelNSide = (Int_t)(badChannelsSSD->GetBadChannelN(i,j));
220       pedestalNSide = pedestalSSD->GetPedestalN(i,j);
221       if(badChannelNSide == 0) {
222         if(fLayer == 5) 
223           gHistPedestalNSideLayer5->Fill(pedestalNSide);
224         if(fLayer == 6) 
225           gHistPedestalNSideLayer6->Fill(pedestalNSide);
226       }
227     }//loop over strips
228   }//loop over modules
229
230   TString output = "pedestalDistributionsSSD."; output += runNumber; 
231   output += ".root";
232   TFile *f = TFile::Open(output.Data(),"recreate");
233   gHistPedestalPSideLayer5->Write();
234   gHistPedestalNSideLayer5->Write();
235   gHistPedestalPSideLayer6->Write();
236   gHistPedestalNSideLayer6->Write();
237   f->Close();
238 }
239
240 //_____________________________________________________________________//
241 void Noise(AliCDBManager * man) {
242   //Reads the noise OCDB file
243   const Int_t fgkSSDMODULES = 1698;
244   const Int_t fgkSSDSTRIPSPERMODULE = 1536;
245   static const Int_t fgkDefaultNStripsSSD = 768;
246
247   Int_t runNumber = man->GetRun();
248
249   //noise histograms
250   TH1F *gHistNoisePSideLayer5 = new TH1F("gHistNoisePSideLayer5",
251                                          "Noise values (P-side, Layer5); ADC counts; Entries;",
252                                          1000,0,100);
253   TH1F *gHistNoiseNSideLayer5 = new TH1F("gHistNoiseNSideLayer5",
254                                          "Noise values (N-side, Layer5); ADC counts; Entries;",
255                                          1000,0,100);
256   TH1F *gHistNoisePSideLayer6 = new TH1F("gHistNoisePSideLayer6",
257                                          "Noise values (P-side, Layer6); ADC counts; Entries;",
258                                          1000,0,100);
259   TH1F *gHistNoiseNSideLayer6 = new TH1F("gHistNoiseNSideLayer6",
260                                          "Noise values (N-side, Layer6); ADC counts; Entries;",
261                                          1000,0,100);
262
263   Int_t fLayer = 0,fLadder = 0, fModule = 0;
264   Int_t fHistCounter = 0;
265   TString fTitle;
266   TObjArray *array = new TObjArray();
267   TH1D *hNoiseModule[fgkSSDMODULES];   
268   for(Int_t i = 500; i < fgkSSDMODULES + 500; i++) {
269     AliITSgeomTGeo::GetModuleId(i,fLayer,fLadder,fModule);
270     fTitle = "SSD_Noise_Layer"; fTitle += fLayer;
271     fTitle += "_Ladder"; fTitle += fLadder;
272     fTitle += "_Module"; fTitle += fModule;
273     
274     hNoiseModule[fHistCounter] = new TH1D(fTitle.Data(),fTitle.Data(),1540,0,1540);
275     hNoiseModule[fHistCounter]->GetXaxis()->SetTitleColor(1);
276     hNoiseModule[fHistCounter]->GetXaxis()->SetTitle("Strip number");
277     hNoiseModule[fHistCounter]->GetYaxis()->SetTitle("Noise");
278     array->AddLast(hNoiseModule[fHistCounter]);
279     fHistCounter += 1;
280   }
281   
282   //=========================================================//
283   AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
284   AliCDBEntry *entryBadChannelsSSD = man->Get("ITS/Calib/BadChannelsSSD");
285   TObject *emptyBadChannel = (TObject *)entryBadChannelsSSD->GetObject();
286   TString objectnameBadChannel = emptyBadChannel->GetName();
287   if(objectnameBadChannel=="TObjArray") {
288     TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
289     ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
290   }
291   else if(objectnameBadChannel=="AliITSBadChannelsSSDv2") {
292     cout<<"Reading the new format of the calibration file..."<<endl;
293     badChannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
294   }
295
296   //=========================================================//
297   AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
298   AliCDBEntry *entryNoiseSSD = man->Get("ITS/Calib/NoiseSSD");
299   TObject *emptyNoise = (TObject *)entryNoiseSSD->GetObject();
300   TString objectnameNoise = emptyNoise->GetName();
301   if(objectnameNoise=="TObjArray") {
302     TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
303     ReadOldSSDNoise(noiseSSDOld, noiseSSD);
304   }
305   else if(objectnameNoise=="AliITSNoiseSSDv2") {
306     cout<<"Reading the new format of the calibration file..."<<endl;
307     noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
308   }
309   
310   Double_t noisePSide = 0.0, noiseNSide = 0.0;
311   Int_t badChannelPSide = 0, badChannelNSide = 0;
312   for (Int_t i = 0; i < fgkSSDMODULES; i++) {
313     AliITSgeomTGeo::GetModuleId(i+500,fLayer,fLadder,fModule);      
314     //cout<<"Noise for module: "<<i+500<<" - Layer: "<<fLayer<<endl;
315     for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
316       badChannelPSide = (Int_t)(badChannelsSSD->GetBadChannelP(i,j));
317       noisePSide = noiseSSD->GetNoiseP(i,j);
318       hNoiseModule[i]->SetBinContent(j+1,noisePSide);
319       
320       badChannelNSide = (Int_t)(badChannelsSSD->GetBadChannelN(i,j));
321       noiseNSide = noiseSSD->GetNoiseN(i,j);
322       hNoiseModule[i]->SetBinContent(fgkSSDSTRIPSPERMODULE-j,noiseNSide);
323
324       if(badChannelPSide == 0) {
325         if(fLayer == 5) 
326           gHistNoisePSideLayer5->Fill(noisePSide);
327         if(fLayer == 6) 
328           gHistNoisePSideLayer6->Fill(noisePSide);
329       }
330       if(badChannelNSide == 0) {
331         if(fLayer == 5) 
332           gHistNoiseNSideLayer5->Fill(noiseNSide);
333         if(fLayer == 6) 
334           gHistNoiseNSideLayer6->Fill(noiseNSide);
335       }
336     }//loop over strips
337   }//loop over modules
338   
339   TString output1 = "noiseSSD."; output1 += runNumber; output1 += ".root";
340   TFile *f1 = TFile::Open(output1.Data(),"recreate");
341   array->Write();
342   f1->Close();
343
344   TString output2 = "noiseDistributionsSSD."; output2 += runNumber; 
345   output2 += ".root";
346   TFile *f2 = TFile::Open(output2.Data(),"recreate");
347   gHistNoisePSideLayer5->Write();
348   gHistNoiseNSideLayer5->Write();
349   gHistNoisePSideLayer6->Write();
350   gHistNoiseNSideLayer6->Write();
351   f2->Close();
352 }
353
354 //_____________________________________________________________________//
355 void GainCalibration(AliCDBManager * man) {
356   const Int_t fgkSSDMODULES = 1698;
357   static const Int_t fgkDefaultNStripsSSD = 768;
358
359   TH2F *fHistGainMapLayer5 = new TH2F("fHistGainMapLayer5",
360                                       "Layer 5;N_{strip};N_{module}",
361                                       1537,0,1537,
362                                       750,499,1249);
363   fHistGainMapLayer5->GetXaxis()->SetTitleColor(1);
364   fHistGainMapLayer5->SetStats(kFALSE);
365   fHistGainMapLayer5->GetYaxis()->SetTitleOffset(1.8);
366   TH2F *fHistGainMapLayer6 = new TH2F("fHistGainMapLayer6",
367                                       "Layer 6;N_{strip};N_{module}",
368                                       1537,0,1537,
369                                       952,1249,2199);
370   fHistGainMapLayer6->GetXaxis()->SetTitleColor(1);
371   fHistGainMapLayer6->SetStats(kFALSE);
372   fHistGainMapLayer6->GetYaxis()->SetTitleOffset(1.8);
373
374   AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
375   AliCDBEntry *entryGainSSD = man->Get("ITS/Calib/GainSSD");
376   TObject *empty = (TObject *)entryGainSSD->GetObject();
377   TString objectname = empty->GetName();
378   if(objectname=="Gain") {
379     TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
380     ReadOldSSDGain(gainSSDOld, gainSSD);
381   }
382   else if(objectname=="AliITSGainSSDv2") {
383     cout<<"Reading the new format of the calibration file..."<<endl;
384     gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
385   }
386   
387   Int_t layer = 0, ladder = 0, module = 0;
388   Double_t gain = 0;
389   for (Int_t i = 0; i < fgkSSDMODULES; i++) {
390   //for (Int_t i = 0; i < 1; i++) {
391     AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
392     for(Int_t j = 0; j < fgkDefaultNStripsSSD; j++) {
393       gain = gainSSD->GetGainP(i,j);
394       //cout<<"GainP: "<<gain<<endl;
395       if(layer == 5)
396         fHistGainMapLayer5->Fill(j,i+500,gain);
397       if(layer == 6)
398         fHistGainMapLayer6->Fill(j,i+500,gain);
399       
400       gain = gainSSD->GetGainN(i,j);
401       //cout<<"GainN: "<<gain<<endl;
402       if(layer == 5)
403         fHistGainMapLayer5->Fill(fgkDefaultNStripsSSD+j,i+500,gain);
404       if(layer == 6)
405         fHistGainMapLayer6->Fill(fgkDefaultNStripsSSD+j,i+500,gain);
406     }//strip loop
407   }//module loop
408
409   TCanvas *cGain = new TCanvas("cGain","Gain calibration map",0,300,600,300);
410   cGain->SetHighLightColor(10); cGain->SetFillColor(10); cGain->Divide(2,1);
411   
412   cGain->cd(1)->SetBottomMargin(.2); cGain->cd(1)->SetLeftMargin(.15);
413   cGain->cd(1); fHistGainMapLayer5->Draw("colz");
414   cGain->cd(2)->SetBottomMargin(.2); cGain->cd(2)->SetLeftMargin(.15);
415   cGain->cd(2); fHistGainMapLayer6->Draw("colz");
416 }
417
418 //_____________________________________________________________________//
419 void ReadOldSSDNoise(TObjArray *array, 
420                      AliITSNoiseSSDv2 *noiseSSD) {
421   const Int_t fgkSSDSTRIPSPERMODULE = 1536;
422   const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
423
424   Int_t fNMod = array->GetEntries();
425   cout<<"Converting old calibration object for noise..."<<endl;
426
427   //NOISE
428   Double_t noise = 0.0;
429   for (Int_t iModule = 0; iModule < fNMod; iModule++) {
430     AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
431     for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
432       noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
433       if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
434         noiseSSD->AddNoiseP(iModule,iStrip,noise);
435       if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
436         noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
437     }//loop over strips
438   }//loop over modules      
439 }
440
441 //_____________________________________________________________________//
442 void ReadOldSSDPedestal(TObjArray *array, 
443                         AliITSPedestalSSDv2 *pedestalSSD) {
444   const Int_t fgkSSDSTRIPSPERMODULE = 1536;
445   const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
446
447   Int_t fNMod = array->GetEntries();
448   cout<<"Converting old calibration object for pedestal..."<<endl;
449
450   //PEDESTAL
451   Double_t pedestal = 0.0;
452   for (Int_t iModule = 0; iModule < fNMod; iModule++) {
453     AliITSPedestalSSD *pedestalModule = (AliITSPedestalSSD*) (array->At(iModule));
454     for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
455       pedestal = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? pedestalModule->GetPedestalP(iStrip) : pedestalModule->GetPedestalN(1535 - iStrip);
456       if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
457         pedestalSSD->AddPedestalP(iModule,iStrip,pedestal);
458       if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
459         pedestalSSD->AddPedestalN(iModule,1535 - iStrip,pedestal);
460     }//loop over strips
461   }//loop over modules      
462 }
463
464 //_____________________________________________________________________//
465 void ReadOldSSDBadChannels(TObjArray *array, 
466                            AliITSBadChannelsSSDv2 *badChannelsSSD) {
467   Int_t fNMod = array->GetEntries();
468   cout<<"Converting old calibration object for bad channels..."<<endl;
469   for (Int_t iModule = 0; iModule < fNMod; iModule++) {
470     //for (Int_t iModule = 0; iModule < 1; iModule++) {
471     AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
472     TArrayI arrayPSide = bad->GetBadPChannelsList();
473     for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) 
474       badChannelsSSD->AddBadChannelP(iModule,
475                                      iPCounter,
476                                      (Char_t)arrayPSide.At(iPCounter));
477         
478     TArrayI arrayNSide = bad->GetBadNChannelsList();
479     for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) 
480       badChannelsSSD->AddBadChannelN(iModule,
481                                      iNCounter,
482                                      (Char_t)arrayNSide.At(iNCounter));
483     
484   }//loop over modules      
485 }
486
487 //_____________________________________________________________________//
488 void ReadOldSSDGain(TObjArray *array, 
489                     AliITSGainSSDv2 *gainSSD) {
490   Int_t fNMod = array->GetEntries();
491   cout<<"Converting old calibration object for gain..."<<endl;
492
493   //GAIN
494   for (Int_t iModule = 0; iModule < fNMod; iModule++) {
495     AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
496     TArrayF arrayPSide = gainModule->GetGainP();
497     for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
498       gainSSD->AddGainP(iModule,
499                         iPCounter,
500                         arrayPSide.At(iPCounter));
501     TArrayF arrayNSide = gainModule->GetGainN();
502     for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
503       gainSSD->AddGainN(iModule,
504                         iNCounter,
505                         arrayNSide.At(iNCounter));
506   }//loop over modules 
507 }