]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCcalib/AliTPCSelectorTracks.cxx
Update in the AliTPCcalibTracksGain (Marian, Stefan)
[u/mrichter/AliRoot.git] / TPC / TPCcalib / AliTPCSelectorTracks.cxx
CommitLineData
35ff5568 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"
3d0ad3bb 31#include "TList.h"
35ff5568 32#include "TH1I.h"
3d0ad3bb 33#include "TChain.h"
35ff5568 34//
35ff5568 35#include "AliTracker.h"
b168fbc0 36#include "AliMagF.h"
35ff5568 37//
38#include "AliESD.h"
3d0ad3bb 39#include "AliESDEvent.h"
35ff5568 40#include "AliESDtrack.h"
41#include "AliESDfriend.h"
42#include "AliESDfriendTrack.h"
43#include "AliTPCseed.h"
44#include "AliTPCclusterMI.h"
3d0ad3bb 45//
35ff5568 46//
47#include "AliTPCcalibTracks.h"
3d0ad3bb 48#include "AliTPCcalibTracksGain.h"
35ff5568 49
3d0ad3bb 50#include "AliTPCSelectorESD.h"
51#include "AliTPCSelectorTracks.h"
671f8b33 52#include "TProof.h"
35ff5568 53
3d0ad3bb 54const char* AliTPCSelectorTracks::fgkOutputFileName = "Output.root";
35ff5568 55
56
57AliTPCSelectorTracks::AliTPCSelectorTracks(TTree *) :
3d0ad3bb 58 AliTPCSelectorESD(),
5c457bb0 59 fInit(kFALSE),
3d0ad3bb 60 fCalibTracks(0),
61 fCalibTracksGain(0)
35ff5568 62{
3d0ad3bb 63 //
64 //
65 //
66 G__SetCatchException(0);
67}
35ff5568 68
3d0ad3bb 69AliTPCSelectorTracks::~AliTPCSelectorTracks(){
70 //
71 //
72 //
35ff5568 73}
74
5c457bb0 75void AliTPCSelectorTracks::InitComponent(){
76 //
77 // Init Components
78 //
35ff5568 79 //
3d0ad3bb 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);
b8334561 87 //
88 static Int_t counter=0;
6fd5d5f2 89 if (!fChain){
6978ddfb 90 Error("InitComponent","ERROR - chain not initialized\n");
6fd5d5f2 91 }
b8334561 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 //
5c457bb0 101 AliTPCcalibTracksCuts *cuts = (AliTPCcalibTracksCuts*)fChain->GetUserInfo()->FindObject("calibTracksCuts");
b8334561 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 }
6978ddfb 118
b8334561 119 fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
120 fOutput->AddLast(fCalibTracks);
3d0ad3bb 121
6978ddfb 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;
5c457bb0 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);
6fd5d5f2 137
5c457bb0 138 printf(" ***** SlaveBegin ***** \n");
35ff5568 139}
140
141
2617ff5b 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");
6978ddfb 148 printf ("Terminate CalibTracksGain.. \n");
2617ff5b 149 if (fCalibTracksGain) fCalibTracksGain->Terminate();
150}
151
152
153
154
3d0ad3bb 155Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
35ff5568 156{
6978ddfb 157 //
158 //
159 //
5c457bb0 160 if (!fInit) InitComponent();
b8334561 161 if (!fInit) return 0;
3d0ad3bb 162 Int_t status = ReadEvent(entry);
163 if (status<0) return status;
164 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
6978ddfb 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;
35ff5568 192}
193
194
35ff5568 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.
b168fbc0 200
b168fbc0 201
3d0ad3bb 202 if (!fOutput) return;
203
3d0ad3bb 204 TFile file(fgkOutputFileName, "recreate");
2617ff5b 205 fCalibTracksGain = (AliTPCcalibTracksGain*)fOutput->FindObject("calibTracksGain");
6978ddfb 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
2617ff5b 208 if (fCalibTracksGain) fCalibTracksGain->Evaluate();
3d0ad3bb 209 fOutput->Write();
210 file.Close();
211 printf("Successfully written file to '%s'.", fgkOutputFileName);
2617ff5b 212
3d0ad3bb 213
214 Info("Destructor","Destuctor");
2617ff5b 215 //delete fCalibTracksGain;
216 //delete fCalibTracks;
3d0ad3bb 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();
b168fbc0 225
35ff5568 226}
227
228