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"
36 #include "AliTracker.h"
39 #include "AliESDEvent.h" // new container
41 #include "AliESDtrack.h"
42 #include "AliESDfriend.h"
43 #include "AliESDfriendTrack.h"
44 #include "AliTPCseed.h"
45 #include "AliTPCclusterMI.h"
47 #include "AliSysInfo.h"
48 #include "AliTPCSelectorESD.h"
54 AliTPCSelectorESD::AliTPCSelectorESD(TTree *tree) :
61 fSysWatch(0), // system info
62 fFileWatch(0), // file watch - write the status of the analyzed files
65 G__SetCatchException(0);
69 fSysWatch = new fstream("syswatch2.log", ios_base::out|ios_base::trunc);
70 fFileWatch = new fstream("filewatch.log", ios_base::out|ios_base::trunc);
71 if (gProof) fDebugLevel = gProof->GetLogLevel();
72 if (tree) fChain=tree;
76 void AliTPCSelectorESD::Begin(TTree * /*tree*/)
78 // The Begin() function is called at the start of the query.
79 // When running with PROOF Begin() is only called on the client.
80 // The tree argument is deprecated (on PROOF 0 is passed).
82 TString option = GetOption();
86 void AliTPCSelectorESD::SlaveBegin(TTree * tree)
88 // The SlaveBegin() function is called after the Begin() function.
89 // When running with PROOF SlaveBegin() is called on each slave server.
90 // The tree argument is deprecated (on PROOF 0 is passed).
91 if (tree) fChain = tree;
94 fNtracks = new TH1I("ntracks","Number of tracks",100,0,400);
95 fNtracksFriend = new TH1I("ntracksF","Number of friend tracks",100,0,400);
96 fNClusters = new TH1I("ncluster","Number of clusters",100,0,200);
97 fOutput->AddLast(fNtracks);
98 fOutput->AddLast(fNtracksFriend);
99 fOutput->AddLast(fNClusters);
104 void AliTPCSelectorESD::CleanESD(){
106 Bool_t isNew = fESDevent!=0;
124 Bool_t AliTPCSelectorESD::Process(Long64_t entry)
126 // The Process() function is called for each entry in the tree (or possibly
127 // keyed object in the case of PROOF) to be processed. The entry argument
128 // specifies which entry in the currently loaded tree is to be processed.
129 // It can be passed to either AliTPCSelectorESD::GetEntry() or TBranch::GetEntry()
130 // to read either all or the required parts of the data. When processing
131 // keyed objects with PROOF, the object is already loaded and is available
132 // via the fObject pointer.
134 // This function should contain the "body" of the analysis. It can contain
135 // simple or elaborate selection criteria, run algorithms on the data
136 // of the event and typically fill histograms.
138 // The processing can be stopped by calling Abort().
140 // Use fStatus to set the return value of TTree::Process().
142 // The return value is currently not used.
144 Int_t status = ProcessIn(entry);
146 (*fFileWatch) << "__" << status ;
154 Int_t AliTPCSelectorESD::ReadEvent(Long64_t entry){
160 if (!fChain) return -1;
161 if (!fChain->GetTree()) return -1;
163 fChain->GetTree()->GetEntry(entry);
164 } catch (std::bad_alloc) {
165 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
172 // Info("Procces","0");
173 if (!fESD && !fESDevent) {
179 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
182 fESDevent->SetESDfriend(fESDfriend);
186 fNtracks->Fill(ntracks);
187 Info("Procces", Form("entry\t%d: Ntracks = %d",entry, ntracks));
189 if (!fESDfriend || fESDfriend->GetNumberOfTracks() != ntracks) {
193 catch (std::bad_alloc) {
194 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
202 if (fESDfriend) fNtracksFriend->Fill(fESDfriend->GetNumberOfTracks());
203 Info("Procces","2: PROBLEM");
206 if (fESD) fESD->SetESDfriend(fESDfriend);
211 Int_t AliTPCSelectorESD::ProcessIn(Long64_t entry)
214 // User part of proccess method
218 // USER code to go here
220 Int_t status = ReadEvent(entry);
221 if (status<0) return status;
222 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
226 Info("Procces", Form("entry\t%d: NtracksF = %d",entry,fESDfriend->GetNumberOfTracks() ));
228 for (Int_t tr = 0; tr < ntracks; tr++){
229 AliESDtrack *esdTrack = fESD ? (AliESDtrack*) fESD->GetTrack(tr): (AliESDtrack*) fESDevent->GetTrack(tr);
230 AliESDfriendTrack *friendtrack = (AliESDfriendTrack*) esdTrack->GetFriendTrack();
233 for (Int_t i=0;;i++){
234 cobject = friendtrack->GetCalibObject(i);
236 seed = dynamic_cast<AliTPCseed*>(cobject);
240 //Info("Process",Form("Proccessing track%d\n",tr));
242 fNClusters->Fill(seed->GetNumberOfClusters());
253 void AliTPCSelectorESD::SlaveTerminate()
255 // The SlaveTerminate() function is called after all entries or objects
256 // have been processed. When running with PROOF SlaveTerminate() is called
257 // on each slave server.
258 printf ("SlaveTerminate.. \n");
262 void AliTPCSelectorESD::Terminate()
264 // The Terminate() function is the last function to be called during
265 // a query. It always runs on the client, it can be used to present
266 // the results graphically or save the results to file.
268 printf ("Terminate... \n");
269 if (!fOutput) return;
270 TFile file("Output.root","recreate");
271 printf("fOutput contains the following: \n");
273 printf("Trying to write the file 'Output.root'... \n");
282 void AliTPCSelectorESD::Init(TTree *tree)
284 // The Init() function is called when the selector needs to initialize
285 // a new tree or chain. Typically here the branch addresses and branch
286 // pointers of the tree will be set.
287 // It is normaly not necessary to make changes to the generated
288 // code, but the routine can be extended by the user if needed.
289 // Init() will be called many times when running on PROOF
290 // (once per file to be processed).
292 // Set branch addresses and branch pointers
293 static Int_t counter=0;
294 printf(Form("\nAliTPCSelectorESD::Init Accesing%d time\n",counter));
298 //if (counter>1) return;
299 tree->SetBranchStatus("*",1);
301 // New AliESDevent format
303 if (!fChain->GetBranch("ESD")){
307 if (fESDevent) delete fESDevent;
308 fESDevent = new AliESDEvent();
309 fESDevent->ReadFromTree(tree); // Attach the branch with ESD friends
310 fESDfriend = (AliESDfriend*)fESDevent->FindListObject("AliESDfriend");
311 tree->SetBranchAddress("ESDfriend.",&fESDfriend);
320 // fChain->SetMakeClass(1);
321 fChain->SetBranchAddress("ESD",&fESD);
322 Info("Init","Enter");
324 if (fChain->GetBranch("ESDfriend")) {
325 fChain->SetBranchAddress("ESDfriend",&fESDfriend);
326 Info("Init","V0-ESDfriend.");
329 if (fChain->GetBranch("ESDfriend.")){
330 Info("Init","V1-ESDfriend.");
331 fChain->SetBranchAddress("ESDfriend.",&fESDfriend);
337 // Try to solve problem
340 Info("Init","Problem");
341 if (tree->GetBranch("ESD")){
342 Info("InitTree",tree->GetBranch("ESD")->GetFile()->GetName());
344 sprintf(fname,"%s/AliESDfriends.root",gSystem->DirName(tree->GetBranch("ESD")->GetFile()->GetName()));
345 Info("InitFile",fname);
346 if (tree->AddFriend("esdFriendTree",fname)){
347 Info("InitFileOK",fname);
348 if (fChain->GetBranch("ESDfriend")) {
349 fChain->SetBranchAddress("ESDfriend",&fESDfriend);
350 Info("Init","V0-ESDfriend.");
353 if (fChain->GetBranch("ESDfriend.")){
354 Info("Init","V1-ESDfriend.");
355 fChain->SetBranchAddress("ESDfriend.",&fESDfriend);
364 Bool_t AliTPCSelectorESD::Notify()
366 // The Notify() function is called when a new file is opened. This
367 // can be either for a new TTree in a TChain or when when a new TTree
368 // is started when using PROOF. It is normaly not necessary to make changes
369 // to the generated code, but the routine can be extended by the
370 // user if needed. The return value is currently not used.
373 const char * fname = "UNKNOWN";
374 const char * hname = gSystem->HostName();
375 if (!fChain) return kFALSE;
376 if (fChain->GetCurrentFile()){
377 fname = fChain->GetCurrentFile()->GetName();
379 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
382 // Print statistic to log file
385 // (*fFileWatch) << endl;
386 // (*fFileWatch) << hname <<"\t"
395 void AliTPCSelectorESD::DumpSysInfo(Int_t entry){
397 // dump system info to log file
398 // entry - entry number in the chain
400 const char * fname = "UNKNOWN";
401 const char * hname = gSystem->HostName();
402 if (fChain->GetCurrentFile()){
403 fname = fChain->GetCurrentFile()->GetName();
412 gSystem->GetCpuInfo(&cpuInfo, 1000);
413 gSystem->GetMemInfo(&memInfo);
414 gSystem->GetProcInfo(&procInfo);
416 (*fSysWatch) << hname <<"\t" // hname - hostname
417 << fname <<"\t" // fname - filename
418 << entry <<"\t" // entry - entry number
419 << stamp.GetSec()<<"\t" // time - time stamp in seconds
420 << memInfo.fMemUsed<<"\t" //
421 << memInfo.fSwapUsed<<"\t" //
422 << procInfo.fMemResident<<"\t" //
423 << procInfo.fMemVirtual<<"\t" //
424 << cpuInfo.fUser <<"\t" //
425 << cpuInfo.fSys <<"\t" //
426 << procInfo.fCpuUser<<"\t" //
427 << procInfo.fCpuSys<<"\t" //
430 AliSysInfo::AddStamp(fname);