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 TH2F* hHitsNoCuts = 0;
82 Int_t nVtxbins = pars->GetNvtxBins();
84 for(Int_t det =1; det<=3;det++)
86 Int_t nRings = (det==1 ? 1 : 2);
87 for(Int_t ring = 0;ring<nRings;ring++)
89 Char_t ringChar = (ring == 0 ? 'I' : 'O');
90 Int_t nSec = (ring == 0 ? 20 : 40);
92 for(Int_t i = 0; i< nVtxbins; i++) {
93 TH2F* hBg = pars->GetBackgroundCorrection(det, ringChar, i);
94 hMult = new TH2F(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,i),Form("mult_FMD%d%c_vtxbin%d",det,ringChar,i),
96 hBg->GetXaxis()->GetXmin(),
97 hBg->GetXaxis()->GetXmax(),
98 nSec, 0, 2*TMath::Pi());
100 fOutputList->Add(hMult);
101 hHits = new TH2F(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i),Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i),
103 hBg->GetXaxis()->GetXmin(),
104 hBg->GetXaxis()->GetXmax(),
105 nSec, 0, 2*TMath::Pi());
107 /* hHitsNoCuts = new TH2F(Form("hits_NoCuts_FMD%d%c_vtxbin%d",det,ringChar,i),Form("hits_NoCuts_FMD%d%c_vtxbin%d",det,ringChar,i),
109 hBg->GetXaxis()->GetXmin(),
110 hBg->GetXaxis()->GetXmax(),
111 nSec, 0, 2*TMath::Pi());
115 //hHitsNoCuts->Sumw2();
117 fHitList->Add(hHits);
118 fOutputList->Add(hHits);
119 // fHitList->Add(hHitsNoCuts);
120 // fOutputList->Add(hHitsNoCuts);
129 //_____________________________________________________________________
130 void AliFMDAnalysisTaskBackgroundCorrection::ConnectInputData(Option_t */*option*/)
133 fInputList = (TList*)GetInputData(0);
137 //_____________________________________________________________________
138 void AliFMDAnalysisTaskBackgroundCorrection::Exec(Option_t */*option*/)
140 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
142 fVertexString = (TObjString*)fInputList->At(0);
144 Int_t vtxbin = fVertexString->GetString().Atoi();
145 fOutputVertexString->SetString(Form("%d",vtxbin));
147 fNevents.Fill(vtxbin);
149 for(UShort_t det=1;det<=3;det++) {
150 Int_t nRings = (det==1 ? 1 : 2);
151 for (UShort_t ir = 0; ir < nRings; ir++) {
152 Char_t ringChar = (ir == 0 ? 'I' : 'O');
153 TH2F* hMult = (TH2F*)fOutputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
161 for(UShort_t det=1;det<=3;det++) {
163 Int_t nRings = (det==1 ? 1 : 2);
164 for (UShort_t ir = 0; ir < nRings; ir++) {
165 Char_t ringChar = (ir == 0 ? 'I' : 'O');
167 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
169 TH2F* hMultInput = (TH2F*)fInputList->FindObject(Form("FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
170 TH2F* hHits = (TH2F*)fOutputList->FindObject(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
172 if(pars->GetProcessHits())
173 hHits->Add(hMultInput);
175 TH2F* hBg = pars->GetBackgroundCorrection(det, ringChar, vtxbin);
177 hMultTotal->Add(hMultInput);
179 hMultTotal->Divide(hBg);//,"B");
180 /*for(Int_t i = 1; i<=hTmp->GetNbinsX();i++) {
181 for(Int_t j = 1; j<=hTmp->GetNbinsY();j++) {
182 Float_t mult = hTmp->GetBinContent(i,j);
183 if(mult == 0) continue;
184 Float_t correction = hBg->GetBinContent(i,j);
186 Float_t multcor = mult;
188 multcor = multcor/correction;
190 std::cout<<"Warning! No correction for bin "<<i<<" , "<<j<<std::endl;
192 hTmp->SetBinContent(i,j,multcor);
198 PostData(0, fOutputList);
202 //_____________________________________________________________________
203 void AliFMDAnalysisTaskBackgroundCorrection::Terminate(Option_t */*option*/) {
204 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
206 Int_t nVtxbins = pars->GetNvtxBins();
208 for(UShort_t det=1;det<=3;det++) {
209 Int_t nRings = (det==1 ? 1 : 2);
210 for (UShort_t ir = 0; ir < nRings; ir++) {
211 Char_t ringChar = (ir == 0 ? 'I' : 'O');
212 for(Int_t i =0; i<nVtxbins; i++) {
213 TH2F* hHits = (TH2F*)fOutputList->FindObject(Form("hits_FMD%d%c_vtxbin%d",det,ringChar,i));
214 TH1D* hHitsproj = hHits->ProjectionX(Form("hits_FMD%d%c_vtxbin%d_proj",det,ringChar,i),1,hHits->GetNbinsY());
215 TH1D* hHitsNoCuts = (TH1D*)hHitsproj->Clone(Form("hits_NoCuts_FMD%d%c_vtxbin%d_proj",det,ringChar,i));
217 hHitsNoCuts->Scale(1/pars->GetEventSelectionEfficiency(i));
218 fHitList->Add(hHitsproj);
219 fHitList->Add(hHitsNoCuts);
225 //_____________________________________________________________________