]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALCalibCoefs.cxx
Temporary disable the raw version, it will be taken from FEE
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibCoefs.cxx
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
16 /* $Log$ */
17
18 //_________________________________________________________________________
19 //    Calibration coefficients
20 //
21 //*-- Author: Aleksei Pavlinov (WSU, Detroit, USA) 
22
23 #include "AliEMCALCalibCoefs.h"
24
25 #include "AliRun.h"
26 #include "AliEMCALCalibData.h"
27 #include "AliCDBMetaData.h"
28 #include "AliCDBId.h"
29 #include "AliCDBEntry.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBStorage.h"
32 #include "AliEMCALGeometry.h"
33
34 #include "TH1F.h"
35
36 TableClassImpl(AliEMCALCalibCoefs,calibCoef)
37
38 // Get initial Calib Data from DB
39 AliEMCALCalibCoefs* AliEMCALCalibCoefs::GetCalibTableFromDb(const char *tn)
40 {
41   // Initial cc with decalibration
42   char* dbString  = "local:///data/r22b/ALICE/PROD/CALIBRATION_May_2007/PI0/PDSF/10GEV/DECALIB/DeCalibDB"; 
43   AliEMCALCalibData* caldata = (AliEMCALCalibData*)
44     (AliCDBManager::Instance()->GetStorage(dbString)
45      ->Get("EMCAL/Calib/Data",gAlice->GetRunNumber())->GetObject());
46   if(caldata == 0) return 0;
47
48   AliEMCALCalibCoefs *tab = new  AliEMCALCalibCoefs(tn);
49   tab->SetCalibMethod(AliEMCALCalibCoefs::kMC);
50
51   AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
52   for(Int_t id=0; id<g->GetNCells(); id++){
53     Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0, iphiCell=0, ietaCell=0;
54     g->GetCellIndex(id, nSupMod, nModule, nIphi, nIeta);
55     g->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphiCell, ietaCell);
56
57     calibCoef r;
58     r.absId = id;
59     r.cc    = caldata->GetADCchannel(nSupMod, ietaCell, iphiCell);
60     r.eCc   = 0.0;
61
62     tab->AddAt(&r);
63   }
64   tab->Purge();
65   tab->SetCalibMethod(AliEMCALCalibCoefs::kPI0);
66
67   return tab;
68 }
69
70 TH1F* AliEMCALCalibCoefs::GetHistOfCalibTableFromDb(const char *tn)
71 {
72   // First SM only
73   AliEMCALGeometry *g = AliEMCALGeometry::GetInstance("");
74
75   AliEMCALCalibCoefs* tab = GetCalibTableFromDb(tn);
76   if(tab==0) return 0;
77
78   TH1F *h = new TH1F("hCCfirst", " cc first  (in MeV)", 70, 12., 19.);
79   calibCoef *r;
80   for(Int_t i=0; i<tab->GetNRows(); i++){
81     r = tab->GetTable(i);
82     if(i>=1152) break;
83     h->Fill(r->cc*1000.); 
84   }
85   delete tab;
86   return h;
87 }
88
89 calibCoef *AliEMCALCalibCoefs::GetRow(const int absId)
90 {
91   calibCoef *r=0;
92   for(int id=0; id<GetNRows(); id++){
93     r = GetTable(id);
94     if(r->absId == absId) return r;
95   }
96   return 0;
97 }
98
99 void AliEMCALCalibCoefs::PrintTable()
100 {
101   printf(" Table : %s : nrows %i \n", GetName(), int(GetNRows()));
102   for(int i=0; i<GetNRows(); i++) PrintTable(i);
103 }
104
105 void AliEMCALCalibCoefs::PrintTable(const Int_t i)
106 {
107   if(i>=GetNRows()) return;
108   printf("row %i \n", i);
109   PrintRec(GetTable(i));
110 }
111
112 void AliEMCALCalibCoefs::PrintRec(calibCoef* r)
113 {
114   if(r==0) return;
115   printf(" abs Id %5.5i cc %7.6f eCc %7.6f \n", r->absId, r->cc, r->eCc);
116 }