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.
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
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.
18 // To use this file, try the following session on your Tree T:
20 // Root > T->Process("esdClus.C")
21 // Root > T->Process("esdClus.C","some options")
22 // Root > T->Process("esdClus.C+")
25 // 05/11/2006 HH Correct for large pads (outer sectors) in amplitude plots
35 #include "AliTracker.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"
47 #include "AliTPCcalibTracks.h"
48 #include "AliTPCcalibTracksGain.h"
50 #include "AliTPCSelectorESD.h"
51 #include "AliTPCSelectorTracks.h"
54 const char* AliTPCSelectorTracks::fgkOutputFileName = "Output.root";
57 AliTPCSelectorTracks::AliTPCSelectorTracks(TTree *) :
66 G__SetCatchException(0);
69 AliTPCSelectorTracks::~AliTPCSelectorTracks(){
75 void AliTPCSelectorTracks::InitComponent(){
80 // USER -COMPONENT definder part
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);
88 static Int_t counter=0;
90 Error("InitComponent","ERROR - chain not initialized\n");
92 Info("InitComponent",Form("Selector initialization No\t%d\n", counter));
97 AliTPCClusterParam *clusterParam = (AliTPCClusterParam*)fChain->GetUserInfo()->FindObject("AliTPCClusterParam");
99 if (clusterParam == 0) Error("InitComponent","CLUSTER PARAM NOT FOUND IN CHAIN! \n");
101 AliTPCcalibTracksCuts *cuts = (AliTPCcalibTracksCuts*)fChain->GetUserInfo()->FindObject("calibTracksCuts");
102 if (cuts != 0) Info("InitComponent","cuts found in fChain! \n");
104 Error("InitComponent","CUTS NOT FOUND IN CHAIN\n");
106 if (clusterParam==0 && fInput){
107 clusterParam = (AliTPCClusterParam*)fInput->FindObject("AliTPCClusterParam");
108 Error("InitComponent","CLUSTER PARAM NOT FOUND IN PROOF\n");
110 if (cuts==0 &&fInput ){
111 cuts = (AliTPCcalibTracksCuts*)fInput->FindObject("calibTracksCuts");
112 Error("InitComponent","CUTS NOT FOUND IN PROOF\n");
114 if (!cuts || !clusterParam) {
115 if (fInput) fInput->Print();
119 fCalibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
120 fOutput->AddLast(fCalibTracks);
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);
130 void AliTPCSelectorTracks::SlaveBegin(TTree * tree)
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).
136 AliTPCSelectorESD::SlaveBegin(tree);
138 printf(" ***** SlaveBegin ***** \n");
142 void AliTPCSelectorTracks::SlaveTerminate()
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 if (fCalibTracksGain) fCalibTracksGain->Terminate();
154 Int_t AliTPCSelectorTracks::ProcessIn(Long64_t entry)
159 if (!fInit) InitComponent();
160 if (!fInit) return 0;
161 Int_t status = ReadEvent(entry);
162 if (status<0) return status;
163 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
166 // USER code to go here
170 for (Int_t tr = 0; tr < ntracks; tr++){
171 AliESDtrack *esdTrack = fESD ? (AliESDtrack*) fESD->GetTrack(tr): (AliESDtrack*) fESDevent->GetTrack(tr);
172 AliESDfriendTrack *friendtrack = (AliESDfriendTrack*) esdTrack->GetFriendTrack();
174 TObject *cobject = 0;
175 for (Int_t i = 0; ; i++){
176 cobject = friendtrack->GetCalibObject(i);
178 seed = dynamic_cast<AliTPCseed*>(cobject);
183 fNClusters->Fill(seed->GetNumberOfClusters());
185 fCalibTracks->Process(seed, esdTrack); // analysis is done in fCalibTracks
186 fCalibTracksGain->Process(seed);
194 void AliTPCSelectorTracks::Terminate()
196 // The Terminate() function is the last function to be called during
197 // a query. It always runs on the client, it can be used to present
198 // the results graphically or save the results to file.
201 if (!fOutput) return;
203 TFile file(fgkOutputFileName, "recreate");
204 fCalibTracksGain = (AliTPCcalibTracksGain*)fOutput->FindObject("calibTracksGain");
205 // evaluate all fitters before saving them, because it doesn't seem to be possible
206 // to evaluate a TLinearFitter after it has been loaded from a root file
207 if (fCalibTracksGain) fCalibTracksGain->Evaluate();
210 printf("Successfully written file to '%s'.", fgkOutputFileName);
213 Info("Destructor","Destuctor");
214 //delete fCalibTracksGain;
215 //delete fCalibTracks;
216 // printf ("Terminate... \n");
217 // if (!fOutput) return;
218 // TFile file("Output.root","recreate");
219 // printf("fOutput contains the following: \n");
221 // printf("Trying to write the file 'Output.root'... \n");