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
32 #include "TTimeStamp.h"
39 #include "AliTracker.h"
42 #include "AliESDEvent.h" // new container
44 #include "AliESDtrack.h"
45 #include "AliESDfriend.h"
46 #include "AliESDfriendTrack.h"
47 #include "AliTPCseed.h"
48 #include "AliTPCclusterMI.h"
50 #include "AliComparisonDraw.h"
51 #include "AliComparisonSelector.h"
56 AliComparisonSelector::AliComparisonSelector(TTree *) :
61 fSysWatch(0), // system info
62 fFileWatch(0), // file watch - write the status of the analyzed files
68 G__SetCatchException(0);
72 fSysWatch = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
73 fFileWatch = new fstream("filewatch.log", ios_base::out|ios_base::trunc);
74 if (gProof) fDebugLevel = gProof->GetLogLevel();
78 void AliComparisonSelector::Begin(TTree * /*tree*/)
80 // The Begin() function is called at the start of the query.
81 // When running with PROOF Begin() is only called on the client.
82 // The tree argument is deprecated (on PROOF 0 is passed).
84 TString option = GetOption();
88 void AliComparisonSelector::SlaveBegin(TTree * tree)
90 // The SlaveBegin() function is called after the Begin() function.
91 // When running with PROOF SlaveBegin() is called on each slave server.
92 // The tree argument is deprecated (on PROOF 0 is passed).
94 fComp = new AliComparisonDraw;
96 fOutput->AddLast(fComp);
100 void AliComparisonSelector::Clean(){
104 Bool_t AliComparisonSelector::Process(Long64_t entry)
106 // The Process() function is called for each entry in the tree (or possibly
107 // keyed object in the case of PROOF) to be processed. The entry argument
108 // specifies which entry in the currently loaded tree is to be processed.
109 // It can be passed to either AliComparisonSelector::GetEntry() or TBranch::GetEntry()
110 // to read either all or the required parts of the data. When processing
111 // keyed objects with PROOF, the object is already loaded and is available
112 // via the fObject pointer.
114 // This function should contain the "body" of the analysis. It can contain
115 // simple or elaborate selection criteria, run algorithms on the data
116 // of the event and typically fill histograms.
118 // The processing can be stopped by calling Abort().
120 // Use fStatus to set the return value of TTree::Process().
122 // The return value is currently not used.
124 Int_t status = ProcessIn(entry);
126 (*fFileWatch) << "__" << status ;
134 Int_t AliComparisonSelector::ReadEvent(Long64_t entry){
140 if (!fChain) return -1;
141 if (!fChain->GetTree()) return -1;
142 TTree * tree = fChain->GetTree();
143 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
144 tree->GetBranch("MC")->SetAddress(&fInfoMC);
145 tree->GetBranch("RC")->SetAddress(&fInfoRC);
148 fChain->GetTree()->GetEntry(entry);
149 } catch (std::bad_alloc) {
150 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
157 Int_t AliComparisonSelector::ProcessIn(Long64_t entry)
160 // User part of proccess method
164 // USER code to go here
166 Int_t status = ReadEvent(entry);
167 if (status<0) return status;
168 fComp->Process(fInfoMC, fInfoRC);
174 void AliComparisonSelector::SlaveTerminate()
176 // The SlaveTerminate() function is called after all entries or objects
177 // have been processed. When running with PROOF SlaveTerminate() is called
178 // on each slave server.
179 printf ("SlaveTerminate.. \n");
183 void AliComparisonSelector::Terminate()
185 // The Terminate() function is the last function to be called during
186 // a query. It always runs on the client, it can be used to present
187 // the results graphically or save the results to file.
189 printf ("Terminate... \n");
190 if (!fOutput) return;
191 TFile file("Output.root","recreate");
192 printf("fOutput contains the following: \n");
194 printf("Trying to write the file 'Output.root'... \n");
203 void AliComparisonSelector::Init(TTree *tree)
205 // The Init() function is called when the selector needs to initialize
206 // a new tree or chain. Typically here the branch addresses and branch
207 // pointers of the tree will be set.
208 // It is normaly not necessary to make changes to the generated
209 // code, but the routine can be extended by the user if needed.
210 // Init() will be called many times when running on PROOF
211 // (once per file to be processed).
213 // Set branch addresses and branch pointers
217 tree->SetBranchStatus("*",1);
219 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
220 tree->GetBranch("MC")->SetAddress(&fInfoMC);
221 tree->GetBranch("RC")->SetAddress(&fInfoRC);
227 Bool_t AliComparisonSelector::Notify()
229 // The Notify() function is called when a new file is opened. This
230 // can be either for a new TTree in a TChain or when when a new TTree
231 // is started when using PROOF. It is normaly not necessary to make changes
232 // to the generated code, but the routine can be extended by the
233 // user if needed. The return value is currently not used.
236 const char * fname = "UNKNOWN";
237 const char * hname = gSystem->HostName();
238 if (fChain->GetCurrentFile()){
239 fname = fChain->GetCurrentFile()->GetName();
244 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
247 // Print statistic to log file
250 (*fFileWatch) << endl;
251 (*fFileWatch) << hname <<"\t"
260 void AliComparisonSelector::DumpSysInfo(Int_t entry){
262 // dump system info to log file
263 // entry - entry number in the chain
265 const char * fname = "UNKNOWN";
266 const char * hname = gSystem->HostName();
267 if (fChain->GetCurrentFile()){
268 fname = fChain->GetCurrentFile()->GetName();
277 gSystem->GetCpuInfo(&cpuInfo, 1000);
278 gSystem->GetMemInfo(&memInfo);
279 gSystem->GetProcInfo(&procInfo);
281 (*fSysWatch) << hname <<"\t" // hname - hostname
282 << fname <<"\t" // fname - filename
283 << entry <<"\t" // entry - entry number
284 << stamp.GetSec()<<"\t" // time - time stamp in seconds
285 << memInfo.fMemUsed<<"\t" //
286 << memInfo.fSwapUsed<<"\t" //
287 << procInfo.fMemResident<<"\t" //
288 << procInfo.fMemVirtual<<"\t" //
289 << cpuInfo.fUser <<"\t" //
290 << cpuInfo.fSys <<"\t" //
291 << procInfo.fCpuUser<<"\t" //
292 << procInfo.fCpuSys<<"\t" //