Introducing the FMD trackreferences in the stepmanager as well as a strip address...
[u/mrichter/AliRoot.git] / FMD / analysis / AliFMDAnalysisTaskDndeta.cxx
CommitLineData
7c3e5162 1
2#include <TROOT.h>
3#include <TSystem.h>
4#include <TInterpreter.h>
5#include <TChain.h>
6#include <TFile.h>
7#include <TList.h>
8#include <iostream>
9#include "TH2F.h"
10#include "AliFMDAnalysisTaskDndeta.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"
17#include "AliStack.h"
18#include "AliLog.h"
19#include "AliESDVertex.h"
20#include "TMath.h"
21#include "AliFMDAnaParameters.h"
22#include "AliFMDGeometry.h"
23
24ClassImp(AliFMDAnalysisTaskDndeta)
25
26
27AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta()
28: fDebug(0),
29 fOutputList(0),
30 fInputList(0),
31 fArray(0),
32 fInputArray(0),
33 fVertexString(0x0),
34 fNevents(),
35 fStandalone(kTRUE)
36{
37 // Default constructor
38 DefineInput (0, TList::Class());
39 DefineOutput(0, TList::Class());
40}
41//_____________________________________________________________________
42AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta(const char* name, Bool_t SE):
43 AliAnalysisTask(name, "Density"),
44 fDebug(0),
45 fOutputList(0),
46 fInputList(0),
47 fArray(),
48 fInputArray(0),
49 fVertexString(0x0),
50 fNevents(),
51 fStandalone(kTRUE)
52{
53 fStandalone = SE;
54 if(fStandalone) {
55 DefineInput (0, TList::Class());
56 DefineInput(1, TObjString::Class());
57 DefineOutput(0, TList::Class());
58
59 }
60}
61//_____________________________________________________________________
62void AliFMDAnalysisTaskDndeta::CreateOutputObjects()
63{
64 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
65
66 fArray.SetName("FMD");
67 fArray.SetOwner();
68
69 if(!fOutputList)
70 fOutputList = new TList();
71 fOutputList->SetName("BackgroundCorrected");
72
73
74 TH2F* hMult = 0;
75
76 Int_t nVtxbins = pars->GetNvtxBins();
77
78 for(Int_t det =1; det<=3;det++)
79 {
80 TObjArray* detArray = new TObjArray();
81 detArray->SetName(Form("FMD%d",det));
82 fArray.AddAtAndExpand(detArray,det);
83 Int_t nRings = (det==1 ? 1 : 2);
84 for(Int_t ring = 0;ring<nRings;ring++)
85 {
86 Char_t ringChar = (ring == 0 ? 'I' : 'O');
87 Int_t nSec = (ring == 0 ? 20 : 40);
88
89 TObjArray* vtxArray = new TObjArray();
90 vtxArray->SetName(Form("FMD%d%c",det,ringChar));
91 detArray->AddAtAndExpand(vtxArray,ring);
92 for(Int_t i = 0; i< nVtxbins; i++) {
93 TH2F* hBg = pars->GetBackgroundCorrection(det, ringChar, i);
94 hMult = new TH2F(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),
95 hBg->GetNbinsX(),
96 hBg->GetXaxis()->GetXmin(),
97 hBg->GetXaxis()->GetXmax(),
98 nSec, 0, 2*TMath::Pi());
99 hMult->Sumw2();
100 fOutputList->Add(hMult);
101 vtxArray->AddAtAndExpand(hMult,i);
102
103 }
104 }
105 }
106
107 fNevents.SetBins(nVtxbins,0,nVtxbins);
108 fNevents.SetName("nEvents");
109 fOutputList->Add(&fNevents);
110
111
112}
113//_____________________________________________________________________
114void AliFMDAnalysisTaskDndeta::ConnectInputData(Option_t */*option*/)
115{
116 if(fStandalone) {
117 fInputList = (TList*)GetInputData(0);
118 fVertexString = (TObjString*)GetInputData(1);
119 }
120}
121//_____________________________________________________________________
122void AliFMDAnalysisTaskDndeta::Exec(Option_t */*option*/)
123{
124 Int_t vtxbin = fVertexString->GetString().Atoi();
125 fNevents.Fill(vtxbin);
126
127 for(UShort_t det=1;det<=3;det++) {
128 //TObjArray* detInputArray = (TObjArray*)fInputArray->At(det);
129 TObjArray* detArray = (TObjArray*)fArray.At(det);
130 Int_t nRings = (det==1 ? 1 : 2);
131 for (UShort_t ir = 0; ir < nRings; ir++) {
132 Char_t ringChar = (ir == 0 ? 'I' : 'O');
133 //TObjArray* vtxInputArray = (TObjArray*)detInputArray->At(ir);
134 TObjArray* vtxArray = (TObjArray*)detArray->At(ir);
135 TH2F* hMultTotal = (TH2F*)vtxArray->At(vtxbin);
136
137
138 TH2F* hMultInput = (TH2F*)fInputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
139 // std::cout<<hMultInput->GetEntries()<<std::endl;
140 hMultTotal->Add(hMultInput);
141
142
143 }
144 }
145 if(fStandalone) {
146 PostData(0, fOutputList);
147 }
148
149}
150//_____________________________________________________________________
151void AliFMDAnalysisTaskDndeta::Terminate(Option_t */*option*/) {
152
153 /*
154 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
155
156 Int_t nVtxbins = pars->GetNvtxBins();
157
158 for(UShort_t det=1;det<=3;det++) {
159 TObjArray* detArray = (TObjArray*)fArray.At(det);
160 Int_t nRings = (det==1 ? 1 : 2);
161 for (UShort_t ir = 0; ir < nRings; ir++) {
162 TObjArray* vtxArray = (TObjArray*)detArray->At(ir);
163 for(Int_t i =0; i<nVtxbins; i++) {
164 TH2F* hMultTotal = (TH2F*)vtxArray->At(i);
165 if(fNevents.At(i))
166 hMultTotal->Scale(1/(Float_t)fNevents.At(i));
167 }
168 }
169 }
170 */
171}
172//_____________________________________________________________________
173//
174//
175// EOF