]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveTRDTrackList.cxx
Fix for #76933: Fix access operator
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDTrackList.cxx
index 50d8aeaba9402d736ae2337418d61f316b785912..5ae6859fd743af5ab482ba4c4a1cb9f3a9931705 100644 (file)
@@ -1,10 +1,11 @@
-// Author: Benjamin Hess   25/09/2008
+// Author: Benjamin Hess   29/01/2010
 
 /*************************************************************************
- * Copyright (C) 2008-2009, Alexandru Bercuci, Benjamin Hess.            *
+ * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess.            *
  * All rights reserved.                                                  *
  *************************************************************************/
 
+
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
 // AliEveTRDTrackList                                                   //
@@ -77,7 +78,7 @@
 #include <EveDet/AliEveTRDTrackListEditor.h>
 
 #include <../PWG1/TRD/AliTRDrecoTask.h>
-#include <../PWG1/TRD/macros/AliTRDperformanceTrain.h>
+#include <../PWG1/TRD/AliTRDpwg1Helper.h>
 
 ClassImp(AliEveTRDTrackList)
 
@@ -172,7 +173,7 @@ Int_t AliEveTRDTrackList::AddMacro(const Char_t* path, const Char_t* nameC, Bool
 
   // Expand the path and create the pathname
   Char_t* systemPath = gSystem->ExpandPathName(path);
-  sprintf(pathname, "%s/%s", systemPath, nameC);
+  snprintf(pathname, fkMaxMacroPathNameLength, "%s/%s", systemPath, nameC);
   delete systemPath;
   systemPath = 0;
 
@@ -263,7 +264,7 @@ void AliEveTRDTrackList::AddStandardContent()
 {
   // Adds standard macros to the macro list.
 
-  // Add your standard macros here, e.g.: 
+  // Add your standard macros here, e.g.:
   // To add a macro use:
   // AddMacro("$(ALICE_ROOT)/myFolder", "myMacroName.C");
   // -> If the file does not exist, nothing happens. So if you want to handle this,
@@ -278,10 +279,19 @@ void AliEveTRDTrackList::AddStandardContent()
     return;
   }
 
-  AliTRDrecoTask *task = 0x0;
-  TList *fPlots = 0x0;
-  for(Int_t it=2; it<NTRDQATASKS; it++){
-    TClass c(fgkTRDtaskClassName[it]);
+  const Char_t *fgkTRDPWG1taskClassName[AliTRDpwg1Helper::kNTRDQATASKS] = {
+    "AliTRDcheckESD"
+    ,"AliTRDinfoGen"
+    ,"AliTRDcheckDET"
+    ,"AliTRDefficiency"
+    ,"AliTRDresolution"
+    ,"AliTRDcheckPID"
+    ,"AliTRDv0Monitor"
+  };
+  AliTRDrecoTask *task(NULL);
+  TList *fPlots(NULL);
+  for(Int_t it=2; it<AliTRDpwg1Helper::kNTRDQATASKS; it++){
+    TClass c(fgkTRDPWG1taskClassName[it]);
     task = (AliTRDrecoTask*)c.New();
     task->SetMCdata(kFALSE);
     if(!(fPlots = task->GetPlotFunctors())){
@@ -296,7 +306,7 @@ void AliEveTRDTrackList::AddStandardContent()
     }
 
     // export task to CINT and add functions
-    gROOT->ProcessLine(Form("%s* %s = (%s*)0x%lx;", fgkTRDtaskClassName[it], task->GetName(), fgkTRDtaskClassName[it], (void*)task));
+    gROOT->ProcessLine(Form("%s* %s = (%s*)%p;", fgkTRDPWG1taskClassName[it], task->GetName(), fgkTRDPWG1taskClassName[it], (void*)task));
     TIter iter(fPlots); TMethodCall *m = 0x0;
     while((m = dynamic_cast<TMethodCall*>(iter()))){
       AddMacroFast("", Form("%s->%s", task->GetName(), m->GetMethodName()), kSingleTrackHisto);
@@ -304,6 +314,7 @@ void AliEveTRDTrackList::AddStandardContent()
   }
 }
 
+
 //______________________________________________________
 Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TList* procIterator)
 {
@@ -323,7 +334,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
   // A.B. gROOT->Reset();
   
   // Clear old data and re-allocate
-  if (fDataTree == 0x0){ 
+  if (!fDataTree){
     TDirectory *cwd = gDirectory;
     fDataTree = new TTreeSRedirector(Form("/tmp/TRD.TrackListMacroData_%s.root", gSystem->Getenv("USER")));
     cwd->cd();
@@ -345,17 +356,13 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
 
   TMacroData* macro = 0;
 
-  Char_t** procCmds = 0;
-  AliEveTRDTrackListMacroType* mProcType = 0;
-  if (procIterator->GetEntries() > 0) {
-    procCmds = new Char_t*[procIterator->GetEntries()];
-    mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
-  }
+  TString* procCmds = new TString[procIterator->GetEntries()];
+  AliEveTRDTrackListMacroType* mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
 
-  Char_t** selCmds  = 0;
-  AliEveTRDTrackListMacroType* mSelType = 0;
+  TString* selCmds(NULL);
+  AliEveTRDTrackListMacroType* mSelType(NULL);
   if (selIterator->GetEntries() > 0) {
-    selCmds = new Char_t*[selIterator->GetEntries()];
+    selCmds = new TString[selIterator->GetEntries()];
     mSelType = new AliEveTRDTrackListMacroType[selIterator->GetEntries()];
   }
   
@@ -363,16 +370,13 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
 
   AliEveTRDTrackListMacroType macroType = kUnknown;
   Int_t numHistoMacros = 0;
-  TH1** histos = 0;
+  TH1** histos(NULL);
 
-  AliEveTRDTrack* track1 = 0;
-  AliEveTRDTrack* track2 = 0;
+  AliEveTRDTrack* track1(NULL);
+  AliEveTRDTrack* track2(NULL);
 
   // Collect the commands for each process macro and add them to "data-from-list"
   for (Int_t i = 0; i < procIterator->GetEntries(); i++){
-    procCmds[i] = new Char_t[(fkMaxMacroPathNameLength + fkMaxApplyCommandLength)];
-    memset(procCmds[i], '\0', sizeof(Char_t) * (fkMaxMacroNameLength + fkMaxApplyCommandLength));
-
     macro = (TMacroData*)fMacroList->GetValue(procIterator->At(i)->GetTitle());
 
     if (!macro){
@@ -392,14 +396,14 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
       mProcType[i] = macroType;
       numHistoMacros++;
       // Create the command 
-      sprintf(procCmds[i], macro->GetCmd());
+      procCmds[i] = macro->GetCmd();
 
       // Add to "data-from-list" -> Mark as a histo macro with the substring "(histo macro)"
       fDataFromMacroList->Add(new TObjString(Form("%s (histo macro)", macro->GetName())));
     } else if (macroType == kSingleTrackAnalyse || macroType == kCorrelTrackAnalyse) {
       mProcType[i] = macroType;
       // Create the command 
-      sprintf(procCmds[i], macro->GetCmd());
+      procCmds[i] = macro->GetCmd();
 
       // Add to "data-from-list"
       fDataFromMacroList->Add(new TObjString(macro->GetName()));
@@ -413,9 +417,6 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
 
   // Collect the commands for each selection macro and add them to "data-from-list"
   for (Int_t i = 0; i < selIterator->GetEntries(); i++){
-    selCmds[i] = new Char_t[(fkMaxMacroPathNameLength + fkMaxApplyCommandLength)];
-    memset(selCmds[i], '\0', sizeof(Char_t) * (fkMaxMacroNameLength + fkMaxApplyCommandLength));
-
     macro = (TMacroData*)fMacroList->GetValue(selIterator->At(i)->GetTitle());
 
     if (!macro){
@@ -435,26 +436,27 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
     // Single track select macro
     if (macroType == kSingleTrackSelect) {
       // Has already been processed by ApplySTSelectionMacros(...)
-      mSelType[i] = macroType;         
+      if(mSelType) mSelType[i] = macroType;
     }
     // Correlated tracks select macro
     else if (macroType == kCorrelTrackSelect) {
-      mSelType[i] = macroType;  
+      if(mSelType) mSelType[i] = macroType;  
  
       // Create the command
-      sprintf(selCmds[i], macro->GetCmd());
+      if(selCmds) selCmds[i] = macro->GetCmd();
     } else {
       Error("Apply process macros", 
         Form("Macro list corrupted: Macro \"%s/%s.C\" is not registered as a selection macro!", 
         macro->GetPath(), macro->GetName()));
-      mSelType[i] = kUnknown;
+      if(mSelType) mSelType[i] = kUnknown;
     } 
   }  
 
   // Allocate memory for the histograms
-  if (numHistoMacros > 0)  histos = new TH1*[numHistoMacros];
-  for (Int_t i = 0; i < numHistoMacros; i++)  histos[i] = 0x0;
-
+  if (numHistoMacros > 0){
+    histos = new TH1*[numHistoMacros];
+    memset(histos, 0, numHistoMacros*sizeof(TH1*));
+  }
 
   //////////////////////////////////
   // WALK THROUGH THE LIST OF TRACKS
@@ -466,14 +468,14 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
     if (!track1->GetRnrState())  continue;
     
     // Cast to AliTRDtrackV1
-    gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track1));
+    gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track1));
     gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_1 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
 
     // Collect data for each macro
     for (Int_t i = 0, histoIndex = 0; i < procIterator->GetEntries(); i++){
       // Single track histo
       if (mProcType[i] == kSingleTrackHisto){
-        histos[histoIndex++] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
+        if(histos) histos[histoIndex++] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
        // Correlated tracks histo
       } else if (mProcType[i] == kCorrelTrackHisto) {
         // Loop over all pairs behind the current one - together with the other loop this will be a loop
@@ -491,13 +493,13 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
           if (!track2->GetRnrState())  continue;
       
           // Cast to AliTRDtrackV1
-          gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track2));
+          gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track2));
           gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_2 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
 
           // Select track by default (so it will be processed, if there are no correlated tracks selection macros!)
           selectedByCorrSelMacro = kTRUE;
           for (Int_t j = 0; j < selIterator->GetEntries(); j++){
-            if (mSelType[j] == kCorrelTrackSelect){
+            if (mSelType && mSelType[j] == kCorrelTrackSelect){
               selectedByCorrSelMacro = (Bool_t)gROOT->ProcessLineSync(selCmds[j]);
               if (!selectedByCorrSelMacro)  break;
             }
@@ -506,7 +508,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
           // If the pair has not been selected by the correlated tracks selection macros, skip it!
           if (!selectedByCorrSelMacro) continue;
           
-          histos[histoIndex] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
+          if(histos) histos[histoIndex] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
         }
         histoIndex++;
       }
@@ -547,13 +549,13 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
           if (!track2->GetRnrState())  continue;
     
           // Cast to AliTRDtrackV1
-          gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track2));
+          gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track2));
           gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_2 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
 
           // Select track by default (so it will be processed, if there are no correlated tracks selection macros!)
           selectedByCorrSelMacro = kTRUE;
           for (Int_t j = 0; j < selIterator->GetEntries(); j++) {
-            if (mSelType[j] == kCorrelTrackSelect) {
+            if (mSelType && mSelType[j] == kCorrelTrackSelect) {
               selectedByCorrSelMacro = (Bool_t)gROOT->ProcessLineSync(selCmds[j]);
               if (!selectedByCorrSelMacro)  break;
             }
@@ -594,21 +596,21 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
     }
   }
 
-  if (fDataTree != 0) delete fDataTree;
-  fDataTree = 0;
+  if (fDataTree) delete fDataTree;
+  fDataTree = NULL;
 
-  if (procCmds != 0)  delete [] procCmds;
-  procCmds = 0;
-  if (mProcType != 0)  delete mProcType;
-  mProcType = 0;
+  if (procCmds)  delete [] procCmds;
+  procCmds = NULL;
+  if (mProcType)  delete [] mProcType;
+  mProcType = NULL;
 
-  if (selCmds != 0)  delete [] selCmds;
-  selCmds = 0;
-  if (mSelType != 0)  delete mSelType;
-  mSelType = 0;
+  if (selCmds)  delete [] selCmds;
+  selCmds = NULL;
+  if (mSelType)  delete [] mSelType;
+  mSelType = NULL;
 
-  if (histos != 0)  delete [] histos;
-  histos = 0;
+  if (histos)  delete [] histos;
+  histos = NULL;
 
   // Clear root
   // A.B. gROOT->Reset();
@@ -673,7 +675,7 @@ void AliEveTRDTrackList::ApplySTSelectionMacros(const TList* iterator)
         if (!track1->GetRnrState()) continue;
 
         // Cast to AliTRDtrackV1
-        gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track1));
+        gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track1));
         gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_1 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
         selectedByMacro = (Bool_t)gROOT->ProcessLineSync(macro->GetCmd());
         track1->SetRnrState(selectedByMacro && track1->GetRnrState());