1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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'.
21 * Revision 1.1 2007/08/08 15:58:01 hristov
25 //_________________________________________________________________________
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
31 //*-- Author: Aleksei Pavlinov (WSU, Detroit, USA)
33 #include "AliEMCALCalibCoefs.h"
36 #include "AliEMCALCalibData.h"
37 #include "AliCDBMetaData.h"
39 #include "AliCDBEntry.h"
40 #include "AliCDBManager.h"
41 #include "AliCDBStorage.h"
42 #include "AliEMCALGeometry.h"
47 ClassImp(AliEMCALCalibCoef)
49 AliEMCALCalibCoef::AliEMCALCalibCoef() : fAbsId(-1), fCc(-1), fECc(-1)
51 // default constructor
53 AliEMCALCalibCoef::AliEMCALCalibCoef(const Int_t id, const Double_t c, const Double_t ec) :
54 fAbsId(id), fCc(c), fECc(ec)
58 // ----------------------------------------------------------------------
60 ClassImp(AliEMCALCalibCoefs)
62 AliEMCALCalibCoefs::AliEMCALCalibCoefs() : TNamed("",""), fTable(0), fCurrentInd(0), fCalibMethod(0)
64 // default constructor
67 AliEMCALCalibCoefs::AliEMCALCalibCoefs(const char* name, const Int_t nrow) : TNamed(name,"table of cell information") , fTable(0), fCurrentInd(0), fCalibMethod(0)
70 fTable = new TObjArray(nrow);
73 void AliEMCALCalibCoefs::AddAt(AliEMCALCalibCoef* r)
76 (*fTable)[fCurrentInd] = new AliEMCALCalibCoef(*r);
80 AliEMCALCalibCoefs::~AliEMCALCalibCoefs()
89 AliEMCALCalibCoef* AliEMCALCalibCoefs::GetTable(Int_t i) const
92 return (AliEMCALCalibCoef*)fTable->At(i);
96 // Get initial Calib Data from DB
97 AliEMCALCalibCoefs* AliEMCALCalibCoefs::GetCalibTableFromDb(const char *tn, AliEMCALCalibData **calData)
100 // See ~/macros/ALICE/sim.C for choice of CDB
101 // Get calib. table which was used than calculated rec.points
103 static char *calibType = "EMCAL/Calib/*";
104 static char *calibTypeData = "EMCAL/Calib/Data";
108 AliCDBManager* man = AliCDBManager::Instance();
109 AliCDBStorage* specificStorage = man->GetSpecificStorage(calibType);
111 AliEMCALCalibData* caldata = (AliEMCALCalibData*)
112 specificStorage->Get(calibTypeData, gAlice->GetRunNumber())->GetObject();
113 if(caldata == 0) return 0;
115 AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
117 AliEMCALCalibCoefs *tab = new AliEMCALCalibCoefs(tn,g->GetNCells());
118 tab->SetCalibMethod(AliEMCALCalibCoefs::kMC);
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);
127 r.fCc = caldata->GetADCchannel(nSupMod, ietaCell, iphiCell); // column(ietaCell) : row(iphiCell)
133 tab->SetCalibMethod(AliEMCALCalibCoefs::kPI0);
134 calData[0] = caldata;
136 printf("\n <I> AliEMCALCalibCoefs::GetCalibTableFromDb \n name |%s| title |%s| | storage |%s|\n",
137 caldata->GetName(), caldata->GetTitle(), specificStorage->GetURI().Data());
142 TH1F* AliEMCALCalibCoefs::GetHistOfCalibTableFromDb(const char *tn)
145 AliEMCALCalibData *calData[1]; // unused here
147 AliEMCALCalibCoefs* tab = GetCalibTableFromDb(tn, calData);
150 TH1F *h = new TH1F("hCCfirst", " fCc first (in MeV)", 70, 12., 19.);
151 AliEMCALCalibCoef *r;
152 for(Int_t i=0; i<tab->GetSize(); i++){
153 r = tab->GetTable(i);
155 h->Fill(r->fCc*1000.); // GEV ->MeV
161 AliEMCALCalibData* AliEMCALCalibCoefs::GetCalibTableForDb(const AliEMCALCalibCoefs *tab, const char* dbLocation,
164 // See EMCAL/macros/CalibrationDB/AliEMCALSetCDB.C
165 // Define and save to CDB
166 printf("<I> AliEMCALCalibCoefs::GetCalibTableForDb started \n");
167 AliEMCALCalibData* caldata=0;
168 if(tab==0) return caldata;
172 Int_t beamPeriod = 1;
173 char* objFormat = "";
174 caldata = new AliEMCALCalibData("EMCAL");
175 caldata->SetTitle(coment);
177 AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
179 for(int id=0; id<tab->GetSize(); id++){
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);
186 AliEMCALCalibCoef *r = tab->GetTable(id);
187 // ietaCell - column; iphiCell - row
188 caldata->SetADCchannel (nSupMod, ietaCell, iphiCell, r->fCc);
189 caldata->SetADCpedestal(nSupMod, ietaCell, iphiCell, ped);
191 printf("<I> Fill AliEMCALCalibData table \n");
192 //Store calibration data into database
195 md.SetComment(objFormat);
196 md.SetBeamPeriod(beamPeriod);
197 md.SetResponsible("Aleksei Pavlinov");
199 AliCDBManager* man = AliCDBManager::Instance();
201 printf("<E> AliEMCALCalibCoefs::GetCalibTableForDb : define AliCDBManager, NO saving !! \n");
203 printf("<I> AliCDBManager %p \n", man);
204 AliCDBId id("EMCAL/Calib/Data",firstRun,lastRun); // create in EMCAL/Calib/Data DBFolder
205 TString dBFolder(dbLocation);
206 AliCDBStorage* loc = man->GetStorage(dBFolder.Data());
207 loc->Put(caldata, id, &md);
213 AliEMCALCalibCoef *AliEMCALCalibCoefs::GetRow(const int absId)
216 AliEMCALCalibCoef *r=0;
217 for(int id=0; id<fTable->GetSize(); id++){
219 if(r->fAbsId == absId) return r;
224 void AliEMCALCalibCoefs::PrintTable()
227 printf(" Table : %s : nrows %i \n", GetName(), int(fTable->GetSize()));
228 for(int i=0; i<fTable->GetSize(); i++) PrintTable(i);
231 void AliEMCALCalibCoefs::PrintTable(const Int_t i)
234 if(i>=fTable->GetSize()) return;
235 printf("row %i \n", i);
236 PrintRec(GetTable(i));
239 void AliEMCALCalibCoefs::PrintRec(AliEMCALCalibCoef* r)
243 printf(" abs Id %5.5i fCc %7.6f fECc %7.6f \n", r->fAbsId, r->fCc, r->fECc);