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"
54 ClassImp(AliComparisonSelector)
57 AliComparisonSelector::AliComparisonSelector(TTree *) :
62 fSysWatch(0), // system info
63 fFileWatch(0), // file watch - write the status of the analyzed files
69 G__SetCatchException(0);
73 fSysWatch = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
74 fFileWatch = new fstream("filewatch.log", ios_base::out|ios_base::trunc);
75 if (gProof) fDebugLevel = gProof->GetLogLevel();
79 void AliComparisonSelector::Begin(TTree * /*tree*/)
81 // The Begin() function is called at the start of the query.
82 // When running with PROOF Begin() is only called on the client.
83 // The tree argument is deprecated (on PROOF 0 is passed).
85 TString option = GetOption();
89 void AliComparisonSelector::SlaveBegin(TTree * tree)
91 // The SlaveBegin() function is called after the Begin() function.
92 // When running with PROOF SlaveBegin() is called on each slave server.
93 // The tree argument is deprecated (on PROOF 0 is passed).
95 fComp = new AliComparisonDraw;
97 fOutput->AddLast(fComp);
101 void AliComparisonSelector::Clean(){
105 Bool_t AliComparisonSelector::Process(Long64_t entry)
107 // The Process() function is called for each entry in the tree (or possibly
108 // keyed object in the case of PROOF) to be processed. The entry argument
109 // specifies which entry in the currently loaded tree is to be processed.
110 // It can be passed to either AliComparisonSelector::GetEntry() or TBranch::GetEntry()
111 // to read either all or the required parts of the data. When processing
112 // keyed objects with PROOF, the object is already loaded and is available
113 // via the fObject pointer.
115 // This function should contain the "body" of the analysis. It can contain
116 // simple or elaborate selection criteria, run algorithms on the data
117 // of the event and typically fill histograms.
119 // The processing can be stopped by calling Abort().
121 // Use fStatus to set the return value of TTree::Process().
123 // The return value is currently not used.
125 Int_t status = ProcessIn(entry);
127 (*fFileWatch) << "__" << status ;
135 Int_t AliComparisonSelector::ReadEvent(Long64_t entry){
141 if (!fChain) return -1;
142 if (!fChain->GetTree()) return -1;
143 TTree * tree = fChain->GetTree();
144 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
145 tree->GetBranch("MC")->SetAddress(&fInfoMC);
146 tree->GetBranch("RC")->SetAddress(&fInfoRC);
149 fChain->GetTree()->GetEntry(entry);
150 } catch (std::bad_alloc) {
151 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
158 Int_t AliComparisonSelector::ProcessIn(Long64_t entry)
161 // User part of proccess method
165 // USER code to go here
167 Int_t status = ReadEvent(entry);
168 if (status<0) return status;
169 fComp->Process(fInfoMC, fInfoRC);
175 void AliComparisonSelector::SlaveTerminate()
177 // The SlaveTerminate() function is called after all entries or objects
178 // have been processed. When running with PROOF SlaveTerminate() is called
179 // on each slave server.
180 printf ("SlaveTerminate.. \n");
184 void AliComparisonSelector::Terminate()
186 // The Terminate() function is the last function to be called during
187 // a query. It always runs on the client, it can be used to present
188 // the results graphically or save the results to file.
190 printf ("Terminate... \n");
191 if (!fOutput) return;
192 TFile file("Output.root","recreate");
193 printf("fOutput contains the following: \n");
195 printf("Trying to write the file 'Output.root'... \n");
204 void AliComparisonSelector::Init(TTree *tree)
206 // The Init() function is called when the selector needs to initialize
207 // a new tree or chain. Typically here the branch addresses and branch
208 // pointers of the tree will be set.
209 // It is normaly not necessary to make changes to the generated
210 // code, but the routine can be extended by the user if needed.
211 // Init() will be called many times when running on PROOF
212 // (once per file to be processed).
214 // Set branch addresses and branch pointers
218 tree->SetBranchStatus("*",1);
220 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
221 tree->GetBranch("MC")->SetAddress(&fInfoMC);
222 tree->GetBranch("RC")->SetAddress(&fInfoRC);
228 Bool_t AliComparisonSelector::Notify()
230 // The Notify() function is called when a new file is opened. This
231 // can be either for a new TTree in a TChain or when when a new TTree
232 // is started when using PROOF. It is normaly not necessary to make changes
233 // to the generated code, but the routine can be extended by the
234 // user if needed. The return value is currently not used.
237 const char * fname = "UNKNOWN";
238 const char * hname = gSystem->HostName();
239 if (fChain->GetCurrentFile()){
240 fname = fChain->GetCurrentFile()->GetName();
245 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
248 // Print statistic to log file
251 (*fFileWatch) << endl;
252 (*fFileWatch) << hname <<"\t"
261 void AliComparisonSelector::DumpSysInfo(Int_t entry){
263 // dump system info to log file
264 // entry - entry number in the chain
266 const char * fname = "UNKNOWN";
267 const char * hname = gSystem->HostName();
268 if (fChain->GetCurrentFile()){
269 fname = fChain->GetCurrentFile()->GetName();
278 gSystem->GetCpuInfo(&cpuInfo, 1000);
279 gSystem->GetMemInfo(&memInfo);
280 gSystem->GetProcInfo(&procInfo);
282 (*fSysWatch) << hname <<"\t" // hname - hostname
283 << fname <<"\t" // fname - filename
284 << entry <<"\t" // entry - entry number
285 << stamp.GetSec()<<"\t" // time - time stamp in seconds
286 << memInfo.fMemUsed<<"\t" //
287 << memInfo.fSwapUsed<<"\t" //
288 << procInfo.fMemResident<<"\t" //
289 << procInfo.fMemVirtual<<"\t" //
290 << cpuInfo.fUser <<"\t" //
291 << cpuInfo.fSys <<"\t" //
292 << procInfo.fCpuUser<<"\t" //
293 << procInfo.fCpuSys<<"\t" //