]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveTRDTrackList.cxx
Changes for bug #70680: AliROOT Coverity DELETE_ARRAY checker fix
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDTrackList.cxx
index 1135fa4c8b9db8d516367c61fc29a9f829e0cff8..612ee3cf2d5f9b15de82dd3f40ec4c3c54f02da5 100644 (file)
@@ -1,10 +1,11 @@
-// Author: Benjamin Hess   25/09/2008
+// Author: Benjamin Hess   29/01/2010
 
 /*************************************************************************
- * Copyright (C) 2008, Alexandru Bercuci, Benjamin Hess.                 *
+ * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess.            *
  * All rights reserved.                                                  *
  *************************************************************************/
 
+
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
 // AliEveTRDTrackList                                                   //
 
 #include <AliTRDReconstructor.h>
 
-#include <EveDet/AliEveTRDTrackList.h>
 #include <EveDet/AliEveTRDTrackList.h>
 #include <EveDet/AliEveTRDTrackListEditor.h>
 
-#include <qaRec/AliTRDrecoTask.h>
-#include <qaRec/run.h>
+#include <../PWG1/TRD/AliTRDrecoTask.h>
+#include <../PWG1/TRD/macros/AliTRDperformanceTrain.h>
 
 ClassImp(AliEveTRDTrackList)
 
@@ -195,6 +195,9 @@ Int_t AliEveTRDTrackList::AddMacro(const Char_t* path, const Char_t* nameC, Bool
  
   gROOT->ProcessLineSync(Form(".L %s+%c", pathname, forceReload ? '+' : ' '));
 
+  // We need this line... otherwise, in some cases, there will be problems concerning ACLIC
+  gROOT->ProcessLineSync(Form(".L %s", pathname));
+
   AliEveTRDTrackListMacroType type = GetMacroType(name, kFALSE);
 
   // Clean up again
@@ -268,11 +271,17 @@ void AliEveTRDTrackList::AddStandardContent()
   // use the return value of AddMacro (NOT_EXIST_ERROR is returned, if file does not exist)
   // (-> You can also check for other return values (see AddMacro(...)))
 
-  if(gSystem->Load("libANALYSIS.so")<0) return;
-  if(gSystem->Load("libTRDqaRec.so")<0) return;
+  const Char_t *libs[] = {"libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
+  Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
+  for(Int_t ilib=0; ilib<nlibs; ilib++){
+    if(gSystem->Load(libs[ilib]) >= 0) continue;
+    AliError(Form("Fail loading %s.", libs[ilib]));
+    return;
+  }
+
   AliTRDrecoTask *task = 0x0;
   TList *fPlots = 0x0;
-  for(Int_t it=0; it<NTRDTASKS; it++){
+  for(Int_t it=2; it<NTRDQATASKS; it++){
     TClass c(fgkTRDtaskClassName[it]);
     task = (AliTRDrecoTask*)c.New();
     task->SetMCdata(kFALSE);
@@ -288,7 +297,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;", fgkTRDtaskClassName[it], task->GetName(), fgkTRDtaskClassName[it], (void*)task));
     TIter iter(fPlots); TMethodCall *m = 0x0;
     while((m = dynamic_cast<TMethodCall*>(iter()))){
       AddMacroFast("", Form("%s->%s", task->GetName(), m->GetMethodName()), kSingleTrackHisto);
@@ -337,17 +346,17 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
 
   TMacroData* macro = 0;
 
-  Char_t** procCmds = 0;
+  TString* procCmds = 0;
   AliEveTRDTrackListMacroType* mProcType = 0;
   if (procIterator->GetEntries() > 0) {
-    procCmds = new Char_t*[procIterator->GetEntries()];
+    procCmds = new TString[procIterator->GetEntries()];
     mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
   }
 
-  Char_t** selCmds  = 0;
+  TString* selCmds(NULL);
   AliEveTRDTrackListMacroType* mSelType = 0;
   if (selIterator->GetEntries() > 0) {
-    selCmds = new Char_t*[selIterator->GetEntries()];
+    selCmds = new TString[selIterator->GetEntries()];
     mSelType = new AliEveTRDTrackListMacroType[selIterator->GetEntries()];
   }
   
@@ -357,14 +366,11 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
   Int_t numHistoMacros = 0;
   TH1** histos = 0;
 
-  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){
@@ -384,14 +390,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()));
@@ -405,9 +411,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){
@@ -434,7 +437,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
       mSelType[i] = macroType;  
  
       // Create the command
-      sprintf(selCmds[i], macro->GetCmd());
+      selCmds[i] = macro->GetCmd();
     } else {
       Error("Apply process macros", 
         Form("Macro list corrupted: Macro \"%s/%s.C\" is not registered as a selection macro!", 
@@ -458,7 +461,7 @@ 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
@@ -471,7 +474,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
         // Loop over all pairs behind the current one - together with the other loop this will be a loop
         // over all pairs. We have a pair of tracks, if and only if both tracks of the pair are selected (Rnr-state)
         // and are not equal.
-        // The correlated tracks process macro will applied to all pairs that will be additionally selected by
+        // The correlated tracks process macro will be applied to all pairs that will be additionally selected by
         // all correlated tracks selection macros.
         TEveElement::List_i iter2 = iter;
         iter2++;
@@ -483,7 +486,7 @@ 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!)
@@ -527,7 +530,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
         // Loop over all pairs behind the current one - together with the other loop this will be a loop
         // over all pairs. We have a pair of tracks, if and only if both tracks of the pair are selected (Rnr-state)
         // and are not equal.
-        // The correlated tracks process macro will applied to all pairs that will be additionally selected by
+        // The correlated tracks process macro will be applied to all pairs that will be additionally selected by
         // all correlated tracks selection macros.
         TEveElement::List_i iter2 = iter;
         iter2++;
@@ -539,7 +542,7 @@ 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!)
@@ -591,7 +594,7 @@ Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TL
 
   if (procCmds != 0)  delete [] procCmds;
   procCmds = 0;
-  if (mProcType != 0)  delete mProcType;
+  if (mProcType != 0)  delete [] mProcType;
   mProcType = 0;
 
   if (selCmds != 0)  delete [] selCmds;
@@ -630,9 +633,9 @@ void AliEveTRDTrackList::ApplySTSelectionMacros(const TList* iterator)
   // Clear root
   // A.B. gROOT->Reset();
 
-  // Select all tracks at first. A track is then deselect, if at least one selection macro
-  // returns kFALSE for this track
-  // Enable all tracks (Note: EnableListElements(..) will call "ElementChanged", which will cause unforeseen behavior!)
+  // Select all tracks at first. A track is then deselected, if at least one selection macro
+  // returns kFALSE for this track.
+  // Enable all tracks (Note: EnableListElements(..) will call "ElementChanged", which will cause unforeseen behaviour!)
   for (TEveElement::List_i iter = this->BeginChildren(); iter != this->EndChildren(); ++iter) ((TEveElement*)(*iter))->SetRnrState(kTRUE);
   SetRnrState(kTRUE);
   
@@ -665,7 +668,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());               
@@ -742,12 +745,12 @@ AliEveTRDTrackList::AliEveTRDTrackListMacroType AliEveTRDTrackList::GetMacroType
       if (strstr(f->GetMangledName(), "oPconstsPAliTRDtrackV1mUsP") != 0x0 &&
           strstr(f->GetMangledName(), "cOconstsPAliTRDtrackV1mUsP") != 0x0)
       {
-        // Single track select macro?
+        // Correlated track select macro?
         if (!strcmp(f->GetReturnTypeName(), "Bool_t")) 
         { 
           type = kCorrelTrackSelect;     
         }
-        // single track histo macro?
+        // Correlated track histo macro?
         else if (!strcmp(f->GetReturnTypeName(), "TH1*"))
         {
           type = kCorrelTrackHisto;
@@ -856,10 +859,10 @@ void AliEveTRDTrackList::UpdateTrackStyle(AliEveTRDTrack::AliEveTRDTrackState s,
       CLRBIT(fSelectedStyle, AliEveTRDTrack::kSource);
       switch(ss)
       {
-      case AliTRDReconstructor::kLQPID:
+      case AliTRDpidUtil::kLQ:
         CLRBIT(fSelectedStyle, AliEveTRDTrack::kPID);
         break;
-      case AliTRDReconstructor::kNNPID:
+      case AliTRDpidUtil::kNN:
         SETBIT(fSelectedStyle, AliEveTRDTrack::kPID);
         break;
       }