]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCSelectorTracks.cxx
Important bug fix. The trigger inputs were not reset inside the event loop, so the...
[u/mrichter/AliRoot.git] / TPC / AliTPCSelectorTracks.cxx
CommitLineData
10757ee9 1// The class definition in esdClus.h has been generated automatically
2// by the ROOT utility TTree::MakeSelector(). This class is derived
3// from the ROOT class TSelector. For more information on the TSelector
4// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
5
6// The following methods are defined in this file:
7// Begin(): called everytime a loop on the tree starts,
8// a convenient place to create your histograms.
9// SlaveBegin(): called after Begin(), when on PROOF called only on the
10// slave servers.
11// Process(): called for each event, in this function you decide what
12// to read and fill your histograms.
13// SlaveTerminate: called at the end of the loop on the tree, when on PROOF
14// called only on the slave servers.
15// Terminate(): called at the end of the loop on the tree,
16// a convenient place to draw/fit your histograms.
17//
18// To use this file, try the following session on your Tree T:
19//
20// Root > T->Process("esdClus.C")
21// Root > T->Process("esdClus.C","some options")
22// Root > T->Process("esdClus.C+")
23//
24// Modification log:
25// 05/11/2006 HH Correct for large pads (outer sectors) in amplitude plots
26
27#include "TSystem.h"
28#include <TPDGCode.h>
29#include <TStyle.h>
30#include "TCint.h"
31#include "TList.h"
32#include "TH1I.h"
33#include "TChain.h"
34//
35#include "AliTracker.h"
36#include "AliMagF.h"
37//
38#include "AliESD.h"
39#include "AliESDEvent.h"
40#include "AliESDtrack.h"
41#include "AliESDfriend.h"
42#include "AliESDfriendTrack.h"
43#include "AliTPCseed.h"
44#include "AliTPCclusterMI.h"
45//
46//
47#include "AliTPCcalibTracks.h"
48#include "AliTPCcalibTracksGain.h"
49
50#include "AliTPCSelectorESD.h"
51#include "AliTPCSelectorTracks.h"
52#include "TProof.h"
53
54const char* AliTPCSelectorTracks::fgkOutputFileName = "Output.root";
55
56
57AliTPCSelectorTracks::AliTPCSelectorTracks(TTree *) :
58 AliTPCSelectorESD(),
59 fInit(kFALSE),
60 fCalibTracks(0),
61 fCalibTracksGain(0)
62{
63 //
64 //
65 //
66 G__SetCatchException(0);
67}
68
69AliTPCSelectorTracks::~AliTPCSelectorTracks(){
70 //
71 //
72 //
73}
74
75void AliTPCSelectorTracks::InitComponent(){
76 //
77 // Init Components
78 //
79 //
80 // USER -COMPONENT definder part
81 //
82 // before calling the process function, two objects have to be added to the chain/tree:
83 // clusterParam, the cluster parametrization and cuts, a AliTPCcalibTracksCuts object
84 // they have to be added in the following manner:
85 // chain->GetUserInfo()->AddLast(clusterParam);
86 // chain->GetUserInfo()->AddLast(cuts);
87 //
88 static Int_t counter=0;
89 if (!fChain){
90 Error("InitComponent","ERROR - chain not initialized\n");
91 }
92 Info("InitComponent",Form("Selector initialization No\t%d\n", counter));
93 counter++;
94 //
95
96
97 AliTPCClusterParam *clusterParam = (AliTPCClusterParam*)fChain->GetUserInfo()->FindObject("AliTPCClusterParam");
98 //
99 if (clusterParam == 0) Error("InitComponent","CLUSTER PARAM NOT FOUND IN CHAIN! \n");
100 //
101 AliTPCcalibTracksCuts *cuts = (AliTPCcalibTracksCuts*)fChain->GetUserInfo()->FindObject("calibTracksCuts");
102 if (cuts != 0) Info("InitComponent","cuts found in fChain! \n");
103 else{
104 Error("InitComponent","CUTS NOT FOUND IN CHAIN\n");
105 }
106 if (clusterParam==0 && fInput){
107 clusterParam = (AliTPCClusterParam*)fInput->FindObject("AliTPCClusterParam");
108 Error("InitComponent","CLUSTER PARAM NOT FOUND IN PROOF\n");
109 }
110 if (cuts==0 &&fInput ){
111 cuts = (AliTPCcalibTracksCuts*)fInput->FindObject("calibTracksCuts");
112 Error("InitComponent","CUTS NOT FOUND IN PROOF\n");
113 }
114 if (!cuts || !clusterParam) {
115 if (fInput) fInput->Print();
116 return;
117 }
118
119 fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
120 fOutput->AddLast(fCalibTracks);
121
122 AliTPCcalibTracksGain* prevIter = (AliTPCcalibTracksGain*)fChain->GetUserInfo()->FindObject("calibTracksGain");
123 if (!prevIter) Info("InitComponent", "Previous iteration of calibTracksGain not found, continuing without.");
124 TNamed* debugStreamPrefix = (TNamed*)fChain->GetUserInfo()->FindObject("debugStreamPrefix");
125 fCalibTracksGain = new AliTPCcalibTracksGain("calibTracksGain", "Gain calibration object for tracks", cuts, debugStreamPrefix, prevIter);
126 fOutput->AddLast(fCalibTracksGain);
127 fInit=kTRUE;
128}
129
130void AliTPCSelectorTracks::SlaveBegin(TTree * tree)
131{
132 // The SlaveBegin() function is called after the Begin() function.
133 // When running with PROOF SlaveBegin() is called on each slave server.
134 // The tree argument is deprecated (on PROOF 0 is passed).
135
136 AliTPCSelectorESD::SlaveBegin(tree);
137
138 printf(" ***** SlaveBegin ***** \n");
139}
140
141
142void AliTPCSelectorTracks::SlaveTerminate()
143{
144 // The SlaveTerminate() function is called after all entries or objects
145 // have been processed. When running with PROOF SlaveTerminate() is called
146 // on each slave server.
147 printf ("SlaveTerminate.. \n");
148 printf ("Terminate CalibTracksGain.. \n");
149 if (fCalibTracksGain) fCalibTracksGain->Terminate();
150}
151
152
153
154
155Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
156{
157 //
158 //
159 //
160 if (!fInit) InitComponent();
161 if (!fInit) return 0;
162 Int_t status = ReadEvent(entry);
163 if (status<0) return status;
164 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
165 //
166 //
167 // USER code to go here
168 //
169 AliTPCseed *seed;
170
171 for (Int_t tr = 0; tr < ntracks; tr++){
172 AliESDtrack *esdTrack = fESD ? (AliESDtrack*) fESD->GetTrack(tr): (AliESDtrack*) fESDevent->GetTrack(tr);
173 AliESDfriendTrack *friendtrack = (AliESDfriendTrack*) esdTrack->GetFriendTrack();
174 seed = 0;
175 TObject *cobject = 0;
176 for (Int_t i = 0; ; i++){
177 cobject = friendtrack->GetCalibObject(i);
178 if (!cobject) break;
179 seed = dynamic_cast<AliTPCseed*>(cobject);
180 if (seed) break;
181 }
182
183 if (seed) {
184 fNClusters->Fill(seed->GetNumberOfClusters());
185 //
186 fCalibTracks->Process(seed, esdTrack); // analysis is done in fCalibTracks
187 fCalibTracksGain->Process(seed);
188 }
189 }
190 CleanESD();
191 return 0;
192}
193
194
195void AliTPCSelectorTracks::Terminate()
196{
197 // The Terminate() function is the last function to be called during
198 // a query. It always runs on the client, it can be used to present
199 // the results graphically or save the results to file.
200
201
202 if (!fOutput) return;
203
204 TFile file(fgkOutputFileName, "recreate");
205 fCalibTracksGain = (AliTPCcalibTracksGain*)fOutput->FindObject("calibTracksGain");
206 // evaluate all fitters before saving them, because it doesn't seem to be possible
207 // to evaluate a TLinearFitter after it has been loaded from a root file
208 if (fCalibTracksGain) fCalibTracksGain->Evaluate();
209 fOutput->Write();
210 file.Close();
211 printf("Successfully written file to '%s'.", fgkOutputFileName);
212
213
214 Info("Destructor","Destuctor");
215 //delete fCalibTracksGain;
216 //delete fCalibTracks;
217// printf ("Terminate... \n");
218// if (!fOutput) return;
219// TFile file("Output.root","recreate");
220// printf("fOutput contains the following: \n");
221// fOutput->Print();
222// printf("Trying to write the file 'Output.root'... \n");
223// fOutput->Write();
224// file.Close();
225
226}
227
228