]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterDataSourceFrame.cxx
Removed hardwired gain inefficiency. Will be taken from the gain map.
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterDataSourceFrame.cxx
CommitLineData
0145e89a 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
b09247a2 18#include <cstdlib>
0145e89a 19#include "AliMUONPainterDataSourceFrame.h"
20
8741815f 21#include "AliLog.h"
0145e89a 22#include "AliMUONPainterDataSourceItem.h"
23#include "AliMUONPainterEnv.h"
24#include "AliMUONPainterHelper.h"
25#include "AliMUONPainterRegistry.h"
1286237e 26#include "AliMUONTrackerACFDataMaker.h"
8741815f 27#include "AliMUONTrackerCalibratedDataMaker.h"
0145e89a 28#include "AliMUONTrackerOCDBDataMaker.h"
29#include "AliMUONTrackerRawDataMaker.h"
0b376ef1 30#include "AliRawReader.h"
0145e89a 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
51const char* AliMUONPainterDataSourceFrame::fgkNumberOfDataSourcesKey = "NumberOfDataSources";
52const char* AliMUONPainterDataSourceFrame::fgkDataSourceURIKey = "DataSourceURI.%d";
53
54///\cond CLASSIMP
55ClassImp(AliMUONPainterDataSourceFrame)
56///\endcond
57
58//_____________________________________________________________________________
59AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, UInt_t w, UInt_t h)
60: TGCompositeFrame(p,w,h,kVerticalFrame),
10eb3d17 61 fRecentSourceSelector(new TGGroupFrame(this,"Recent sources",kHorizontalFrame)),
62 fRawSelector(new TGGroupFrame(this,"Raw file URI",kHorizontalFrame)),
8741815f 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)),
49419555 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)")),
8741815f 70 fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")),
10eb3d17 71 fHistoMin(new TGNumberEntry(fRawSelector23,0)),
72 fHistoMax(new TGNumberEntry(fRawSelector23,4096)),
8741815f 73 fRawOCDBPath(new TGTextEntry(fRawSelector22,"")),
10eb3d17 74 fOCDBSelector(new TGGroupFrame(this,"OCDB Path",kHorizontalFrame)),
75 fDataReaders(new TGGroupFrame(this,"Data sources")),
8741815f 76 fFilePath(new TGTextEntry(fRawSelector21,"")),
0145e89a 77 fOCDBPath(new TGTextEntry(fOCDBSelector,"")),
78 fRunSelector(new TGNumberEntry(fOCDBSelector,0)),
79 fOCDBTypes(new TGComboBox(fOCDBSelector)),
80 fRecentSources(new TGComboBox(fRecentSourceSelector)),
1286237e 81 fItems(new TObjArray),
82 fACFSelector(new TGGroupFrame(this,"ASCII Calib File",kHorizontalFrame)),
83 fACFPath(new TGTextEntry(fACFSelector,"")),
84 fACFTypes(new TGComboBox(fACFSelector))
0145e89a 85{
86 /// Ctor
87
88 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
89
49419555 90 reg->Connect("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",
0145e89a 91 "AliMUONPainterDataSourceFrame",
92 this,
49419555 93 "DataMakerWasRegistered(AliMUONVTrackerDataMaker*)");
0145e89a 94
49419555 95 reg->Connect("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",
0145e89a 96 "AliMUONPainterDataSourceFrame",
97 this,
49419555 98 "DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)");
0145e89a 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));
1286237e 123
0145e89a 124 /// Raw file selection
125
8741815f 126 TGButton* openButton = new TGPictureButton(fRawSelector21,
0145e89a 127 gClient->GetPicture("fileopen.xpm"));
128 openButton->SetToolTipText("Click to open file dialog");
129
8741815f 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
10eb3d17 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));
8741815f 140 fRawSelector22->AddFrame(fRawOCDBPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
141 fRawOCDBPath->SetEnabled(kFALSE);
0145e89a 142
8741815f 143 fRawSelector23->AddFrame(fHistogramButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
10eb3d17 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
8741815f 153 TGButton* createRawButton = new TGTextButton(fRawSelector,"Create data source");
0145e89a 154
8741815f 155 fRawSelector->AddFrame(fRawSelector2, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
156 fRawSelector->AddFrame(createRawButton, new TGLayoutHints(kLHintsCenterY,5,5,5,5));
157
10eb3d17 158 fCalibrateNoGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
159 fCalibrateGainConstantCapa->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
160 fCalibrateGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
8741815f 161
0145e89a 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);
1ffbeb9d 177 fOCDBTypes->AddEntry("HV",3);
0145e89a 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
0145e89a 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));
1286237e 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));
0145e89a 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
1286237e 228 AddFrame(fACFSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
229
0145e89a 230 AddFrame(fDataReaders, new TGLayoutHints(kLHintsExpandX,10,10,10,10));
231
232}
233
234//_____________________________________________________________________________
235AliMUONPainterDataSourceFrame::~AliMUONPainterDataSourceFrame()
236{
237 /// dtor
238
239 delete fItems;
240}
241
242//_____________________________________________________________________________
243void
244AliMUONPainterDataSourceFrame::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
8741815f 265//_____________________________________________________________________________
266void
267AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
268{
269 /// Calibrate button was clicked.
270
10eb3d17 271 if ( fCalibrateNoGain->IsOn() ||
272 fCalibrateGainConstantCapa->IsOn() ||
273 fCalibrateGain->IsOn() )
8741815f 274 {
275 fRawOCDBPath->SetEnabled(kTRUE);
276 fRawOCDBPath->SetFocus();
8741815f 277 }
278 else
279 {
280 fRawOCDBPath->SetEnabled(kFALSE);
10eb3d17 281 }
282}
283
284//_____________________________________________________________________________
285void
286AliMUONPainterDataSourceFrame::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);
8741815f 299 }
300}
301
1286237e 302//_____________________________________________________________________________
303void
304AliMUONPainterDataSourceFrame::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
0145e89a 318//_____________________________________________________________________________
319void
320AliMUONPainterDataSourceFrame::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
1286237e 335//_____________________________________________________________________________
336void
337AliMUONPainterDataSourceFrame::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
0145e89a 351//_____________________________________________________________________________
352void
353AliMUONPainterDataSourceFrame::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
1286237e 367//_____________________________________________________________________________
368void
369AliMUONPainterDataSourceFrame::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
0145e89a 397//_____________________________________________________________________________
398void
399AliMUONPainterDataSourceFrame::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//_____________________________________________________________________________
430void
431AliMUONPainterDataSourceFrame::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
10eb3d17 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()));
0145e89a 472
473 if ( CreateRawDataSource(uri) )
474 {
475 fFilePath->SetText("");
476 fRawOCDBPath->SetText("");
477 }
478}
479
480//_____________________________________________________________________________
481Bool_t
482AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
483{
484 /// Create a new raw data source, given its URI
485
486 TString filename;
487 TString ocdbPath;
10eb3d17 488 TString calibMode;
489 TString sxmin("0.0");
490 TString sxmax("4096.0");
0145e89a 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();
10eb3d17 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();
0145e89a 516 }
517
518 AliRawReader* rawReader = 0x0;
519
0b376ef1 520 if ( filename.Contains(TRegexp("^alien")) )
0145e89a 521 {
0b376ef1 522 // insure we've initialized the grid...
523 if (!gGrid)
0145e89a 524 {
0b376ef1 525 TGrid::Connect("alien://");
0145e89a 526 }
0145e89a 527 }
0b376ef1 528
529 rawReader = AliRawReader::Create(filename.Data());
530
531 if (!rawReader)
0145e89a 532 {
0b376ef1 533 AliError(Form("Could not open file %s",filename.Data()));
534 fFilePath->SetText("");
535 return kFALSE;
0145e89a 536 }
0b376ef1 537
10eb3d17 538 /// Basic test to see if the file is correct
539 Bool_t ok = rawReader->NextEvent();
540 if (!ok)
0145e89a 541 {
10eb3d17 542 AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
543 fFilePath->SetText("");
0145e89a 544 return kFALSE;
545 }
546
10eb3d17 547 rawReader->RewindEvents();
548
8741815f 549 AliMUONVTrackerDataMaker* reader(0x0);
550 Bool_t histogram(kFALSE);
551
10eb3d17 552 if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
553
8741815f 554 if ( ocdbPath.Length() > 0 )
555 {
10eb3d17 556 reader = new AliMUONTrackerCalibratedDataMaker(rawReader,ocdbPath.Data(),
557 calibMode.Data(),
558 histogram,
559 sxmin.Atof(),
560 sxmax.Atof());
8741815f 561 }
562 else
563 {
8741815f 564 reader = new AliMUONTrackerRawDataMaker(rawReader,histogram);
565 }
0145e89a 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
10eb3d17 577 env->Set(Form(fgkDataSourceURIKey,n),uri.Data());
0145e89a 578
10eb3d17 579 AddRecentSource(uri.Data());
0145e89a 580
581 env->Save();
582
583 return kTRUE;
584}
585
586//_____________________________________________________________________________
587void
49419555 588AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
0145e89a 589{
590 /// Update ourselves as a new data reader was created
591
0145e89a 592 AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
593
10eb3d17 594 item->Connect("StartRunning()",
595 "AliMUONPainterDataSourceFrame",
596 this,
b0cbe180 597 "StartRunning()");
10eb3d17 598
599 item->Connect("StopRunning()",
600 "AliMUONPainterDataSourceFrame",
601 this,
b0cbe180 602 "StopRunning()");
10eb3d17 603
0145e89a 604 fDataReaders->AddFrame(item);
605
606 fItems->Add(item);
607
608 fDataReaders->MapSubwindows();
609 fDataReaders->Resize();
610}
611
612//_____________________________________________________________________________
613void
49419555 614AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(AliMUONVTrackerDataMaker* maker)
0145e89a 615{
49419555 616 /// Update ourselves as a data reader was deleted
0145e89a 617
49419555 618 AliMUONPainterDataSourceItem* theItem(0x0);
10eb3d17 619
49419555 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
0145e89a 641}
642
643//_____________________________________________________________________________
644void
645AliMUONPainterDataSourceFrame::OpenFileDialog()
646{
647 /// Open a file dialog to select a file to be read
648
649 TGFileInfo fileInfo;
650
10eb3d17 651 const char* fileTypes[] = {
652 "ROOT files","*.root",
653 "DATE files","*.raw",
654 "All files","*",
655 0,0 };
656
657 fileInfo.fFileTypes = fileTypes;
49419555 658 delete[] fileInfo.fIniDir;
659
660 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
661
662 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
10eb3d17 663
0145e89a 664 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
665 kFDOpen,&fileInfo);
666
0145e89a 667 fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
49419555 668
669 env->Set("LastOpenDir",fileInfo.fIniDir);
670 env->Save();
0145e89a 671}
672
673
1286237e 674//_____________________________________________________________________________
675void
676AliMUONPainterDataSourceFrame::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
0145e89a 703//_____________________________________________________________________________
704void
705AliMUONPainterDataSourceFrame::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
10eb3d17 713 if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) ||
714 uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) )
0145e89a 715 {
716 CreateRawDataSource(uri);
717 }
718 else if ( uri.Contains(TRegexp("^OCDB")) )
719 {
720 CreateOCDBDataSource(uri);
721 }
1286237e 722 else if ( uri.Contains(TRegexp("^ACF")) )
723 {
724 CreateACFDataSource(uri);
725 }
0145e89a 726
727 fRecentSources->Select(-1);
728}
729
10eb3d17 730//_____________________________________________________________________________
731void
b0cbe180 732AliMUONPainterDataSourceFrame::StartRunning()
10eb3d17 733{
734 /// One data source starts running. Disable the Run button of the other ones
b0cbe180 735
736 AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
737
738 AliInfo("");
739
10eb3d17 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//_____________________________________________________________________________
752void
b0cbe180 753AliMUONPainterDataSourceFrame::StopRunning()
10eb3d17 754{
755 /// One data source stops running. Enable the Run button of all items
b0cbe180 756
10eb3d17 757 TIter next(fItems);
758 AliMUONPainterDataSourceItem* o;
759 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
760 {
761 o->EnableRun();
762 }
763}
764