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 "AliHeader.h"
26 //#include "TDatabasePDG.h"
27 //#include "TParticlePDG.h"
28 #include "AliFMDStripIndex.h"
29 ClassImp(AliFMDAnalysisTaskDndeta)
32 AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta()
42 // Default constructor
43 DefineInput (0, TList::Class());
44 DefineOutput(0, TList::Class());
46 //_____________________________________________________________________
47 AliFMDAnalysisTaskDndeta::AliFMDAnalysisTaskDndeta(const char* name, Bool_t SE):
48 AliAnalysisTask(name, "Density"),
60 DefineInput (0, TList::Class());
61 DefineInput(1, TObjString::Class());
62 DefineOutput(0, TList::Class());
66 //_____________________________________________________________________
67 void AliFMDAnalysisTaskDndeta::CreateOutputObjects()
69 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
72 fOutputList = new TList();
73 fOutputList->SetName("BackgroundCorrected");
78 TH1F* hPrimVertexBin = 0;
81 TH2F* hBgTmp = pars->GetBackgroundCorrection(1, 'I', 0);
82 TH1F* hPrimary = new TH1F("hMultvsEta","hMultvsEta",
84 hBgTmp->GetXaxis()->GetXmin(),
85 hBgTmp->GetXaxis()->GetXmax());
87 fOutputList->Add(hPrimary);
88 Int_t nVtxbins = pars->GetNvtxBins();
90 for(Int_t i = 0; i< nVtxbins; i++) {
92 for(Int_t det =1; det<=3;det++)
94 Int_t nRings = (det==1 ? 1 : 2);
95 for(Int_t ring = 0;ring<nRings;ring++)
97 Char_t ringChar = (ring == 0 ? 'I' : 'O');
98 Int_t nSec = (ring == 0 ? 20 : 40);
102 hBg = pars->GetBackgroundCorrection(det, ringChar, i);
103 hMult = new TH2F(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i),
105 hBg->GetXaxis()->GetXmin(),
106 hBg->GetXaxis()->GetXmax(),
107 nSec, 0, 2*TMath::Pi());
109 hHits = new TH1F(Form("hMCHits_FMD%d%c_vtxbin%d",det,ringChar,i),Form("hMCHits_FMD%d%c_vtxbin%d",det,ringChar,i),
111 hBg->GetXaxis()->GetXmin(),
112 hBg->GetXaxis()->GetXmax());
114 fOutputList->Add(hHits);
117 fOutputList->Add(hMult);
123 for(Int_t i = 0; i< nVtxbins; i++) {
125 hPrimVertexBin = new TH1F(Form("primmult_vtxbin%d",i),
126 Form("primmult_vtxbin%d",i),
128 hBgTmp->GetXaxis()->GetXmin(),
129 hBgTmp->GetXaxis()->GetXmax());
130 hPrimVertexBin->Sumw2();
131 fOutputList->Add(hPrimVertexBin);
135 fNevents.SetBins(nVtxbins,0,nVtxbins);
136 fNevents.SetName("nEvents");
137 fNMCevents.SetBins(nVtxbins,0,nVtxbins);
138 fNMCevents.SetName("nMCEvents");
139 fOutputList->Add(&fNevents);
140 fOutputList->Add(&fNMCevents);
143 //_____________________________________________________________________
144 void AliFMDAnalysisTaskDndeta::ConnectInputData(Option_t */*option*/)
147 fInputList = (TList*)GetInputData(0);
150 //_____________________________________________________________________
151 void AliFMDAnalysisTaskDndeta::Exec(Option_t */*option*/)
153 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
154 fVertexString = (TObjString*)fInputList->At(0);
156 Int_t vtxbin = fVertexString->GetString().Atoi();
158 fNevents.Fill(vtxbin);
160 for(UShort_t det=1;det<=3;det++) {
161 Int_t nRings = (det==1 ? 1 : 2);
162 for (UShort_t ir = 0; ir < nRings; ir++) {
163 Char_t ringChar = (ir == 0 ? 'I' : 'O');
165 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
168 TH2F* hMultInput = (TH2F*)fInputList->FindObject(Form("mult_FMD%d%c_vtxbin%d",det,ringChar,vtxbin));
170 hMultTotal->Add(hMultInput);
175 if(pars->GetProcessPrimary())
179 PostData(0, fOutputList);
183 //_____________________________________________________________________
184 void AliFMDAnalysisTaskDndeta::Terminate(Option_t */*option*/) {
187 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
189 Int_t nVtxbins = pars->GetNvtxBins();
191 for(UShort_t det=1;det<=3;det++) {
192 Int_t nRings = (det==1 ? 1 : 2);
193 for (UShort_t ir = 0; ir < nRings; ir++) {
194 Char_t ringChar = (ir == 0 ? 'I' : 'O');
195 for(Int_t i =0; i<nVtxbins; i++) {
197 TH1F* hSharingEff = pars->GetSharingEfficiency(det,ringChar,i);
198 TH1F* hSharingEffTrVtx = pars->GetSharingEfficiencyTrVtx(det,ringChar,i);
199 TH2F* hMultTotal = (TH2F*)fOutputList->FindObject(Form("dNdeta_FMD%d%c_vtxbin%d",det,ringChar,i));
200 TH2F* hMultTrVtx = (TH2F*)hMultTotal->Clone(Form("dNdeta_FMD%d%c_TrVtx_vtxbin%d",det,ringChar,i));
202 for(Int_t nx=1; nx<hMultTotal->GetNbinsX(); nx++) {
203 Float_t correction = hSharingEff->GetBinContent(nx);
204 Float_t correctionTrVtx = hSharingEffTrVtx->GetBinContent(nx);
205 for(Int_t ny=1; ny<hMultTotal->GetNbinsY(); ny++) {
208 hMultTotal->SetBinContent(nx,ny,hMultTotal->GetBinContent(nx,ny)/correction);
209 Float_t error = TMath::Sqrt(TMath::Power(hMultTotal->GetBinError(nx,ny),2) + TMath::Power(hMultTotal->GetBinContent(nx,ny)*hSharingEff->GetBinError(nx),2)) / correction;
210 hMultTotal->SetBinError(nx,ny,error);
212 if(correctionTrVtx != 0){
213 hMultTrVtx->SetBinContent(nx,ny,hMultTrVtx->GetBinContent(nx,ny)/correctionTrVtx);
214 Float_t error = TMath::Sqrt(TMath::Power(hMultTrVtx->GetBinError(nx,ny),2) + TMath::Power(hMultTrVtx->GetBinContent(nx,ny)*hSharingEffTrVtx->GetBinError(nx),2)) / correctionTrVtx;
215 hMultTrVtx->SetBinError(nx,ny,error);
221 //hMultTotal->Divide(hSharingEff);
223 hMultTotal->Scale(1/pars->GetEventSelectionEfficiency(i));
225 //hMultTrVtx->Divide(hSharingEffTrVtx);
227 TH1D* hMultProj = hMultTotal->ProjectionX(Form("dNdeta_FMD%d%c_vtxbin%d_proj",det,ringChar,i),1,hMultTotal->GetNbinsY());
228 TH1D* hMultProjTrVtx = hMultTrVtx->ProjectionX(Form("dNdeta_FMD%d%c_TrVtx_vtxbin%d_proj",det,ringChar,i),1,hMultTotal->GetNbinsY());
229 fOutputList->Add(hMultTrVtx);
230 fOutputList->Add(hMultProj);
231 fOutputList->Add(hMultProjTrVtx);
237 //_____________________________________________________________________
238 void AliFMDAnalysisTaskDndeta::ProcessPrimary() {
240 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
241 AliMCEvent* mcEvent = eventHandler->MCEvent();
245 fLastTrackByStrip.Reset(-1);
247 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
249 AliMCParticle* particle = 0;
250 AliStack* stack = mcEvent->Stack();
252 TH1F* hPrimary = (TH1F*)fOutputList->FindObject("hMultvsEta");
253 AliHeader* header = mcEvent->Header();
254 AliGenEventHeader* genHeader = header->GenEventHeader();
257 genHeader->PrimaryVertex(vertex);
258 if(TMath::Abs(vertex.At(2)) > pars->GetVtxCutZ())
260 Double_t delta = 2*pars->GetVtxCutZ()/pars->GetNvtxBins();
261 Double_t vertexBinDouble = (vertex.At(2) + pars->GetVtxCutZ()) / delta;
262 Int_t vertexBin = (Int_t)vertexBinDouble;
264 Bool_t firstTrack = kTRUE;
266 // we loop over the primaries only unless we need the hits (diagnostics running slowly)
267 Int_t nTracks = stack->GetNprimary();
268 if(pars->GetProcessHits())
269 nTracks = stack->GetNtrack();
271 for(Int_t i = 0 ;i<nTracks;i++) {
272 particle = (AliMCParticle*) mcEvent->GetTrack(i);
276 if(stack->IsPhysicalPrimary(i) && particle->Charge() != 0) {
277 hPrimary->Fill(particle->Eta());
280 TH1F* hPrimVtxBin = (TH1F*)fOutputList->FindObject(Form("primmult_vtxbin%d",vertexBin));
281 hPrimVtxBin->Fill(particle->Eta());
283 fNMCevents.Fill(vertexBin);
288 if(pars->GetProcessHits()) {
290 for(Int_t j=0; j<particle->GetNumberOfTrackReferences();j++) {
292 AliTrackReference* ref = particle->GetTrackReference(j);
293 UShort_t det,sec,strip;
295 if(ref->DetectorId() != AliTrackReference::kFMD)
297 AliFMDStripIndex::Unpack(ref->UserId(),det,ring,sec,strip);
298 Float_t thisStripTrack = fLastTrackByStrip(det,ring,sec,strip);
299 if(particle->Charge() != 0 && i != thisStripTrack ) {
302 Float_t eta = pars->GetEtaFromStrip(det,ring,sec,strip,vertex.At(2));//-1*TMath::Log(TMath::Tan(0.5*theta));
303 TH1F* hHits = (TH1F*)fOutputList->FindObject(Form("hMCHits_FMD%d%c_vtxbin%d",det,ring,vertexBin));
308 Float_t nstrips = (ring =='O' ? 256 : 512);
310 fLastTrackByStrip(det,ring,sec,strip) = (Float_t)i;
313 fLastTrackByStrip(det,ring,sec,strip-1) = (Float_t)i;
314 if(strip < (nstrips - 1))
315 fLastTrackByStrip(det,ring,sec,strip+1) = (Float_t)i;
329 //_____________________________________________________________________