]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALCell.cxx
removed static from variable declaration in AliEMCALGeometry::GetPhiCenterOfSM
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCell.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 /*
17 $Log$
18 Revision 1.3  2007/09/12 17:44:22  pavlinov
19 fixed compilation problem under SuSe Linux
20
21 Revision 1.2  2007/09/11 19:38:15  pavlinov
22 added pi0 calibration, linearity, shower profile
23
24 */ 
25
26 //_________________________________________________________________________
27 // Cell folder which will keep all information 
28 // about cell(tower) itself
29 // Initial version was created with TDataSet staf
30 // TObjectSet -> TFolder; Sep 6, 2007
31 //
32 //*-- Author: Aleksei Pavlinov (WSU, Detroit, USA) 
33
34 #include "AliEMCALCell.h"
35 #include "AliEMCALHistoUtilities.h"
36 #include "AliEMCALGeometry.h"
37 #include "AliEMCALFolder.h"
38 #include "AliEMCALSuperModule.h"
39 #include "AliEMCALCalibData.h"
40 #include "AliEMCALRecPointsQaESDSelector.h"
41 #include "AliEMCALCalibCoefs.h"
42
43 #include <cassert>
44
45 #include <TROOT.h>
46 #include <TStyle.h>
47 #include <TList.h>
48 #include <TH1.h>
49 #include <TF1.h>
50 #include <TNtuple.h>
51
52 typedef  AliEMCALHistoUtilities u;
53
54 ClassImp(AliEMCALCell)
55
56 AliEMCALCell::AliEMCALCell() : 
57 TFolder(), 
58  fParent(0),fLh(0),
59 fAbsId(0),fSupMod(0),fModule(0),fPhi(0),fEta(0),fPhiCell(0),fEtaCell(0),fCcIn(0),fCcOut(0),
60 fFun(0)
61 {
62 }
63
64 AliEMCALCell::AliEMCALCell(const Int_t absId, const char* title) : 
65   TFolder(Form("Cell%4.4i",absId),title), 
66  fParent(0),fLh(0),
67 fAbsId(absId),fSupMod(0),fModule(0),fPhi(0),fEta(0),fPhiCell(0),fEtaCell(0),fCcIn(0),fCcOut(0),
68 fFun(0)
69 {
70   // Oct 15, 2007  
71   AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
72   g->GetCellIndex(fAbsId, fSupMod, fModule, fPhi, fEta);
73   g->GetCellPhiEtaIndexInSModule(fSupMod, fModule, fPhi, fEta, fPhiCell, fEtaCell);
74
75
76
77 AliEMCALCell::~AliEMCALCell()
78 {
79   // dtor
80 }
81 //-------------------------------------------------------------------------------------
82
83 void AliEMCALCell::SetCCfromDB(AliEMCALCalibData *ccDb)
84 {
85   // Oct 15, 2007
86   if(ccDb == 0) return;
87   // fADCchannelEC = fCalibData->GetADCchannel(iSupMod,ieta,iphi);
88   // fetaCel-column; fPhiCell- row
89   fCcIn = ccDb->GetADCchannel(fSupMod, fEtaCell, fPhiCell); // in GeV
90
91   TH1* h = (TH1*)GetHists()->At(0);
92   u::AddToNameAndTitle(h, 0, Form(", cc %5.2f MeV", fCcIn*1.e+3));
93 }
94
95 void AliEMCALCell::SetCCfromCCTable(AliEMCALCalibCoefs *t)
96 {
97   // Oct 15, 2007
98   if(t == 0) return;
99
100   if(fLh == 0) {
101     fLh = BookHists();
102     Add(fLh);
103   }
104
105   AliEMCALCalibCoef *r = t->GetTable(fAbsId);
106   if(r && r->fAbsId == fAbsId) {
107     fCcIn = r->fCc;
108   } else { // something wrong
109     if(r) printf(" fAbsId %i : r->absId %i \n", fAbsId, r->fAbsId);
110     assert(0);
111   }
112
113   TH1* h = (TH1*)GetHists()->At(0);
114   u::AddToNameAndTitle(h, 0, Form(", cc %5.2f MeV", fCcIn*1.e+3));
115 }
116
117 void AliEMCALCell::FillEffMass(const Double_t mgg)
118 {
119   u::FillH1(GetHists(), 0, mgg);
120 }
121
122 void AliEMCALCell::FillCellNtuple(TNtuple *nt)
123 {
124   if(nt==0) return;
125   nt->Fill(fAbsId,fSupMod,fModule,fPhi,fEta,fPhiCell,fEtaCell,fCcIn,fCcOut);
126 }
127
128 void AliEMCALCell::FitHist(TH1* h, const char* name, const char* opt)
129 {
130   // Oct 15, 2007
131   TString optFit(""), sopt(opt);
132   sopt.ToUpper();
133   if(h==0) return; 
134   printf("<I> AliEMCALCell::FitHist : |%s| is started : opt %s\n", h->GetName(), opt);
135   TString tit(h->GetTitle());
136
137   TF1 *gausPol2 = 0, *g=0, *bg=0;
138   if(h->GetListOfFunctions()->GetSize() == 0 || 1) {
139     g = u::Gausi(name, 0.0, 0.4, h); // gaus estimation
140
141     g->SetParLimits(0, h->Integral()/20., h->Integral());
142     g->SetParLimits(1, 0.08, 0.20);
143     g->SetParLimits(2, 0.001, 0.02);
144
145     g->SetParameter(0, 1200.);
146     g->SetParameter(1, h->GetBinLowEdge(h->GetMaximumBin()));
147     g->SetParameter(2, 0.010);
148
149     g->SetLineColor(kRed);
150     g->SetLineWidth(2);
151
152     optFit = "0NQ";
153     h->Fit(g, optFit.Data(),"", 0.001, 0.3);
154
155     optFit = "0NQIME";
156     h->Fit(g, optFit.Data(),"", 0.001, 0.3);
157
158     bg = new TF1(Form("bg%s",name), "pol2", 0.0, 0.3);  
159     optFit = "0NQ";
160     h->Fit(bg, optFit.Data(),"", 0.0, 0.3);
161
162     gausPol2 = u::GausiPol2(name, 0.00, 0.3, g, bg);
163     optFit = "0Q";
164     h->Fit(gausPol2, optFit.Data(),"", 0.03, 0.28);
165   // Clean up
166     delete g;
167     delete bg;
168     optFit = "0IME+"; // no drwaing at all
169     if(tit.Contains("SM") || sopt.Contains("DRAW")) optFit = "IME+";
170   } else {
171     gausPol2 = (TF1*)h->GetListOfFunctions()->At(0);
172     optFit = "IME+";
173     printf("<I> Function is defined alredy : %s optFit %s \n", gausPol2->GetTitle(), optFit.Data());
174   }
175   //  optFit = "IME+";
176   h->Fit(gausPol2, optFit.Data(),"", 0.01, 0.28);
177
178   if(optFit.Contains("0") == 0) {
179     gStyle->SetOptFit(111);
180     u::DrawHist(h,2);
181   }
182   printf("<I> AliEMCALCell::FitHist : |%s| is ended \n\n", h->GetName());
183 }
184
185 void AliEMCALCell::FitEffMassHist(const char* opt)
186 {
187   // Oct 15, 2007
188   static Double_t mPI0  = 0.13498; // mass of pi0
189   static Double_t mPI02 = mPI0*mPI0; // mass**2
190
191   AliEMCALFolder* emcal = AliEMCALRecPointsQaESDSelector::GetEmcalFolder();
192   Int_t it = emcal->GetIterationNumber();
193
194   TH1* h = (TH1*)GetHists()->At(0);
195
196   FitHist(h, GetName(), opt);
197
198   fFun = (TF1*)h->GetListOfFunctions()->At(0);
199   if(fFun) {
200     Double_t mpi = fFun->GetParameter(1), mpi2 = mpi*mpi;
201     Double_t ccTmp = fCcIn * mPI02 / mpi2;
202     if(it<=1) { // Jul 16, 2007
203       fCcOut = ccTmp;
204     } else {
205       fCcOut = (ccTmp + fCcIn)/2.;
206     }
207     printf(" fFun %s | %s : iet %i\n", fFun->GetName(), fFun->GetTitle(), it);
208   }
209   printf(" %s | fCcIn %6.5f -> % 6.5f <- fCcOut \n", GetTitle(), fCcIn , fCcOut);
210 }
211
212 void AliEMCALCell::PrintInfo()
213 {
214   // Oct 15, 2007
215   printf(" %s %s \n", GetName(), GetTitle());
216   if(fLh == 0 ) return;
217   TH1* h = (TH1*)GetHists()->At(0);
218   TF1 *f = (TF1*)h->GetListOfFunctions()->At(0);
219   if(fFun) printf(" fFun : %s | %s \n", fFun->GetName(),  fFun->GetTitle());
220   else fFun = f;
221   // if(f) f->Dump();
222 }
223
224 TList* AliEMCALCell::BookHists()
225 {
226   // Oct 15, 2007
227   gROOT->cd();
228   TH1::AddDirectory(1);
229
230   AliEMCALFolder* emcal = AliEMCALRecPointsQaESDSelector::GetEmcalFolder();
231   Int_t it = emcal->GetIterationNumber();
232
233   new TH1F("01_EffMass", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.98 MeV) ", 60,0.0,0.3);
234
235   TList *l = AliEMCALHistoUtilities::MoveHistsToList(Form("HistsOfCell%4.4i",fAbsId), kFALSE);
236   AliEMCALHistoUtilities::AddToNameAndTitleToList(l, Form("4.4i_It%i",fAbsId,it),
237                                                   Form(" Cell %4.4i, iter. %i",fAbsId, it));
238
239   TH1::AddDirectory(0);
240   return l;
241 }