]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/macros/BadModules/MakeRandomBadChannelMap.C
Removing obsolete scripts
[u/mrichter/AliRoot.git] / PHOS / macros / BadModules / MakeRandomBadChannelMap.C
CommitLineData
856c0dbe 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TH3.h"
3#include "TF1.h"
4#include "TFile.h"
5#include "TLine.h"
6#include "TCanvas.h"
7#include "AliPHOSEmcBadChannelsMap.h"
8#include "AliCDBId.h"
9#include "AliCDBMetaData.h"
10#include "AliCDBEntry.h"
11#include "AliCDBManager.h"
12#endif
13
14void MakeRandomBadChannelMap(const TString modules="3",
15 const Float_t fractionBad=0.02)
16{
17 // Create a random bad channel map for selected modules
18 // with a fraction of bad channel equal to fractionBad
19 // Author Yuri Kharlov
20 // 20.07.2008
21
22 const Int_t nZ=56, nX=64;
23 Int_t module;
24 AliPHOSEmcBadChannelsMap badMap;
25 TH2I *hBadChannels[5];
26 TCanvas *cb[5];
27 gStyle->SetOptStat(10);
28
29 for (Int_t iModule=0; iModule<modules.Length(); iModule++) {
30 const char chMod = modules[iModule];
31 module = atoi(&chMod);
32 if (module<1 || module>5) {
33 printf("Wrong module number %d, can be from 1 to 5\n",module);
34 exit(1);
35 }
36 printf("Creating bad channel map for module %d\n",module);
37
38 hBadChannels[iModule] = new TH2I(Form("hBadChannels%d",module),
39 Form("Bad channels for module %d",module),
40 nZ,1,nZ, nX,1,nX);
41 hBadChannels[iModule]->SetXTitle("z, cells");
42 hBadChannels[iModule]->SetYTitle("x, cells");
43 for(Int_t iZ=1; iZ<=nZ; iZ++){
44 for(Int_t iX=1; iX<=nX; iX++){
45 if (gRandom->Rndm() < fractionBad) {
46 hBadChannels[iModule]->SetBinContent(iZ,iX,1);
47 badMap.SetBadChannel(module,iZ,iX);
48 }
49 }
50 }
51 cb[iModule] = new TCanvas(Form("BadMap%d",module),
52 Form("Bad channels for module %d",module),
53 15+iModule*40,15+iModule*40,500,600) ;
54 cb[iModule]->SetFillColor(kWhite);
55 hBadChannels[iModule]->DrawClone("box") ;
56 }
57
58
59// TFile * fout = new TFile("BadMap.root","recreate") ;
60// hBadMap->Write() ;
61// fout->Close() ;
62
63 // put now result to local CDB
64 AliCDBManager *CDB = AliCDBManager::Instance();
65 CDB->SetDefaultStorage("local://./");
66
67 AliCDBMetaData *md= new AliCDBMetaData();
68 md->SetResponsible("Yuri Kharlov");
69 md->SetComment(Form("Random bad channel map with %.3f bad channels",fractionBad));
70 AliCDBId id("PHOS/Calib/EmcBadChannels",0,999999);
71 CDB->Put(&badMap,id, md);
72
73
74}