]>
Commit | Line | Data |
---|---|---|
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 | ||
18fdb171 | 8 | #if !defined(__CINT__) |
9 | #include "TControlBar.h" | |
10 | #include "TString.h" | |
11 | #include "TRandom.h" | |
12 | #include "TH2F.h" | |
13 | #include "TCanvas.h" | |
14 | ||
15 | #include "AliRun.h" | |
16 | #include "AliPHOSCalibData.h" | |
17 | #include "AliCDBMetaData.h" | |
18 | #include "AliCDBId.h" | |
19 | #include "AliCDBEntry.h" | |
20 | #include "AliCDBManager.h" | |
21 | #include "AliCDBStorage.h" | |
22 | #endif | |
23 | ||
f162be9a | 24 | static const Int_t nMod = 5; |
25 | static const Int_t nCol = 56; | |
26 | static const Int_t nRow = 64; | |
18fdb171 | 27 | |
83a8ef25 | 28 | void AliPHOSSetCDB() |
29 | { | |
18fdb171 | 30 | TControlBar *menu = new TControlBar("vertical","PHOS CDB"); |
31 | menu->AddButton("Help to run PHOS CDB","Help()", | |
6404864b | 32 | "Explains how to use PHOS CDB menus"); |
18fdb171 | 33 | menu->AddButton("Equal CC","SetCC(0)", |
6404864b | 34 | "Set equal CC"); |
35 | menu->AddButton("Full decalibration","SetCC(1)", | |
36 | "Set random decalibration CC"); | |
37 | menu->AddButton("Residual decalibration","SetCC(2)", | |
e2e977c3 | 38 | "Set residual decalibration calibration coefficients"); |
39 | ||
18fdb171 | 40 | menu->AddButton("Read equal CC","GetCC(0)", |
6404864b | 41 | "Read equal calibration coefficients"); |
18fdb171 | 42 | menu->AddButton("Read random CC","GetCC(1)", |
43 | "Read random decalibration calibration coefficients"); | |
6404864b | 44 | menu->AddButton("Read residual CC","GetCC(2)", |
e2e977c3 | 45 | "Read residial calibration coefficients"); |
6404864b | 46 | menu->AddButton("Exit","gApplication->Terminate(0)","Quit aliroot session"); |
18fdb171 | 47 | menu->Show(); |
83a8ef25 | 48 | } |
49 | ||
50 | //------------------------------------------------------------------------ | |
18fdb171 | 51 | void Help() |
83a8ef25 | 52 | { |
6404864b | 53 | TString string="\nSet calibration parameters and write them into ALICE OCDB:"; |
54 | string += "\n\tPress button \"Equal CC\" to create equal calibration coefficients;"; | |
55 | string += "\n\tPress button \"Full decalibration\" to create \n\t random calibration coefficients with 20\% spread \n\t to imitate fully decalibrated detector;"; | |
56 | string += "\n\tPress button \"Residual decalibration\" to create \n\t random calibration coefficients with +-2\% spread\n\t to imitate decalibrated detector after initial calibration.\n"; | |
57 | printf("%s",string.Data()); | |
83a8ef25 | 58 | } |
3a429efa | 59 | |
83a8ef25 | 60 | //------------------------------------------------------------------------ |
18fdb171 | 61 | void SetCC(Int_t flag=0) |
83a8ef25 | 62 | { |
63 | // Writing calibration coefficients into the Calibration DB | |
64 | // Arguments: | |
65 | // flag=0: all calibration coefficients are equal | |
f162be9a | 66 | // flag=1: decalibration coefficients |
67 | // flag=2: calibration coefficients equal to inverse decalibration ones | |
3a429efa | 68 | // Author: Boris Polishchuk (Boris.Polichtchouk at cern.ch) |
83a8ef25 | 69 | |
70 | TString DBFolder; | |
71 | Int_t firstRun = 0; | |
f162be9a | 72 | Int_t lastRun = 0; |
83a8ef25 | 73 | Int_t beamPeriod = 1; |
18fdb171 | 74 | char* objFormat = ""; |
83a8ef25 | 75 | |
69d5d19c | 76 | AliPHOSCalibData* cdb = 0; |
77 | ||
83a8ef25 | 78 | if (flag == 0) { |
16b8ada8 | 79 | DBFolder ="local://InitCalibDB"; |
83a8ef25 | 80 | firstRun = 0; |
c87f07e5 | 81 | lastRun = 999999; |
d53cb5cc | 82 | objFormat = "PHOS initial pedestals and ADC gain factors (5x64x56)"; |
69d5d19c | 83 | cdb = new AliPHOSCalibData(); |
84 | cdb->CreateNew(); | |
83a8ef25 | 85 | } |
69d5d19c | 86 | |
83a8ef25 | 87 | else if (flag == 1) { |
6404864b | 88 | DBFolder ="local://FullDecalibDB"; |
c87f07e5 | 89 | firstRun = 0; |
90 | lastRun = 999999; | |
6404864b | 91 | objFormat = "PHOS fully decalibrated calibration coefficients (5x64x56)"; |
69d5d19c | 92 | |
93 | cdb = new AliPHOSCalibData(); | |
6404864b | 94 | cdb->RandomEmc(0.8,1.2); |
95 | cdb->RandomCpv(0.0008,0.0016); | |
83a8ef25 | 96 | } |
16b8ada8 | 97 | |
f162be9a | 98 | else if (flag == 2) { |
e2e977c3 | 99 | DBFolder ="local://ResidualCalibDB"; |
f162be9a | 100 | firstRun = 0; |
e2e977c3 | 101 | lastRun = 999999; |
6404864b | 102 | objFormat = "PHOS residual calibration coefficients (5x64x56)"; |
e2e977c3 | 103 | |
f162be9a | 104 | cdb = new AliPHOSCalibData(); |
e2e977c3 | 105 | cdb->RandomEmc(0.98,1.02); |
106 | cdb->RandomCpv(0.00115,0.00125); | |
f162be9a | 107 | } |
108 | ||
83a8ef25 | 109 | //Store calibration data into database |
16b8ada8 | 110 | |
111 | AliCDBMetaData md; | |
112 | md.SetComment(objFormat); | |
113 | md.SetBeamPeriod(beamPeriod); | |
114 | md.SetResponsible("Boris Polichtchouk"); | |
115 | ||
69d5d19c | 116 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); |
6404864b | 117 | if(gSystem->Getenv("STORAGE")){ |
118 | cout << "Setting specific storage" << endl; | |
119 | AliCDBManager::Instance()->SetSpecificStorage("PHOS/*",DBFolder.Data()); | |
120 | } | |
83a8ef25 | 121 | |
69d5d19c | 122 | cdb->WriteEmc(firstRun,lastRun,&md); |
123 | cdb->WriteCpv(firstRun,lastRun,&md); | |
6404864b | 124 | cdb->WriteEmcBadChannelsMap(firstRun,lastRun,&md); |
83a8ef25 | 125 | |
83a8ef25 | 126 | } |
3a429efa | 127 | |
128 | //------------------------------------------------------------------------ | |
18fdb171 | 129 | void GetCC(Int_t flag=0) |
3a429efa | 130 | { |
131 | // Read calibration coefficients into the Calibration DB | |
132 | // Arguments: | |
133 | // flag=0: all calibration coefficients are equal | |
f162be9a | 134 | // flag=1: decalibration coefficients |
135 | // flag=2: calibration coefficients equal to inverse decalibration ones | |
3a429efa | 136 | // Author: Yuri.Kharlov at cern.ch |
137 | ||
6404864b | 138 | gStyle->SetPalette(1); |
139 | gStyle->SetOptStat(0); | |
3a429efa | 140 | TString DBFolder; |
f162be9a | 141 | Int_t runNumber; |
3a429efa | 142 | |
143 | if (flag == 0) { | |
16b8ada8 | 144 | DBFolder ="local://InitCalibDB"; |
f162be9a | 145 | runNumber = 0; |
3a429efa | 146 | } |
147 | else if (flag == 1) { | |
6404864b | 148 | DBFolder ="local://FullDecalibDB"; |
149 | runNumber = 0; | |
3a429efa | 150 | } |
e2e977c3 | 151 | else if (flag == 2) { |
152 | DBFolder ="local://ResidualCalibDB"; | |
153 | runNumber = 0; | |
154 | } | |
16b8ada8 | 155 | |
69d5d19c | 156 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); |
6404864b | 157 | if(gSystem->Getenv("STORAGE")){ |
158 | cout << "Setting specific storage" << endl; | |
159 | AliCDBManager::Instance()->SetSpecificStorage("PHOS/*",DBFolder.Data()); | |
160 | } | |
3a429efa | 161 | |
f162be9a | 162 | AliPHOSCalibData* clb = new AliPHOSCalibData(runNumber); |
3a429efa | 163 | |
69d5d19c | 164 | TH2::AddDirectory(kFALSE); |
165 | ||
69d5d19c | 166 | TH2F* hGain[5]; |
167 | ||
6404864b | 168 | TCanvas *cGain = new TCanvas("cGain","PHOS EMC Gain factors",10,10,700,500); |
169 | cGain->Divide(3,2); | |
3a429efa | 170 | |
e2e977c3 | 171 | for (Int_t module=1; module<=nMod; module++) { |
3a429efa | 172 | TString nameGain="hGain"; |
173 | nameGain+=module; | |
174 | TString titleGain="Gain factors in module "; | |
175 | titleGain+=module; | |
176 | hGain[module-1] = new TH2F(nameGain.Data(),titleGain.Data(), | |
177 | nCol,1.,1.*nCol,nRow,1.,1.*nRow); | |
178 | ||
179 | for (Int_t column=1; column<=nCol; column++) { | |
180 | for (Int_t row=1; row<=nRow; row++) { | |
6404864b | 181 | Float_t gain = clb->GetADCchannelEmc (module,column,row); |
3a429efa | 182 | hGain[module-1]->SetBinContent(column,row,gain); |
183 | } | |
184 | } | |
3a429efa | 185 | cGain->cd(module); |
6404864b | 186 | hGain[module-1]->SetMinimum(0); |
187 | hGain[module-1]->Draw("colz"); | |
3a429efa | 188 | } |
3a429efa | 189 | cGain->Print("gains.eps"); |
190 | } |