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