]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliQADataMaker.cxx
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / STEER / STEER / AliQADataMaker.cxx
index bf607c71d504186d0ee1fb865d6d604422a0e844..b66083238ce25ad58f3c3bb3a9bacb865dd12098 100644 (file)
@@ -356,6 +356,7 @@ Int_t AliQADataMaker::SetEventTrigClasses(const char* triggers)
   int nTrigs = tarr->GetEntriesFast();
   if (!nTrigs) {
     AliWarningClass("The string for event triggers is empty");
+    delete tarr;
     return 0;
   }
   int nTrClasses = 0;
@@ -502,13 +503,13 @@ TObjArray* AliQADataMaker::GetMatchingHistos(TObjArray ** list, Int_t index, TOb
        int indCl = GetEventTrigClass(icl)->GetUniqueID();
        //      AliInfo(Form("Ind %d at %d of %p of %p",index,indCl, arr, list[AliRecoParam::AConvert(fEventSpecie)]));
        TH1* histo = dynamic_cast<TH1*>(arr->At(indCl));
-       dest->AddLast(histo);
+       if (histo) dest->AddLast(histo);
        //      AliInfo(Form("EvCl%d IndTr%d add to %d IndH %d %p %s",icl,indCl,dest->LastIndex(),index,histo,histo ? histo->GetName():"XXX"));
       }
       // check if original histo was kept
       if (arr->TestBit(AliQAv1::GetOrigHistoKeptBit())) {
        TH1* histo = dynamic_cast<TH1*>(arr->At(GetNTrigClasses()));
-       dest->AddLast(histo);
+       if (histo) dest->AddLast(histo);
        //      AliInfo(Form("Def add to %d inex: %d %p %s",dest->LastIndex(),index,histo,histo ? histo->GetName():"XXX"));
       }
     }
@@ -527,7 +528,7 @@ Int_t AliQADataMaker::FillData(TObjArray ** list, Int_t index, double x)
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH1*)arr->At(ih))->Fill(x);
+    for (int ih=count;ih--;) if ((TH1*)arr->At(ih)) ((TH1*)arr->At(ih))->Fill(x);
   }
   return count;
 }
@@ -540,7 +541,7 @@ Int_t AliQADataMaker::FillData(TObjArray ** list, Int_t index, double x, double
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH1*)arr->At(ih))->Fill(x,y);
+    for (int ih=count;ih--;) if ((TH1*)arr->At(ih)) ((TH1*)arr->At(ih))->Fill(x,y);
   }
   return count;
 }
@@ -553,7 +554,7 @@ Int_t AliQADataMaker::FillData(TObjArray ** list, Int_t index, double x, double
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->Fill(x,y,z);
+    for (int ih=count;ih--;) if ((TH2*)arr->At(ih)) ((TH2*)arr->At(ih))->Fill(x,y,z);
   }
   return count;
 }
@@ -566,7 +567,7 @@ Int_t AliQADataMaker::SetDataBinContent(TObjArray ** list, Int_t index, int bin,
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->SetBinContent(bin,w);
+    for (int ih=count;ih--;)  if ((TH2*)arr->At(ih)) ((TH2*)arr->At(ih))->SetBinContent(bin,w);
   }
   return count;
 }
@@ -579,7 +580,7 @@ Int_t AliQADataMaker::SetDataBinContent(TObjArray ** list, Int_t index, int binX
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->SetBinContent(binX,binY,w);
+    for (int ih=count;ih--;)  if ((TH2*)arr->At(ih)) ((TH2*)arr->At(ih))->SetBinContent(binX,binY,w);
   }
   return count;
 }
@@ -592,7 +593,7 @@ Int_t AliQADataMaker::SetDataBinError(TObjArray ** list, Int_t index, int bin, d
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->SetBinError(bin,err);
+    for (int ih=count;ih--;)  if ((TH2*)arr->At(ih)) ((TH2*)arr->At(ih))->SetBinError(bin,err);
   }
   return count;
 }
@@ -605,7 +606,7 @@ Int_t AliQADataMaker::SetDataBinError(TObjArray ** list, Int_t index, int binX,
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->SetBinError(binX,binY,err);
+    for (int ih=count;ih--;)  if ((TH2*)arr->At(ih)) ((TH2*)arr->At(ih))->SetBinError(binX,binY,err);
   }
   return count;
 }
@@ -618,7 +619,7 @@ Int_t AliQADataMaker::ResetData(TObjArray ** list, Int_t index, Option_t* option
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->Reset(option);
+    for (int ih=count;ih--;)  if ((TH1*)arr->At(ih)) ((TH1*)arr->At(ih))->Reset(option);
   }
   return count;
 }
@@ -631,7 +632,7 @@ Int_t AliQADataMaker::ResetStatsData(TObjArray ** list, Int_t index)
   int count = 0;
   if (arr) {
     count = arr->GetEntriesFast();
-    for (int ih=count;ih--;) ((TH2*)arr->At(ih))->ResetStats();
+    for (int ih=count;ih--;) if ((TH1*)arr->At(ih))  ((TH1*)arr->At(ih))->ResetStats();
   }
   return count;
 }
@@ -831,34 +832,67 @@ void AliQADataMaker::SetCloningRequest(TObjArray* aliases, TObjArray* histos)
   int nhisto = fgCloningRequest->GetEntriesFast();
   //
   int naliasUsed = 0;
+  for (int ial=0;ial<nalias;ial++) fgTrigClasses->At(ial)->SetUniqueID(kDummyID); // reset usage flag
+  //
+  for (int ih=nhisto;ih--;) {
+    TNamed* histo = (TNamed*)fgCloningRequest->At(ih);
+    TString histoReq = histo->GetTitle();    // list of aliases for which the histo must be cloned
+    TObjArray* alList = histoReq.Tokenize(" ");
+    // 
+    if (!alList) {
+      AliErrorClass(Form("Invalid cloning request is found for histo %s :|%s|",histo->GetName(),histo->GetTitle()));
+      fgCloningRequest->RemoveAt(ih);
+      delete histo;
+      continue;
+    }
+    TString confirmedAliases = "";
+    for (int iha=alList->GetEntriesFast();iha--;) {
+      // check if corresponding alias is defined
+      Bool_t aliasOK = kFALSE;
+      for (int ial=0;ial<nalias;ial++) {
+       TNamed* alias = (TNamed*)fgTrigClasses->At(ial);
+       TString aliasName = alias->GetName();
+       if (aliasName == alList->At(iha)->GetName()) { // found
+         aliasOK = kTRUE;
+         if (alias->GetUniqueID() == kDummyID) alias->SetUniqueID(naliasUsed++);      // acknowledge used alias
+       }
+      }
+      if (!aliasOK) {
+       AliErrorClass(Form("Cloning for undefined trigger alias %s is requested for histo %s, SUPPRESSING",
+                     alList->At(iha)->GetName(),histo->GetName()));
+      }
+      else confirmedAliases += Form("%s ",alList->At(iha)->GetName());
+    }
+    if (confirmedAliases.IsNull()) {
+      AliErrorClass(Form("All requested trigger aliases for histo %s are undefined, SUPPRESSING",histo->GetName()));
+      fgCloningRequest->RemoveAt(ih);
+      delete histo;
+    }
+    else histo->SetTitle(confirmedAliases.Data());
+    //
+    delete alList;
+  }
+  fgCloningRequest->Compress();
+  //
+  // check if there are unused aliases
+  naliasUsed = 0;
   for (int ial=0;ial<nalias;ial++) {
     TNamed* alias = (TNamed*)fgTrigClasses->At(ial);
-    alias->SetUniqueID(kDummyID);
-    TString aliasName = alias->GetName();
-    for (int ih=nhisto;ih--;) {
-      TNamed* histo = (TNamed*)fgCloningRequest->At(ih);
-      TString histoReq = histo->GetTitle();    // list of aliases for which the histo must be cloned
-      TObjArray* alList = histoReq.Tokenize(" ");
-      if (!alList) continue;
-      for (int iha=alList->GetEntriesFast();iha--;) {
-       if (!(aliasName == alList->At(iha)->GetName())) continue;
-       alias->SetUniqueID(naliasUsed++);      // acknowledge used alias
-       break;
-      }
-      if (alias->GetUniqueID()!=kDummyID) break;  // once alias is validated, check the next one
+    if (alias->GetUniqueID() != kDummyID) alias->SetUniqueID(naliasUsed++); // count as defined
+    else {
+      AliWarningClass(Form("Suppressing unused trigger alias %s\t->\t%s",alias->GetName(),alias->GetTitle()));
+      delete fgTrigClasses->RemoveAt(ial);
     }
   }
-  // eliminate unused aliases
-  for (int ial=0;ial<nalias;ial++) if (fgTrigClasses->At(ial)->GetUniqueID()==kDummyID) delete fgTrigClasses->RemoveAt(ial);
   fgTrigClasses->Compress();
   //
-  AliInfoClass("Aliases for trigger classes:");
+  AliInfoClass("Confirmed aliases for trigger classes:");
   for (int i=0;i<fgTrigClasses->GetEntriesFast();i++) {
     TNamed* item = (TNamed*)fgTrigClasses->At(i);
     AliInfoClass(Form("%s -> %s",item->GetName(),item->GetTitle()));
   }
   //
-  AliInfoClass("Histograms to clone:");
+  AliInfoClass("Confirmed histograms to clone:");
   for (int i=0;i<fgCloningRequest->GetEntriesFast();i++) {
     TNamed* item = (TNamed*)fgCloningRequest->At(i);
     AliInfoClass(Form("%s -> %s %s",item->GetName(),item->GetTitle(),