]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/PedestalDB/AliEMCALPedestalCDB.C
Change reco param default and OCDB settings, PbPb clusterizer is v2 and minimum cell...
[u/mrichter/AliRoot.git] / EMCAL / macros / PedestalDB / AliEMCALPedestalCDB.C
CommitLineData
40164976 1// Script to create dead channel map and store them into CDB
2// - 4 sets of maps parameters can be created, with now dead channels
3// and 5%, 10%, 20% and 30% of dead channels
4// - it reads the stored map in a given file.
5// Author: Gustavo Conesa
6
7//.x $ALICE_ROOT/EMCAL/macros/CalibrationDB/AliEMCALSetTowerStatusCDB.C
8
9#if !defined(__CINT__)
10#include <TControlBar.h>
11#include <TString.h>
12#include <TRandom.h>
13#include <TStyle.h>
14#include <TH2.h>
15#include <TF1.h>
16#include <TCanvas.h>
17
18#include "AliRun.h"
19#include "AliCaloCalibPedestal.h"
20#include "AliEMCALGeoParams.h"
21#include "AliCDBMetaData.h"
22#include "AliCDBId.h"
23#include "AliCDBEntry.h"
24#include "AliCDBManager.h"
25#include "AliCDBStorage.h"
26#endif
27
28
29void AliEMCALPedestalCDB()
30{
31 TControlBar *menu = new TControlBar("vertical","EMCAL CDB");
32 menu->AddButton("Help to run EMCAL CDB","Help()",
33 "Explains how to use EMCAL CDS menus");
34 menu->AddButton("Equal Tower Status Map, all Alive","SetTowerStatusMap(0)",
35 "Set all channels to alive");
36 menu->AddButton("Create Random Status Map, 5% dead","SetTowerStatusMap(5)",
37 "Set randomly 5% of the channels dead");
38 menu->AddButton("Create Random Status Map, 10% dead","SetTowerStatusMap(10)",
39 "Set randomly 10% of the channels dead");
40 menu->AddButton("Create Random Status Map, 20% dead","SetTowerStatusMap(20)",
41 "Set randomly 20% of the channels dead");
42 menu->AddButton("Create Random Status Map, 30% dead","SetTowerStatusMap(30)",
43 "Set randomly 30% of the channels dead");
1769b3d1 44 menu->AddButton("Set Map from txt file","SetTowerStatusMap(\"map.txt\")",
45 "Read bad channels from txt file and set them in root file");
40164976 46 menu->AddButton("Read Tower Status Map","GetTowerStatusMap()",
47 "Read initial equal calibration coefficients");
48 menu->Show();
49}
50
51//------------------------------------------------------------------------
52void Help()
53{
54 char *string =
55 "\nSet tower status map (dead, hot, alive) and write them into ALICE CDB. Press button \"Equal kAlive\" to set all channels alive. Press button \"Random, 5% dead\" to create random dead channel map at 5%\n";
56 printf(string);
57}
58
59//------------------------------------------------------------------------
60void SetTowerStatusMap(Int_t percent=0)
61{
62 // Writing status of all the channels in the OCDB with equal value
63 // except a percent to be not alive. Right now only "alive" or "dead",
64 // we need to implement the other cases like "hot"
65
66 TString sDBFolder ="local://PedestalsDB";
67 Int_t firstRun = 0;
68 Int_t lastRun = 999999999;
69 Int_t beamPeriod = 1;
1769b3d1 70 char* objFormat = Form("%d percent of bad channels", percent);
40164976 71
72 AliCaloCalibPedestal *caloped=new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal);
5c9f65e3 73 caloped->Init();
74
40164976 75 TObjArray map = caloped->GetDeadMap();
76 printf("MAP entries %d\n",map.GetEntries());
5c9f65e3 77
40164976 78 TRandom rn;
79 //for(Int_t iSM = 0; iSM < AliEMCALGeoParams::fgkEMCALModules; iSM ++){
80 for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){
81 Int_t ndead = 0;
82 printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY());
83 for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){
84 for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){
85 //printf("Bin (%d-%d) Content, before: %d ",i,j,((TH2D*)map[iSM])->GetBinContent(i, j));
86
87 if(rn.Uniform(0,100) > percent)
5c9f65e3 88 caloped->SetChannelStatus(iSM, i, j, AliCaloCalibPedestal::kAlive);
40164976 89 else{
5c9f65e3 90 caloped->SetChannelStatus(iSM, i, j, AliCaloCalibPedestal::kDead);
40164976 91 ndead++;
92 }
93 //printf("; after: %d \n",((TH2D*)map[iSM])->GetBinContent(i, j));
94 }
95 }
96 caloped->SetDeadTowerCount(caloped->GetDeadTowerCount()+ndead);
97 printf("--- dead %d\n",ndead);
98 }
99
100 printf("--- total dead %d\n",caloped->GetDeadTowerCount());
101
40164976 102 //Store map into database
103
104 AliCDBMetaData md;
105 md.SetComment(objFormat);
106 md.SetBeamPeriod(beamPeriod);
107 md.SetResponsible("Gustavo Conesa");
108
109 AliCDBId id("EMCAL/Calib/Pedestals",firstRun,lastRun); // create in EMCAL/Calib/Pedestal sDBFolder
110
111 AliCDBManager* man = AliCDBManager::Instance();
112 AliCDBStorage* loc = man->GetStorage(sDBFolder.Data());
113 loc->Put(caloped, id, &md);
114
115}
116
1769b3d1 117//____________________________________________
118
119
120
121
122//------------------------------------------------------------------------
123void SetTowerStatusMap(char * file = "map.txt")
124{
125 // Get the list of dead/hot channels from file and set them in OCDB
126
127 TString sDBFolder ="local://PedestalsDB";
128 Int_t firstRun = 0;
129 Int_t lastRun = 999999999;
130 Int_t beamPeriod = 1;
131 char* objFormat = Form("bad channels extracted from file %s", file);
132
133 AliCaloCalibPedestal *caloped=new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal);
5c9f65e3 134 caloped->Init();
135
1769b3d1 136 // Read parameter file line-by-line
137 ifstream f;
138 f.open(file);
139
140 Int_t iSM=-1, icol=-1, irow=-1, istatus=-1, ndead=0 ;
141 TString string;
142 if (f.good()) {
143 while(string.ReadLine(f, kFALSE) && !f.eof()) {
144
145 sscanf(string.Data(), "%d %d %d %d",&iSM,&icol,&irow,&istatus);
146 cout<<"SM= "<<iSM<<", col= "<<icol<<", row= "<<irow<<", status="<<istatus<<endl;
147 if(iSM==-1) continue;
5c9f65e3 148 caloped->SetChannelStatus(iSM, icol, irow, istatus);
1769b3d1 149 ndead++;
150 }
151 }
152 caloped->SetDeadTowerCount(ndead-2);
153 printf("--- dead %d\n",ndead-2);
154
155 printf("--- total dead %d\n",caloped->GetDeadTowerCount());
156
1769b3d1 157 //Store map into database
158
159 AliCDBMetaData md;
160 md.SetComment(objFormat);
161 md.SetBeamPeriod(beamPeriod);
162 md.SetResponsible("Gustavo Conesa");
163
164 AliCDBId id("EMCAL/Calib/Pedestals",firstRun,lastRun); // create in EMCAL/Calib/Pedestal sDBFolder
165
166 AliCDBManager* man = AliCDBManager::Instance();
167 AliCDBStorage* loc = man->GetStorage(sDBFolder.Data());
168 loc->Put(caloped, id, &md);
169
170}
171
172
40164976 173//------------------------------------------------------------------------
174void GetTowerStatusMap()
175{
176 // Read status map
177
178 TString sDBFolder ="local://PedestalsDB";
179 Int_t runNumber = 0;
180
181 AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*)
182 (AliCDBManager::Instance()
183 ->GetStorage(sDBFolder.Data())
184 ->Get("EMCAL/Calib/Pedestals",
185 runNumber)->GetObject());
186
187 cout<<endl;
188 TObjArray map = caloped->GetDeadMap();
189 printf("MAP entries %d\n",map.GetEntries());
190 for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){
191 TCanvas *cMap = new TCanvas(Form("cMap%d",iSM),Form("SM %d dead map",iSM), 12,12,400,400);
192 cMap->Divide(1,1);
193 Int_t ndead = 0;
194 printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY());
195 for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){
1769b3d1 196 for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){
197 if(((TH2D*)map[iSM])->GetBinContent(i, j)!=AliCaloCalibPedestal::kAlive)
198 printf("Bin (%d-%d) Content: %d \n",i,j,((TH2D*)map[iSM])->GetBinContent(i, j));
199
200 if(((TH2D*)map[iSM])->GetBinContent(i, j)==AliCaloCalibPedestal::kDead ||
201 ((TH2D*)map[iSM])->GetBinContent(i, j)==AliCaloCalibPedestal::kHot)
202 ndead++;
203 }
40164976 204 }
205 printf("--- dead %d\n",ndead);
206 cMap->cd(iSM);
207 (TH2D*)map[iSM])->Draw("lego2");
1769b3d1 208}
209
210printf("Total DEAD %d\n", caloped->GetDeadTowerCount());
40164976 211
40164976 212}