]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveBase/AliEveTrackCounterEditor.cxx
Fix enums as reported by coverity
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveTrackCounterEditor.cxx
index cf6d21d4a6c6367c753d504a7ef44ad27e8c77fa..2803b6672fd0c81c17995480af1a44bd540a2fe4 100644 (file)
@@ -10,6 +10,7 @@
 #include "AliEveTrackCounterEditor.h"
 #include "AliEveTrackCounter.h"
 #include "AliEveEventManager.h"
+#include "AliESDEvent.h"
 
 #include "TGedEditor.h"
 #include "TVirtualPad.h"
@@ -21,6 +22,8 @@
 #include "TGComboBox.h"
 #include "TGMsgBox.h"
 
+#include "TGButtonGroup.h"
+
 #include "TTree.h"
 #include "TH1F.h"
 
@@ -30,6 +33,7 @@
 
 #include "TROOT.h"
 #include "TSystem.h" // File input/output for track-count status.
+#include "TDatime.h"
 
 //______________________________________________________________________________
 // GUI editor for AliEveTrackCounter.
@@ -41,11 +45,13 @@ ClassImp(AliEveTrackCounterEditor)
 AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t width, Int_t height,
                                                UInt_t options, Pixel_t back) :
    TGedFrame(p, width, height, options | kVerticalFrame, back),
-   fM(0),
+   fM(0), fAF(0), fDF(0),
    fClickAction(0),
    fInfoLabelTracks   (0),
    fInfoLabelTracklets(0),
-   fEventId(0)
+   fEventId(0),
+   fEventCat(0),
+   fScanSummaryFile(0)
 {
    // Constructor.
 
@@ -53,8 +59,22 @@ AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t widt
 
    Int_t labelW = 42;
 
+
+   // Active frame
+
+   fAF = new TGVerticalFrame(this);
+
+   { // Deactivate button
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
+
+      TGTextButton* b = new TGTextButton(f, "Deactivate");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 4));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoDeactivate()");
+
+      fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
+   }
    { // ClickAction
-      TGHorizontalFrame* f = new TGHorizontalFrame(this);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
       TGLabel* lab = new TGLabel(f, "Click:");
       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
       fClickAction = new TGComboBox(f);
@@ -67,32 +87,30 @@ AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t widt
                             "DoClickAction(Int_t)");
       f->AddFrame(fClickAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
 
-      AddFrame(f);
+      fAF->AddFrame(f);
    }
-
    { // fInfoLabelTracks
-      TGHorizontalFrame* f = new TGHorizontalFrame(this);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
       TGLabel* lab = new TGLabel(f, "Tracks:");
       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
 
       fInfoLabelTracks = new TGLabel(f);
       f->AddFrame(fInfoLabelTracks, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
 
-      AddFrame(f);
+      fAF->AddFrame(f);
    }
    { // fInfoLabelTracklets
-      TGHorizontalFrame* f = new TGHorizontalFrame(this);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
       TGLabel* lab = new TGLabel(f, "Tracklets:");
       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
 
       fInfoLabelTracklets = new TGLabel(f);
       f->AddFrame(fInfoLabelTracklets, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
 
-      AddFrame(f);
+      fAF->AddFrame(f);
    }
-
    {
-      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
 
       TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
       TGLabel* l = new TGLabel(g, "Event:");
@@ -114,11 +132,10 @@ AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t widt
       f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
       b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoNext()");
 
-      AddFrame(f);
+      fAF->AddFrame(f);
    }
-
    {
-      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
 
       TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
       TGLabel* l = new TGLabel(g, "Report:");
@@ -135,10 +152,10 @@ AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t widt
       f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
       b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoFileReport()");
 
-      AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
+      fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
    }
    {
-      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
 
       TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
       TGLabel* l = new TGLabel(g, "Histos:");
@@ -151,11 +168,44 @@ AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t widt
       f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
       b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoShowHistos()");
 
-      AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
+      fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
+   }
+   {
+      TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
+
+      TGButtonGroup *fTypeSelector = new TGButtonGroup(f, "Event Categorization");
+      new TGRadioButton(fTypeSelector, "Good");
+      new TGRadioButton(fTypeSelector, "Splash");
+      new TGRadioButton(fTypeSelector, "Empty");
+      new TGRadioButton(fTypeSelector, "Background");
+      new TGRadioButton(fTypeSelector, "Unclear/Other");
+      fTypeSelector->Connect("Clicked(Int_t)", "AliEveTrackCounterEditor", this, "DoEventCategorization(Int_t)");
+
+      f->AddFrame(fTypeSelector, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
+   
+      fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
+   }
+
+   AddFrame(fAF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
+
+
+   // Disabled frame
+
+   fDF = new TGVerticalFrame(this);
+
+   { // Activate button
+      TGHorizontalFrame* f = new TGHorizontalFrame(fDF, 210, 20, kFixedWidth);
+
+      TGTextButton* b = new TGTextButton(f, "Activate");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoActivate()");
+
+      fDF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
    }
 
-  AliEveEventManager::GetMaster()->Connect("NewEventLoaded()",
-                        "AliEveTrackCounterEditor", this, "UpdateModel()");
+   AddFrame(fDF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
+
+   AliEveEventManager::GetMaster()->Connect("NewEventLoaded()", "AliEveTrackCounterEditor", this, "UpdateModel()");
 }
 
 AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
@@ -163,15 +213,22 @@ AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
   // Destructor.
 
   AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
+
+  if (fScanSummaryFile) {
+    fScanSummaryFile->close();
+    delete fScanSummaryFile;
+    fScanSummaryFile = 0;
+  }
 }
 
 /******************************************************************************/
 
 void AliEveTrackCounterEditor::UpdateModel()
 {
-  if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject())
+  TEveException e;
+  if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject(e))
   {
-    SetModel(fM->GetEditorObject());
+    SetModel(fM->GetEditorObject(e));
   }
 }
 
@@ -180,12 +237,62 @@ void AliEveTrackCounterEditor::SetModel(TObject* obj)
 {
    // Set model object.
 
-   fM = dynamic_cast<AliEveTrackCounter*>(obj);
+   fM = static_cast<AliEveTrackCounter*>(obj);
+
+   if (fM->GetActive())
+   {
+      ShowFrame(fAF); HideFrame(fDF);
+      fClickAction->Select(fM->fClickAction, kFALSE);
+      fInfoLabelTracks   ->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks,    fM->fGoodTracks));
+      fInfoLabelTracklets->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracklets, fM->fGoodTracklets));
+      fEventId->SetNumber(fM->GetEventId());
+   }
+   else
+   {
+     ShowFrame(fDF); HideFrame(fAF);
+   }
+
+   Layout();
+}
+
+/******************************************************************************/
+
+void AliEveTrackCounterEditor::DoActivate()
+{
+   // Activate track-counter
+
+   fM->SetActive(kTRUE);
+   AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
+   fGedEditor->Layout();
 
-   fClickAction->Select(fM->fClickAction, kFALSE);
-   fInfoLabelTracks   ->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks,    fM->fGoodTracks));
-   fInfoLabelTracklets->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracklets, fM->fGoodTracklets));
-   fEventId->SetNumber(fM->GetEventId());
+   if (fScanSummaryFile) {
+     fScanSummaryFile->close();
+     delete fScanSummaryFile;
+   }
+
+   char fname[200];
+   TDatime dat;
+   snprintf(fname, 200,"ScanSummary.%i.%i.txt", dat.GetDate(), dat.GetTime());
+   fScanSummaryFile = new ofstream(fname);
+   (*fScanSummaryFile) << "Scan summary" << std::endl;
+   (*fScanSummaryFile) << "Scan started at " << dat.GetDate() << " " << dat.GetTime() << std::endl;
+   AliESDEvent *esd = AliEveEventManager::AssertESD();
+   (*fScanSummaryFile) << "Run number " << esd->GetRunNumber() << std::endl;
+}
+
+void AliEveTrackCounterEditor::DoDeactivate()
+{
+   // Deactivate track-counter.
+
+   fM->SetActive(kFALSE);
+   AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
+
+   if (fScanSummaryFile) {
+     fScanSummaryFile->close();
+     delete fScanSummaryFile;
+     fScanSummaryFile = 0;
+   }
 }
 
 /******************************************************************************/
@@ -203,6 +310,35 @@ void AliEveTrackCounterEditor::DoNext()
 {
    // Slot for Next.
 
+   if (fScanSummaryFile) {
+     AliESDEvent *esd = AliEveEventManager::AssertESD();
+     (*fScanSummaryFile) << std::hex << std::right ;
+     fScanSummaryFile->width(5); (*fScanSummaryFile) << esd->GetPeriodNumber() << "   " ;
+     fScanSummaryFile->width(6); (*fScanSummaryFile) << esd->GetOrbitNumber() << "   ";
+     fScanSummaryFile->width(4); (*fScanSummaryFile) << esd->GetBunchCrossNumber() << "   ";
+     switch (fEventCat) {
+     case 1: (*fScanSummaryFile) << "GOOD        "; break;
+     case 2: (*fScanSummaryFile) << "SPLASH      "; break;
+     case 3: (*fScanSummaryFile) << "EMPTY       "; break;
+     case 4: (*fScanSummaryFile) << "BACKGROUND  "; break;
+     case 5: (*fScanSummaryFile) << "OTHER       "; break;
+     default: break;
+     }
+     if (fM->GetActive())
+       {
+        (*fScanSummaryFile) << std::dec;
+        fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fAllTracks << "  ";
+        fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fGoodTracks << "     ";
+        fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fAllTracklets << "  ";
+        fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fGoodTracklets << "   ";
+       }
+     if ((esd->GetPrimaryVertex()) && (esd->GetPrimaryVertex()->GetStatus()))
+       { fScanSummaryFile->width(9); (*fScanSummaryFile) << esd->GetPrimaryVertex()->GetZ(); }
+     else { (*fScanSummaryFile) << "NOVTX    "; }
+
+     (*fScanSummaryFile) << std::endl;
+   }
+
    AliEveEventManager::GetMaster()->NextEvent();
 }
 
@@ -210,6 +346,7 @@ void AliEveTrackCounterEditor::DoNext()
 void AliEveTrackCounterEditor::DoSetEvent()
 {
    // Slot for SetEvent.
+
    AliEveEventManager::GetMaster()->GotoEvent((Int_t) fEventId->GetNumber());
 }
 
@@ -236,51 +373,8 @@ void AliEveTrackCounterEditor::DoShowHistos()
 {
   // Slot for ShowHistos.
 
-  static const TEveException kEH("AliEveTrackCounterEditor::DoShowHistos ");
-
+  TEveUtil::Macro("make_scan_results.C");
   TEveUtil::Macro("show_scan_results.C");
-
-  TTree* t = (TTree*) gDirectory->Get("SR");
-
-  if (t == 0)
-    throw kEH + "Tree 'SR' with scan results not found.";
-
-  TCanvas *c = 0;
-
-  //----------------------------------------------------------------------------
-  // Tracks
-  //----------------------------------------------------------------------------
-
-  c = new TCanvas("Tracks", "Track Scanning Results", 800, 600);
-  c->Divide(2, 3);
-
-  c->cd(1);
-  t->Draw("Sum$(T.fLabel & 1)");
-
-  c->cd(2);
-  t->Draw("T.GetSign()", "T.fLabel & 1");
-
-  c->cd(3);
-  t->Draw("T.GetSign()", "T.fLabel & 1");
-
-  c->cd(4);
-  t->Draw("T.Eta()", "T.fLabel & 1");
-
-  c->cd(5);
-  t->Draw("T.Phi()", "T.fLabel & 1");
-
-  c->Modified();
-  c->Update();
-
-  //----------------------------------------------------------------------------
-  // Trackelts
-  //----------------------------------------------------------------------------
-
-  c = new TCanvas("Tracklets", "Tracklet Scanning Results", 800, 600);
-  (new TLatex(0.2, 0.4, "Not yet available"))->Draw();
-
-  c->Modified();
-  c->Update();
 }
 
 /******************************************************************************/
@@ -292,3 +386,12 @@ void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
 
    fM->SetClickAction(mode);
 }
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoEventCategorization(Int_t mode)
+{
+   // Slot for ClickAction.
+
+  printf("Mode is %i\n", mode);
+  fEventCat = mode;
+}