1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliMUONPainterDataSourceItem.h"
20 #include "AliMUONVTrackerDataMaker.h"
21 #include "AliMUONVTrackerData.h"
26 #include <Riostream.h>
28 ///\class AliMUONPainterDataSourceItem
30 /// Widget to show one data source, and allow to run/stop/rewind/remove it
32 /// WARNING : the thread business is not really working yet (AliRawReaders are
33 /// not really thread-safe for the moment). So please use a single raw data
34 /// source at a time, otherwise you'll get a crash !
36 ///\author Laurent Aphecetche, Subatech
39 ClassImp(AliMUONPainterDataSourceItem)
44 void* RunFunction(void* args)
46 Long_t* params = (Long_t*)(args);
48 AliMUONPainterDataSourceItem* calling = reinterpret_cast<AliMUONPainterDataSourceItem*>(params[0]);
49 AliMUONVTrackerDataMaker* reader = reinterpret_cast<AliMUONVTrackerDataMaker*> (params[1]);
55 ok = reader->NextEvent();
64 //_____________________________________________________________________________
65 AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p,
67 AliMUONVTrackerDataMaker* reader)
68 : TGCompositeFrame(p,w,h,kHorizontalFrame),
70 fSourceName(new TGLabel(this,reader->Data()->Name())),
71 fSource(new TGLabel(this,reader->Source().Data())),
72 fNumberOfEvents(new TGLabel(this,"0")),
73 fRun(new TGTextButton(this,"Run")),
74 fStop(new TGTextButton(this,"Stop")),
75 fRewind(new TGTextButton(this,"Rewind")),
76 fRemove(new TGTextButton(this,"Remove")),
84 fRun->SetEnabled(reader->Data()->IsRunnable());
85 fRun->Connect("Clicked()",
86 "AliMUONPainterDataSourceItem",
90 fStop->SetEnabled(kFALSE);
91 fStop->Connect("Clicked()",
92 "AliMUONPainterDataSourceItem",
96 fRewind->SetEnabled(kFALSE);
97 fRewind->Connect("Clicked()",
98 "AliMUONPainterDataSourceItem",
102 fRemove->Connect("Clicked()",
103 "AliMUONPainterDataSourceItem",
107 AddFrame(fSourceName, new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5));
108 AddFrame(fSource,new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,5,5,5,5));
109 AddFrame(fNumberOfEvents,new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5));
110 AddFrame(fRun,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
111 AddFrame(fStop,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
112 AddFrame(fRewind,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
113 AddFrame(fRemove,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
115 reader->Data()->Connect("NumberOfEventsChanged()",
116 "AliMUONPainterDataSourceItem",
122 //_____________________________________________________________________________
123 AliMUONPainterDataSourceItem::~AliMUONPainterDataSourceItem()
126 TThread::Delete(fThread);
130 //_____________________________________________________________________________
132 AliMUONPainterDataSourceItem::Remove()
134 /// Remove button was clicked
137 //_____________________________________________________________________________
139 AliMUONPainterDataSourceItem::Reset()
142 fDataReader->Data()->Clear();
145 //_____________________________________________________________________________
147 AliMUONPainterDataSourceItem::Rewind()
149 /// Rewind button was clicked
151 fRewind->SetEnabled(kTRUE);
155 TThread::Delete(fThread);
159 fRun->SetEnabled(kTRUE);
160 fStop->SetEnabled(kFALSE);
161 fRewind->SetEnabled(kFALSE);
163 fDataReader->Rewind();
165 fShouldReset = kTRUE;
168 //_____________________________________________________________________________
170 AliMUONPainterDataSourceItem::Run()
172 /// Run button was clicked
177 fShouldReset = kFALSE;
180 fRemove->SetEnabled(kFALSE);
184 fParams[0] = (Long_t)(this);
185 fParams[1] = (Long_t)(fDataReader);
186 fThread = new TThread(RunFunction,(void*)(&fParams[0]));
190 fDataReader->SetRunning(kTRUE);
192 fRun->SetEnabled(kFALSE);
193 fStop->SetEnabled(kTRUE);
196 //_____________________________________________________________________________
198 AliMUONPainterDataSourceItem::Stop()
200 /// Stop button was clicked
202 fDataReader->SetRunning(kFALSE);
204 fStop->SetEnabled(kFALSE);
205 fRun->SetEnabled(kTRUE);
206 fRemove->SetEnabled(kTRUE);
209 //_____________________________________________________________________________
211 AliMUONPainterDataSourceItem::Update()
215 fNumberOfEvents->SetText(Form("%10d",fDataReader->Data()->NumberOfEvents()));