]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPainterDataSourceFrame.cxx
Updated serial number for station 345
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterDataSourceFrame.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 **************************************************************************/
15
16 // $Id$
17
18 #include <cstdlib>
19 #include "AliMUONPainterDataSourceFrame.h"
20
21 #include "AliLog.h"
22 #include "AliMUONPainterDataSourceItem.h"
23 #include "AliMUONPainterEnv.h"
24 #include "AliMUONPainterHelper.h"
25 #include "AliMUONPainterRegistry.h"
26 #include "AliMUONTrackerACFDataMaker.h"
27 #include "AliMUONTrackerCalibratedDataMaker.h"
28 #include "AliMUONTrackerOCDBDataMaker.h"
29 #include "AliMUONTrackerRawDataMaker.h"
30 #include "AliRawReader.h"
31 #include <TGButton.h>
32 #include <TGComboBox.h>
33 #include <TGFileDialog.h>
34 #include <TGNumberEntry.h>
35 #include <TGTextEntry.h>
36 #include <TGrid.h>
37 #include <TObjArray.h>
38 #include <TObjString.h>
39 #include <TRegexp.h>
40 #include <TString.h>
41 #include <TSystem.h>
42
43 ///\class AliMUONPainterDataSourceFrame
44 ///
45 /// A complete frame to select and display various data sources to 
46 /// be displayed : either raw data or OCDB data. 
47 /// Later on we might add digits and clusters for instance.
48 ///
49 ///\author Laurent Aphecetche, Subatech
50
51 const char* AliMUONPainterDataSourceFrame::fgkNumberOfDataSourcesKey = "NumberOfDataSources";
52 const char* AliMUONPainterDataSourceFrame::fgkDataSourceURIKey = "DataSourceURI.%d";
53
54 ///\cond CLASSIMP
55 ClassImp(AliMUONPainterDataSourceFrame)
56 ///\endcond
57
58 //_____________________________________________________________________________
59 AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, UInt_t w, UInt_t h)
60 : TGCompositeFrame(p,w,h,kVerticalFrame),
61   fRecentSourceSelector(new TGGroupFrame(this,"Recent sources",kHorizontalFrame)),
62   fRawSelector(new TGGroupFrame(this,"Raw file URI",kHorizontalFrame)),
63   fRawSelector2(new TGCompositeFrame(fRawSelector,w,h,kVerticalFrame)),
64   fRawSelector21(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
65   fRawSelector22(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
66   fRawSelector23(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
67   fCalibrateNoGain(new TGCheckButton(fRawSelector22,"Ped subraction")),
68   fCalibrateGainConstantCapa(new TGCheckButton(fRawSelector22,"Ped subraction + gain (capa cste)")),
69   fCalibrateGain(new TGCheckButton(fRawSelector22,"Full calib (Ped subraction + gain with capa)")),
70   fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")),
71   fHistoMin(new TGNumberEntry(fRawSelector23,0)),
72   fHistoMax(new TGNumberEntry(fRawSelector23,4096)),
73   fRawOCDBPath(new TGTextEntry(fRawSelector22,"")),
74   fOCDBSelector(new TGGroupFrame(this,"OCDB Path",kHorizontalFrame)),
75   fDataReaders(new TGGroupFrame(this,"Data sources")),
76   fFilePath(new TGTextEntry(fRawSelector21,"")),
77   fOCDBPath(new TGTextEntry(fOCDBSelector,"")),
78   fRunSelector(new TGNumberEntry(fOCDBSelector,0)),
79   fOCDBTypes(new TGComboBox(fOCDBSelector)),
80   fRecentSources(new TGComboBox(fRecentSourceSelector)),
81   fItems(new TObjArray),
82   fACFSelector(new TGGroupFrame(this,"ASCII Calib File",kHorizontalFrame)),
83   fACFPath(new TGTextEntry(fACFSelector,"")),
84   fACFTypes(new TGComboBox(fACFSelector))
85 {
86   /// Ctor
87   
88     AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
89     
90     reg->Connect("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",
91                  "AliMUONPainterDataSourceFrame",
92                  this,
93                  "DataMakerWasRegistered(AliMUONVTrackerDataMaker*)");
94     
95     reg->Connect("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",
96                  "AliMUONPainterDataSourceFrame",
97                  this,
98                  "DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)");
99     
100     fItems->SetOwner(kFALSE);
101     
102     /// Recent source selection
103     
104     AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
105     
106     Int_t nsources = env->Integer(fgkNumberOfDataSourcesKey);
107     
108     for ( Int_t i = 0; i < nsources; ++i )
109     {
110       AddRecentSource(env->String(Form(fgkDataSourceURIKey,i)));
111     }
112
113     fRecentSources->Resize(100,20);
114     
115     TGButton* createRecentButton = new TGTextButton(fRecentSourceSelector,"Create data source");
116     createRecentButton->Connect("Clicked()",
117                                 "AliMUONPainterDataSourceFrame",
118                                 this,
119                                 "OpenRecentSource()");
120     
121     fRecentSourceSelector->AddFrame(fRecentSources,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
122     fRecentSourceSelector->AddFrame(createRecentButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
123                      
124     /// Raw file selection
125     
126     TGButton* openButton = new TGPictureButton(fRawSelector21,
127                                            gClient->GetPicture("fileopen.xpm"));
128     openButton->SetToolTipText("Click to open file dialog");
129                                         
130     fRawSelector2->AddFrame(fRawSelector21, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
131     fRawSelector2->AddFrame(fRawSelector22, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
132     fRawSelector2->AddFrame(fRawSelector23, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
133
134     fRawSelector21->AddFrame(openButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
135     fRawSelector21->AddFrame(fFilePath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
136
137     fRawSelector22->AddFrame(fCalibrateNoGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
138     fRawSelector22->AddFrame(fCalibrateGainConstantCapa, new TGLayoutHints(kLHintsTop,5,5,5,5));
139     fRawSelector22->AddFrame(fCalibrateGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
140     fRawSelector22->AddFrame(fRawOCDBPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
141     fRawOCDBPath->SetEnabled(kFALSE);
142     
143     fRawSelector23->AddFrame(fHistogramButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
144     
145     fHistogramButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"HistogramButtonClicked()");
146     
147     fHistoMin->SetState(kFALSE);
148     fHistoMax->SetState(kFALSE);
149     
150     fRawSelector23->AddFrame(fHistoMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
151     fRawSelector23->AddFrame(fHistoMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
152     
153     TGButton* createRawButton = new TGTextButton(fRawSelector,"Create data source");
154     
155     fRawSelector->AddFrame(fRawSelector2, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
156     fRawSelector->AddFrame(createRawButton, new TGLayoutHints(kLHintsCenterY,5,5,5,5));
157         
158     fCalibrateNoGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
159     fCalibrateGainConstantCapa->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
160     fCalibrateGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
161
162     openButton->Connect("Clicked()",
163                         "AliMUONPainterDataSourceFrame",
164                         this,
165                         "OpenFileDialog()");
166
167     createRawButton->Connect("Clicked()",
168                         "AliMUONPainterDataSourceFrame",
169                         this,
170                         "CreateRawDataSource()");
171     
172     /// OCDB selection
173     
174     fOCDBTypes->AddEntry("Pedestals",0);
175     fOCDBTypes->AddEntry("Gains",1);
176     fOCDBTypes->AddEntry("Capacitances",2);
177     fOCDBTypes->AddEntry("HV",3);
178     fOCDBTypes->Select(0);
179     fOCDBTypes->Resize(100,20);
180     
181     TGButton* createOCDBButton = new TGTextButton(fOCDBSelector,"Create data source");
182     createOCDBButton->Connect("Clicked()",
183                              "AliMUONPainterDataSourceFrame",
184                              this,
185                              "CreateOCDBDataSource()");
186     
187     fOCDBSelector->AddFrame(fOCDBPath,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));    
188     fOCDBSelector->AddFrame(fRunSelector,new TGLayoutHints(kLHintsTop,5,5,5,5));
189     fOCDBSelector->AddFrame(fOCDBTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
190     fOCDBSelector->AddFrame(createOCDBButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
191     
192     
193     /// ASCII calibration file selection
194     
195     TGButton* openButtonACF = new TGPictureButton(fACFSelector,
196                                                   gClient->GetPicture("fileopen.xpm"));
197     openButtonACF->SetToolTipText("Click to open file dialog");
198     
199     fACFTypes->AddEntry("Pedestals",0);
200     fACFTypes->AddEntry("Gains",1);
201     fACFTypes->AddEntry("Capacitances",2);
202     fACFTypes->Select(0);
203     fACFTypes->Resize(100,20);
204     
205     fACFSelector->AddFrame(openButtonACF,new TGLayoutHints(kLHintsTop,5,5,5,5));                                      
206     fACFSelector->AddFrame(fACFPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
207     fACFSelector->AddFrame(fACFTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
208
209     TGButton* createACFButton = new TGTextButton(fACFSelector,"Create data source");
210     createACFButton->Connect("Clicked()",
211                               "AliMUONPainterDataSourceFrame",
212                               this,                              
213                              "CreateACFDataSource()");
214     
215     openButtonACF->Connect("Clicked()",
216                            "AliMUONPainterDataSourceFrame",
217                            this,
218                            "OpenFileDialogACF()");
219     
220     fACFSelector->AddFrame(createACFButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
221
222     AddFrame(fRecentSourceSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
223
224     AddFrame(fRawSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
225
226     AddFrame(fOCDBSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
227
228     AddFrame(fACFSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
229     
230     AddFrame(fDataReaders, new TGLayoutHints(kLHintsExpandX,10,10,10,10));
231     
232 }
233
234 //_____________________________________________________________________________
235 AliMUONPainterDataSourceFrame::~AliMUONPainterDataSourceFrame()
236 {
237   /// dtor
238   
239   delete fItems;
240 }
241
242 //_____________________________________________________________________________
243 void
244 AliMUONPainterDataSourceFrame::AddRecentSource(const char* name)
245 {  
246   /// Add a source to the list of recently used sources
247   
248   TGListBox* lb = fRecentSources->GetListBox();
249   
250   for ( Int_t i = 0; i < lb->GetNumberOfEntries(); ++i ) 
251   {
252     TGTextLBEntry* t = (TGTextLBEntry*)lb->GetEntry(i);
253     TString s(t->GetText()->GetString());
254     if ( s == name ) 
255     {
256       return;
257     }
258   }
259   
260   fRecentSources->AddEntry(name,lb->GetNumberOfEntries());
261   fRecentSources->MapSubwindows();
262   fRecentSources->Layout();
263 }
264
265 //_____________________________________________________________________________
266 void
267 AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
268 {
269   /// Calibrate button was clicked.
270   
271   if ( fCalibrateNoGain->IsOn() ||
272        fCalibrateGainConstantCapa->IsOn() ||
273        fCalibrateGain->IsOn() ) 
274   {
275     fRawOCDBPath->SetEnabled(kTRUE);
276     fRawOCDBPath->SetFocus();
277   }
278   else
279   {
280     fRawOCDBPath->SetEnabled(kFALSE);
281   }
282 }
283
284 //_____________________________________________________________________________
285 void
286 AliMUONPainterDataSourceFrame::HistogramButtonClicked()
287 {
288   /// Histogram button was clicked.
289   
290   if ( fHistogramButton->IsOn() )
291   {
292     fHistoMin->SetState(kTRUE);
293     fHistoMax->SetState(kTRUE);
294   }
295   else
296   {
297     fHistoMin->SetState(kFALSE);
298     fHistoMax->SetState(kFALSE);
299   }
300 }
301
302 //_____________________________________________________________________________
303 void
304 AliMUONPainterDataSourceFrame::CreateACFDataSource()
305 {
306   /// Create an ACF data source (using information from the widgets)
307   
308   TString acfPath = fACFPath->GetText();
309   TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fACFTypes->GetSelectedEntry());
310   TString type = t->GetText()->GetString();
311   
312   CreateACFDataSource(acfPath,type);
313   
314   fACFPath->SetText("");
315 }
316
317
318 //_____________________________________________________________________________
319 void
320 AliMUONPainterDataSourceFrame::CreateOCDBDataSource()
321 {
322   /// Create an OCDB data source (using information from the widgets)
323   
324   TString cdbPath = fOCDBPath->GetText();
325   Int_t runNumber = fRunSelector->GetIntNumber();
326   TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fOCDBTypes->GetSelectedEntry());
327   TString type = t->GetText()->GetString();
328   
329   CreateOCDBDataSource(cdbPath,runNumber,type);
330   
331   fOCDBPath->SetText("");
332   fRunSelector->SetNumber(0);  
333 }
334
335 //_____________________________________________________________________________
336 void
337 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& uri)
338 {
339   /// Create an ACF data source, given it's URI
340   
341   TObjArray* a = uri.Tokenize(";");
342   TString acfPath = static_cast<TObjString*>(a->At(1))->String();
343   TString type = static_cast<TObjString*>(a->At(2))->String();
344   
345   CreateACFDataSource(acfPath,type);
346   
347   delete a;
348 }
349
350
351 //_____________________________________________________________________________
352 void
353 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& uri)
354 {
355   /// Create an OCDB data source, given it's URI
356   
357   TObjArray* a = uri.Tokenize(";");
358   TString cdbPath = static_cast<TObjString*>(a->At(1))->String();
359   TString srun = static_cast<TObjString*>(a->At(2))->String();
360   TString type = static_cast<TObjString*>(a->At(3))->String();
361   
362   CreateOCDBDataSource(cdbPath,atoi(srun.Data()),type);
363   
364   delete a;
365 }
366
367 //_____________________________________________________________________________
368 void
369 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& acfPath, const TString& type)
370 {
371   /// Create an ACF data source for a given (path,type) 
372
373   AliMUONVTrackerDataMaker* reader = new AliMUONTrackerACFDataMaker(acfPath.Data(),
374                                                                     type.Data());
375   
376   if ( reader->IsValid() ) 
377   {
378     AliMUONPainterRegistry::Instance()->Register(reader);
379     
380     AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
381     
382     Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
383     
384     env->Set(fgkNumberOfDataSourcesKey,n+1);
385     
386     TString ds(Form("ACF;%s;%s",acfPath.Data(),type.Data()));
387     
388     env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
389     
390     env->Save();
391     
392     AddRecentSource(ds.Data());
393   }
394   
395 }
396
397 //_____________________________________________________________________________
398 void
399 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& cdbPath,
400                                                     Int_t runNumber,
401                                                     const TString& type)
402 {
403   /// Create an OCDB data source for a given (path,runnumber,type) triplet
404   
405   AliMUONVTrackerDataMaker* reader = new AliMUONTrackerOCDBDataMaker(cdbPath.Data(),
406                                                                        runNumber,
407                                                                        type.Data());
408   
409   if ( reader->IsValid() ) 
410   {
411     AliMUONPainterRegistry::Instance()->Register(reader);
412     
413     AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
414     
415     Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
416     
417     env->Set(fgkNumberOfDataSourcesKey,n+1);
418     
419     TString ds(Form("OCDB;%s;%d;%s",cdbPath.Data(),runNumber,type.Data()));
420     
421     env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
422     
423     env->Save();
424     
425     AddRecentSource(ds.Data());
426   }
427 }
428
429 //_____________________________________________________________________________
430 void 
431 AliMUONPainterDataSourceFrame::CreateRawDataSource()
432 {
433   /// Create a new raw data source (using info from the widgets)
434   
435   TString uri(gSystem->ExpandPathName(fFilePath->GetText()));
436   
437   if ( gSystem->AccessPathName(uri.Data()) )
438   {
439     AliError(Form("File %s does not exist",uri.Data()));
440     fFilePath->SetText("");
441     return;
442   }
443
444   TString calibMode("");
445   TString name("RAW");
446   
447   if ( fCalibrateGain->IsOn() ) 
448   {
449     calibMode = "GAIN";
450     name = "CALC";
451   }
452   
453   if ( fCalibrateGainConstantCapa->IsOn() ) 
454   {
455     calibMode = "GAINCONSTANTCAPA";
456     name = "CALG";
457   }
458   
459   if ( fCalibrateNoGain->IsOn() ) 
460   {
461     calibMode = "NOGAIN";
462     name = "CALZ";
463   }
464   
465   uri = Form("%s%s;%s;%s;%s;%s;%s",
466              ( fHistogramButton->IsOn() ? "H":""),
467              name.Data(),uri.Data(),
468              ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
469              ( calibMode.Length() > 0 ? calibMode.Data() : " "),
470              Form("%e",fHistoMin->GetNumber()),
471              Form("%e",fHistoMax->GetNumber()));
472   
473   if ( CreateRawDataSource(uri) )
474   {
475     fFilePath->SetText("");
476     fRawOCDBPath->SetText("");
477   }
478 }
479
480 //_____________________________________________________________________________
481 Bool_t 
482 AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
483 {
484   /// Create a new raw data source, given its URI
485   
486   TString filename;
487   TString ocdbPath;
488   TString calibMode;
489   TString sxmin("0.0");
490   TString sxmax("4096.0");
491   
492   TObjArray* a = uri.Tokenize(";");
493   
494   filename = static_cast<TObjString*>(a->At(1))->String();
495   
496   if ( a->GetLast() > 1 ) 
497   {
498     ocdbPath = static_cast<TObjString*>(a->At(2))->String();
499     if ( ocdbPath == " " ) ocdbPath = "";
500   }
501
502   if ( a->GetLast() > 2 ) 
503   {
504     calibMode = static_cast<TObjString*>(a->At(3))->String();
505     if ( calibMode == " " ) calibMode = "";
506   }
507
508   if ( a->GetLast() > 3 ) 
509   {
510     sxmin = static_cast<TObjString*>(a->At(4))->String();
511   }
512
513   if ( a->GetLast() > 4 ) 
514   {
515     sxmax = static_cast<TObjString*>(a->At(5))->String();
516   }
517   
518   AliRawReader* rawReader = 0x0;
519
520   if ( filename.Contains(TRegexp("^alien")) )
521   {
522     // insure we've initialized the grid...
523     if (!gGrid)
524     {
525       TGrid::Connect("alien://");
526     }
527   }
528   
529   rawReader = AliRawReader::Create(filename.Data());
530
531   if (!rawReader)
532   {
533     AliError(Form("Could not open file %s",filename.Data()));
534     fFilePath->SetText("");
535     return kFALSE;
536   }
537   
538   /// Basic test to see if the file is correct
539   Bool_t ok = rawReader->NextEvent();
540   if (!ok)
541   {
542     AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
543     fFilePath->SetText("");
544     return kFALSE;
545   }
546   
547   rawReader->RewindEvents();
548   
549   AliMUONVTrackerDataMaker* reader(0x0);
550   Bool_t histogram(kFALSE);
551   
552   if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
553
554   if ( ocdbPath.Length() > 0 ) 
555   {
556     reader = new AliMUONTrackerCalibratedDataMaker(rawReader,ocdbPath.Data(),
557                                                    calibMode.Data(),
558                                                    histogram,
559                                                    sxmin.Atof(),
560                                                    sxmax.Atof());
561   }
562   else
563   {
564     reader = new AliMUONTrackerRawDataMaker(rawReader,histogram);
565   }
566   
567   reader->SetSource(filename.Data());
568   
569   AliMUONPainterRegistry::Instance()->Register(reader);
570   
571   AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
572   
573   Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
574   
575   env->Set(fgkNumberOfDataSourcesKey,n+1);
576   
577   env->Set(Form(fgkDataSourceURIKey,n),uri.Data());
578   
579   AddRecentSource(uri.Data());
580   
581   env->Save();
582
583   return kTRUE;
584 }
585
586 //_____________________________________________________________________________
587 void 
588 AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
589 {
590   /// Update ourselves as a new data reader was created
591   
592   AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
593       
594   item->Connect("StartRunning()",
595                 "AliMUONPainterDataSourceFrame",
596                 this,
597                 "StartRunning()");
598
599   item->Connect("StopRunning()",
600                 "AliMUONPainterDataSourceFrame",
601                 this,
602                 "StopRunning()");
603   
604   fDataReaders->AddFrame(item);
605   
606   fItems->Add(item);
607
608   fDataReaders->MapSubwindows();
609   fDataReaders->Resize();
610 }
611
612 //_____________________________________________________________________________
613 void 
614 AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(AliMUONVTrackerDataMaker* maker)
615 {
616   /// Update ourselves as a data reader was deleted
617   
618   AliMUONPainterDataSourceItem* theItem(0x0);
619   
620   TIter next(fItems);
621   AliMUONPainterDataSourceItem* item;
622   
623   while ( ( item = static_cast<AliMUONPainterDataSourceItem*>(next()) ) && !theItem )
624   {
625     if ( item->DataMaker() == maker ) 
626     {
627       theItem = item;
628     }
629   }
630   
631   if  (!theItem) return;
632   
633   fDataReaders->RemoveFrame(theItem);
634   fItems->Remove(theItem);
635   theItem->DestroyWindow();
636   delete theItem;
637   
638   fDataReaders->MapSubwindows();
639   fDataReaders->Resize();
640
641 }
642
643 //_____________________________________________________________________________
644 void
645 AliMUONPainterDataSourceFrame::OpenFileDialog()
646 {
647   /// Open a file dialog to select a file to be read
648   
649   TGFileInfo fileInfo;
650   
651   const char* fileTypes[] = { 
652     "ROOT files","*.root",
653     "DATE files","*.raw",
654     "All files","*",
655     0,0 };
656   
657   fileInfo.fFileTypes = fileTypes;
658   delete[] fileInfo.fIniDir;
659
660   AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
661   
662   fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
663   
664   new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
665                    kFDOpen,&fileInfo);
666   
667   fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
668   
669   env->Set("LastOpenDir",fileInfo.fIniDir);
670   env->Save();  
671 }
672
673
674 //_____________________________________________________________________________
675 void
676 AliMUONPainterDataSourceFrame::OpenFileDialogACF()
677 {
678   /// Open a file dialog to select an ASCII calibration file to be read
679   
680   TGFileInfo fileInfo;
681   
682   const char* fileTypes[] = { 
683     "All files","*",
684     0,0 };
685   
686   fileInfo.fFileTypes = fileTypes;
687   delete[] fileInfo.fIniDir;
688   
689   AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
690   
691   fileInfo.fIniDir = StrDup(env->String("LastOpenDirACF","."));
692   
693   new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
694                    kFDOpen,&fileInfo);
695   
696   fACFPath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
697   
698   env->Set("LastOpenDirACF",fileInfo.fIniDir);
699   env->Save();  
700 }
701
702
703 //_____________________________________________________________________________
704 void
705 AliMUONPainterDataSourceFrame::OpenRecentSource()
706 {
707   /// Open one source from the recently used ones
708   
709   TGTextLBEntry* t = (TGTextLBEntry*)fRecentSources->GetSelectedEntry();
710
711   TString uri(t->GetText()->GetString());
712   
713   if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) || 
714        uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) )
715   {
716     CreateRawDataSource(uri);
717   }
718   else if ( uri.Contains(TRegexp("^OCDB")) )
719   {
720     CreateOCDBDataSource(uri);
721   }
722   else if ( uri.Contains(TRegexp("^ACF")) )
723   {
724     CreateACFDataSource(uri);
725   }
726   
727   fRecentSources->Select(-1);
728 }
729
730 //_____________________________________________________________________________
731 void
732 AliMUONPainterDataSourceFrame::StartRunning()
733 {
734   /// One data source starts running. Disable the Run button of the other ones
735   
736   AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
737   
738   AliInfo("");
739   
740   TIter next(fItems);
741   AliMUONPainterDataSourceItem* o;
742   while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
743   {
744     if ( o != item ) 
745     {
746       o->DisableRun();
747     }
748   }
749 }  
750
751 //_____________________________________________________________________________
752 void
753 AliMUONPainterDataSourceFrame::StopRunning()
754 {
755   /// One data source stops running. Enable the Run button of all items
756   
757   TIter next(fItems);
758   AliMUONPainterDataSourceItem* o;
759   while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
760   {
761     o->EnableRun();
762   }
763 }
764