]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/OADB/CompareAODB_OCDB.C
move macro to new directory
[u/mrichter/AliRoot.git] / EMCAL / macros / OADB / CompareAODB_OCDB.C
CommitLineData
c9120365 1// Compare the contents of the calibration, bad channels, etc in OCDB and AODB
2// You need connexion to the grid to run this macro
3// The OADB file can be in a place different than the default in aliroot
4
5// Author : Gustavo Conesa Balbastre (LPSC-CNRS)
6
7void CompareAODB_OCDB(Int_t run = 146806, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL")
8{
9
10 gSystem->Load("libOADB");
11 TGrid::Connect("alien://");
12
13 AliCDBManager* man = AliCDBManager::Instance();
14 man->SetDefaultStorage("raw://");
15 man->SetRun(run);
16 AliCDBStorage *storage = man->GetDefaultStorage();
17
18 // Instantiate EMCAL geometry for the first time
19
20
21 if (run < 140000) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1");
22 else if(run < 171000) geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
23 else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1");
24
25 CheckBadChannels(run, pathOADB, storage, geom);
26 //CheckEnergyCalibration(run, pathOADB, storage, geom);
27 //CheckTimeCalibration(run, pathOADB, storage, geom);
28
29}
30
31//___________________________
32void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom)
33{
34 // Check energy recalibration, Uncomplete
35
36 AliOADBContainer *contRF=new AliOADBContainer("");
37 contRF->InitFromFile(Form("%s/EMCALRecalib.root",pathOADB.Data()),"AliEMCALRecalib");
38
39 const Int_t nSM = geom->GetNumberOfSuperModules();
40
41 TH2I *h[12];
42
43 TObjArray *recal=(TObjArray*)contRF->GetObject(run);
44 if(recal)
45 {
46 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
47
48 if(recalpass)
49 {
50 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
51
52 if(recalib)
53 {
54 for (Int_t i=0; i < nSM; ++i)
55 {
56 h[i] = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
57 if (!h[i])
58 {
59 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
60 continue;
61 }
62 }
63 }else printf("Energy recalibration OADB not found 1\n");
64 }else printf("Energy recalibration OADB not found 2\n");
65 }else printf("Energy recalibration OADB not found 3\n");
66
67 // TO COMPLETE
68}
69
70//_____________________
71void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom)
72{
73 // Get the OCDB bad channels and compare to the OADB ones
74
75 //const Int_t nSM = static_const (geom->GetNumberOfSuperModules());
76 const Int_t nSM = static_cast<const Int_t> (geom->GetNumberOfSuperModules());
77
78 // Access OCDB histograms
79 AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*) (storage->Get("EMCAL/Calib/Pedestals", run)->GetObject());
80
81 // Access directly the OCDB file and not the latest version
82 //TFile * f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Pedestals/Run145954_146856_v3_s0.root","READ");
83 //AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
84 //AliCaloCalibPedestal * caloped = (AliCaloCalibPedestal *) cdb->GetObject();
85
86 TObjArray map = caloped->GetDeadMap();
87
88 // Access OADB histograms
89 TH2I *hbm[12];
90
91 AliOADBContainer *contBC=new AliOADBContainer("");
92
93 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",pathOADB.Data()),"AliEMCALBadChannels");
94
95 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(run);
96
97 if(arrayBC)
98 {
99 for (Int_t i=0; i < nSM; ++i)
100 {
101 hbm[i]=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
102
103 if (!hbm)
104 {
105 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
106 continue;
107 }
108 }
109 }
110 else
111 {
112 printf("--- Bad map not available \n");
113 return;
114 }
115
116 Int_t badMapOCDB = -1;
117 Int_t badMapAODB = -1;
118 Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
119 for(Int_t i=0;i < nSM*24*48; i++)
120 {
121 //printf("AbsID %d\n",i);
122 geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta);
123 geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol);
124 if(map.At(iSM))badMapOCDB = ((TH2F*)map.At(iSM))->GetBinContent(iCol,iRow);
125 else badMapOCDB = -1;
126 if(hbm[iSM]) badMapAODB = hbm[iSM]->GetBinContent(iCol,iRow);
127 else badMapAODB = -1;
128
129 //if(badMapOCDB>0)
130 if(badMapOCDB!=badMapAODB)
131 printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d OCDB %d, OADB %d\n",
132 i,iCol,iRow,iSM,badMapOCDB, badMapAODB);
133
134 }
135
136}
137
138