]>
Commit | Line | Data |
---|---|---|
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 | // An analysis task to check the T0 data in simulated data | |
20 | // | |
21 | //*-- Alla Maevskaya | |
22 | ////////////////////////////////////////////////////////////////////////////// | |
23 | ||
0b28fd57 | 24 | #include <TCanvas.h> |
1dfe075f | 25 | #include <TChain.h> |
0b28fd57 | 26 | #include <TFile.h> |
1dfe075f | 27 | #include <TH1F.h> |
1dfe075f | 28 | #include <TLegend.h> |
0b28fd57 | 29 | #include <TROOT.h> |
1dfe075f | 30 | |
31 | #include "AliT0QATask.h" | |
32 | #include "AliESD.h" | |
33 | #include "AliLog.h" | |
34 | #include "AliESDVertex.h" | |
35 | ||
36 | //______________________________________________________________________________ | |
37 | AliT0QATask::AliT0QATask(const char *name) : | |
38 | AliAnalysisTask(name,""), | |
39 | fChain(0), | |
40 | fESD(0), | |
41 | fhT01(0), | |
42 | fhT02(0), | |
43 | fhT03(0) | |
44 | { | |
45 | // Constructor. | |
46 | // Input slot #0 works with an Ntuple | |
47 | DefineInput(0, TChain::Class()); | |
48 | // Output slot #0 writes into a TH1 container | |
49 | DefineOutput(0, TObjArray::Class()) ; | |
50 | } | |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliT0QATask::~AliT0QATask() | |
54 | { | |
55 | // dtor | |
56 | fOutputContainer->Clear() ; | |
57 | delete fOutputContainer ; | |
58 | ||
59 | delete fhT01 ; | |
60 | delete fhT02 ; | |
61 | delete fhT03 ; | |
62 | } | |
63 | ||
64 | //______________________________________________________________________________ | |
c52c2132 | 65 | void AliT0QATask::ConnectInputData(const Option_t*) |
1dfe075f | 66 | { |
67 | // Initialisation of branch container and histograms | |
68 | ||
69 | AliInfo(Form("*** Initialization of %s", GetName())) ; | |
70 | ||
71 | // Get input data | |
72 | fChain = dynamic_cast<TChain *>(GetInputData(0)) ; | |
73 | if (!fChain) { | |
74 | AliError(Form("Input 0 for %s not found\n", GetName())); | |
75 | return ; | |
76 | } | |
77 | ||
c52c2132 | 78 | // One should first check if the branch address was taken by some other task |
79 | char ** address = (char **)GetBranchAddress(0, "ESD"); | |
80 | if (address) { | |
81 | fESD = (AliESD*)(*address); | |
82 | } else { | |
83 | fESD = new AliESD(); | |
84 | SetBranchAddress(0, "ESD", &fESD); | |
1dfe075f | 85 | } |
c52c2132 | 86 | } |
1dfe075f | 87 | |
c52c2132 | 88 | //________________________________________________________________________ |
89 | void AliT0QATask::CreateOutputObjects() | |
90 | { | |
91 | // create histograms | |
1dfe075f | 92 | fhT01 = new TH1F("hRealVertex", "Primary vertex", 100, -20, 20); |
93 | fhT02 = new TH1F("hT0start", "T0 start time", 100, 12400, 12600); | |
94 | fhT03 = new TH1F("hT0vertex", "T0vertex", 100, -20, 20); | |
95 | ||
96 | ||
97 | // create output container | |
98 | ||
99 | fOutputContainer = new TObjArray(3) ; | |
100 | fOutputContainer->SetName(GetName()) ; | |
101 | ||
102 | fOutputContainer->AddAt(fhT01, 0) ; | |
103 | fOutputContainer->AddAt(fhT02, 1) ; | |
104 | fOutputContainer->AddAt(fhT03, 2) ; | |
105 | } | |
106 | ||
107 | //______________________________________________________________________________ | |
108 | void AliT0QATask::Exec(Option_t *) | |
109 | { | |
110 | // Processing of one event | |
111 | ||
112 | Long64_t entry = fChain->GetReadEntry() ; | |
113 | ||
114 | if (!fESD) { | |
115 | AliError("fESD is not connected to the input!") ; | |
116 | return ; | |
117 | } | |
118 | ||
119 | if ( !((entry-1)%100) ) | |
120 | AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; | |
121 | ||
122 | // ************************ T0 ************************************* | |
123 | ||
124 | const AliESDVertex * vertex = fESD->GetPrimaryVertex() ; | |
125 | Double_t posZ = vertex->GetZv() ; | |
126 | fhT01->Fill( posZ ) ; | |
127 | ||
128 | fhT02->Fill( fESD->GetT0() ) ; | |
129 | ||
130 | fhT03->Fill( fESD->GetT0zVertex() / 2. ) ; | |
131 | ||
132 | PostData(0, fOutputContainer); | |
133 | ||
134 | } | |
135 | ||
136 | //______________________________________________________________________________ | |
137 | void AliT0QATask::Terminate(Option_t *) | |
138 | { | |
139 | // Processing when the event loop is ended | |
c52c2132 | 140 | fOutputContainer = (TObjArray*)GetOutputData(0); |
141 | fhT01 = (TH1F*)fOutputContainer->At(0); | |
142 | fhT02 = (TH1F*)fOutputContainer->At(1); | |
143 | fhT03 = (TH1F*)fOutputContainer->At(2); | |
144 | ||
1dfe075f | 145 | Float_t mean = fhT02->GetMean(); |
146 | ||
147 | printf ("mean time T0 ps %f\n", mean) ; | |
148 | ||
149 | if ( mean > 12600 || mean < 12400 ) | |
150 | AliWarning (" !!!!!!!!!!-----events sample is WRONG - T0 unreal -------"); | |
151 | ||
152 | TCanvas * cTO1 = new TCanvas("cT01", "T0 ESD Test", 400, 10, 600, 700) ; | |
153 | cTO1->Divide(2, 2) ; | |
154 | ||
155 | cTO1->cd(1) ; | |
156 | fhT01->Draw() ; | |
157 | ||
158 | cTO1->cd(2) ; | |
159 | fhT02->Draw() ; | |
160 | ||
161 | cTO1->cd(3) ; | |
162 | fhT03->Draw() ; | |
163 | ||
164 | ||
165 | cTO1->Print("T0.eps"); | |
166 | ||
167 | char line[1024] ; | |
168 | sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ; | |
169 | gROOT->ProcessLine(line); | |
170 | sprintf(line, ".!rm -fR *.eps"); | |
171 | gROOT->ProcessLine(line); | |
172 | ||
173 | AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ; | |
174 | } |