]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALCalibCoefs.cxx
fixed code violation (almost)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibCoefs.cxx
CommitLineData
16d3c94d 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
b217491f 16/* $Log$
17/* Revision 1.2 2007/09/11 19:38:15 pavlinov
18/* added pi0 calibration, linearity, shower profile
19/*co: warning: `/* $Log' is obsolescent; use ` * $Log'.
0fc11500 20
21 * Revision 1.1 2007/08/08 15:58:01 hristov
22 * */
23
16d3c94d 24
25//_________________________________________________________________________
b217491f 26// Calibration coefficients
27// The place for holding all information after calibration
28// - not only calibration coefficients.
29// For flash Adc we should keep at least ratio of high/low gains
16d3c94d 30//
31//*-- Author: Aleksei Pavlinov (WSU, Detroit, USA)
32
33#include "AliEMCALCalibCoefs.h"
34
35#include "AliRun.h"
36#include "AliEMCALCalibData.h"
37#include "AliCDBMetaData.h"
38#include "AliCDBId.h"
39#include "AliCDBEntry.h"
40#include "AliCDBManager.h"
41#include "AliCDBStorage.h"
42#include "AliEMCALGeometry.h"
43
44#include "TH1F.h"
0fc11500 45#include <TString.h>
16d3c94d 46
b217491f 47ClassImp(AliEMCALCalibCoef)
16d3c94d 48
b217491f 49AliEMCALCalibCoef::AliEMCALCalibCoef() : fAbsId(-1), fCc(-1), fECc(-1)
50{
51 // default constructor
52}
53AliEMCALCalibCoef::AliEMCALCalibCoef(const Int_t id, const Double_t c, const Double_t ec) :
54fAbsId(id), fCc(c), fECc(ec)
55{
56 // Oct 16, 2007
57}
0fc11500 58// ----------------------------------------------------------------------
59
60ClassImp(AliEMCALCalibCoefs)
61
62AliEMCALCalibCoefs::AliEMCALCalibCoefs() : TNamed("",""), fTable(0), fCurrentInd(0), fCalibMethod(0)
63{
b217491f 64 // default constructor
0fc11500 65}
66
67AliEMCALCalibCoefs::AliEMCALCalibCoefs(const char* name, const Int_t nrow) : TNamed(name,"table of cell information") , fTable(0), fCurrentInd(0), fCalibMethod(0)
68{
b217491f 69 // Oct 16, 2007
0fc11500 70 fTable = new TObjArray(nrow);
71}
72
b217491f 73void AliEMCALCalibCoefs::AddAt(AliEMCALCalibCoef* r)
16d3c94d 74{
b217491f 75 // Oct 16, 2007
76 (*fTable)[fCurrentInd] = new AliEMCALCalibCoef(*r);
0fc11500 77 fCurrentInd++;
78}
79
80AliEMCALCalibCoefs::~AliEMCALCalibCoefs()
81{
b217491f 82 // Destructor
0fc11500 83 if(fTable) {
84 fTable->Delete();
85 delete fTable;
86 }
87}
88
b217491f 89AliEMCALCalibCoef* AliEMCALCalibCoefs::GetTable(Int_t i) const
0fc11500 90{
b217491f 91 // Oct 16, 2007
92 return (AliEMCALCalibCoef*)fTable->At(i);
0fc11500 93}
94
95
96// Get initial Calib Data from DB
97AliEMCALCalibCoefs* AliEMCALCalibCoefs::GetCalibTableFromDb(const char *tn, AliEMCALCalibData **calData)
98{
99 //
100 // See ~/macros/ALICE/sim.C for choice of CDB
101 // Get calib. table which was used than calculated rec.points
102 //
103 static char *calibType = "EMCAL/Calib/*";
104 static char *calibTypeData = "EMCAL/Calib/Data";
105 // Initial cc
106 calData[0] = 0;
107
108 AliCDBManager* man = AliCDBManager::Instance();
109 AliCDBStorage* specificStorage = man->GetSpecificStorage(calibType);
110
16d3c94d 111 AliEMCALCalibData* caldata = (AliEMCALCalibData*)
0fc11500 112 specificStorage->Get(calibTypeData, gAlice->GetRunNumber())->GetObject();
16d3c94d 113 if(caldata == 0) return 0;
114
0fc11500 115 AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
116
117 AliEMCALCalibCoefs *tab = new AliEMCALCalibCoefs(tn,g->GetNCells());
16d3c94d 118 tab->SetCalibMethod(AliEMCALCalibCoefs::kMC);
119
16d3c94d 120 for(Int_t id=0; id<g->GetNCells(); id++){
121 Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0, iphiCell=0, ietaCell=0;
122 g->GetCellIndex(id, nSupMod, nModule, nIphi, nIeta);
123 g->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphiCell, ietaCell);
124
b217491f 125 AliEMCALCalibCoef r;
126 r.fAbsId = id;
127 r.fCc = caldata->GetADCchannel(nSupMod, ietaCell, iphiCell); // column(ietaCell) : row(iphiCell)
128 r.fECc = 0.0;
16d3c94d 129
130 tab->AddAt(&r);
131 }
0fc11500 132 // tab->Purge();
16d3c94d 133 tab->SetCalibMethod(AliEMCALCalibCoefs::kPI0);
0fc11500 134 calData[0] = caldata;
135
136 printf("\n <I> AliEMCALCalibCoefs::GetCalibTableFromDb \n name |%s| title |%s| | storage |%s|\n",
137 caldata->GetName(), caldata->GetTitle(), specificStorage->GetURI().Data());
16d3c94d 138
139 return tab;
140}
141
142TH1F* AliEMCALCalibCoefs::GetHistOfCalibTableFromDb(const char *tn)
143{
144 // First SM only
0fc11500 145 AliEMCALCalibData *calData[1]; // unused here
16d3c94d 146
0fc11500 147 AliEMCALCalibCoefs* tab = GetCalibTableFromDb(tn, calData);
16d3c94d 148 if(tab==0) return 0;
149
b217491f 150 TH1F *h = new TH1F("hCCfirst", " fCc first (in MeV)", 70, 12., 19.);
151 AliEMCALCalibCoef *r;
0fc11500 152 for(Int_t i=0; i<tab->GetSize(); i++){
16d3c94d 153 r = tab->GetTable(i);
154 if(i>=1152) break;
b217491f 155 h->Fill(r->fCc*1000.); // GEV ->MeV
16d3c94d 156 }
157 delete tab;
158 return h;
159}
160
0fc11500 161AliEMCALCalibData* AliEMCALCalibCoefs::GetCalibTableForDb(const AliEMCALCalibCoefs *tab, const char* dbLocation,
162const char* coment)
163{
0fc11500 164 // See EMCAL/macros/CalibrationDB/AliEMCALSetCDB.C
165 // Define and save to CDB
b217491f 166 printf("<I> AliEMCALCalibCoefs::GetCalibTableForDb started \n");
0fc11500 167 AliEMCALCalibData* caldata=0;
168 if(tab==0) return caldata;
169
170 Int_t firstRun = 0;
171 Int_t lastRun = 10;
172 Int_t beamPeriod = 1;
173 char* objFormat = "";
174 caldata = new AliEMCALCalibData("EMCAL");
175 caldata->SetTitle(coment);
176
177 AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
178
179 for(int id=0; id<tab->GetSize(); id++){
180 Float_t ped=0.;
181
182 Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0, iphiCell=0, ietaCell=0;
183 g->GetCellIndex(id, nSupMod, nModule, nIphi, nIeta);
184 g->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphiCell, ietaCell);
185
b217491f 186 AliEMCALCalibCoef *r = tab->GetTable(id);
0fc11500 187 // ietaCell - column; iphiCell - row
b217491f 188 caldata->SetADCchannel (nSupMod, ietaCell, iphiCell, r->fCc);
0fc11500 189 caldata->SetADCpedestal(nSupMod, ietaCell, iphiCell, ped);
190 }
191 printf("<I> Fill AliEMCALCalibData table \n");
192 //Store calibration data into database
193
194 AliCDBMetaData md;
195 md.SetComment(objFormat);
196 md.SetBeamPeriod(beamPeriod);
197 md.SetResponsible("Aleksei Pavlinov");
198
199 AliCDBManager* man = AliCDBManager::Instance();
200 if(man == 0) {
201 printf("<E> AliEMCALCalibCoefs::GetCalibTableForDb : define AliCDBManager, NO saving !! \n");
202 } else {
203 printf("<I> AliCDBManager %p \n", man);
204 AliCDBId id("EMCAL/Calib/Data",firstRun,lastRun); // create in EMCAL/Calib/Data DBFolder
b217491f 205 TString dBFolder(dbLocation);
206 AliCDBStorage* loc = man->GetStorage(dBFolder.Data());
0fc11500 207 loc->Put(caldata, id, &md);
208 }
209
210 return caldata;
211}
212
b217491f 213AliEMCALCalibCoef *AliEMCALCalibCoefs::GetRow(const int absId)
16d3c94d 214{
b217491f 215 // Oct 16, 2007
216 AliEMCALCalibCoef *r=0;
0fc11500 217 for(int id=0; id<fTable->GetSize(); id++){
16d3c94d 218 r = GetTable(id);
b217491f 219 if(r->fAbsId == absId) return r;
16d3c94d 220 }
221 return 0;
222}
223
224void AliEMCALCalibCoefs::PrintTable()
225{
b217491f 226 // Oct 16, 2007
0fc11500 227 printf(" Table : %s : nrows %i \n", GetName(), int(fTable->GetSize()));
228 for(int i=0; i<fTable->GetSize(); i++) PrintTable(i);
16d3c94d 229}
230
231void AliEMCALCalibCoefs::PrintTable(const Int_t i)
232{
b217491f 233 // Oct 16, 2007
0fc11500 234 if(i>=fTable->GetSize()) return;
16d3c94d 235 printf("row %i \n", i);
236 PrintRec(GetTable(i));
237}
238
b217491f 239void AliEMCALCalibCoefs::PrintRec(AliEMCALCalibCoef* r)
16d3c94d 240{
b217491f 241 // Oct 16, 2007
16d3c94d 242 if(r==0) return;
b217491f 243 printf(" abs Id %5.5i fCc %7.6f fECc %7.6f \n", r->fAbsId, r->fCc, r->fECc);
16d3c94d 244}