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