]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added two Get methods to get counters in histograms without drawing them (Philippe P.)
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Nov 2010 17:52:37 +0000 (17:52 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Nov 2010 17:52:37 +0000 (17:52 +0000)
PWG3/base/AliCounterCollection.cxx
PWG3/base/AliCounterCollection.h

index 9f7b0eaac5dc5a6fa300b73581e5ca23c3c83de1..9e1b502fe14d0e0ede7846c5776822f911edc85c 100644 (file)
@@ -976,9 +976,9 @@ Int_t AliCounterCollection::GetMaxLabelSize(THashList* labels) const
 }
 
 //-----------------------------------------------------------------------
-TH1D* AliCounterCollection::Draw(TString rubric, TString selections)
+TH1D* AliCounterCollection::Get(TString rubric, TString selections)
 {
-  /// Draw counters of the rubric "rubric" for the given "selection".
+  /// Get counters of the rubric "rubric" for the given "selection".
   /// Format of "selections" is rubric:[any-]keyWord,keyWord,../rubric:[any-]keyWord,.. (order does not matter).
   /// Results are integrated over rubrics not specified neither in "rubric1" nor in "selections".
   /// It is the responsability of the user to delete the returned histogram.
@@ -999,14 +999,13 @@ TH1D* AliCounterCollection::Draw(TString rubric, TString selections)
   // project counters in the rubrics to print according to the selections
   TH1D* hist = static_cast<TH1D*>(Projection(rubricsToPrint, selections));
   
-  // draw counters
+  // make it ready to display
   if (hist) {
     
-    // draw histogram
-    hist->Draw("htext");
+    // remove statistic box
     hist->SetStats(kFALSE);
     
-    // draw X axis
+    // prepare X axis
     TAxis* axis = hist->GetXaxis();
     THashList* labels = axis->GetLabels();
     Int_t nLabels = (labels) ? labels->GetSize() : 1;
@@ -1014,7 +1013,7 @@ TH1D* AliCounterCollection::Draw(TString rubric, TString selections)
     axis->SetNdivisions(1,kFALSE);
     axis->SetTitle(rubric.Data());
     
-    // draw Y axis
+    // prepare Y axis
     hist->GetYaxis()->SetTitle("Counts");
   }
   
@@ -1022,9 +1021,9 @@ TH1D* AliCounterCollection::Draw(TString rubric, TString selections)
 }
 
 //-----------------------------------------------------------------------
-TH2D* AliCounterCollection::Draw(TString rubric1, TString rubric2, TString selections)
+TH2D* AliCounterCollection::Get(TString rubric1, TString rubric2, TString selections)
 {
-  /// Draw counters of the "rubric1" vs "rubric2" for the given "selection".
+  /// Get counters of the "rubric1" vs "rubric2" for the given "selection".
   /// Format of "selections" is rubric:[any-]keyWord,keyWord,../rubric:[any-]keyWord,.. (order does not matter).
   /// Results are integrated over rubrics not specified neither in "rubric1", "rubric2" nor in "selections".
   /// It is the responsability of the user to delete the returned histogram.
@@ -1050,11 +1049,10 @@ TH2D* AliCounterCollection::Draw(TString rubric1, TString rubric2, TString selec
   // draw counters
   if (hist) {
     
-    // draw histogram
-    hist->Draw("text");
+    // remove statistic box
     hist->SetStats(kFALSE);
     
-    // draw X axis
+    // prepare X axis
     TAxis* axisX = hist->GetXaxis();
     THashList* labelsX = axisX->GetLabels();
     Int_t nLabelsX = (labelsX) ? labelsX->GetSize() : 1;
@@ -1062,7 +1060,7 @@ TH2D* AliCounterCollection::Draw(TString rubric1, TString rubric2, TString selec
     axisX->SetNdivisions(1,kFALSE);
     axisX->SetTitle(rubric2.Data());
     
-    // draw Y axis
+    // prepare Y axis
     TAxis* axisY = hist->GetYaxis();
     THashList* labelsY = axisY->GetLabels();
     Int_t nLabelsY = (labelsY) ? labelsY->GetSize() : 1;
@@ -1074,6 +1072,30 @@ TH2D* AliCounterCollection::Draw(TString rubric1, TString rubric2, TString selec
   return hist;
 }
 
+//-----------------------------------------------------------------------
+TH1D* AliCounterCollection::Draw(TString rubric, TString selections)
+{
+  /// Draw counters of the rubric "rubric" for the given "selection".
+  /// Format of "selections" is rubric:[any-]keyWord,keyWord,../rubric:[any-]keyWord,.. (order does not matter).
+  /// Results are integrated over rubrics not specified neither in "rubric1" nor in "selections".
+  /// It is the responsability of the user to delete the returned histogram.
+  TH1D* hist = Get(rubric, selections);
+  if (hist) hist->Draw("htext");
+  return hist;
+}
+
+//-----------------------------------------------------------------------
+TH2D* AliCounterCollection::Draw(TString rubric1, TString rubric2, TString selections)
+{
+  /// Draw counters of the "rubric1" vs "rubric2" for the given "selection".
+  /// Format of "selections" is rubric:[any-]keyWord,keyWord,../rubric:[any-]keyWord,.. (order does not matter).
+  /// Results are integrated over rubrics not specified neither in "rubric1", "rubric2" nor in "selections".
+  /// It is the responsability of the user to delete the returned histogram.
+  TH2D* hist = Get(rubric1, rubric2, selections);
+  if (hist) hist->Draw("text");
+  return hist;
+}
+
 //-----------------------------------------------------------------------
 TObject* AliCounterCollection::Projection(const TObjArray& data, const TString& selections)
 {
index c5918fd0841c71ed17bd14dd70f99855f4b0d648..4e15e85389370999abe2d580de7a4ddcc570962f 100644 (file)
@@ -43,6 +43,10 @@ public:
   
   // Get the overall statistics for the given selection (result is integrated over not specified rubrics)
   Double_t GetSum(TString selections = "");
+  // Get counters of the rubric "rubric1" for the given "selection"
+  TH1D* Get(TString rubric1, TString selections);
+  // Get counters of the "rubric1" vs "rubric2" for the given "selection"
+  TH2D* Get(TString rubric1, TString rubric2, TString selections);
   
   // Print every individual counters if opt=="", else call "Print(TString rubrics=opt, TString selections="")"
   virtual void Print(const Option_t* opt = "") const;