]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/analysis/AliFMDAnalysisTaskCollector.cxx
This is rather large upgrade of the analysis. The sharing correction has been improve...
[u/mrichter/AliRoot.git] / FMD / analysis / AliFMDAnalysisTaskCollector.cxx
CommitLineData
c48a797f 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
10#include "AliFMDAnalysisTaskCollector.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 "AliESDVertex.h"
19#include "AliFMDAnaParameters.h"
20
21ClassImp(AliFMDAnalysisTaskCollector)
22
23
24AliFMDAnalysisTaskCollector::AliFMDAnalysisTaskCollector()
25: fDebug(0),
26 fChain(0x0),
27 fESD(0x0),
c48a797f 28 fOutputList(0),
29 fArray(0),
30 fEdistHist(0),
31 fZvtxDist(0)
32{
33 // Default constructor
34 DefineInput (0, TChain::Class());
35 DefineOutput(0, TList::Class());
36}
37//____________________________________________________________________
38AliFMDAnalysisTaskCollector::AliFMDAnalysisTaskCollector(const char* name):
39 AliAnalysisTask(name, "AnalysisTaskFMD"),
40 fDebug(0),
41 fChain(0x0),
42 fESD(0x0),
c48a797f 43 fOutputList(0),
44 fArray(0),
45 fEdistHist(0),
46 fZvtxDist(0)
47{
48 // Default constructor
49 DefineInput (0, TChain::Class());
50 DefineOutput(0, TList::Class());
51}
52//____________________________________________________________________
53void AliFMDAnalysisTaskCollector::CreateOutputObjects()
54{
55 // Create the output container
56 printf("AnalysisTaskFMD::CreateOutPutData() \n");
57
58 fOutputList = new TList();//(TList*)GetOutputData(0);
59
60 fArray = new TObjArray();
61 fArray->SetName("FMD");
62 fArray->SetOwner();
63 TH1F* hEdist = 0;
64 for(Int_t det =1; det<=3;det++)
65 {
66 TObjArray* detArray = new TObjArray();
67 detArray->SetName(Form("FMD%d",det));
68 fArray->AddAtAndExpand(detArray,det);
69 Int_t nRings = (det==1 ? 1 : 2);
70 for(Int_t ring = 0;ring<nRings;ring++)
71 {
72 Char_t ringChar = (ring == 0 ? 'I' : 'O');
73 hEdist = new TH1F(Form("FMD%d%c",det,ringChar),Form("FMD%d%c",det,ringChar),100,0,3);
74 hEdist->SetXTitle("#Delta E / E_{MIP}");
b82e76e0 75 fOutputList->Add(hEdist);
c48a797f 76 detArray->AddAtAndExpand(hEdist,ring);
77 }
78 }
79
80
81
82 fZvtxDist = new TH1F("ZvtxDist","Vertex distribution",100,-30,30);
83 fZvtxDist->SetXTitle("z vertex");
b82e76e0 84 //fOutputList->Add(fArray);
c48a797f 85 fOutputList->Add(fZvtxDist);
86}
87//____________________________________________________________________
88void AliFMDAnalysisTaskCollector::Init()
89{
90 // Initialization
91 printf("AnalysisTaskFMD::Init() \n");
92
93
94}
95//____________________________________________________________________
96void AliFMDAnalysisTaskCollector::ConnectInputData(Option_t */*option*/)
97{
98 fChain = (TChain*)GetInputData(0);
99 fESD = new AliESDEvent();
100 fESD->ReadFromTree(fChain);
101
102}
103//____________________________________________________________________
104void AliFMDAnalysisTaskCollector::Exec(Option_t */*option*/)
105{
106 AliESD* old = fESD->GetAliESDOld();
107 if (old) {
108 fESD->CopyFromOldESD();
109 }
bb8a464f 110 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
c48a797f 111
c48a797f 112 Double_t vertex[3];
bb8a464f 113
114 GetVertex(vertex);
115 if(vertex[0] == 0 && vertex[1] == 0 && vertex[2] == 0)
116 return;
c48a797f 117 fZvtxDist->Fill(vertex[2]);
bb8a464f 118
119 if(TMath::Abs(vertex[2]) > pars->GetVtxCutZ())
120 return;
121
c48a797f 122 AliESDFMD* fmd = fESD->GetFMDData();
123 if (!fmd) return;
124
125 for(UShort_t det=1;det<=3;det++) {
126 TObjArray* detArray = (TObjArray*)fArray->At(det);
127 Int_t nRings = (det==1 ? 1 : 2);
128 for (UShort_t ir = 0; ir < nRings; ir++) {
129 TH1F* Edist = (TH1F*)detArray->At(ir);
130 Char_t ring = (ir == 0 ? 'I' : 'O');
131 UShort_t nsec = (ir == 0 ? 20 : 40);
132 UShort_t nstr = (ir == 0 ? 512 : 256);
133 for(UShort_t sec =0; sec < nsec; sec++) {
134 for(UShort_t strip = 0; strip < nstr; strip++) {
135 Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
136 if(mult == AliESDFMD::kInvalidMult) continue;
137 Edist->Fill(mult);
138
139 }
140 }
141 }
142 }
143
144 PostData(0, fOutputList);
145
146}
147//____________________________________________________________________
148void AliFMDAnalysisTaskCollector::Terminate(Option_t */*option*/)
149{
b82e76e0 150 /*
c48a797f 151 for(UShort_t det=1;det<=3;det++) {
152 TObjArray* detArray = (TObjArray*)fArray->At(det);
153 Int_t nRings = (det==1 ? 1 : 2);
154 for (UShort_t ir = 0; ir < nRings; ir++) {
155 TH1F* hEdist = (TH1F*)detArray->At(ir);
156 hEdist->SetAxisRange(0.4,hEdist->GetXaxis()->GetXmax());
157 Float_t max = hEdist->GetBinCenter(hEdist->GetMaximumBin());
158 hEdist->Fit("landau","","",max-0.1,2*max);
159 }
160 }
b82e76e0 161 */
c48a797f 162}
bb8a464f 163//_____________________________________________________________________
164void AliFMDAnalysisTaskCollector::GetVertex(Double_t* vertexXYZ)
165{
166 const AliESDVertex* vertex = 0;
167 vertex = fESD->GetPrimaryVertex();
168 if (!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
169 vertex = fESD->GetPrimaryVertexSPD();
170 if (!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
171 vertex = fESD->GetPrimaryVertexTPC();
172
173 if (!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
174 vertex = fESD->GetVertex();
175
176 if (vertex && (vertexXYZ[0] != 0 || vertexXYZ[1] != 0 || vertexXYZ[2] != 0)) {
177 vertex->GetXYZ(vertexXYZ);
178 //std::cout<<vertex->GetName()<<" "<< vertex->GetTitle() <<" "<< vertex->GetZv()<<std::endl;
179 return;
180 }
181 else if (fESD->GetESDTZERO()) {
182 vertexXYZ[0] = 0;
183 vertexXYZ[1] = 0;
184 vertexXYZ[2] = fESD->GetT0zVertex();
185
186 return;
187 }
188
189 return;
190}
c48a797f 191//____________________________________________________________________
192//
193// EOF
194//