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"
27 #include <Riostream.h>
29 ///\class AliMUONPainterDataSourceItem
31 /// Widget to show one data source, and allow to run/stop/rewind/remove it
33 /// WARNING : the thread business is not really working yet (AliRawReaders are
34 /// not really thread-safe for the moment). So please use a single raw data
35 /// source at a time, otherwise you'll get a crash !
37 ///\author Laurent Aphecetche, Subatech
40 ClassImp(AliMUONPainterDataSourceItem)
45 void* RunFunction(void* args)
47 Long_t* params = (Long_t*)(args);
49 AliMUONPainterDataSourceItem* calling = reinterpret_cast<AliMUONPainterDataSourceItem*>(params[0]);
50 AliMUONVTrackerDataMaker* reader = reinterpret_cast<AliMUONVTrackerDataMaker*> (params[1]);
56 ok = reader->NextEvent();
57 if ( !reader->IsRunning() ) gSystem->Sleep(1000);
66 //_____________________________________________________________________________
67 AliMUONPainterDataSourceItem::AliMUONPainterDataSourceItem(const TGWindow* p,
69 AliMUONVTrackerDataMaker* reader)
70 : TGCompositeFrame(p,w,h,kHorizontalFrame),
72 fSourceName(new TGLabel(this,reader->Data()->Name())),
73 fSource(new TGLabel(this,reader->Source().Data())),
74 fNumberOfEvents(new TGLabel(this,Form("%10d",0))),
75 fRun(new TGTextButton(this,"Run")),
76 fStop(new TGTextButton(this,"Stop")),
77 fRewind(new TGTextButton(this,"Rewind")),
78 fRemove(0x0),//new TGTextButton(this,"Remove")),
86 fRun->SetEnabled(reader->Data()->IsRunnable());
87 fRun->Connect("Clicked()",
88 "AliMUONPainterDataSourceItem",
92 fStop->SetEnabled(kFALSE);
93 fStop->Connect("Clicked()",
94 "AliMUONPainterDataSourceItem",
98 fRewind->SetEnabled(kFALSE);
99 fRewind->Connect("Clicked()",
100 "AliMUONPainterDataSourceItem",
104 // fRemove->Connect("Clicked()",
105 // "AliMUONPainterDataSourceItem",
109 AddFrame(fSourceName, new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5));
110 AddFrame(fSource,new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,5,5,5,5));
111 AddFrame(fNumberOfEvents,new TGLayoutHints(kLHintsNormal | kLHintsCenterY,5,5,5,5));
112 AddFrame(fRun,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
113 AddFrame(fStop,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
114 AddFrame(fRewind,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
115 // AddFrame(fRemove,new TGLayoutHints(kLHintsCenterY | kLHintsCenterY,5,5,5,5));
117 reader->Data()->Connect("NumberOfEventsChanged()",
118 "AliMUONPainterDataSourceItem",
124 //_____________________________________________________________________________
125 AliMUONPainterDataSourceItem::~AliMUONPainterDataSourceItem()
128 TThread::Delete(fThread);
133 //_____________________________________________________________________________
135 AliMUONPainterDataSourceItem::EnableRun()
137 /// Enable run button
138 fRun->SetEnabled(kTRUE);
141 //_____________________________________________________________________________
143 AliMUONPainterDataSourceItem::DisableRun()
145 /// Disable run button
146 fRun->SetEnabled(kFALSE);
149 //_____________________________________________________________________________
151 AliMUONPainterDataSourceItem::Reset()
154 fDataReader->Data()->Clear();
157 //_____________________________________________________________________________
159 AliMUONPainterDataSourceItem::Rewind()
161 /// Rewind button was clicked
163 fRewind->SetEnabled(kTRUE);
167 TThread::Delete(fThread);
171 fRun->SetEnabled(kTRUE);
172 fStop->SetEnabled(kFALSE);
173 fRewind->SetEnabled(kFALSE);
175 fDataReader->Rewind();
177 fShouldReset = kTRUE;
180 //_____________________________________________________________________________
182 AliMUONPainterDataSourceItem::Run()
184 /// Run button was clicked
191 fShouldReset = kFALSE;
194 // fRemove->SetEnabled(kFALSE);
198 fParams[0] = (Long_t)(this);
199 fParams[1] = (Long_t)(fDataReader);
200 fThread = new TThread(RunFunction,(void*)(&fParams[0]));
204 fDataReader->SetRunning(kTRUE);
206 fRun->SetEnabled(kFALSE);
207 fStop->SetEnabled(kTRUE);
210 //_____________________________________________________________________________
212 AliMUONPainterDataSourceItem::Stop()
214 /// Stop button was clicked
218 fDataReader->SetRunning(kFALSE);
220 fStop->SetEnabled(kFALSE);
221 fRun->SetEnabled(kTRUE);
223 // fRemove->SetEnabled(kTRUE);
226 //_____________________________________________________________________________
228 AliMUONPainterDataSourceItem::Update()
232 fNumberOfEvents->SetText(Form("%10d",fDataReader->Data()->NumberOfEvents()));
235 //_____________________________________________________________________________
237 AliMUONPainterDataSourceItem::StartRunning()
239 /// Signal we start to run
240 Emit("StartRunning()");
243 //_____________________________________________________________________________
245 AliMUONPainterDataSourceItem::StopRunning()
247 /// Signal we stop to run
248 Emit("StopRunning()");