]>
Commit | Line | Data |
---|---|---|
df71af87 | 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 | /* $Id$ */ | |
17 | ||
18 | // The ESD is available as member fESD | |
19 | // | |
20 | // The Process function is nearly empty. Implement your analysis there and look at the other listed below functions you | |
21 | // might need. | |
22 | // | |
23 | // The following methods can be overrriden. Please do not forgot to call the base class function. | |
24 | // | |
25 | // Begin(): called everytime a loop on the tree starts, | |
26 | // a convenient place to create your histograms. | |
27 | // SlaveBegin(): called after Begin(), when on PROOF called only on the | |
28 | // slave servers. | |
29 | // Init(): called for each new tree. Enable/Disable branches here. | |
30 | // Process(): called for each event, in this function you decide what | |
31 | // to read and fill your histograms. | |
32 | // SlaveTerminate: called at the end of the loop on the tree, when on PROOF | |
33 | // called only on the slave servers. | |
34 | // Terminate(): called at the end of the loop on the tree, | |
35 | // a convenient place to draw/fit your histograms. | |
36 | // | |
37 | // Author: Jan.Fiete.Grosse-Oetringhaus@cern.ch | |
38 | ||
39 | #include "AliROCESDAnalysisSelector.h" | |
40 | ||
41 | #include <AliLog.h> | |
42 | #include <AliESD.h> | |
43 | #include <AliESDfriend.h> | |
44 | #include <../TPC/AliTPCclusterMI.h> | |
45 | #include <../TPC/AliTPCseed.h> | |
46 | ||
df71af87 | 47 | #include <TFile.h> |
48 | #include <TTree.h> | |
49 | #include <TCanvas.h> | |
2d9e89d4 | 50 | |
51 | #include "TPC/AliTPCClusterHistograms.h" | |
df71af87 | 52 | |
53 | ClassImp(AliROCESDAnalysisSelector) | |
54 | ||
55 | AliROCESDAnalysisSelector::AliROCESDAnalysisSelector() : | |
56 | AliSelector(), | |
9cc7192c | 57 | fESDfriend(0) |
df71af87 | 58 | { |
59 | // | |
60 | // Constructor. Initialization of pointers | |
61 | // | |
9cc7192c | 62 | |
63 | for (Int_t i=0; i<kTPCSectors; i++) | |
64 | fClusterHistograms[i] = 0; | |
df71af87 | 65 | } |
66 | ||
67 | AliROCESDAnalysisSelector::~AliROCESDAnalysisSelector() | |
68 | { | |
69 | // | |
70 | // Destructor | |
71 | // | |
72 | } | |
73 | ||
74 | void AliROCESDAnalysisSelector::SlaveBegin(TTree* tree) | |
75 | { | |
76 | // | |
77 | ||
78 | AliSelector::SlaveBegin(tree); | |
df71af87 | 79 | } |
80 | ||
81 | void AliROCESDAnalysisSelector::Init(TTree *tree) | |
82 | { | |
83 | // The Init() function is called when the selector needs to initialize | |
84 | // a new tree or chain. Typically here the branch addresses of the tree | |
85 | // will be set. It is normaly not necessary to make changes to the | |
86 | // generated code, but the routine can be extended by the user if needed. | |
87 | // Init() will be called many times when running with PROOF. | |
88 | ||
89 | AliSelector::Init(tree); | |
90 | ||
91 | // Set branch address | |
92 | if (tree) | |
93 | tree->SetBranchAddress("ESDfriend", &fESDfriend); | |
94 | ||
95 | if (fESDfriend != 0) | |
96 | AliDebug(AliLog::kInfo, "INFO: Found ESDfriend branch in chain."); | |
97 | } | |
98 | ||
99 | Bool_t AliROCESDAnalysisSelector::Process(Long64_t entry) | |
100 | { | |
101 | // | |
102 | // Implement your analysis here. Do not forget to call the parent class Process by | |
103 | // if (AliSelector::Process(entry) == kFALSE) | |
104 | // return kFALSE; | |
105 | // | |
106 | ||
107 | if (AliSelector::Process(entry) == kFALSE) | |
108 | return kFALSE; | |
109 | ||
110 | // Check prerequisites | |
111 | if (!fESD) | |
112 | { | |
113 | AliDebug(AliLog::kError, "ESD branch not available"); | |
114 | return kFALSE; | |
115 | } | |
116 | ||
117 | // Check prerequisites | |
118 | if (!fESDfriend) | |
119 | { | |
120 | AliDebug(AliLog::kError, "ESDfriend branch not available"); | |
121 | return kFALSE; | |
122 | } | |
123 | ||
483b1eb8 | 124 | // printf(Form(" event number: %d ... time stamp: %d \n", fESD->GetEventNumber(), fESD->GetTimeStamp())); |
125 | ||
df71af87 | 126 | fESD->SetESDfriend(fESDfriend); |
127 | ||
128 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
129 | ||
9cc7192c | 130 | Int_t nSkippedSeeds = 0; |
131 | ||
df71af87 | 132 | // loop over esd tracks |
133 | for (Int_t t=0; t<nTracks; t++) | |
134 | { | |
135 | AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (fESD->GetTrack(t)); | |
136 | if (!esdTrack) | |
137 | { | |
138 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t)); | |
139 | continue; | |
140 | } | |
141 | ||
142 | AliESDfriendTrack* friendtrack = const_cast<AliESDfriendTrack*> (dynamic_cast<const AliESDfriendTrack*> (esdTrack->GetFriendTrack())); | |
143 | if (!friendtrack) | |
144 | { | |
145 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve friend of track %d.", t)); | |
146 | continue; | |
147 | } | |
148 | ||
149 | const AliTPCseed* seed = dynamic_cast<const AliTPCseed*> (friendtrack->GetCalibObject(0)); | |
150 | if (!seed) | |
151 | { | |
9cc7192c | 152 | AliDebug(AliLog::kDebug, Form("ERROR: Could not retrieve seed of track %d.", t)); |
153 | nSkippedSeeds++; | |
df71af87 | 154 | continue; |
155 | } | |
156 | ||
157 | for (Int_t clusterID = 0; clusterID < 160; clusterID++) | |
158 | { | |
159 | AliTPCclusterMI* cluster = seed->GetClusterPointer(clusterID); | |
160 | if (!cluster) | |
161 | { | |
162 | //AliDebug(AliLog::kError, Form("ERROR: Could not retrieve cluster %d of track %d.", clusterID, t)); | |
163 | continue; | |
164 | } | |
165 | ||
166 | //AliDebug(AliLog::kDebug, Form("We found a cluster from sector %d", cluster->GetDetector())); | |
167 | ||
9cc7192c | 168 | Int_t detector = cluster->GetDetector(); |
169 | ||
eb884e16 | 170 | if (detector < 0 || detector >= kTPCSectors) { |
171 | AliDebug(AliLog::kDebug, Form("We found a cluster from invalid sector %d", detector)); | |
172 | continue; | |
9cc7192c | 173 | } |
eb884e16 | 174 | |
483b1eb8 | 175 | // TODO: find a clever way to handle the time |
176 | // if (fESD->GetTimeStamp()<1160000000) | |
177 | // continue; | |
178 | ||
9cc7192c | 179 | if (!fClusterHistograms[detector]) |
180 | { | |
eb884e16 | 181 | fClusterHistograms[detector] = new AliTPCClusterHistograms(detector,"",fESD->GetTimeStamp(),fESD->GetTimeStamp()+7*60*60); |
9cc7192c | 182 | } |
df71af87 | 183 | |
483b1eb8 | 184 | fClusterHistograms[detector]->FillCluster(cluster, fESD->GetTimeStamp()); |
df71af87 | 185 | } |
186 | } | |
9cc7192c | 187 | |
188 | if (nSkippedSeeds > 0) | |
189 | printf("WARNING: The seed was not found for %d out of %d tracks.\n", nSkippedSeeds, nTracks); | |
df71af87 | 190 | |
191 | return kTRUE; | |
192 | } | |
193 | ||
194 | void AliROCESDAnalysisSelector::SlaveTerminate() | |
195 | { | |
196 | // | |
197 | ||
9cc7192c | 198 | for (Int_t i=0; i<kTPCSectors; i++) |
199 | if (fClusterHistograms[i]) | |
200 | fOutput->Add(fClusterHistograms[i]); | |
df71af87 | 201 | } |
202 | ||
203 | void AliROCESDAnalysisSelector::Terminate() | |
204 | { | |
9cc7192c | 205 | // TODO read from output list for PROOF |
df71af87 | 206 | |
207 | TFile* file = TFile::Open("rocESD.root", "RECREATE"); | |
2d9e89d4 | 208 | |
9cc7192c | 209 | for (Int_t i=0; i<kTPCSectors; i++) |
483b1eb8 | 210 | if (fClusterHistograms[i]) { |
9cc7192c | 211 | fClusterHistograms[i]->SaveHistograms(); |
483b1eb8 | 212 | TCanvas* c = fClusterHistograms[i]->DrawHistograms(); |
213 | c->SaveAs(Form("%s.eps",c->GetName())); | |
214 | c->SaveAs(Form("%s.gif",c->GetName())); | |
215 | } | |
df71af87 | 216 | file->Close(); |
217 | } |