]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Created more advanced histo drawing for PHOS in alihlteve
authorslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Apr 2010 12:11:07 +0000 (12:11 +0000)
committerslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Apr 2010 12:11:07 +0000 (12:11 +0000)
HLT/EVE/AliHLTEveCalo.cxx
HLT/EVE/AliHLTEveCalo.h

index 21917c3b4694e46bd0f76e2f51fab18416882fec..56e52160bfd6db7a823dd1092cf4d23e4af88a99 100644 (file)
 #include "AliHLTCaloClusterReader.h"
 #include "TEveTrans.h"
 #include "TString.h"
+#include "TH2F.h"
+#include "TH1F.h"
+
+
 
 ClassImp(AliHLTEveCalo);
 
@@ -43,6 +47,11 @@ AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) :
   fName(name)
 {
   // Constructor.
+  for(int i = 0; i < 9; i++) {
+    fPadTitles[i] = "";
+  }
+  
+
 }
 
 AliHLTEveCalo::~AliHLTEveCalo()
@@ -62,6 +71,8 @@ void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
   //See header file for documentation
 
   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) { 
+
+    cout <<"calo histo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<< endl;
     ProcessHistogram(block);
    
   } else {
@@ -162,3 +173,122 @@ void AliHLTEveCalo::ResetElements(){
     }
   }
 }
+
+Int_t AliHLTEveCalo::GetPadNumber(TString name) {
+
+
+  cout << "GetPadNumber name   " << name << endl;
+
+  for(int i = 0; i < 9; i++) {
+    if (!fPadTitles[i].CompareTo(name)){
+      return i+1;
+    }
+    else if (!fPadTitles[i].CompareTo("")) {
+      cout <<"in empty title"<<endl;
+      fPadTitles[i] = name;
+      return i+1;
+    }
+  }
+  
+  cout << "BALLE returning default 1"<< endl;
+
+  return 1;
+
+}
+
+void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount ) {
+  //See header file for documentation
+
+  if ( ! block->GetClassName().CompareTo("TObjArray")) {
+    TIter next((TObjArray*)(block->GetTObject()));
+    TObject *object;
+   
+    while (( object = (TObject*) next())) {
+      
+      Int_t iPad = GetPadNumber((static_cast<TH1*>(object))->GetName());
+      canvas->cd(iPad);
+
+      //Check if histo is 2D histo
+      TH2F* histo = dynamic_cast<TH2F*>(object);
+      if(histo){
+       
+       TString name = histo->GetName();
+       if(name.Contains("ClusterEnergy")) {
+         cout << "BALLE CE"<< endl;
+
+         Int_t lb = histo->FindLastBinAbove(0,1);
+         Int_t fb = histo->FindFirstBinAbove(0,1);
+
+         if(lb > -1) {
+           histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
+           histo->SetAxisRange(0, histo->GetYaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 2) + 3), "Y");
+         }
+       } 
+       
+       else if (name.Contains("MatchDistance")) {
+         cout << "BALLE MD"<< endl;
+         Float_t min = histo->GetXaxis()->GetBinLowEdge( histo->FindFirstBinAbove(0, 1) -3 );
+         Float_t max = histo->GetXaxis()->GetBinUpEdge( histo->FindLastBinAbove(0, 1) + 3);
+         min = TMath::Abs(min);
+         if(min > max) 
+           max = min;
+         histo->SetAxisRange(-max, max, "X");
+
+         min = histo->GetYaxis()->GetBinLowEdge( histo->FindFirstBinAbove(0, 2) -3 );
+         max = histo->GetYaxis()->GetBinUpEdge( histo->FindLastBinAbove(0, 2) + 3 );
+         min = TMath::Abs(min);
+         if(min > max) 
+           max = min;
+         histo->SetAxisRange(-max, max, "Y");
+       } 
+
+       histo->Draw("COLZ");
+      }
+      
+
+      //Must be 1D histo
+      else {
+       TH1F* histo = dynamic_cast<TH1F*>(object);
+       if (histo) {
+
+         TString name = histo->GetName();
+       
+         //canvas->cd(++cdCount);
+         
+         if(name.Contains("Energy")) {
+           histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
+         }
+
+         else if(name.Contains("InvMass")) {
+           histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindLastBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
+         }
+
+         histo->Draw();
+       } else {
+         cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
+       }
+      }
+    }
+  }
+    
+  else if ( ! block->GetClassName().CompareTo("TH1F")) {
+
+    TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
+    ++cdCount;
+    canvas->cd(cdCount);
+    histo->Draw();
+    
+  } 
+  
+  else if ( ! block->GetClassName().CompareTo("TH2F")) {
+    TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
+    if (histo) {
+      ++cdCount;
+      canvas->cd(cdCount);
+      histo->Draw("COLZ");
+    }
+  }
+
+  canvas->cd();
+}
+
index b9c118a6c44d951cb2ae220714052267582b22b7..19fa28351e4c8e3a6c678b97e6177f83439d4a80 100644 (file)
@@ -56,9 +56,12 @@ protected :
 
   /** Process histogram block */
   void ProcessHistogram(AliHLTHOMERBlockDesc * block );
-
-  
   
+  /** Process and draw histograms */
+  void AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount );  
+
+  Int_t GetPadNumber(TString name);  
+
   TEveBoxSet * fBoxSet;            //Boxset for clusters and digist
   
   TEveElementList * fElementList; //Element list to contain the clusters
@@ -66,6 +69,7 @@ protected :
   const Int_t fNModules;          //Number of modules in calorimeter
 
 
+
 private:
   
   /** default constructor prohibited */
@@ -77,6 +81,8 @@ private:
 
   TString fName;  //PHOS or EMCAL
   
+  TString fPadTitles[9];
+
   ClassDef(AliHLTEveCalo, 0);
 };