From Mikolaj. Some fixes of event-selector. Document classes.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jun 2009 13:13:16 +0000 (13:13 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jun 2009 13:13:16 +0000 (13:13 +0000)
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventSelector.cxx
EVE/EveBase/AliEveEventSelector.h
EVE/EveBase/AliEveEventSelectorWindow.cxx
EVE/EveBase/AliEveEventSelectorWindow.h

index 23c4bbc..c950594 100644 (file)
@@ -789,8 +789,6 @@ void AliEveEventManager::NextEvent()
     {
       GotoEvent(nextevent);
     }
-    //else 
-    //  GotoEvent(fEventId + 1);
   }
 }
 
@@ -813,8 +811,6 @@ void AliEveEventManager::PrevEvent()
   {
     GotoEvent(nextevent);
   }
-  //else
-  //  GotoEvent(fEventId - 1);
 }
 
 void AliEveEventManager::Close()
index 9fda57f..e15d0a3 100644 (file)
@@ -4,13 +4,14 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
-///////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
 //
-//  Finds events according to specified criteria
+//  AliEveEventSelector class
+//  selects events according to given criteria
 //
-//  origin: Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+//  origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
 //
-//////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
 
 #include "AliEveEventSelector.h"
 #include "AliEveEventManager.h"
@@ -29,8 +30,7 @@ ClassImp(AliEveEventSelector)
 //_____________________________________________________________________________
 AliEveEventSelector::AliEveEventSelector(AliEveEventManager* evman):
   fPEventManager(evman),
-  fWrapAround(kTRUE),
-  fMaxEventId(fPEventManager->GetMaxEventId()),
+  fWrapAround(kFALSE),
   fSelectOnString(kFALSE),
   fString(""),
   fPEntryList(NULL),
@@ -51,12 +51,12 @@ AliEveEventSelector::AliEveEventSelector(AliEveEventManager* evman):
 void AliEveEventSelector::SetSelectionString( const TString& str )
 {
   //selection string setter
+  //takes care of producing a list of entries passing selection
 
   TTree* pESDTree = fPEventManager->GetESDTree();
   if (!pESDTree || fString==str) return;//don't waist time
   fString = str;
   if (str == "" ) return;//on reset don't recalculate
-  fMaxEventId = fPEventManager->GetMaxEventId();
   pESDTree->Draw( ">>listofentries", fString, "entrylist");
   fPEntryList = dynamic_cast<TEntryList*>(gDirectory->Get("listofentries"));
 }
@@ -64,6 +64,8 @@ void AliEveEventSelector::SetSelectionString( const TString& str )
 //_____________________________________________________________________________
 void AliEveEventSelector::SetSelectionString( const char* str )
 {
+  //selection string setter
+
   TString ts = str;
   SetSelectionString(ts);
 }
@@ -71,12 +73,16 @@ void AliEveEventSelector::SetSelectionString( const char* str )
 //_____________________________________________________________________________
 void AliEveEventSelector::SetTriggerType( const TString& type )
 {
+  //trigger type setter
+
   fTriggerType = type;
 }
 
 //_____________________________________________________________________________
 void AliEveEventSelector::SetTriggerType( const char* type)
 {
+  //trigger type setter
+
   TString ts = type;
   SetTriggerType(ts);
 }
@@ -84,15 +90,16 @@ void AliEveEventSelector::SetTriggerType( const char* type)
 //_____________________________________________________________________________
 void AliEveEventSelector::UpdateEntryList()
 {
-  //update the entrylist from file if file changed
+  //update the entrylist from if file changed
+
   TTree* pESDTree = fPEventManager->GetESDTree();
   if (!pESDTree) return;
   
-  Long64_t treesize = fPEventManager->GetMaxEventId();
-  if (treesize<=fMaxEventId) return; //nothing changed, do nothing
+  Long64_t treesize = fPEventManager->GetMaxEventId()+1;
+  if (treesize<=fLastTreeSize) return; //nothing changed, do nothing
   pESDTree->Draw(">>+fPEntryList", fString, "entrylist",
-      fMaxEventId, treesize-fMaxEventId );
-  fMaxEventId = treesize;
+                 fLastTreeSize+1, treesize-fLastTreeSize );
+  fLastTreeSize = treesize;
 }
 
 //_____________________________________________________________________________
@@ -114,7 +121,7 @@ Bool_t AliEveEventSelector::FindNext( Int_t& output )
   if (!pESDTree) return kFALSE;
   AliESDEvent* pESDEvent = fPEventManager->GetESD();
   Int_t eventId = fPEventManager->GetEventId();
-  fMaxEventId = fPEventManager->GetMaxEventId();
+  Int_t fMaxEventId = fPEventManager->GetMaxEventId();
 
   if (!fSelectOnString)
   {
@@ -145,6 +152,7 @@ Bool_t AliEveEventSelector::FindNext( Int_t& output )
   else
   {
     //select using the entrylist
+    UpdateEntryList(); //update entry list if tree got bigger
     for (Long64_t i=fEntryListId+1; i<fPEntryList->GetN(); i++ )
     {
       Long64_t entry = fPEntryList->GetEntry(i);
@@ -187,7 +195,7 @@ Bool_t AliEveEventSelector::FindPrev( Int_t& output )
   if (!pESDTree) return kFALSE;
   AliESDEvent* pESDEvent = fPEventManager->GetESD();
   Int_t eventId = fPEventManager->GetEventId();
-  fMaxEventId = fPEventManager->GetMaxEventId();
+  Int_t fMaxEventId = fPEventManager->GetMaxEventId();
 
   if (!fSelectOnString)
   {
@@ -252,16 +260,13 @@ Bool_t AliEveEventSelector::FindPrev( Int_t& output )
 Bool_t AliEveEventSelector::CheckOtherSelection( AliESDEvent* pESDEvent )
 {
   //checks the event for any other hardcoded selection criteria
+  
   Bool_t ret=kTRUE;
 
   //trigger stuff
   if (fSelectOnTriggerType)
   {
     TString firedtrclasses = pESDEvent->GetFiredTriggerClasses();
-    printf(firedtrclasses.Data());
-    printf("\n");
-    printf(fTriggerType.Data());
-    printf("\n");
     if (!(firedtrclasses.Contains(fTriggerType))) return kFALSE;
     //if (!pESDEvent->IsTriggerClassFired(fTriggerType.Data())) return kFALSE;
   }
@@ -280,8 +285,8 @@ Bool_t AliEveEventSelector::CheckOtherSelection( AliESDEvent* pESDEvent )
     triggermaskstr += triggermask;
     TString selstr(fTriggerSelectionString); //make copy
     selstr.ReplaceAll(fTriggerMaskPatternString,triggermaskstr);
-    Int_t returncode;
-    Bool_t result = static_cast<Bool_t>(gROOT->ProcessLine(selstr,&returncode));
+    //Int_t returncode;
+    Bool_t result = static_cast<Bool_t>(gROOT->ProcessLine(selstr));//,&returncode));
     //if (!returncode) return kFALSE;
     if (!result) return kFALSE;
   }
@@ -292,6 +297,8 @@ Bool_t AliEveEventSelector::CheckOtherSelection( AliESDEvent* pESDEvent )
 //_____________________________________________________________________________
 void AliEveEventSelector::SetTriggerSelectionString( TString str )
 {
+  //parses and sets the trigger selection formula
+  
   const AliESDRun* run = fPEventManager->GetESD()->GetESDRun();
   for (Int_t i=0; i<run->kNTriggerClasses; i++)
   {
index 5ea1bde..99aaf7d 100644 (file)
@@ -4,13 +4,17 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
-#ifndef AliEveEventSelector_H
-#define AliEveEventSelector_H
-
-// AliEveEventSelector
+////////////////////////////////////////////////////////////////////////////
 //
-// Event selector class
+//  AliEveEventSelector class
+//  selects events according to given criteria
 //
+//  origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
+//
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef AliEveEventSelector_H
+#define AliEveEventSelector_H
 
 #include "AliEveEventManager.h"
 #include <TObject.h>
@@ -72,25 +76,25 @@ private:
   AliEveEventSelector(const AliEveEventSelector&);
   AliEveEventSelector& operator=(const AliEveEventSelector&);
 
-  AliEveEventManager *fPEventManager;
-  Bool_t fWrapAround;
-  Long64_t fMaxEventId;
+  AliEveEventManager *fPEventManager; //event manager
+  Bool_t fWrapAround;                 //go back to the first event after the last?
   
-  Bool_t fSelectOnString;
-  TString fString;
-  TEntryList* fPEntryList;
-  Int_t  fEntryListId;
-
-  Bool_t fSelectOnTriggerType;
-  TString fTriggerType;
-
-  Bool_t fSelectOnTriggerString;
-  TString fTriggerSelectionString;
-  TString fTriggerMaskPatternString;
-
-  Bool_t fSelectOnMultiplicity;
-  Int_t fMultiplicityLow;
-  Int_t fMultiplicityHigh;
+  Bool_t fSelectOnString;             //whether to select on string expression
+  TString fString;                    //expression to select on
+  TEntryList* fPEntryList;            //list of enry numbers after selection
+  Int_t  fEntryListId;                //current entry no. in entry list
+  Int_t fLastTreeSize;                //stores the last treesize
+
+  Bool_t fSelectOnTriggerType;        //whether to select on trigger type
+  TString fTriggerType;               //trigger type
+
+  Bool_t fSelectOnTriggerString;      //whether to select on trigger type with a formula
+  TString fTriggerSelectionString;    //trigger selection formula
+  TString fTriggerMaskPatternString;  //trigger mask placeholder for evaluation
+
+  Bool_t fSelectOnMultiplicity;       //whether to select on multiplicity
+  Int_t fMultiplicityLow;             //lower bound on multiplicity
+  Int_t fMultiplicityHigh;            //higher bound on multiplicity
 
 
   ClassDef(AliEveEventSelector, 2); 
index 75b7299..e00ef00 100644 (file)
@@ -4,6 +4,14 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
+///////////////////////////////////////////////////////////////////////////
+//
+//  implementation of a GUI for the event/trigger selection
+//
+//  origin: Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+//
+//////////////////////////////////////////////////////////////////////////
+
 #include "AliEveEventSelectorWindow.h"
 #include "AliEveEventSelector.h"
 #include "AliEveEventManager.h"
@@ -74,6 +82,7 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
   TGCheckButton* checktextsel = new TGCheckButton(hframetxtsel);
   checktextsel->Connect("Toggled(Bool_t)", "AliEveEventSelector",
                         fPSelector, "SetSelectOnString(Bool_t)");
+  checktextsel->SetState(fPSelector->GetSelectOnString() ? kButtonDown : kButtonUp);
   hframetxtsel->AddFrame(checktextsel, new TGLayoutHints(kLHintsLeft));
 
   fPEntryLowerBound = new TGNumberEntry(hframetxtsel);
@@ -96,6 +105,7 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
   fPCheckTriggerSimple = new TGCheckButton(hframetrigger);
   fPCheckTriggerSimple->Connect("Toggled(Bool_t)","AliEveEventSelector",
                           fPSelector,"SetSelectOnTriggerType(Bool_t)");
+  fPCheckTriggerSimple->SetState(fPSelector->GetSelectOnTriggerType() ? kButtonDown : kButtonUp );
   hframetrigger->AddFrame(fPCheckTriggerSimple, new TGLayoutHints(kLHintsLeft));
   fPComboBoxTrigger = new TGComboBox(hframetrigger);
   fPComboBoxTrigger->Resize(100,20);
@@ -109,6 +119,7 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
   hframetrigger->AddFrame(fPCheckTriggerString, new TGLayoutHints(kLHintsLeft));
   fPCheckTriggerString->Connect("Toggled(Bool_t)","AliEveEventSelector",
                            fPSelector,"SetSelectOnTriggerString(Bool_t)");
+  fPCheckTriggerString->SetState(fPSelector->GetSelectOnTriggerString() ? kButtonDown : kButtonUp );
   fPEntryTriggerSelection = new TGTextEntry(hframetrigger);
   hframetrigger->AddFrame(fPEntryTriggerSelection, new TGLayoutHints(kLHintsExpandX));
   TGTextButton* buttontrigsel = new TGTextButton(hframetrigger,"Set");
@@ -125,6 +136,7 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
   TGCheckButton* checkmult = new TGCheckButton(hframemult);
   checkmult->Connect("Toggled(Bool_t)", "AliEveEventSelector",
                       fPSelector,"SetSelectOnMultiplicity(Bool_t)");
+  checkmult->SetState(fPSelector->GetSelectOnMultiplicity() ? kButtonDown : kButtonUp );
   hframemult->AddFrame(checkmult, new TGLayoutHints(kLHintsLeft));
   fPEntryMultLow = new TGNumberEntry(hframemult);
   hframemult->AddFrame(fPEntryMultLow, new TGLayoutHints(kLHintsLeft));
@@ -145,6 +157,7 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
   hframewrap->AddFrame(checkwraparound, new TGLayoutHints(kLHintsLeft));
   checkwraparound->Connect("Toggled(Bool_t)","AliEveEventSelector",
                            fPSelector, "SetWrapAround(Bool_t)");
+  checkwraparound->SetState(fPSelector->GetWrapAround() ? kButtonDown : kButtonUp );
 
   SetupTriggerSelect();
   
@@ -159,11 +172,14 @@ AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w
 //______________________________________________________________________________
 AliEveEventSelectorWindow::~AliEveEventSelectorWindow()
 {
+  //dtor
 }
 
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::SetupTriggerSelect()
-{   
+{ 
+  //Set up the list of available triggers
+
   // Do nothing if already enabled.
   if (fPComboBoxTrigger->GetNumberOfEntries() > 0)
     return;
@@ -205,6 +221,8 @@ void AliEveEventSelectorWindow::SetupTriggerSelect()
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::DoSetSelectionString()
 {
+  //process the entered formula and send it to the selector
+
   TString str = fPEntryFormula->GetText();
   TString s;
   if (fPEntryLowerBound->GetNumber()==0&&fPEntryHigherBound->GetNumber()==0)
@@ -229,6 +247,8 @@ void AliEveEventSelectorWindow::DoSetSelectionString()
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::DoDrawHistogram()
 {
+  //Draw histogram with formula in the draw field
+
   TTree* tree = fPSelector->GetESDTree();
   TString str = fPDrawFormula->GetText();
   str += ">>selectionhist";
@@ -242,6 +262,8 @@ void AliEveEventSelectorWindow::DoDrawHistogram()
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::DoSetTriggerSelectionString()
 {
+  //Set trigger selection formula
+  
   TString string = fPEntryTriggerSelection->GetText();
   fPSelector->SetTriggerSelectionString(string);
   fPEntryTriggerSelection->SetToolTipText(fPSelector->GetTriggerSelectionString());
@@ -250,6 +272,8 @@ void AliEveEventSelectorWindow::DoSetTriggerSelectionString()
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::DoHandleTriggerFromComboBox(const char* str)
 {
+  //Dispatch the trigger selection to proper destination
+  
   if (fPSelector->GetSelectOnTriggerString() && !fPSelector->GetSelectOnTriggerType())
   {
     fPEntryTriggerSelection->Insert(str);
@@ -262,6 +286,8 @@ void AliEveEventSelectorWindow::DoHandleTriggerFromComboBox(const char* str)
 //______________________________________________________________________________
 void AliEveEventSelectorWindow::DoSetMultiplicityRange()
 {
+  //Set the multiplicity range
+  
   fPSelector->SetMultiplicityLow(fPEntryMultLow->GetNumber());
   fPSelector->SetMultiplicityHigh(fPEntryMultHigh->GetNumber());
 }
index f972a57..e523426 100644 (file)
@@ -4,6 +4,16 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
+////////////////////////////////////////////////////////////////////////////
+//
+//  AliEveEventSelectorWindow class
+//  GUI for setting event and trigger selections
+//
+//  origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
+//
+////////////////////////////////////////////////////////////////////////////
+
+
 #ifndef AliEveEventSelectorWindow_H
 #define AliEveEventSelectorWindow_H
 
@@ -43,21 +53,21 @@ public:
 protected:
 
 private:
-  AliEveEventSelector* fPSelector;
-  TRootEmbeddedCanvas* fPCanvas;
+  AliEveEventSelector* fPSelector; //event selector
+  TRootEmbeddedCanvas* fPCanvas;   //the canvas for histograms
 
-  TGTextEntry* fPDrawFormula;
-  TGTextEntry* fPEntryFormula;
-  TGNumberEntry* fPEntryLowerBound;
-  TGNumberEntry* fPEntryHigherBound;
-  TGTextButton* fPButtonTextDone;
+  TGTextEntry* fPDrawFormula;      //test draw input field
+  TGTextEntry* fPEntryFormula;     //selectin formula field
+  TGNumberEntry* fPEntryLowerBound; //lower boung for the formula
+  TGNumberEntry* fPEntryHigherBound; //higher bound for the formula
+  TGTextButton* fPButtonTextDone;    //done button for selection formula
   
-  TGComboBox* fPComboBoxTrigger;
-  TGTextEntry* fPEntryTriggerSelection;
-  TGCheckButton* fPCheckTriggerSimple;
-  TGCheckButton* fPCheckTriggerString;
-  TGNumberEntry* fPEntryMultHigh;
-  TGNumberEntry* fPEntryMultLow;
+  TGComboBox* fPComboBoxTrigger;     //trigger selection box
+  TGTextEntry* fPEntryTriggerSelection; //trigger selection formula entry field
+  TGCheckButton* fPCheckTriggerSimple;  //use simple trigger select
+  TGCheckButton* fPCheckTriggerString;  //use trigger select formula
+  TGNumberEntry* fPEntryMultHigh;       //lowest allowed multiplicity field
+  TGNumberEntry* fPEntryMultLow;        //higest allowed multiplicity field
 
   AliEveEventSelectorWindow(const AliEveEventSelectorWindow&);
   AliEveEventSelectorWindow& operator=(const AliEveEventSelectorWindow&);