Move pio calibration staff to directiry Calib;
[u/mrichter/AliRoot.git] / EMCAL / Calib / AliEMCALSuperModule.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
0fc11500 16/*
37890aaf 17$Log$
76321f61 18Revision 1.3 2007/11/14 15:34:05 gustavo
19Coding violations corrected
20
37890aaf 21Revision 1.2 2007/09/11 19:38:15 pavlinov
22added pi0 calibration, linearity, shower profile
23
0fc11500 24*/
16d3c94d 25
26//_________________________________________________________________________
27// Top EMCAL folder which will keep all information about EMCAL itself,
28// super Modules (SM), modules, towers, set of hists and so on.
0fc11500 29// TObjectSet -> TFolder; Sep 6, 2007
16d3c94d 30//
37890aaf 31//
32//
16d3c94d 33//*-- Author: Aleksei Pavlinov (WSU, Detroit, USA)
34
35#include "AliEMCALSuperModule.h"
36#include "AliEMCALFolder.h"
37#include "AliEMCALCell.h"
38#include "AliEMCALHistoUtilities.h"
39
40#include <TROOT.h>
41#include <TStyle.h>
42#include <TList.h>
43#include <TH1.h>
44#include <TF1.h>
45#include <TCanvas.h>
46#include <TLegend.h>
47#include <TLegendEntry.h>
48
49typedef AliEMCALHistoUtilities u;
50
51ClassImp(AliEMCALSuperModule)
52
0fc11500 53AliEMCALSuperModule::AliEMCALSuperModule() : TFolder()
54, fParent(0),fLh(0),fSMNumber(0)
16d3c94d 55{
37890aaf 56 //default ctor
16d3c94d 57}
58
59AliEMCALSuperModule::AliEMCALSuperModule(const Int_t m, const char* title) :
0fc11500 60TFolder(Form("SM%2.2i",m), title)
61, fParent(0),fLh(0),fSMNumber(m)
62{
37890aaf 63 //ctor
64}
65
66AliEMCALSuperModule::AliEMCALSuperModule(const AliEMCALSuperModule &sm) :
67TFolder(), fParent(sm.fParent),fLh(sm.fLh),fSMNumber(sm.fSMNumber)
68{
69 //copy ctor
70}
71
72AliEMCALSuperModule & AliEMCALSuperModule::operator =(const AliEMCALSuperModule &sm)
73{
74 // assignment operator
75// if(this == &sm)return *this;
76// ((TObject *)this)->operator=(sm);
77
78 fParent = sm.fParent;
79 fLh = sm.fLh;
80 fSMNumber = sm.fSMNumber;
76321f61 81 return *this;
16d3c94d 82}
83
84AliEMCALSuperModule::~AliEMCALSuperModule()
85{
86 // dtor
87}
88
89void AliEMCALSuperModule::Init()
90{
37890aaf 91 //Initialization method
92
0fc11500 93 if(GetHists()==0) {
94 fLh = BookHists();
95 Add(fLh);
96 }
16d3c94d 97}
98
99void AliEMCALSuperModule::AddCellToEtaRow(AliEMCALCell *cell, const Int_t etaRow)
100{
37890aaf 101 //Adds cells to corresponding Super module Eta Row
0fc11500 102 static TFolder *set;
103 set = dynamic_cast<TFolder*>(FindObject(Form("ETA%2.2i",etaRow)));
16d3c94d 104 if(set==0) {
0fc11500 105 set = new TFolder(Form("ETA%2.2i",etaRow),"eta row");
16d3c94d 106 Add(set);
107 }
108 set->Add(cell);
109}
110
111void AliEMCALSuperModule::FitForAllCells()
112{
37890aaf 113 //Fit histograms of each cell
114
16d3c94d 115 Int_t ncells=0;
116 for(int eta=0; eta<48; eta++) { // eta row
0fc11500 117 TFolder *setEta = dynamic_cast<TFolder*>(FindObject(Form("ETA%2.2i",eta)));
16d3c94d 118 if(setEta) {
0fc11500 119 TList* l = (TList*)setEta->GetListOfFolders();
120 printf(" eta %i : %s : cells %i \n", eta, setEta->GetName(), l->GetSize());
121 for(int phi=0; phi<l->GetSize(); phi++) { // cycle on cells (phi directions)
122 AliEMCALCell* cell = dynamic_cast<AliEMCALCell*>(l->At(phi));
123 if(cell == 0) continue;
124
16d3c94d 125 cell->FitEffMassHist();
126
127 u::FillH1(GetHists(), 1, cell->GetCcIn()*1.e+3);
128 u::FillH1(GetHists(), 2, cell->GetCcOut()*1.e+3);
129
130 TF1 *f = cell->GetFunction();
131 u::FillH1(GetHists(), 3, f->GetParameter(1));
132 u::FillH1(GetHists(), 4, f->GetParameter(2));
133 u::FillH1(GetHists(), 5, f->GetChisquare()/f->GetNDF());
134 u::FillH1(GetHists(), 6, f->GetParameter(0));
135
136 ncells++;
137 }
138 }
139 }
140 printf(" <I> AliEMCALSuperModule::FitForAllCells() : ncells %i with fit \n", ncells);
141}
142
143void AliEMCALSuperModule::FitEffMassHist()
144{
37890aaf 145 //Fit effective mass histogram
16d3c94d 146 TH1* h = (TH1*)GetHists()->At(0);
147 AliEMCALCell::FitHist(h, GetName());
148}
149
150
151void AliEMCALSuperModule::PrintInfo()
152{
37890aaf 153 //Print
16d3c94d 154 printf(" Super Module : %s : %i \n", GetName(), fSMNumber);
155 printf(" # of active cells %i \n", GetNumberOfCells());
156 TH1* h = (TH1*)GetHists()->At(0);
157 printf(" # h->Integral() of eff.mass hist %i \n", int(h->Integral()));
158}
159
160void AliEMCALSuperModule::DrawCC(int iopt)
161{
37890aaf 162 //Draw different cell histograms
16d3c94d 163 TCanvas *c=0;
164 if(iopt==1) c = new TCanvas("ccInOut","ccInOut");
165
166 gStyle->SetOptStat(0);
167
168 TH1 *hCCIn = (TH1*)GetHists()->At(1);
169 TH1 *hCCOut = (TH1*)GetHists()->At(2);
170
0fc11500 171 if(hCCIn == 0) return;
172 if(hCCIn->GetEntries()<10.) return;
173
16d3c94d 174 hCCIn->SetStats(kFALSE);
175 hCCOut->SetStats(kFALSE);
0fc11500 176 hCCOut->SetTitle("CC in and out; Iter 1; Jul 26; All Statistics");
16d3c94d 177 hCCOut->SetXTitle("cc in MeV");
178 hCCOut->SetYTitle(" N ");
179
180 u::DrawHist(hCCOut,2);
181 hCCOut->SetAxisRange(10., 24.);
182 u::DrawHist(hCCIn,2, kRed, "same");
183
184 TLegend *leg = new TLegend(0.5,0.36, 0.97,0.80);
185 TLegendEntry *leIn = leg->AddEntry(hCCIn, Form("input cc : %6.2f #pm %6.2f", hCCIn->GetMean(),hCCIn->GetRMS()), "L");
186 leIn->SetTextColor(hCCIn->GetLineColor());
0fc11500 187
188 if(hCCOut->GetEntries()>10.)
16d3c94d 189 leg->AddEntry(hCCOut, Form("output cc : %6.2f #pm %6.2f", hCCOut->GetMean(),hCCOut->GetRMS()), "L");
0fc11500 190
16d3c94d 191 leg->Draw();
192
193 if(c) c->Update();
194}
195
196Int_t AliEMCALSuperModule::GetNumberOfCells()
197{
37890aaf 198 //Returns number of cells in SM
16d3c94d 199 Int_t ncells=0;
0fc11500 200 TList* l = (TList*)GetListOfFolders();
201 for(int eta=0; eta<l->GetSize(); eta++) { // cycle on eta row
202 TFolder *setEta = dynamic_cast<TFolder*>(l->At(eta));
203 if(setEta==0) continue;
204
205 TList* le = (TList*)setEta->GetListOfFolders();
206 ncells += le->GetSize();
16d3c94d 207 }
208 return ncells;
209}
210
211TList* AliEMCALSuperModule::BookHists()
212{
37890aaf 213 //Initializes histograms
214
16d3c94d 215 gROOT->cd();
216 TH1::AddDirectory(1);
217
37890aaf 218 AliEMCALFolder* emcal = (AliEMCALFolder*)GetParent();
219 Int_t it = emcal->GetIterationNumber();
16d3c94d 220
221 new TH1F("00_EffMass", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.98 MeV) ", 250,0.0,0.5);
222 new TH1F("01_CCInput", "input CC dist.(MEV) ", 200, 5., 25.);
223 new TH1F("02_CCOutput", "output CC dist.(MEV) ", 200, 5., 25.);
224 new TH1F("03_MPI0", "mass of #pi_{0} dist. ", 170, 0.05, 0.22);
225 new TH1F("04_RESPI0", "resolution at #pi_{0} dist. ", 50, 0.0, 0.05);
226 new TH1F("05_XI2/NDF", "#chi^{2} / ndf", 50, 0.0, 5.0);
227 new TH1F("06_NPI0", "number of #pi_{0}", 150, 0.0, 1500.);
228
229 TList *l = AliEMCALHistoUtilities::MoveHistsToList(Form("HistsOfSM_%2.2i",fSMNumber), kFALSE);
230 AliEMCALHistoUtilities::AddToNameAndTitleToList(l, Form("_%2.2i_It%i",fSMNumber, it),
231 Form(" SM %2.2i, Iter %i",fSMNumber, it));
232
233 TH1::AddDirectory(0);
234 return l;
235}