]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/PedestalDB/AliEMCALPedestalCDB.C
Change default param settings in class and change default event species from kDefault...
[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");
44 menu->AddButton("Read Tower Status Map","GetTowerStatusMap()",
45 "Read initial equal calibration coefficients");
46 menu->Show();
47}
48
49//------------------------------------------------------------------------
50void Help()
51{
52 char *string =
53 "\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";
54 printf(string);
55}
56
57//------------------------------------------------------------------------
58void SetTowerStatusMap(Int_t percent=0)
59{
60 // Writing status of all the channels in the OCDB with equal value
61 // except a percent to be not alive. Right now only "alive" or "dead",
62 // we need to implement the other cases like "hot"
63
64 TString sDBFolder ="local://PedestalsDB";
65 Int_t firstRun = 0;
66 Int_t lastRun = 999999999;
67 Int_t beamPeriod = 1;
68 char* objFormat = Form("%d percent decalibrated channels", percent);
69
70 AliCaloCalibPedestal *caloped=new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal);
71 TObjArray map = caloped->GetDeadMap();
72 printf("MAP entries %d\n",map.GetEntries());
73 TRandom rn;
74 //for(Int_t iSM = 0; iSM < AliEMCALGeoParams::fgkEMCALModules; iSM ++){
75 for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){
76 Int_t ndead = 0;
77 printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY());
78 for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){
79 for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){
80 //printf("Bin (%d-%d) Content, before: %d ",i,j,((TH2D*)map[iSM])->GetBinContent(i, j));
81
82 if(rn.Uniform(0,100) > percent)
83 ((TH2D*)map[iSM])->SetBinContent(i, j, AliCaloCalibPedestal::kAlive);
84 else{
85 ((TH2D*)map[iSM])->SetBinContent(i, j, AliCaloCalibPedestal::kDead);
86 ndead++;
87 }
88 //printf("; after: %d \n",((TH2D*)map[iSM])->GetBinContent(i, j));
89 }
90 }
91 caloped->SetDeadTowerCount(caloped->GetDeadTowerCount()+ndead);
92 printf("--- dead %d\n",ndead);
93 }
94
95 printf("--- total dead %d\n",caloped->GetDeadTowerCount());
96
97 caloped->SetDeadMap(map);
98
99 //Store map into database
100
101 AliCDBMetaData md;
102 md.SetComment(objFormat);
103 md.SetBeamPeriod(beamPeriod);
104 md.SetResponsible("Gustavo Conesa");
105
106 AliCDBId id("EMCAL/Calib/Pedestals",firstRun,lastRun); // create in EMCAL/Calib/Pedestal sDBFolder
107
108 AliCDBManager* man = AliCDBManager::Instance();
109 AliCDBStorage* loc = man->GetStorage(sDBFolder.Data());
110 loc->Put(caloped, id, &md);
111
112}
113
114//------------------------------------------------------------------------
115void GetTowerStatusMap()
116{
117 // Read status map
118
119 TString sDBFolder ="local://PedestalsDB";
120 Int_t runNumber = 0;
121
122 AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*)
123 (AliCDBManager::Instance()
124 ->GetStorage(sDBFolder.Data())
125 ->Get("EMCAL/Calib/Pedestals",
126 runNumber)->GetObject());
127
128 cout<<endl;
129 TObjArray map = caloped->GetDeadMap();
130 printf("MAP entries %d\n",map.GetEntries());
131 for(Int_t iSM = 0; iSM < map.GetEntries(); iSM ++){
132 TCanvas *cMap = new TCanvas(Form("cMap%d",iSM),Form("SM %d dead map",iSM), 12,12,400,400);
133 cMap->Divide(1,1);
134 Int_t ndead = 0;
135 printf(" >>> SM %d <<< Entries %d, NbinsX %d, NbinsY %d\n",iSM,((TH2D*)map[iSM])->GetEntries(),((TH2D*)map[iSM])->GetNbinsX(),((TH2D*)map[iSM])->GetNbinsY());
136 for(Int_t i = 0; i < ((TH2D*)map[iSM])->GetNbinsX() ; i++){
137 for(Int_t j = 0; j < ((TH2D*)map[iSM])->GetNbinsY() ; j++){
138 //printf("Bin (%d-%d) Content: %d \n",i,j,((TH2D*)map[iSM])->GetBinContent(i, j));
139
140 if(((TH2D*)map[iSM])->GetBinContent(i, j)==AliCaloCalibPedestal::kDead)
141 ndead++;
142 }
143 }
144 printf("--- dead %d\n",ndead);
145 cMap->cd(iSM);
146 (TH2D*)map[iSM])->Draw("lego2");
147 }
148
149 printf("Total DEAD %d\n", caloped->GetDeadTowerCount());
150
151}