]>
Commit | Line | Data |
---|---|---|
73d51118 | 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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
fc492d0d | 19 | // ANALYSIS task to perrorm TPC calibration // |
20 | ||
73d51118 | 21 | // // |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | #include "AliTPCAnalysisTaskcalib.h" | |
24 | #include "TChain.h" | |
25 | #include "AliTPCcalibBase.h" | |
26 | #include "AliESDEvent.h" | |
27 | #include "AliESDfriend.h" | |
f7f33dec | 28 | #include "AliESDtrack.h" |
73d51118 | 29 | #include "AliESDfriendTrack.h" |
30 | #include "AliTPCseed.h" | |
31 | #include "AliESDInputHandler.h" | |
32 | #include "AliAnalysisManager.h" | |
679480d0 | 33 | #include "TFile.h" |
34 | #include "TSystem.h" | |
35 | #include "TTimeStamp.h" | |
73d51118 | 36 | |
37 | ClassImp(AliTPCAnalysisTaskcalib) | |
38 | ||
f7f33dec | 39 | |
40 | AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib() | |
41 | :AliAnalysisTask(), | |
42 | fCalibJobs(0), | |
43 | fESD(0), | |
44 | fESDfriend(0), | |
5647625c | 45 | fDebugOutputPath("") |
f7f33dec | 46 | { |
47 | // | |
48 | // default constructor | |
49 | // | |
50 | ||
51 | } | |
52 | ||
53 | ||
73d51118 | 54 | AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name) |
55 | :AliAnalysisTask(name,""), | |
56 | fCalibJobs(0), | |
0db06ea6 | 57 | fESD(0), |
f7f33dec | 58 | fESDfriend(0), |
5647625c | 59 | fDebugOutputPath("") |
73d51118 | 60 | { |
61 | // | |
62 | // Constructor | |
63 | // | |
64 | DefineInput(0, TChain::Class()); | |
08669268 | 65 | DefineOutput(0, AliTPCcalibBase::Class()); |
66 | DefineOutput(1, AliTPCcalibBase::Class()); | |
67 | DefineOutput(2, AliTPCcalibBase::Class()); | |
68 | DefineOutput(3, AliTPCcalibBase::Class()); | |
69 | DefineOutput(4, AliTPCcalibBase::Class()); | |
70 | DefineOutput(5, AliTPCcalibBase::Class()); | |
f7f33dec | 71 | fCalibJobs = new TObjArray(0); |
42a48f93 | 72 | fCalibJobs->SetOwner(kTRUE); |
73d51118 | 73 | } |
74 | ||
75 | AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() { | |
76 | // | |
77 | // destructor | |
78 | // | |
f7f33dec | 79 | printf("AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib"); |
edb92719 | 80 | fCalibJobs->Delete(); |
73d51118 | 81 | } |
82 | ||
83 | void AliTPCAnalysisTaskcalib::Exec(Option_t *) { | |
84 | // | |
85 | // Exec function | |
86 | // Loop over tracks and call Process function | |
87 | if (!fESD) { | |
2acad464 | 88 | //Printf("ERROR: fESD not available"); |
73d51118 | 89 | return; |
90 | } | |
91 | fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend")); | |
556a6343 | 92 | Int_t n=fESD->GetNumberOfTracks(); |
93 | Process(fESD); | |
73d51118 | 94 | if (!fESDfriend) { |
2acad464 | 95 | //Printf("ERROR: fESDfriend not available"); |
73d51118 | 96 | return; |
97 | } | |
012c4694 | 98 | if (fESDfriend->TestSkipBit()) return; |
556a6343 | 99 | // |
5822e507 | 100 | Int_t run = fESD->GetRunNumber(); |
73d51118 | 101 | for (Int_t i=0;i<n;++i) { |
102 | AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i); | |
f7f33dec | 103 | AliESDtrack *track=fESD->GetTrack(i); |
0db06ea6 | 104 | TObject *calibObject=0; |
73d51118 | 105 | AliTPCseed *seed=0; |
1f3b7de0 | 106 | if (!friendTrack) continue; |
0db06ea6 | 107 | for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j) |
108 | if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) | |
73d51118 | 109 | break; |
5822e507 | 110 | if (track) Process(track, run); |
73d51118 | 111 | if (seed) |
112 | Process(seed); | |
113 | } | |
73d51118 | 114 | } |
115 | ||
116 | void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) { | |
117 | // | |
118 | // | |
119 | // | |
120 | TTree* tree=dynamic_cast<TTree*>(GetInputData(0)); | |
121 | if (!tree) { | |
2acad464 | 122 | //Printf("ERROR: Could not read chain from input slot 0"); |
73d51118 | 123 | } |
124 | else { | |
125 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
126 | if (!esdH) { | |
2acad464 | 127 | //Printf("ERROR: Could not get ESDInputHandler"); |
73d51118 | 128 | } |
129 | else { | |
130 | fESD = esdH->GetEvent(); | |
684602c8 | 131 | //Printf("*** CONNECTED NEW EVENT ****"); |
73d51118 | 132 | } |
133 | } | |
134 | } | |
135 | ||
136 | void AliTPCAnalysisTaskcalib::CreateOutputObjects() { | |
137 | // | |
138 | // | |
139 | // | |
54b8f8e1 | 140 | //OpenFile(0, "RECREATE"); |
77d31cb8 | 141 | |
08669268 | 142 | for (Int_t i=0; i<fCalibJobs->GetEntries(); i++) |
143 | { | |
144 | if (fCalibJobs->At(i)) | |
145 | PostData(i,(AliTPCcalibBase*)fCalibJobs->At(i)); | |
146 | } | |
73d51118 | 147 | } |
77d31cb8 | 148 | |
0db06ea6 | 149 | void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) { |
7eaa723e | 150 | // |
08825fb4 | 151 | // Terminate |
7eaa723e | 152 | // |
08825fb4 | 153 | AliTPCcalibBase *job=0; |
f7f33dec | 154 | Int_t njobs = fCalibJobs->GetEntriesFast(); |
08825fb4 | 155 | for (Int_t i=0;i<njobs;i++){ |
f7f33dec | 156 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); |
08825fb4 | 157 | if (job) job->Terminate(); |
7eaa723e | 158 | } |
42a48f93 | 159 | |
73d51118 | 160 | } |
161 | ||
f7f33dec | 162 | void AliTPCAnalysisTaskcalib::FinishTaskOutput() |
163 | { | |
164 | // | |
165 | // According description in AliAnalisysTask this method is call | |
166 | // on the slaves before sending data | |
167 | // | |
168 | Terminate("slave"); | |
5647625c | 169 | if(!fDebugOutputPath.IsNull()) { |
170 | RegisterDebugOutput(); | |
171 | } | |
679480d0 | 172 | |
f7f33dec | 173 | } |
174 | ||
175 | ||
73d51118 | 176 | void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) { |
08825fb4 | 177 | // |
178 | // Process ESD event | |
179 | // | |
180 | AliTPCcalibBase *job=0; | |
f7f33dec | 181 | Int_t njobs = fCalibJobs->GetEntriesFast(); |
08825fb4 | 182 | for (Int_t i=0;i<njobs;i++){ |
f7f33dec | 183 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); |
42a48f93 | 184 | if (job) { |
185 | job->UpdateEventInfo(event); | |
c51653e8 | 186 | if (job->AcceptTrigger()) |
187 | job->Process(event); | |
42a48f93 | 188 | } |
08825fb4 | 189 | } |
73d51118 | 190 | } |
191 | ||
192 | void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) { | |
08825fb4 | 193 | // |
194 | // Process TPC track | |
195 | // | |
196 | AliTPCcalibBase *job=0; | |
f7f33dec | 197 | Int_t njobs = fCalibJobs->GetEntriesFast(); |
08825fb4 | 198 | for (Int_t i=0;i<njobs;i++){ |
f7f33dec | 199 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); |
c51653e8 | 200 | if (job) |
201 | if (job->AcceptTrigger()) | |
202 | job->Process(track); | |
f7f33dec | 203 | } |
204 | } | |
205 | ||
5822e507 | 206 | void AliTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) { |
f7f33dec | 207 | // |
208 | // Process ESD track | |
209 | // | |
210 | AliTPCcalibBase *job=0; | |
211 | Int_t njobs = fCalibJobs->GetEntriesFast(); | |
212 | for (Int_t i=0;i<njobs;i++){ | |
213 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); | |
c51653e8 | 214 | if (job) |
215 | if (job->AcceptTrigger()) | |
216 | job->Process(track,run); | |
08825fb4 | 217 | } |
73d51118 | 218 | } |
219 | ||
220 | Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) { | |
f7f33dec | 221 | TIterator *i=fCalibJobs->MakeIterator(); |
73d51118 | 222 | AliTPCcalibBase *job; |
223 | Long64_t n=0; | |
0db06ea6 | 224 | while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next()))) |
73d51118 | 225 | n+=job->Merge(li); |
226 | return n; | |
227 | } | |
228 | ||
229 | void AliTPCAnalysisTaskcalib::Analyze() { | |
08825fb4 | 230 | // |
231 | // Analyze the content of the task | |
232 | // | |
233 | AliTPCcalibBase *job=0; | |
f7f33dec | 234 | Int_t njobs = fCalibJobs->GetEntriesFast(); |
08825fb4 | 235 | for (Int_t i=0;i<njobs;i++){ |
f7f33dec | 236 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); |
08825fb4 | 237 | if (job) job->Analyze(); |
238 | } | |
73d51118 | 239 | } |
f7f33dec | 240 | |
241 | ||
242 | void AliTPCAnalysisTaskcalib::RegisterDebugOutput(){ | |
243 | // | |
244 | // | |
245 | // | |
246 | AliTPCcalibBase *job=0; | |
247 | Int_t njobs = fCalibJobs->GetEntriesFast(); | |
248 | for (Int_t i=0;i<njobs;i++){ | |
249 | job = (AliTPCcalibBase*)fCalibJobs->UncheckedAt(i); | |
250 | if (job) job->RegisterDebugOutput(fDebugOutputPath.Data()); | |
251 | } | |
86cd06f0 | 252 | TString dsName=GetName(); |
253 | dsName+=".root"; | |
254 | TFile fff(dsName.Data(),"recreate"); | |
c51653e8 | 255 | fCalibJobs->Write("TPCCalib",TObject::kSingleKey); |
679480d0 | 256 | fff.Close(); |
257 | // | |
258 | // store - copy debug output to the destination position | |
259 | // currently ONLY for local copy | |
679480d0 | 260 | TString dsName2=fDebugOutputPath.Data(); |
261 | gSystem->MakeDirectory(dsName2.Data()); | |
262 | dsName2+=gSystem->HostName(); | |
263 | gSystem->MakeDirectory(dsName2.Data()); | |
264 | dsName2+="/"; | |
265 | TTimeStamp s; | |
266 | dsName2+=Int_t(s.GetNanoSec()); | |
267 | dsName2+="/"; | |
268 | gSystem->MakeDirectory(dsName2.Data()); | |
269 | dsName2+=dsName; | |
270 | AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data())); | |
271 | printf("copy %s\t%s\n",dsName.Data(),dsName2.Data()); | |
272 | TFile::Cp(dsName.Data(),dsName2.Data()); | |
273 | ||
f7f33dec | 274 | } |