4 #include <TInterpreter.h>
11 #include "AliFMDAnalysisTaskDndeta.h"
12 #include "AliAnalysisManager.h"
13 #include "AliESDFMD.h"
14 #include "AliESDEvent.h"
15 #include "AliAODEvent.h"
16 #include "AliAODHandler.h"
17 #include "AliMCEventHandler.h"
20 #include "AliESDVertex.h"
22 #include "AliFMDAnaParameters.h"
23 //#include "AliFMDGeometry.h"
24 #include "AliGenEventHeader.h"
25 #include "AliGenPythiaEventHeader.h"
26 #include "AliHeader.h"
27 //#include "TDatabasePDG.h"
28 //#include "TParticlePDG.h"
29 #include "AliFMDStripIndex.h"
30 #include "AliESDInputHandler.h"
31 ClassImp(AliFMDAnalysisTaskDndeta)
34 AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta()
44 // Default constructor
45 DefineInput (0, TList::Class());
46 DefineOutput(0, TList::Class());
48 //_____________________________________________________________________
49 AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta(const char* name, Bool_t SE):
50 AliAnalysisTask(name, "Density"),
62 DefineInput (0, TList::Class());
63 DefineInput(1, TObjString::Class());
64 DefineOutput(0, TList::Class());
68 //_____________________________________________________________________
69 void AliFMDAnalysisTaskDndeta::CreateOutputObjects()
71 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
74 fOutputList = new TList();
75 fOutputList->SetName("BackgroundCorrected");
81 TH1F* hPrimVertexBin = 0;
84 TH2F* hBgTmp = pars->GetBackgroundCorrection(1, 'I', 0);
85 TH1F* hPrimary = new TH1F("hMultvsEta","hMultvsEta",
87 hBgTmp->GetXaxis()->GetXmin(),
88 hBgTmp->GetXaxis()->GetXmax());
90 fOutputList->Add(hPrimary);
91 Int_t nVtxbins = pars->GetNvtxBins();
93 for(Int_t i = 0; i< nVtxbins; i++) {
95 for(Int_t det =1; det<=3;det++)
97 Int_t nRings = (det==1 ? 1 : 2);
98 for(Int_t ring = 0;ring<nRings;ring++)
100 Char_t ringChar = (ring == 0 ? 'I' : 'O');
101 Int_t nSec = (ring == 0 ? 20 : 40);
105 hBg = pars->GetBackgroundCorrection(det, ringChar, i);
106 hMult = new TH2F(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),
108 hBg->GetXaxis()->GetXmin(),
109 hBg->GetXaxis()->GetXmax(),
110 nSec, 0, 2*TMath::Pi());
111 hMultTrVtx = new TH2F(Form("dNdetaTrVtx_FMD%d%c_vtxbin%d",det,ringChar,i),Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),
113 hBg->GetXaxis()->GetXmin(),
114 hBg->GetXaxis()->GetXmax(),
115 nSec, 0, 2*TMath::Pi());
116 hHits = new TH1F(Form("hMCHits_FMD%d%c_vtxbin%d",det,ringChar,i),Form("hMCHits_FMD%d%c_vtxbin%d",det,ringChar,i),
118 hBg->GetXaxis()->GetXmin(),
119 hBg->GetXaxis()->GetXmax());
121 fOutputList->Add(hHits);
124 fOutputList->Add(hMult);
127 fOutputList->Add(hMultTrVtx);
133 for(Int_t i = 0; i< nVtxbins; i++) {
135 hPrimVertexBin = new TH1F(Form("primmult_vtxbin%d",i),
136 Form("primmult_vtxbin%d",i),
138 hBgTmp->GetXaxis()->GetXmin(),
139 hBgTmp->GetXaxis()->GetXmax());
140 hPrimVertexBin->Sumw2();
141 fOutputList->Add(hPrimVertexBin);
143 TH2F* hSPDMult = new TH2F(Form("dNdeta_SPD_vtxbin%d",i),Form("dNdeta_SPD_vtxbin%d",i),
145 hBgTmp->GetXaxis()->GetXmin(),
146 hBgTmp->GetXaxis()->GetXmax(),
147 20, 0, 2*TMath::Pi());
149 fOutputList->Add(hSPDMult);
150 TH2F* hSPDMultTrVtx = new TH2F(Form("dNdetaTrVtx_SPD_vtxbin%d",i),Form("dNdetaTrVtx_SPD_vtxbin%d",i),
152 hBgTmp->GetXaxis()->GetXmin(),
153 hBgTmp->GetXaxis()->GetXmax(),
154 20, 0, 2*TMath::Pi());
155 hSPDMultTrVtx->Sumw2();
156 fOutputList->Add(hSPDMultTrVtx);
159 fNevents.SetBins(nVtxbins,0,nVtxbins);
160 fNevents.SetName("nEvents");
161 fNMCevents.SetBins(nVtxbins,0,nVtxbins);
162 fNMCevents.SetName("nMCEvents");
163 fOutputList->Add(&fNevents);
164 fOutputList->Add(&fNMCevents);
167 //_____________________________________________________________________
168 void AliFMDAnalysisTaskDndeta::ConnectInputData(Option_t */*option*/)
171 fInputList = (TList*)GetInputData(0);
174 //_____________________________________________________________________
175 void AliFMDAnalysisTaskDndeta::Exec(Option_t */*option*/)
177 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
178 fVertexString = (TObjString*)fInputList->At(0);
180 Int_t vtxbin = fVertexString->GetString().Atoi();
182 fNevents.Fill(vtxbin);
184 for(UShort_t det=1;det<=3;det++) {
185 Int_t nRings = (det==1 ? 1 : 2);
186 for (UShort_t ir = 0; ir < nRings; ir++) {
187 Char_t ringChar = (ir == 0 ? 'I' : 'O');
189 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
190 TH2F* hMultTotalTrVtx = (TH2F*)fOutputList->FindObject(Form("dNdetaTrVtx_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
192 TH2F* hMultInput = (TH2F*)fInputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
193 TH2F* hMultInputTrVtx = (TH2F*)fInputList->FindObject(Form("multTrVtx_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
195 hMultTotal->Add(hMultInput);
196 hMultTotalTrVtx->Add(hMultInputTrVtx);
202 TH2F* hMultSPDTotal = (TH2F*)fOutputList->FindObject(Form("dNdeta_SPD_vtxbin%d",vtxbin));
203 TH2F* hMultSPDTotalTrVtx = (TH2F*)fOutputList->FindObject(Form("dNdetaTrVtx_SPD_vtxbin%d",vtxbin));
204 TH2F* hMultSPDInput = (TH2F*)fInputList->FindObject(Form("mult_SPD_vtxbin%d",vtxbin));
205 TH2F* hMultSPDInputTrVtx = (TH2F*)fInputList->FindObject(Form("multTrVtx_SPD_vtxbin%d",vtxbin));
206 hMultSPDTotal->Add(hMultSPDInput);
207 hMultSPDTotalTrVtx->Add(hMultSPDInputTrVtx);
210 if(pars->GetProcessPrimary())
214 PostData(0, fOutputList);
218 //_____________________________________________________________________
219 void AliFMDAnalysisTaskDndeta::Terminate(Option_t */*option*/) {
221 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
223 Int_t nVtxbins = pars->GetNvtxBins();
225 for(UShort_t det=1;det<=3;det++) {
226 Int_t nRings = (det==1 ? 1 : 2);
227 for (UShort_t ir = 0; ir < nRings; ir++) {
228 Char_t ringChar = (ir == 0 ? 'I' : 'O');
229 for(Int_t i =0; i<nVtxbins; i++) {
231 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i));
232 //TH2F* hMultTrVtx = (TH2F*)hMultTotal->Clone(Form("dNdeta_FMD%d%c_TrVtx_vtxbin%d",det,ringChar,i));
233 TH2F* hMultTrVtx = (TH2F*)fOutputList->FindObject(Form("dNdetaTrVtx_FMD%d%c_vtxbin%d",det,ringChar,i));
235 TH1D* hMultProj = hMultTotal->ProjectionX(Form("dNdeta_FMD%d%c_vtxbin%d_proj",det,ringChar,i),1,hMultTotal->GetNbinsY());
236 TH1D* hMultProjTrVtx = hMultTrVtx->ProjectionX(Form("dNdeta_FMD%d%c_TrVtx_vtxbin%d_proj",det,ringChar,i),1,hMultTotal->GetNbinsY());
237 //fOutputList->Add(hMultTrVtx);
238 fOutputList->Add(hMultProj);
239 fOutputList->Add(hMultProjTrVtx);
244 for(Int_t i =0; i<nVtxbins; i++) {
246 TH2F* hSPDMult = (TH2F*)fOutputList->FindObject(Form("dNdeta_SPD_vtxbin%d",i));
247 TH2F* hSPDMultTrVtx = (TH2F*)fOutputList->FindObject(Form("dNdetaTrVtx_SPD_vtxbin%d",i));
249 TH1D* hMultProj = hSPDMult->ProjectionX(Form("dNdeta_SPD_vtxbin%d_proj",i),1,hSPDMult->GetNbinsY());
250 TH1D* hMultProjTrVtx = hSPDMultTrVtx->ProjectionX(Form("dNdetaTrVtx_SPD_vtxbin%d_proj",i),1,hSPDMultTrVtx->GetNbinsY());
252 fOutputList->Add(hMultProj);
253 fOutputList->Add(hMultProjTrVtx);
257 std::cout<<"FMD analysis accepted "<<fNevents.GetEntries()<<" events"<<std::endl;
259 //_____________________________________________________________________
260 void AliFMDAnalysisTaskDndeta::ProcessPrimary() {
262 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
263 AliMCEvent* mcEvent = eventHandler->MCEvent();
267 fLastTrackByStrip.Reset(-1);
269 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
271 AliMCParticle* particle = 0;
272 AliStack* stack = mcEvent->Stack();
274 TH1F* hPrimary = (TH1F*)fOutputList->FindObject("hMultvsEta");
275 AliHeader* header = mcEvent->Header();
276 AliGenEventHeader* genHeader = header->GenEventHeader();
279 genHeader->PrimaryVertex(vertex);
280 if(TMath::Abs(vertex.At(2)) > pars->GetVtxCutZ())
282 Double_t delta = 2*pars->GetVtxCutZ()/pars->GetNvtxBins();
283 Double_t vertexBinDouble = (vertex.At(2) + pars->GetVtxCutZ()) / delta;
284 Int_t vertexBin = (Int_t)vertexBinDouble;
286 Bool_t firstTrack = kTRUE;
288 // we loop over the primaries only unless we need the hits (diagnostics running slowly)
289 Int_t nTracks = stack->GetNprimary();
290 if(pars->GetProcessHits())
291 nTracks = stack->GetNtrack();
293 for(Int_t i = 0 ;i<nTracks;i++) {
294 particle = (AliMCParticle*) mcEvent->GetTrack(i);
298 if(stack->IsPhysicalPrimary(i) && particle->Charge() != 0) {
299 hPrimary->Fill(particle->Eta());
302 TH1F* hPrimVtxBin = (TH1F*)fOutputList->FindObject(Form("primmult_vtxbin%d",vertexBin));
303 hPrimVtxBin->Fill(particle->Eta());
305 fNMCevents.Fill(vertexBin);
310 if(pars->GetProcessHits()) {
312 for(Int_t j=0; j<particle->GetNumberOfTrackReferences();j++) {
314 AliTrackReference* ref = particle->GetTrackReference(j);
315 UShort_t det,sec,strip;
317 if(ref->DetectorId() != AliTrackReference::kFMD)
319 AliFMDStripIndex::Unpack(ref->UserId(),det,ring,sec,strip);
320 Float_t thisStripTrack = fLastTrackByStrip(det,ring,sec,strip);
321 if(particle->Charge() != 0 && i != thisStripTrack ) {
324 Float_t eta = pars->GetEtaFromStrip(det,ring,sec,strip,vertex.At(2));//-1*TMath::Log(TMath::Tan(0.5*theta));
325 TH1F* hHits = (TH1F*)fOutputList->FindObject(Form("hMCHits_FMD%d%c_vtxbin%d",det,ring,vertexBin));
330 Float_t nstrips = (ring =='O' ? 256 : 512);
332 fLastTrackByStrip(det,ring,sec,strip) = (Float_t)i;
335 fLastTrackByStrip(det,ring,sec,strip-1) = (Float_t)i;
336 if(strip < (nstrips - 1))
337 fLastTrackByStrip(det,ring,sec,strip+1) = (Float_t)i;
351 //_____________________________________________________________________