4 #include <TInterpreter.h>
10 #include "AliFMDAnalysisTaskBackgroundCorrection.h"
11 #include "AliAnalysisManager.h"
12 #include "AliESDFMD.h"
13 #include "AliESDEvent.h"
14 #include "AliAODEvent.h"
15 #include "AliAODHandler.h"
16 #include "AliMCEventHandler.h"
19 #include "AliESDVertex.h"
21 #include "AliFMDAnaParameters.h"
22 //#include "AliFMDGeometry.h"
24 ClassImp(AliFMDAnalysisTaskBackgroundCorrection)
27 AliFMDAnalysisTaskBackgroundCorrection::AliFMDAnalysisTaskBackgroundCorrection()
35 fOutputVertexString(0)
37 // Default constructor
38 DefineInput (0, TList::Class());
39 DefineOutput(0, TList::Class());
42 //_____________________________________________________________________
43 AliFMDAnalysisTaskBackgroundCorrection::AliFMDAnalysisTaskBackgroundCorrection(const char* name, Bool_t SE):
44 AliAnalysisTask(name, "Density"),
52 fOutputVertexString(0)
56 DefineInput (0, TList::Class());
57 DefineOutput(0, TList::Class());
60 //_____________________________________________________________________
61 void AliFMDAnalysisTaskBackgroundCorrection::CreateOutputObjects()
63 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
66 fOutputList = new TList();
67 fOutputList->SetName("BackgroundCorrectedPerEvent");
69 fHitList = new TList();
70 fHitList->SetName("HitsList");
73 fOutputVertexString = new TObjString();
75 fOutputList->Add(fOutputVertexString);
81 Int_t nVtxbins = pars->GetNvtxBins();
83 for(Int_t det =1; det<=3;det++)
85 Int_t nRings = (det==1 ? 1 : 2);
86 for(Int_t ring = 0;ring<nRings;ring++)
88 Char_t ringChar = (ring == 0 ? 'I' : 'O');
89 Int_t nSec = (ring == 0 ? 20 : 40);
91 for(Int_t i = 0; i< nVtxbins; i++) {
92 TH2F* hBg = pars->GetBackgroundCorrection(det, ringChar, i);
93 hMult = new TH2F(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,i),Form("mult_FMD%d%c_vtxbin%d",det,ringChar,i),
95 hBg->GetXaxis()->GetXmin(),
96 hBg->GetXaxis()->GetXmax(),
97 nSec, 0, 2*TMath::Pi());
99 fOutputList->Add(hMult);
100 hHits = new TH2F(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i),Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i),
102 hBg->GetXaxis()->GetXmin(),
103 hBg->GetXaxis()->GetXmax(),
104 nSec, 0, 2*TMath::Pi());
107 fHitList->Add(hHits);
108 fOutputList->Add(hHits);
117 //_____________________________________________________________________
118 void AliFMDAnalysisTaskBackgroundCorrection::ConnectInputData(Option_t */*option*/)
121 fInputList = (TList*)GetInputData(0);
125 //_____________________________________________________________________
126 void AliFMDAnalysisTaskBackgroundCorrection::Exec(Option_t */*option*/)
128 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
130 fVertexString = (TObjString*)fInputList->At(0);
132 Int_t vtxbin = fVertexString->GetString().Atoi();
133 fOutputVertexString->SetString(Form("%d",vtxbin));
135 fNevents.Fill(vtxbin);
137 for(UShort_t det=1;det<=3;det++) {
138 Int_t nRings = (det==1 ? 1 : 2);
139 for (UShort_t ir = 0; ir < nRings; ir++) {
140 Char_t ringChar = (ir == 0 ? 'I' : 'O');
141 TH2F* hMult = (TH2F*)fOutputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
149 for(UShort_t det=1;det<=3;det++) {
151 Int_t nRings = (det==1 ? 1 : 2);
152 for (UShort_t ir = 0; ir < nRings; ir++) {
153 Char_t ringChar = (ir == 0 ? 'I' : 'O');
155 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
157 TH2F* hMultInput = (TH2F*)fInputList->FindObject(Form("FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
158 TH2F* hHits = (TH2F*)fOutputList->FindObject(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
160 if(pars->GetProcessHits())
161 hHits->Add(hMultInput);
163 TH2F* hBg = pars->GetBackgroundCorrection(det, ringChar, vtxbin);
165 hMultTotal->Add(hMultInput);
167 hMultTotal->Divide(hBg);//,"B");
168 /*for(Int_t i = 1; i<=hTmp->GetNbinsX();i++) {
169 for(Int_t j = 1; j<=hTmp->GetNbinsY();j++) {
170 Float_t mult = hTmp->GetBinContent(i,j);
171 if(mult == 0) continue;
172 Float_t correction = hBg->GetBinContent(i,j);
174 Float_t multcor = mult;
176 multcor = multcor/correction;
178 std::cout<<"Warning! No correction for bin "<<i<<" , "<<j<<std::endl;
180 hTmp->SetBinContent(i,j,multcor);
186 PostData(0, fOutputList);
190 //_____________________________________________________________________
191 void AliFMDAnalysisTaskBackgroundCorrection::Terminate(Option_t */*option*/) {
192 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
194 Int_t nVtxbins = pars->GetNvtxBins();
196 for(UShort_t det=1;det<=3;det++) {
197 Int_t nRings = (det==1 ? 1 : 2);
198 for (UShort_t ir = 0; ir < nRings; ir++) {
199 Char_t ringChar = (ir == 0 ? 'I' : 'O');
200 for(Int_t i =0; i<nVtxbins; i++) {
201 TH2F* hHits = (TH2F*)fOutputList->FindObject(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i));
202 TH1D* hHitsproj = hHits->ProjectionX(Form("hits_FMD%d%c_vtxbin%d_proj",det,ringChar,i),1,hHits->GetNbinsY());
203 fHitList->Add(hHitsproj);
209 //_____________________________________________________________________