1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // A test analysis task to check the pt of tracks distribution in simulated data
22 //////////////////////////////////////////////////////////////////////////////
31 #include "AliAnalysisTaskPt.h"
35 //________________________________________________________________________
36 AliAnalysisTaskPt::AliAnalysisTaskPt(const char *name) :
37 AliAnalysisTask(name,""),
42 // Input slot #0 works with an Ntuple
43 DefineInput(0, TChain::Class());
44 // Output slot #0 writes into a TH1 container
45 DefineOutput(0, TObjArray::Class());
48 //________________________________________________________________________
49 void AliAnalysisTaskPt::ConnectInputData(Option_t *)
51 // Initialisation of branch container and histograms
53 AliInfo(Form("*** Initialization of %s", GetName())) ;
56 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
58 AliError(Form("Input 0 for %s not found\n", GetName()));
62 // One should first check if the branch address was taken by some other task
63 char ** address = (char **)GetBranchAddress(0, "ESD");
65 fESD = (AliESD*)(*address);
68 SetBranchAddress(0, "ESD", &fESD);
72 //________________________________________________________________________
73 void AliAnalysisTaskPt::CreateOutputObjects()
76 fhPt = new TH1F("fhPt","This is the Pt distribution",15,0.1,3.1);
77 fhPt->SetStats(kTRUE);
78 fhPt->GetXaxis()->SetTitle("P_{T} [GeV]");
79 fhPt->GetYaxis()->SetTitle("#frac{dN}{dP_{T}}");
80 fhPt->GetXaxis()->SetTitleColor(1);
81 fhPt->SetMarkerStyle(kFullCircle);
83 // create output container
85 fOutputContainer = new TObjArray(1) ;
86 fOutputContainer->SetName(GetName()) ;
88 fOutputContainer->AddAt(fhPt, 0) ;
91 //________________________________________________________________________
92 void AliAnalysisTaskPt::Exec(Option_t *)
94 // Processing of one event
96 Long64_t entry = fChain->GetReadEntry() ;
99 AliError("fESD is not connected to the input!") ;
103 if ( !((entry-1)%100) )
104 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
106 //************************ Pt tracks *************************************
108 for(Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
109 AliESDtrack * ESDTrack = fESD->GetTrack(iTracks);
110 Double_t momentum[3];
111 ESDTrack->GetPxPyPz(momentum);
112 Double_t Pt = sqrt(pow(momentum[0],2) + pow(momentum[1],2));
116 PostData(0, fOutputContainer);
119 //________________________________________________________________________
120 void AliAnalysisTaskPt::Terminate(Option_t *)
122 // Processing when the event loop is ended
124 TCanvas *c1 = new TCanvas("c1","Pt",10,10,310,310);
125 c1->SetFillColor(10);
126 c1->SetHighLightColor(10);
128 c1->cd(1)->SetLeftMargin(0.15);
129 c1->cd(1)->SetBottomMargin(0.15);
130 c1->cd(1)->SetLogy();
131 fOutputContainer = (TObjArray*)GetOutputData(0);
132 fhPt = (TH1F*)fOutputContainer->At(0);
133 if (fhPt) fhPt->DrawCopy("E");
135 c1->Print("TracksPt.eps");
138 sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ;
139 gROOT->ProcessLine(line);
140 sprintf(line, ".!rm -fR *.eps");
141 gROOT->ProcessLine(line);
143 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ;