]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/Macros/AliTRDCheckPreprocessor.C
Update on calibration classes by Raphaelle
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDCheckPreprocessor.C
1 #if !defined( __CINT__) || defined(__MAKECINT__)
2
3
4 #include <Riostream.h>
5 #include <TSystem.h>
6 #include <TProfile2D.h>
7 #include <TCanvas.h>
8 #include <TH1F.h>
9 #include <TH2I.h>
10 #include <TStyle.h>
11
12 #include "AliTestShuttle.h"
13 #include "AliShuttleInterface.h"
14 #include "AliCDBManager.h"
15 #include "AliCDBStorage.h"
16 #include "AliCDBEntry.h"
17
18
19 #include "../TRD/AliTRDarrayF.h"
20 #include "../TRD/AliTRDCalibPadStatus.h"
21 #include "../TRD/Cal/AliTRDCalPadStatus.h"
22 #include "../TRD/Cal/AliTRDCalDet.h"
23 #include "../TRD/Cal/AliTRDCalSm.h"
24 #include "../TRD/Cal/AliTRDCalPad.h"
25 #include "../TRD/Cal/AliTRDCalROC.h"
26
27
28 #endif
29
30
31 void AliTRDCheckPreprocessor()
32 {
33   // load library
34   //gSystem->Load("libTestShuttle.so");
35
36
37   AliTestShuttle::SetMainCDB("local://TestCDB_New");
38   AliTestShuttle::SetMainRefStorage("local://TestReference_New");
39   printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
40   printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
41
42   //Style
43   //************************
44   gStyle->SetPalette(1);
45   gStyle->SetOptStat(1111);
46   gStyle->SetPadBorderMode(0);
47   gStyle->SetCanvasColor(10);
48   gStyle->SetPadLeftMargin(0.13);
49   gStyle->SetPadRightMargin(0.13);
50
51   //Check the reference data 
52   //***************************
53
54   //Test reference data gain HLT
55   //***************************
56   Int_t ErrorRefDataGainHLT = 0;
57   AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/Gain", 9);  
58   if(!entry) ErrorRefDataGainHLT = 1;
59   else{
60     TH2I *histogainhlt = (TH2I *) entry->GetObject();
61     if(!histogainhlt) ErrorRefDataGainHLT = 2;
62     else{
63       Int_t NbinsX = histogainhlt->GetNbinsY();
64       if(NbinsX != 540) ErrorRefDataGainHLT = 3;
65       TCanvas *cgainhlt = new TCanvas("cgainhlt","",50,50,600,800);
66       cgainhlt->cd();
67       histogainhlt->Draw("LEGO");
68     }
69   }
70
71
72   //Test reference data vdriftt0 HLT
73   //***************************
74   Int_t ErrorRefDataVdriftT0HLT = 0;
75   if(entry) delete entry;
76   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/VdriftT0", 9);
77   if(!entry) ErrorRefDataVdriftT0HLT = 1;
78   else{
79     TProfile2D *histovdriftt0hlt = (TProfile2D *) entry->GetObject();
80     if(!histovdriftt0hlt) ErrorRefDataVdriftT0HLT = 2;
81     else{
82       Int_t NbinsX = histovdriftt0hlt->GetNbinsY();
83       if(NbinsX != 540) ErrorRefDataVdriftT0HLT = 3;
84       TCanvas *cvdrifthlt = new TCanvas("cvdrifthlt","",50,50,600,800);
85       cvdrifthlt->cd();
86       histovdriftt0hlt->Draw("LEGO");
87     }
88   }
89   
90   
91   //Test reference data PRF HLT
92   //***************************
93   Int_t ErrorRefDataPRFHLT = 0;
94   if(entry) delete entry;
95   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/PRF", 9);
96   if(!entry) ErrorRefDataPRFHLT = 1;
97   else{
98     TProfile2D *histoprfhlt = (TProfile2D *) entry->GetObject();
99     if(!histoprfhlt) ErrorRefDataPRFHLT = 2;
100     else{
101       Int_t NbinsX = histoprfhlt->GetNbinsY();
102       if(NbinsX != 540) ErrorRefDataPRFHLT = 3;
103       TCanvas *cprfhlt = new TCanvas("cprfhlt","",50,50,600,800);
104       cprfhlt->cd();
105       histoprfhlt->Draw("LEGO");
106     }
107   }
108   
109
110   //Test reference data PadStatus DAQ
111   //***************************
112   Int_t ErrorRefDataPadStatus = 0;
113   if(entry) delete entry;
114   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/DAQData/PadStatus", 9);
115   if(!entry) ErrorRefDataPadStatus = 1;
116   else{
117     AliTRDCalibPadStatus *calpadstatus = (AliTRDCalibPadStatus *) entry->GetObject();
118     if(!calpadstatus) ErrorRefDataPadStatus = 2;
119     else{
120       //Make the AliTRDCalDet correspondant
121       AliTRDCalDet *calDet = new AliTRDCalDet("dummy","dummy for mean");
122       for(Int_t k = 0; k < 540; k++){
123         calDet->SetValue(k,10.0);
124       }
125
126       //Make the AliTRDCalPad correspondant
127       AliTRDCalPad *calPad1 = new AliTRDCalPad("meanpad","dummy for mean");
128       AliTRDCalPad *calPad2 = new AliTRDCalPad("squarespad","dummy for squares");
129       AliTRDCalROC *calROC1 = 0x0;
130       AliTRDCalROC *calROC2 = 0x0;
131       for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det)
132     {
133       AliTRDCalROC *calROC11 = calPad1->GetCalROC(det);
134       AliTRDCalROC *calROC22 = calPad2->GetCalROC(det);
135       calROC1                = calpadstatus->GetCalRocMean(det,kTRUE);
136       calROC2                = calpadstatus->GetCalRocRMS(det,kTRUE);
137       for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
138         calROC11->SetValue(k,calROC1->GetValue(k));
139         calROC22->SetValue(k,calROC2->GetValue(k));
140       }
141     }
142       TCanvas *cpadstatusm = new TCanvas("cpadstatusm","cpadstatusm",50,50,600,800);
143       cpadstatusm->Divide(3,2);
144       cpadstatusm->cd(1);
145       ((TH2F *)calPad1->MakeHisto2DSmPl(1,0,calDet,0,9.0,11.0,-1))->Draw("colz");
146       cpadstatusm->cd(2);
147       ((TH2F *)calPad1->MakeHisto2DSmPl(1,1,calDet,0,9.0,11.0,-1))->Draw("colz");
148       cpadstatusm->cd(3);
149       ((TH2F *)calPad1->MakeHisto2DSmPl(1,2,calDet,0,9.0,11.0,-1))->Draw("colz");
150       cpadstatusm->cd(4);
151       ((TH2F *)calPad1->MakeHisto2DSmPl(1,3,calDet,0,9.0,11.0,-1))->Draw("colz");
152       cpadstatusm->cd(5);
153       ((TH2F *)calPad1->MakeHisto2DSmPl(1,4,calDet,0,9.0,11.0,-1))->Draw("colz");
154       cpadstatusm->cd(6);
155       ((TH2F *)calPad1->MakeHisto2DSmPl(1,5,calDet,0,9.0,11.0,-1))->Draw("colz");
156
157       TCanvas *cpadstatusrms = new TCanvas("cpadstatusrrms","cpadstatusrms",50,50,600,800);
158       cpadstatusrms->Divide(3,2);
159       cpadstatusrms->cd(1);
160       ((TH2F *)calPad2->MakeHisto2DSmPl(1,0,calDet,0,0.2,2.0,-1))->Draw("colz");
161       cpadstatusrms->cd(2);
162       ((TH2F *)calPad2->MakeHisto2DSmPl(1,1,calDet,0,0.2,2.0,-1))->Draw("colz");
163       cpadstatusrms->cd(3);
164       ((TH2F *)calPad2->MakeHisto2DSmPl(1,2,calDet,0,0.2,2.0,-1))->Draw("colz");
165       cpadstatusrms->cd(4);
166       ((TH2F *)calPad2->MakeHisto2DSmPl(1,3,calDet,0,0.2,2.0,-1))->Draw("colz");
167       cpadstatusrms->cd(5);
168       ((TH2F *)calPad2->MakeHisto2DSmPl(1,4,calDet,0,0.2,2.0,-1))->Draw("colz");
169       cpadstatusrms->cd(6);
170       ((TH2F *)calPad2->MakeHisto2DSmPl(1,5,calDet,0,0.2,2.0,-1))->Draw("colz");
171     }
172   }
173
174   //Test reference data vdriftt0 DAQ
175   //***************************
176   Int_t ErrorRefDataVdriftT0DAQ = 0;
177   if(entry) delete entry;
178   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/DAQData/VdriftT0", 9);
179   if(!entry) ErrorRefDataVdriftT0DAQ = 1;
180   else{
181     TProfile2D *histovdriftt0daq = (TProfile2D *) entry->GetObject();
182     if(!histovdriftt0daq) ErrorRefDataVdriftT0DAQ = 2;
183     else{
184       Int_t NbinsX = histovdriftt0daq->GetNbinsY();
185       if(NbinsX != 540) ErrorRefDataVdriftT0DAQ = 3;
186       TCanvas *cvdriftdaq = new TCanvas("cvdriftdaq","",50,50,600,800);
187       cvdriftdaq->cd();
188       histovdriftt0daq->Draw("LEGO");
189     }
190   }
191
192
193   //Check the detector OCDB values
194   //********************************
195  
196   //Test for pads
197   //******************
198   //Gain
199   //*****
200   AliTRDCalPad *calPad = 0x0;
201   Int_t ErrorGainPad = 0;
202   if(entry) delete entry;
203   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalGainFactor", 9);
204   if(!entry) ErrorGainPad++;
205   else{
206     calPad = (AliTRDCalPad *) entry->GetObject();
207     if(!calPad) ErrorGainPad++;
208     else{
209       for(Int_t det = 0; det < 540; det++){
210         AliTRDCalROC *calROC = calPad->GetCalROC(det);
211         for(Int_t channel =0; channel < calROC->GetNchannels(); channel++){
212           if(calROC->GetValue(channel) != 1.0) ErrorGainPad++;
213         }//channel loop
214       }//det loop
215     }
216   }
217
218   //Vdrift
219   //*****
220   Int_t ErrorVdriftPad = 0;
221   if(entry) delete entry;
222   if(calPad) delete calPad;
223   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalVdrift", 9);
224   if(!entry) ErrorVdriftPad++;
225   else{
226     calPad = (AliTRDCalPad *) entry->GetObject();
227     if(!calPad) ErrorVdriftPad++;
228     else{
229       for(Int_t det = 0; det < 540; det++){
230         AliTRDCalROC *calROC = calPad->GetCalROC(det);
231         for(Int_t channel =0; channel < calROC->GetNchannels(); channel++){
232           if(calROC->GetValue(channel) != 1.0) ErrorVdriftPad++;
233         }//channel loop
234       }//det loop
235     }
236   }
237
238   //T0
239   //*****
240   Int_t ErrorT0Pad = 0;
241   if(entry) delete entry;
242   if(calPad) delete calPad;
243   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalT0", 9);
244   if(!entry) ErrorT0Pad++;
245   else{
246     calPad = (AliTRDCalPad *) entry->GetObject();
247     if(!calPad) ErrorT0Pad++;
248     else{
249       for(Int_t det = 0; det < 540; det++){
250         AliTRDCalROC *calROC = calPad->GetCalROC(det);
251         for(Int_t channel =0; channel < calROC->GetNchannels(); channel++){
252           if(calROC->GetValue(channel) != 0.0) ErrorT0Pad++;
253         }//channel loop
254       }//det loop
255     }
256   }
257
258
259   //PRFWidth
260   //********
261   Int_t ErrorPRFWidthPad = 0;
262   if(entry) delete entry;
263   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PRFWidth", 9);
264   if(!entry) ErrorPRFWidthPad++;
265   else{
266     AliTRDCalPad *calPadPrf = (AliTRDCalPad *) entry->GetObject();
267     if(!calPadPrf) ErrorPRFWidthPad++;
268     else{
269       Float_t value = 0.0;
270       
271       for(Int_t plane = 0; plane < 6; plane++){
272         
273         if(plane == 0) value = 0.515;
274         if(plane == 1) value = 0.502;
275         if(plane == 2) value = 0.491;
276         if(plane == 3) value = 0.481;
277         if(plane == 4) value = 0.471;
278         if(plane == 5) value = 0.463;
279         
280         for(Int_t chamber = 0; chamber < 5; chamber++){
281           for(Int_t sector = 0; sector < 18; sector++){
282             
283             AliTRDCalROC *calROC = calPadPrf->GetCalROC(plane,chamber,sector);
284             for(Int_t channel =0; channel < calROC->GetNchannels(); channel++){
285               if((calROC->GetValue(channel) > 1.25*value) || (calROC->GetValue(channel) < 0.8*value)) ErrorPRFWidthPad++;
286             }//channel loop
287           }//sector loop
288         }//chamber loop
289       }//plane loop
290       TCanvas *cpadprf = new TCanvas("cpadprf","cpadprf",50,50,600,800);
291       cpadprf->cd();
292       ((TH1F *)calPadPrf->MakeHisto1D(0,0,0.45,0.58,-1))->Draw();
293     }
294   }
295
296
297   
298   //Padstatus
299   //********
300   Int_t ErrorPadStatusPad = 0;
301   if(entry) delete entry;
302   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PadStatus", 9);
303   if(!entry) ErrorPadStatusPad++;
304   else{
305     AliTRDCalPadStatus *calPadStatus = (AliTRDCalPadStatus *) entry->GetObject();
306     if(!calPadStatus) ErrorPadStatusPad++;
307     else{
308       TCanvas *cpadstatus = new TCanvas("cpadstatus","cpadstatus",50,50,600,800);
309       cpadstatus->Divide(3,2);
310       cpadstatus->cd(1);
311       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,0))->Draw("colz");
312       cpadstatus->cd(2);
313       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,1))->Draw("colz");
314       cpadstatus->cd(3);
315       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,2))->Draw("colz");
316       cpadstatus->cd(4);
317       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,3))->Draw("colz");
318       cpadstatus->cd(5);
319       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,4))->Draw("colz");
320       cpadstatus->cd(6);
321       ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,5))->Draw("colz");
322     }
323   }
324
325   //Test for detector values
326   //*************************
327
328   //Gain
329   //******
330   Int_t ErrorGainDetector = 0;
331   if(entry) delete entry;
332   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberGainFactor", 9);  
333   if(!entry) ErrorGainDetector++;
334   else{
335     AliTRDCalDet *objectg = (AliTRDCalDet *) entry->GetObject();
336     if(!objectg) ErrorGainDetector++;
337     else{
338       for(Int_t det = 0; det < 540; det++){
339         if((objectg->GetValue(det)> 2.0) || (objectg->GetValue(det) < 0.0)) ErrorGainDetector++;
340       }
341       TCanvas *cdetgain = new TCanvas("cdetgain","",50,50,600,800);
342       cdetgain->cd();
343       ((TH1F *)objectg->MakeHisto1Distribution(0.0,2.0,-1))->Draw();
344     }
345   }
346  
347
348   //Vdrift
349   //******
350   Int_t ErrorVdriftDetector = 0;
351   if(entry) delete entry;
352   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberVdrift", 9);  
353   if(!entry) ErrorVdriftDetector++;
354   else{
355     AliTRDCalDet *objectv = (AliTRDCalDet *) entry->GetObject();
356     if(!objectv) ErrorVdriftDetector++;
357     else{
358       for(Int_t det = 0; det < 540; det++){
359         if((objectv->GetValue(det)> 2.5) || (objectv->GetValue(det) < 0.6)) ErrorVdriftDetector++;
360       }
361       TCanvas *cdetv = new TCanvas("cdetv","",50,50,600,800);
362       cdetv->cd();
363       ((TH1F *)objectv->MakeHisto1Distribution(0.6,2.5,-1))->Draw();
364     }
365   }
366
367
368   //T0
369   //******
370   Int_t ErrorT0Detector = 0;
371   if(entry) delete entry;
372   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberT0", 9);  
373   if(!entry) ErrorT0Detector++;
374   else{
375     AliTRDCalDet *objectt = (AliTRDCalDet *) entry->GetObject();
376     if(!objectt) ErrorT0Detector++;
377     else{
378       for(Int_t det = 0; det < 540; det++){
379         if((objectt->GetValue(det)> 1.0) || (objectt->GetValue(det) < -1.0)) ErrorT0Detector++;
380       }
381       TCanvas *cdett = new TCanvas("cdett","",50,50,600,800);
382       cdett->cd();
383       ((TH1F *)objectt->MakeHisto1Distribution(-0.5,0.5,-1))->Draw();
384     }
385   }
386
387   
388
389   //Time Monitoring Gain
390   //********************
391
392   Int_t ErrorGainMonitoring = 0;
393   if(entry) delete entry;
394   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/SmGainFactor", 9);  
395   if(!entry) ErrorGainMonitoring++;
396   else{
397     AliTRDCalSm *smg = (AliTRDCalSm *) entry->GetObject();
398     if(!smg) ErrorGainMonitoring++;
399     else{
400       if(smg->GetEntries() != 2) ErrorGainMonitoring++;
401       TH1F * distributiong = new TH1F("gaintime","gaintime",200,16,64);
402       for(Int_t sm = 0; sm < 18; sm++){
403         distributiong->Fill(smg->GetValue(sm,0));
404       }
405       TCanvas *cgaintime = new TCanvas("cgaintime","",50,50,600,800);
406       cgaintime->cd();
407       distributiong->Draw();
408     }
409   }
410
411
412   //Time Monitoring Vdrift
413   //********************
414
415   Int_t ErrorVdriftMonitoring = 0;
416   if(entry) delete entry;
417   entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/SmVdriftFactor", 9); 
418   if(!entry) ErrorVdriftMonitoring++;
419   else{ 
420     AliTRDCalSm *smv = (AliTRDCalSm *) entry->GetObject();
421     if(!smv) ErrorVdriftMonitoring++;
422     else{
423       if(smv->GetEntries() != 2) ErrorVdriftMonitoring++;
424       TH1F * distributionv = new TH1F("vdrifttime","vdrifttime",200,1.0,2.0);
425       for(Int_t sm = 0; sm < 18; sm++){
426         distributionv->Fill(smv->GetValue(sm,0));
427       }
428       TCanvas *cvdrifttime = new TCanvas("cvdrifttime","",50,50,600,800);
429       cvdrifttime->cd();
430       distributionv->Draw();
431     }
432   }
433
434
435
436   //Bilan
437   //**************
438
439   //OCDB values
440   //************
441
442   printf("For the local gain factor there are %d strange values\n",ErrorGainPad);
443   printf("For the local vdrift there are %d strange values\n",ErrorVdriftPad);
444   printf("For the local t0 there are %d strange values\n",ErrorT0Pad);
445   printf("For the chamber gain factor there are %d strange values\n",ErrorGainDetector);
446   printf("For the chamber vdrift there are %d strange values\n",ErrorVdriftDetector);
447   printf("For the chamber t0 there are %d strange values\n",ErrorT0Detector);
448   printf("For the prf width there are %d strange values\n",ErrorPRFWidthPad);
449
450   if(ErrorGainMonitoring > 0) printf("there is more than one value in time for the gain time dependence\n");
451   if(ErrorVdriftMonitoring > 0) printf("there is more than one value in time for the gain time dependence\n");
452
453   if(ErrorPadStatusPad > 0) printf("there is no calPadStatus object\n");
454
455
456  //Reference data
457  //****************
458
459   //gain HLT
460   
461   if(ErrorRefDataGainHLT == 1) printf("There is no reference data entry for the gain HLT!\n");
462   if(ErrorRefDataGainHLT == 2) printf("There is no reference data histogram for the gain HLT!\n");
463   if(ErrorRefDataGainHLT == 3) printf("The reference data histogram has not the good number of Xbins for the gain HLT!\n");
464   // vdrift HLT
465
466   if(ErrorRefDataVdriftT0HLT == 1) printf("There is no reference data entry for the vdriftt0 HLT!\n");
467   if(ErrorRefDataVdriftT0HLT == 2) printf("There is no reference data histogram for the vdriftt0 HLT!\n");
468   if(ErrorRefDataVdriftT0HLT == 3) printf("The reference data profile has not the good number of Xbins for the gain HLT!\n");
469   
470   // prf HLT
471   if(ErrorRefDataPRFHLT == 1) printf("There is no reference data entry for the prf HLT!\n");
472   if(ErrorRefDataPRFHLT == 2) printf("There is no reference data profile for the prf HLT!\n");
473   if(ErrorRefDataPRFHLT == 3) printf("The reference data profile has not the good number of Xbins for the prf HLT!\n");
474   
475   // vdrift DAQ
476
477   if(ErrorRefDataVdriftT0DAQ == 1) printf("There is no reference data entry for the vdriftt0 DAQ!\n");
478   if(ErrorRefDataVdriftT0DAQ == 2) printf("There is no reference data histogram for the vdriftt0 DAQ!\n");
479   if(ErrorRefDataVdriftT0DAQ == 3) printf("The reference data profile has not the good number of Xbins for the gain DAQ!\n");
480
481
482   // PadStatus DAQ
483
484   if(ErrorRefDataPadStatus == 1) printf("There is no reference data entry for the pad status DAQ!\n");
485   if(ErrorRefDataPadStatus == 2) printf("There is no reference data object for pad status DAQ!\n");
486   
487  
488 }