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) :
60 fNtracks(0), //! number of Tracks
61 fNtracksFriend(0), //! number of firend Tracks
62 fNClusters(0), //! number of clusters on track
63 fRegPath(0), // path to store persistent data
65 fSysWatch(0), // system info
66 fFileWatch(0), // file watch - write the status of the analyzed files
69 G__SetCatchException(0);
73 fSysWatch = new fstream("syswatch2.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();
76 if (tree) fChain=tree;
80 void AliTPCSelectorESD::Begin(TTree * /*tree*/)
82 // The Begin() function is called at the start of the query.
83 // When running with PROOF Begin() is only called on the client.
84 // The tree argument is deprecated (on PROOF 0 is passed).
86 TString option = GetOption();
91 void AliTPCSelectorESD::SetInputList(TList *input) {
96 TNamed *regData = (TNamed*)input->FindObject("debugStreamPrefix");
97 if (regData) fRegPath = new TString(regData->GetTitle());
102 void AliTPCSelectorESD::SlaveBegin(TTree * tree)
104 // The SlaveBegin() function is called after the Begin() function.
105 // When running with PROOF SlaveBegin() is called on each slave server.
106 // The tree argument is deprecated (on PROOF 0 is passed).
107 if (tree) fChain = tree;
110 fNtracks = new TH1I("ntracks","Number of tracks",100,0,400);
111 fNtracksFriend = new TH1I("ntracksF","Number of friend tracks",100,0,400);
112 fNClusters = new TH1I("ncluster","Number of clusters",100,0,200);
113 fOutput->AddLast(fNtracks);
114 fOutput->AddLast(fNtracksFriend);
115 fOutput->AddLast(fNClusters);
120 void AliTPCSelectorESD::CleanESD(){
122 Bool_t isNew = fESDevent!=0;
140 Bool_t AliTPCSelectorESD::Process(Long64_t entry)
142 // The Process() function is called for each entry in the tree (or possibly
143 // keyed object in the case of PROOF) to be processed. The entry argument
144 // specifies which entry in the currently loaded tree is to be processed.
145 // It can be passed to either AliTPCSelectorESD::GetEntry() or TBranch::GetEntry()
146 // to read either all or the required parts of the data. When processing
147 // keyed objects with PROOF, the object is already loaded and is available
148 // via the fObject pointer.
150 // This function should contain the "body" of the analysis. It can contain
151 // simple or elaborate selection criteria, run algorithms on the data
152 // of the event and typically fill histograms.
154 // The processing can be stopped by calling Abort().
156 // Use fStatus to set the return value of TTree::Process().
158 // The return value is currently not used.
160 Int_t status = ProcessIn(entry);
162 (*fFileWatch) << "__" << status ;
170 Int_t AliTPCSelectorESD::ReadEvent(Long64_t entry){
176 if (!fChain) return -1;
177 if (!fChain->GetTree()) return -1;
179 fChain->GetTree()->GetEntry(entry);
180 } catch (std::bad_alloc) {
181 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
188 // Info("Procces","0");
189 if (!fESD && !fESDevent) {
195 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
198 fESDevent->SetESDfriend(fESDfriend);
202 fNtracks->Fill(ntracks);
203 Info("Procces", Form("entry\t%d: Ntracks = %d",entry, ntracks));
205 if (!fESDfriend || fESDfriend->GetNumberOfTracks() != ntracks) {
209 catch (std::bad_alloc) {
210 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
218 if (fESDfriend) fNtracksFriend->Fill(fESDfriend->GetNumberOfTracks());
219 Info("Procces","2: PROBLEM");
222 if (fESD) fESD->SetESDfriend(fESDfriend);
227 Int_t AliTPCSelectorESD::ProcessIn(Long64_t entry)
230 // User part of proccess method
234 // USER code to go here
236 Int_t status = ReadEvent(entry);
237 if (status<0) return status;
238 Int_t ntracks = (fESD) ? fESD->GetNumberOfTracks() : fESDevent->GetNumberOfTracks();
242 Info("Procces", Form("entry\t%d: NtracksF = %d",entry,fESDfriend->GetNumberOfTracks() ));
244 for (Int_t tr = 0; tr < ntracks; tr++){
245 AliESDtrack *esdTrack = fESD ? (AliESDtrack*) fESD->GetTrack(tr): (AliESDtrack*) fESDevent->GetTrack(tr);
246 AliESDfriendTrack *friendtrack = (AliESDfriendTrack*) esdTrack->GetFriendTrack();
249 for (Int_t i=0;;i++){
250 cobject = friendtrack->GetCalibObject(i);
252 seed = dynamic_cast<AliTPCseed*>(cobject);
256 //Info("Process",Form("Proccessing track%d\n",tr));
258 fNClusters->Fill(seed->GetNumberOfClusters());
269 void AliTPCSelectorESD::SlaveTerminate()
271 // The SlaveTerminate() function is called after all entries or objects
272 // have been processed. When running with PROOF SlaveTerminate() is called
273 // on each slave server.
274 printf ("SlaveTerminate.. \n");
278 void AliTPCSelectorESD::Terminate()
280 // The Terminate() function is the last function to be called during
281 // a query. It always runs on the client, it can be used to present
282 // the results graphically or save the results to file.
284 printf ("Terminate... \n");
285 if (!fOutput) return;
286 TFile file("Output.root","recreate");
287 printf("fOutput contains the following: \n");
289 printf("Trying to write the file 'Output.root'... \n");
298 void AliTPCSelectorESD::Init(TTree *tree)
300 // The Init() function is called when the selector needs to initialize
301 // a new tree or chain. Typically here the branch addresses and branch
302 // pointers of the tree will be set.
303 // It is normaly not necessary to make changes to the generated
304 // code, but the routine can be extended by the user if needed.
305 // Init() will be called many times when running on PROOF
306 // (once per file to be processed).
308 // Set branch addresses and branch pointers
309 static Int_t counter=0;
310 printf(Form("\nAliTPCSelectorESD::Init Accesing%d time\n",counter));
314 //if (counter>1) return;
315 tree->SetBranchStatus("*",1);
317 // New AliESDevent format
319 if (!fChain->GetBranch("ESD")){
323 if (fESDevent) delete fESDevent;
324 fESDevent = new AliESDEvent();
325 fESDevent->ReadFromTree(tree); // Attach the branch with ESD friends
326 fESDfriend = (AliESDfriend*)fESDevent->FindListObject("AliESDfriend");
327 tree->SetBranchAddress("ESDfriend.",&fESDfriend);
336 // fChain->SetMakeClass(1);
337 fChain->SetBranchAddress("ESD",&fESD);
338 Info("Init","Enter");
340 if (fChain->GetBranch("ESDfriend")) {
341 fChain->SetBranchAddress("ESDfriend",&fESDfriend);
342 Info("Init","V0-ESDfriend.");
345 if (fChain->GetBranch("ESDfriend.")){
346 Info("Init","V1-ESDfriend.");
347 fChain->SetBranchAddress("ESDfriend.",&fESDfriend);
353 // Try to solve problem
356 Info("Init","Problem");
357 if (tree->GetBranch("ESD")){
358 Info("InitTree",tree->GetBranch("ESD")->GetFile()->GetName());
360 sprintf(fname,"%s/AliESDfriends.root",gSystem->DirName(tree->GetBranch("ESD")->GetFile()->GetName()));
361 Info("InitFile",fname);
362 if (tree->AddFriend("esdFriendTree",fname)){
363 Info("InitFileOK",fname);
364 if (fChain->GetBranch("ESDfriend")) {
365 fChain->SetBranchAddress("ESDfriend",&fESDfriend);
366 Info("Init","V0-ESDfriend.");
369 if (fChain->GetBranch("ESDfriend.")){
370 Info("Init","V1-ESDfriend.");
371 fChain->SetBranchAddress("ESDfriend.",&fESDfriend);
380 Bool_t AliTPCSelectorESD::Notify()
382 // The Notify() function is called when a new file is opened. This
383 // can be either for a new TTree in a TChain or when when a new TTree
384 // is started when using PROOF. It is normaly not necessary to make changes
385 // to the generated code, but the routine can be extended by the
386 // user if needed. The return value is currently not used.
389 const char * fname = "UNKNOWN";
390 const char * hname = gSystem->HostName();
391 if (!fChain) return kFALSE;
392 if (fChain->GetCurrentFile()){
393 fname = fChain->GetCurrentFile()->GetName();
395 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
398 // Print statistic to log file
401 // (*fFileWatch) << endl;
402 // (*fFileWatch) << hname <<"\t"
410 void AliTPCSelectorESD::RegisterData(){
412 // Register persistent data
415 gSystem->Exec(Form("mkdir %s/%s",fRegPath->Data(), gSystem->HostName()));
416 printf("Register data to\t%s\n",fRegPath->Data());
418 sprintf(command,"cp *.log %s/%s/",fRegPath->Data(), gSystem->HostName());
419 gSystem->Exec(command);
420 sprintf(command,"cp *.root %s/%s/",fRegPath->Data(), gSystem->HostName());
421 gSystem->Exec(command);
426 void AliTPCSelectorESD::DumpSysInfo(Int_t entry){
428 // dump system info to log file
429 // entry - entry number in the chain
431 const char * fname = "UNKNOWN";
432 const char * hname = gSystem->HostName();
433 if (fChain->GetCurrentFile()){
434 fname = fChain->GetCurrentFile()->GetName();
443 gSystem->GetCpuInfo(&cpuInfo, 1000);
444 gSystem->GetMemInfo(&memInfo);
445 gSystem->GetProcInfo(&procInfo);
447 (*fSysWatch) << hname <<"\t" // hname - hostname
448 << fname <<"\t" // fname - filename
449 << entry <<"\t" // entry - entry number
450 << stamp.GetSec()<<"\t" // time - time stamp in seconds
451 << memInfo.fMemUsed<<"\t" //
452 << memInfo.fSwapUsed<<"\t" //
453 << procInfo.fMemResident<<"\t" //
454 << procInfo.fMemVirtual<<"\t" //
455 << cpuInfo.fUser <<"\t" //
456 << cpuInfo.fSys <<"\t" //
457 << procInfo.fCpuUser<<"\t" //
458 << procInfo.fCpuSys<<"\t" //
461 AliSysInfo::AddStamp(fname);