83a8ef25 |
1 | /* $Id$ */ |
2 | |
3 | // Script to create calibration parameters and store them into CDB |
4 | // Two sets of calibration parameters can be created: |
5 | // 1) equal parameters |
6 | // 2) randomly distributed parameters for decalibrated detector silumations |
7 | |
8 | void AliPHOSSetCDB() |
9 | { |
10 | menu = new TControlBar("vertical","PHOS CDB"); |
11 | menu->AddButton("Help to run PHOS CDB","Help()", |
12 | "Explains how to use PHOS CDS menus"); |
13 | menu->AddButton("Equal CC","SetCC(0)", |
14 | "Set equal calibration coefficients"); |
15 | menu->AddButton("Decalibrate","SetCC(1)", |
16 | "Set random calibration coefficients"); |
17 | menu->Show(); |
18 | } |
19 | |
20 | //------------------------------------------------------------------------ |
21 | Help() |
22 | { |
23 | char *string = |
24 | "\nSet calibration parameters and write them into ALICE CDB. |
25 | Press button \"Equal CC\" to create equal pedestals and gain factors. |
26 | Press button \"Decalibrate\" to create random pedestals and gain factors to imitate decalibrated detector\n"; |
27 | printf(string); |
28 | } |
29 | //------------------------------------------------------------------------ |
30 | SetCC(Int_t flag=0) |
31 | { |
32 | // Writing calibration coefficients into the Calibration DB |
33 | // Arguments: |
34 | // flag=0: all calibration coefficients are equal |
35 | // flag=1: all calibration coefficients random (decalibration) |
36 | // Author: Boris Polishchuk (Boris.Polichtchouk@cern.ch) |
37 | |
38 | TString DBFolder; |
39 | Int_t firstRun = 0; |
40 | Int_t lastRun = 10; |
41 | Int_t beamPeriod = 1; |
42 | char* objFormat; |
43 | |
44 | if (flag == 0) { |
45 | DBFolder ="InitCalibDB"; |
46 | firstRun = 0; |
47 | lastRun = 0; |
48 | objFormat = "PHOS initial gain factors and pedestals"; |
49 | } |
50 | else if (flag == 1) { |
51 | DBFolder ="DeCalibDB"; |
52 | firstRun = 0; |
53 | lastRun = 10; |
54 | objFormat = "PHOS random pedestals and ADC gain factors (5x64x56)"; |
55 | } |
56 | |
57 | // create DB directory |
58 | if(!gSystem->OpenDirectory(DBFolder)){ |
59 | printf("Warning: folder %s does not exist, I will create it!", |
60 | DBFolder.Data()); |
61 | TString command = "mkdir "+ DBFolder; |
62 | gSystem->Exec(command.Data()); |
63 | } |
64 | |
65 | AliPHOSCalibData *calibda=new AliPHOSCalibData("PHOS"); |
66 | |
67 | Float_t fADCpedestalEmc = 0.005; |
68 | Float_t fADCchanelEmc = 0.0015; |
69 | |
70 | TRandom rn; |
71 | |
72 | for(Int_t module=1; module<6; module++) { |
73 | for(Int_t column=1; column<57; column++) { |
74 | for(Int_t row=1; row<65; row++) { |
75 | if (flag == 0) { |
76 | // Decalibration: |
77 | // Spread calibration coefficients uniformly with |
78 | // Cmax/Cmin = 5, (Cmax-Cmin)/2 = 0.0015 |
79 | // and pedestals 0.005 +-10% |
80 | fADCchanelEmc =rn.Uniform(0.00075,0.00375); |
81 | fADCpedestalEmc=rn.Uniform(0.0045,0.0055); |
82 | } |
83 | calibda->SetADCchannelEmc (module,column,row,fADCchanelEmc); |
84 | calibda->SetADCpedestalEmc(module,column,row,fADCpedestalEmc); |
85 | } |
86 | } |
87 | } |
88 | |
89 | //Store calibration data into database |
90 | |
91 | AliCDBMetaData md("PHOS/Calib/GainFactors_and_Pedestals", |
92 | firstRun,lastRun,beamPeriod, |
93 | objFormat, |
94 | "B. Polishchuk", |
95 | "PHOS calibration"); |
96 | |
97 | AliCDBLocal *loc = new AliCDBLocal(DBFolder.Data()); |
98 | AliCDBStorage::Instance()->Put(calibda, md); |
99 | AliCDBStorage::Instance()->Delete(); |
100 | } |