]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCcalib/AliTPCSelectorTracks.cxx
Changes due to new PROOF (Marian)
[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"
35ff5568 52
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
3d0ad3bb 75
5c457bb0 76void AliTPCSelectorTracks::InitComponent(){
77 //
78 // Init Components
79 //
35ff5568 80 //
3d0ad3bb 81 // USER -COMPONENT definder part
82 //
83 // before calling the process function, two objects have to be added to the chain/tree:
84 // clusterParam, the cluster parametrization and cuts, a AliTPCcalibTracksCuts object
85 // they have to be added in the following manner:
86 // chain->GetUserInfo()->AddLast(clusterParam);
87 // chain->GetUserInfo()->AddLast(cuts);
88 //
6fd5d5f2 89 if (!fChain){
90 printf("EROOR - chain not initialized\n");
91 }
92
93 AliTPCClusterParam *clusterParam = (AliTPCClusterParam*)fChain->GetUserInfo()->FindObject("AliTPCClusterParam");
5c457bb0 94 if (clusterParam != 0) printf("clusterParam found in fChain! \n");
95 AliTPCcalibTracksCuts *cuts = (AliTPCcalibTracksCuts*)fChain->GetUserInfo()->FindObject("calibTracksCuts");
96 if (cuts != 0) printf("cuts found in fChain! \n");
97
98 fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
3d0ad3bb 99 fOutput->AddLast(fCalibTracks);
100
101 fCalibTracksGain = new AliTPCcalibTracksGain("calibTracksGain", "Gain calibration object for tracks");
102 fOutput->AddLast(fCalibTracksGain);
6fd5d5f2 103 fInit=kTRUE;
5c457bb0 104}
105
106void AliTPCSelectorTracks::SlaveBegin(TTree * tree)
107{
108 // The SlaveBegin() function is called after the Begin() function.
109 // When running with PROOF SlaveBegin() is called on each slave server.
110 // The tree argument is deprecated (on PROOF 0 is passed).
111
112 AliTPCSelectorESD::SlaveBegin(tree);
6fd5d5f2 113
5c457bb0 114 printf(" ***** SlaveBegin ***** \n");
35ff5568 115}
116
117
3d0ad3bb 118Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
35ff5568 119{
35ff5568 120 //
3d0ad3bb 121 //
122 //
5c457bb0 123 if (!fInit) InitComponent();
3d0ad3bb 124 Int_t status = ReadEvent(entry);
125 if (status<0) return status;
126 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
127 //
35ff5568 128 //
129 // USER code to go here
130 //
131 AliTPCseed *seed;
35ff5568 132
b168fbc0 133 for (Int_t tr = 0; tr < ntracks; tr++){
3d0ad3bb 134 AliESDtrack *esdTrack = fESD ? (AliESDtrack*) fESD->GetTrack(tr): (AliESDtrack*) fESDevent->GetTrack(tr);
135 AliESDfriendTrack *friendtrack = (AliESDfriendTrack*) esdTrack->GetFriendTrack();
136 seed = 0;
137 TObject *cobject=0;
138 for (Int_t i=0;;i++){
139 cobject = friendtrack->GetCalibObject(i);
140 if (!cobject) break;
141 seed = dynamic_cast<AliTPCseed*>(cobject);
142 if (seed) break;
143 }
144
35ff5568 145 if (seed) {
35ff5568 146 fNClusters->Fill(seed->GetNumberOfClusters());
147 //
3d0ad3bb 148 //fCalibTracks->Process(seed, esdTrack); // analysis is done in fCalibTracks
149 //if (!AliTPCcalibTracksGain::AcceptTrack(seed)) {/*cerr << "not accepted" << endl;*/ continue; }
150 fCalibTracksGain->AddTrack(seed);
35ff5568 151 }
152 }
b168fbc0 153 CleanESD();
3d0ad3bb 154 return 0;
35ff5568 155
156}
157
158
35ff5568 159void AliTPCSelectorTracks::Terminate()
160{
161 // The Terminate() function is the last function to be called during
162 // a query. It always runs on the client, it can be used to present
163 // the results graphically or save the results to file.
b168fbc0 164
b168fbc0 165
3d0ad3bb 166 if (!fOutput) return;
167
168 // evaluate all fitters before saving them, because it doesn't seem to be possible
169 // to evaluate a TLinearFitter after it has been loaded from a root file
170 // for (UInt_t iSegment = 0; iSegment < 36; iSegment++) {
171// for (UInt_t iPadType = 0; iPadType < 3; iPadType++) {
172// for (UInt_t iFitType = 0; iFitType < 3; iFitType++)
173// fCalibTracksGain->Evaluate(iSegment, iPadType, iFitType);
174// }
175// }
176 TFile file(fgkOutputFileName, "recreate");
177 fOutput->Write();
178 file.Close();
179 printf("Successfully written file to '%s'.", fgkOutputFileName);
180
181
182 Info("Destructor","Destuctor");
183 delete fCalibTracksGain;
184 delete fCalibTracks;
185// printf ("Terminate... \n");
186// if (!fOutput) return;
187// TFile file("Output.root","recreate");
188// printf("fOutput contains the following: \n");
189// fOutput->Print();
190// printf("Trying to write the file 'Output.root'... \n");
191// fOutput->Write();
192// file.Close();
b168fbc0 193
35ff5568 194}
195
196