]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ESDCheck/AliAnalysisTaskPt.cxx
bug fix in the vertex selection
[u/mrichter/AliRoot.git] / ESDCheck / AliAnalysisTaskPt.cxx
CommitLineData
1dfe075f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
0b28fd57 15
16/* $Id$ */
17
1dfe075f 18//_________________________________________________________________________
19// A test analysis task to check the pt of tracks distribution in simulated data
20//
21//*-- Panos
22//////////////////////////////////////////////////////////////////////////////
23
0b28fd57 24#include <TCanvas.h>
1dfe075f 25#include <TChain.h>
1dfe075f 26#include <TFile.h>
0b28fd57 27#include <TH1.h>
28#include <TROOT.h>
1dfe075f 29#include <TSystem.h>
1f588058 30#include <TString.h>
1dfe075f 31
32#include "AliAnalysisTaskPt.h"
33#include "AliESD.h"
34#include "AliLog.h"
35
36//________________________________________________________________________
37AliAnalysisTaskPt::AliAnalysisTaskPt(const char *name) :
38 AliAnalysisTask(name,""),
5effd3c6 39 fChain(0),
1dfe075f 40 fESD(0),
5effd3c6 41 fhPt(0),
42 fOutputContainer(0)
1dfe075f 43{
44 // Constructor.
45 // Input slot #0 works with an Ntuple
46 DefineInput(0, TChain::Class());
47 // Output slot #0 writes into a TH1 container
48 DefineOutput(0, TObjArray::Class());
49}
50
51//________________________________________________________________________
c52c2132 52void AliAnalysisTaskPt::ConnectInputData(Option_t *)
1dfe075f 53{
54 // Initialisation of branch container and histograms
55
56 AliInfo(Form("*** Initialization of %s", GetName())) ;
57
58 // Get input data
59 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
60 if (!fChain) {
61 AliError(Form("Input 0 for %s not found\n", GetName()));
62 return ;
63 }
64
c52c2132 65 // One should first check if the branch address was taken by some other task
66 char ** address = (char **)GetBranchAddress(0, "ESD");
67 if (address) {
68 fESD = (AliESD*)(*address);
69 } else {
70 fESD = new AliESD();
71 SetBranchAddress(0, "ESD", &fESD);
1dfe075f 72 }
c52c2132 73}
1dfe075f 74
c52c2132 75//________________________________________________________________________
76void AliAnalysisTaskPt::CreateOutputObjects()
77{
78 // create histograms
1e20f195 79
80 OpenFile(0) ;
81
1dfe075f 82 fhPt = new TH1F("fhPt","This is the Pt distribution",15,0.1,3.1);
83 fhPt->SetStats(kTRUE);
84 fhPt->GetXaxis()->SetTitle("P_{T} [GeV]");
85 fhPt->GetYaxis()->SetTitle("#frac{dN}{dP_{T}}");
86 fhPt->GetXaxis()->SetTitleColor(1);
87 fhPt->SetMarkerStyle(kFullCircle);
88
89 // create output container
90
91 fOutputContainer = new TObjArray(1) ;
92 fOutputContainer->SetName(GetName()) ;
93
94 fOutputContainer->AddAt(fhPt, 0) ;
95}
96
97//________________________________________________________________________
98void AliAnalysisTaskPt::Exec(Option_t *)
99{
100 // Processing of one event
101
102 Long64_t entry = fChain->GetReadEntry() ;
103
104 if (!fESD) {
105 AliError("fESD is not connected to the input!") ;
106 return ;
107 }
108
109 if ( !((entry-1)%100) )
110 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
111
112 //************************ Pt tracks *************************************
113
114 for(Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
115 AliESDtrack * ESDTrack = fESD->GetTrack(iTracks);
116 Double_t momentum[3];
117 ESDTrack->GetPxPyPz(momentum);
118 Double_t Pt = sqrt(pow(momentum[0],2) + pow(momentum[1],2));
119 fhPt->Fill(Pt);
120 }//track loop
121
122 PostData(0, fOutputContainer);
123}
124
125//________________________________________________________________________
126void AliAnalysisTaskPt::Terminate(Option_t *)
127{
128 // Processing when the event loop is ended
84eb42a1 129
2704006a 130 Bool_t problem=kFALSE;
131
84eb42a1 132 AliInfo(Form(" *** %s Report:", GetName())) ;
133
1dfe075f 134 TCanvas *c1 = new TCanvas("c1","Pt",10,10,310,310);
135 c1->SetFillColor(10);
136 c1->SetHighLightColor(10);
137
138 c1->cd(1)->SetLeftMargin(0.15);
139 c1->cd(1)->SetBottomMargin(0.15);
84eb42a1 140 if (fhPt->GetMaximum() > 0 )
141 c1->cd(1)->SetLogy();
c52c2132 142 fOutputContainer = (TObjArray*)GetOutputData(0);
143 fhPt = (TH1F*)fOutputContainer->At(0);
144 if (fhPt) fhPt->DrawCopy("E");
1dfe075f 145
146 c1->Print("TracksPt.eps");
147
148 char line[1024] ;
84eb42a1 149 sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ;
1dfe075f 150 gROOT->ProcessLine(line);
151 sprintf(line, ".!rm -fR *.eps");
152 gROOT->ProcessLine(line);
153
2704006a 154 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
155
1f588058 156 TString report ;
2704006a 157 if(problem)
158 report="Problems found, please check!!!";
159 else
160 report="OK";
161
1f588058 162 AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report.Data())) ;
1dfe075f 163}