From: cvetan Date: Fri, 16 May 2008 13:22:38 +0000 (+0000) Subject: First version of the online reco + AliEVE attached to it. (Matevz and Cvetan) X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=319f30847dffdde01b1ad0801c1e289950bf6d66;hp=f39fcb6015aa77000bd751c33176a25e3f29e81e First version of the online reco + AliEVE attached to it. (Matevz and Cvetan) --- diff --git a/EVE/EveBase/AliEveEventManager.cxx b/EVE/EveBase/AliEveEventManager.cxx index 36eac983c34..7d98be9b8ee 100644 --- a/EVE/EveBase/AliEveEventManager.cxx +++ b/EVE/EveBase/AliEveEventManager.cxx @@ -65,7 +65,11 @@ AliEveEventManager::AliEveEventManager() : fRunLoader (0), fESDFile (0), fESDTree (0), fESD (0), fESDfriend (0), fESDfriendExists(kFALSE), - fRawReader (0) + fRawReader (0), + fAutoLoad(kFALSE), + fAutoLoadTime(5.), + fAutoLoadTimer(0), + fIsOnline(kFALSE) { // Default constructor. } @@ -77,7 +81,11 @@ AliEveEventManager::AliEveEventManager(TString path, Int_t ev) : fRunLoader (0), fESDFile (0), fESDTree (0), fESD (0), fESDfriend (0), fESDfriendExists(kFALSE), - fRawReader (0) + fRawReader (0), + fAutoLoad(kFALSE), + fAutoLoadTime(5.), + fAutoLoadTimer(0), + fIsOnline(kFALSE) { // Constructor with event-directory URL and event-id. @@ -89,6 +97,7 @@ AliEveEventManager::~AliEveEventManager() { // Destructor. + if (fAutoLoadTimer) delete fAutoLoadTimer; // Somewhat unclear what to do here. // In principle should close all data sources and deregister from // TEveManager. @@ -283,6 +292,21 @@ void AliEveEventManager::Open() SetTitle(fPath); } +void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd) +{ + // Set an event from an external source + // The method is used in the online visualisation + fRunLoader = runLoader; + fRawReader = rawReader; + fESD = esd; + fIsOnline = kTRUE; + SetTitle("Online event in memory"); + SetName("Online Event"); + + ElementChanged(); + AfterNewEventLoaded(); +} + void AliEveEventManager::GotoEvent(Int_t event) { // Load data for specified event. @@ -360,7 +384,7 @@ void AliEveEventManager::GotoEvent(Int_t event) fEventId = event; SetName(Form("Event %d", fEventId)); - UpdateItems(); + ElementChanged(); AfterNewEventLoaded(); } @@ -499,3 +523,84 @@ TGeoManager* AliEveEventManager::AssertGeometry() gGeoManager = AliGeomManager::GetGeometry(); return gGeoManager; } + +void AliEveEventManager::SetAutoLoad(Bool_t autoLoad) +{ + // Set the automatic event loading mode + fAutoLoad = autoLoad; + StartStopAutoLoadTimer(); +} + +void AliEveEventManager::SetAutoLoadTime(Double_t time) +{ + // Set the auto-load time in seconds + fAutoLoadTime = time; + StartStopAutoLoadTimer(); +} + +void AliEveEventManager::StartStopAutoLoadTimer() +{ + // Create if needed and start + // the automatic event loading timer + if (fAutoLoad) { + if (!fAutoLoadTimer) { + fAutoLoadTimer = new TTimer; + fAutoLoadTimer->Connect("Timeout()","AliEveEventManager",this,"NextEvent()"); + } + fAutoLoadTimer->Start((Long_t)fAutoLoadTime*1000,kTRUE); + } + else { + if (fAutoLoadTimer) fAutoLoadTimer->Stop(); + } +} + +void AliEveEventManager::PrevEvent() +{ + // Loads previous event + // only in case of manual mode + if (!fIsOnline) { + GotoEvent(fEventId - 1); + StartStopAutoLoadTimer(); + } +} + +void AliEveEventManager::NextEvent() +{ + // Loads next event + // either in automatic (online) or + // manual mode + + if (fIsOnline) { + if (fAutoLoadTimer) fAutoLoadTimer->Stop(); + + DestroyElements(); + + gSystem->ExitLoop(); + } + else { + GotoEvent(fEventId + 1); + StartStopAutoLoadTimer(); + } +} + +const char* AliEveEventManager::GetEventInfo() const +{ + // Dumps the event-header contents + + static TString eventInfo; + + if (!fRawReader) return "No event information is available"; + + const UInt_t* id = fRawReader->GetEventId(); + const UInt_t* pattern = fRawReader->GetTriggerPattern(); + const UInt_t* attr = fRawReader->GetAttributes(); + eventInfo.Form("Run#: %d\nEvent type: %d\nPeriod: %x\nOrbit: %x\nBC: %x\nTrigger: %x-%x\nDetectors: %x\nAttributes:%x-%x-%x", + fRawReader->GetRunNumber(),fRawReader->GetType(), + (((id)[0]>>4)&0x0fffffff),((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)),((id)[1]&0x00000fff), + pattern[0],pattern[1], + *fRawReader->GetDetectorPattern(), + attr[0],attr[1],attr[2]); + + return eventInfo.Data(); +} + diff --git a/EVE/EveBase/AliEveEventManager.h b/EVE/EveBase/AliEveEventManager.h index 564cf4e75af..e02bfcf2313 100644 --- a/EVE/EveBase/AliEveEventManager.h +++ b/EVE/EveBase/AliEveEventManager.h @@ -46,9 +46,11 @@ public: virtual void Open(); + void SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd); + virtual void GotoEvent(Int_t event); - virtual void NextEvent() { GotoEvent(fEventId + 1); } - virtual void PrevEvent() { GotoEvent(fEventId - 1); } + virtual void NextEvent(); + virtual void PrevEvent(); virtual void Close(); Int_t GetEventId() const { return fEventId; } @@ -58,6 +60,7 @@ public: AliESDfriend* GetESDfriend() const { return fESDfriend; } Bool_t GetESDfriendExists() const { return fESDfriendExists; } virtual const Text_t* GetTitle() const { return fPath.Data(); } + const char* GetEventInfo() const; static AliRunLoader* AssertRunLoader(); static AliESDEvent* AssertESD(); @@ -68,6 +71,14 @@ public: static TGeoManager* AssertGeometry(); + Bool_t GetAutoLoad() const {return fAutoLoad;} + Double_t GetAutoLoadTime() const {return fAutoLoadTime;} + void SetAutoLoad(Bool_t autoLoad); + void SetAutoLoadTime(Double_t time); + Bool_t GetIsOnline() const {return fIsOnline;} + + void StartStopAutoLoadTimer(); + protected: TString fPath; // URL to event-data. Int_t fEventId; // Id of current event. @@ -82,6 +93,11 @@ protected: AliRawReader* fRawReader; // Raw-adata reader. + Bool_t fAutoLoad; // Automatic loading of events (online) + Double_t fAutoLoadTime; // Auto-load time in seconds + TTimer *fAutoLoadTimer; // Timer for automatic event loading + Bool_t fIsOnline; // Are we running online? + static TString fgESDFileName; // Name by which to open ESD. static TString fgRawFileName; // Name by which to open raw-data file. static TString fgCdbUri; // Global URI to CDB. diff --git a/EVE/EveBase/AliEveEventManagerEditor.cxx b/EVE/EveBase/AliEveEventManagerEditor.cxx index 8a1ec7cc2fa..f871ee7d379 100644 --- a/EVE/EveBase/AliEveEventManagerEditor.cxx +++ b/EVE/EveBase/AliEveEventManagerEditor.cxx @@ -13,13 +13,10 @@ #include "TVirtualPad.h" #include "TColor.h" -// Cleanup these includes: -#include "TGLabel.h" -#include "TGButton.h" -#include "TGNumberEntry.h" -#include "TGColorSelect.h" -#include "TGDoubleSlider.h" - +#include +#include +#include +#include //______________________________________________________________________________ // GUI editor for AliEveEventManager. @@ -31,17 +28,60 @@ ClassImp(AliEveEventManagerEditor) AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back) : TGedFrame(p, width, height, options | kVerticalFrame, back), - fM(0) - // Initialize widget pointers to 0 + fM(0), + fAutoLoad(0), + fAutoLoadTime(0), + fNextEvent(0), + fPrevEvent(0), + fEventInfo(0) { // Constructor. MakeTitle("AliEveEventManager"); // Create widgets - // fXYZZ = new TGSomeWidget(this, ...); - // AddFrame(fXYZZ, new TGLayoutHints(...)); - // fXYZZ->Connect("SignalName()", "Reve::AliEveEventManagerEditor", this, "DoXYZZ()"); + { + fAutoLoadTime = new TEveGValuator(this, "Autoload time:", 110, 0); + fAutoLoadTime->SetShowSlider(kFALSE); + fAutoLoadTime->SetNELength(4); + fAutoLoadTime->Build(); + fAutoLoadTime->SetLimits(0, 1000); + fAutoLoadTime->SetToolTip("Automatic event loading time in seconds"); + fAutoLoadTime->Connect("ValueSet(Double_t)", + "AliEveEventManagerEditor", this, "DoSetAutoLoadTime()"); + + fAutoLoad = new TGCheckButton(fAutoLoadTime,"Autoload"); + fAutoLoad->SetToolTipText("Automatic event loading (online)"); + fAutoLoadTime->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 12, 0, 2, 0)); + fAutoLoad->Connect("Toggled(Bool_t)", + "AliEveEventManagerEditor", this, "DoSetAutoLoad()"); + AddFrame(fAutoLoadTime); + } + { + TGHorizontalFrame* f = new TGHorizontalFrame(this); + fPrevEvent = new TGTextButton(f, "Previous Event"); + f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsExpandX, 0,4,0,0)); + fPrevEvent->Connect("Clicked()", + "AliEveEventManagerEditor", this, "DoPrevEvent()"); + fNextEvent = new TGTextButton(f, "Next Event"); + f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsExpandX, 4,0,0,0)); + fNextEvent->Connect("Clicked()", + "AliEveEventManagerEditor", this, "DoNextEvent()"); + AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0)); + } + + { + TGVerticalFrame* f = new TGVerticalFrame(this); + + TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:"); + f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2)); + + fEventInfo = new TGTextView(f, 200, 200); + f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); + + AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); + } + } /******************************************************************************/ @@ -54,7 +94,13 @@ void AliEveEventManagerEditor::SetModel(TObject* obj) fM = dynamic_cast(obj); // Set values of widgets - // fXYZZ->SetValue(fM->GetXYZZ()); + fAutoLoadTime->SetValue(fM->GetAutoLoadTime()); + fAutoLoadTime->SetEnabled(fM->GetAutoLoad()); + fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp); + + fPrevEvent->SetEnabled(!fM->GetIsOnline()); + + fEventInfo->LoadBuffer(fM->GetEventInfo()); } /******************************************************************************/ @@ -62,10 +108,34 @@ void AliEveEventManagerEditor::SetModel(TObject* obj) // Implements callback/slot methods //______________________________________________________________________________ -// void AliEveEventManagerEditor::DoXYZZ() -// { -// // Slot for XYZZ. -// -// fM->SetXYZZ(fXYZZ->GetValue()); -// Update(); -// } +void AliEveEventManagerEditor::DoSetAutoLoad() +{ + // Set the auto-load flag + // + fM->SetAutoLoad(fAutoLoad->IsOn()); + Update(); +} + +//______________________________________________________________________________ +void AliEveEventManagerEditor::DoSetAutoLoadTime() +{ + // Set the auto-load time in seconds + // + fM->SetAutoLoadTime(fAutoLoadTime->GetValue()); + fM->SetAutoLoad(fAutoLoad->IsOn()); + Update(); +} + +//______________________________________________________________________________ +void AliEveEventManagerEditor::DoPrevEvent() +{ + // Load previous event + fM->PrevEvent(); +} + +//______________________________________________________________________________ +void AliEveEventManagerEditor::DoNextEvent() +{ + // Load next event + fM->NextEvent(); +} diff --git a/EVE/EveBase/AliEveEventManagerEditor.h b/EVE/EveBase/AliEveEventManagerEditor.h index 6e9f5cac1fd..52188224924 100644 --- a/EVE/EveBase/AliEveEventManagerEditor.h +++ b/EVE/EveBase/AliEveEventManagerEditor.h @@ -12,10 +12,9 @@ #include "TGedFrame.h" -class TGButton; class TGCheckButton; -class TGNumberEntry; -class TGColorSelect; +class TEveGValuator; +class TGTextView; class AliEveEventManager; @@ -33,13 +32,22 @@ public: virtual void SetModel(TObject* obj); // Declare callback/slot methods - // void DoXYZZ(); + void DoSetAutoLoad(); + void DoSetAutoLoadTime(); + void DoPrevEvent(); + void DoNextEvent(); protected: AliEveEventManager *fM; // Model object. // Declare widgets - // TGSomeWidget* fXYZZ; + TGCheckButton *fAutoLoad; // Check-box for automatic loading of events + TEveGValuator *fAutoLoadTime; // Time for automatic loading of events + + TGTextButton *fNextEvent; // Load next event + TGTextButton *fPrevEvent; // Load previous event + + TGTextView *fEventInfo; // Text box with event info private: AliEveEventManagerEditor(const AliEveEventManagerEditor&); // Not implemented diff --git a/EVE/macros/alieve_online.C b/EVE/macros/alieve_online.C new file mode 100644 index 00000000000..7b59917c33d --- /dev/null +++ b/EVE/macros/alieve_online.C @@ -0,0 +1,12 @@ +/************************************************************************** + * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * + * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * + * full copyright notice. * + **************************************************************************/ + +void alieve_online() +{ + // List of macros to be executed + gROOT->Macro("its_raw.C"); + gROOT->Macro("its_clusters.C"); +} diff --git a/STEER/AliReconstruction.cxx b/STEER/AliReconstruction.cxx index e8601e165c4..9e3bfc5665f 100644 --- a/STEER/AliReconstruction.cxx +++ b/STEER/AliReconstruction.cxx @@ -642,6 +642,19 @@ Bool_t AliReconstruction::Run(const char* input) AliCodeTimerAuto(""); if (!InitRun(input)) return kFALSE; + + Bool_t runAliEVE = kFALSE; + if (strcmp(gProgName,"alieve") == 0) runAliEVE = kTRUE; + + if (runAliEVE) { + TString macroStr; + macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT")); + AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data())); + if (gROOT->LoadMacro(macroStr.Data()) != 0) + runAliEVE = kFALSE; + else + gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->SetAutoLoad(kTRUE);gAliEveEvent->AddNewEventCommand(\"alieve_online()\");gEve->AddEvent(gAliEveEvent);};"); + } //******* The loop over events Int_t iEvent = 0; @@ -649,6 +662,13 @@ Bool_t AliReconstruction::Run(const char* input) (fRawReader && fRawReader->NextEvent())) { if (!RunEvent(iEvent)) return kFALSE; iEvent++; + + if (runAliEVE) { + AliInfo("Running AliEVE..."); + gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd)); + gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();"); + gSystem->Run(); + } } if (!FinishRun()) return kFALSE;