]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterDataSourceFrame.cxx
Fixed warning
[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"
8f0acce4 25#include "AliMUONPainterDataRegistry.h"
a0dc65b4 26#include "AliMUONRecoParam.h"
1286237e 27#include "AliMUONTrackerACFDataMaker.h"
b6f591ae 28#include "AliMUONTrackerDataMaker.h"
0145e89a 29#include "AliMUONTrackerOCDBDataMaker.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,"")),
f162bb90 77 fOCDBPath(new TGTextEntry(fOCDBSelector,"alien://folder=/alice/data/2009/OCDB")),
0145e89a 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
8f0acce4 88 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
0145e89a 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);
2b8a1212 177 fOCDBTypes->AddEntry("HV",3);
178 fOCDBTypes->AddEntry("KillMap",4);
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);
2b8a1212 209 fACFTypes->AddEntry("Capacitances",2);
210 fACFTypes->AddEntry("HV",3);
211 fACFTypes->AddEntry("KillMap",4);
1286237e 212 fACFTypes->Select(0);
213 fACFTypes->Resize(100,20);
214
215 fACFSelector->AddFrame(openButtonACF,new TGLayoutHints(kLHintsTop,5,5,5,5));
216 fACFSelector->AddFrame(fACFPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
217 fACFSelector->AddFrame(fACFTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
218
219 TGButton* createACFButton = new TGTextButton(fACFSelector,"Create data source");
220 createACFButton->Connect("Clicked()",
221 "AliMUONPainterDataSourceFrame",
222 this,
223 "CreateACFDataSource()");
224
225 openButtonACF->Connect("Clicked()",
226 "AliMUONPainterDataSourceFrame",
227 this,
228 "OpenFileDialogACF()");
229
230 fACFSelector->AddFrame(createACFButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
0145e89a 231
232 AddFrame(fRecentSourceSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
233
234 AddFrame(fRawSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
235
236 AddFrame(fOCDBSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
237
1286237e 238 AddFrame(fACFSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
239
0145e89a 240 AddFrame(fDataReaders, new TGLayoutHints(kLHintsExpandX,10,10,10,10));
241
242}
243
244//_____________________________________________________________________________
245AliMUONPainterDataSourceFrame::~AliMUONPainterDataSourceFrame()
246{
247 /// dtor
248
249 delete fItems;
250}
251
252//_____________________________________________________________________________
253void
254AliMUONPainterDataSourceFrame::AddRecentSource(const char* name)
255{
256 /// Add a source to the list of recently used sources
257
258 TGListBox* lb = fRecentSources->GetListBox();
259
260 for ( Int_t i = 0; i < lb->GetNumberOfEntries(); ++i )
261 {
262 TGTextLBEntry* t = (TGTextLBEntry*)lb->GetEntry(i);
263 TString s(t->GetText()->GetString());
264 if ( s == name )
265 {
266 return;
267 }
268 }
269
270 fRecentSources->AddEntry(name,lb->GetNumberOfEntries());
271 fRecentSources->MapSubwindows();
272 fRecentSources->Layout();
273}
274
8741815f 275//_____________________________________________________________________________
276void
277AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
278{
279 /// Calibrate button was clicked.
280
10eb3d17 281 if ( fCalibrateNoGain->IsOn() ||
282 fCalibrateGainConstantCapa->IsOn() ||
283 fCalibrateGain->IsOn() )
8741815f 284 {
285 fRawOCDBPath->SetEnabled(kTRUE);
286 fRawOCDBPath->SetFocus();
8741815f 287 }
288 else
289 {
290 fRawOCDBPath->SetEnabled(kFALSE);
10eb3d17 291 }
292}
293
294//_____________________________________________________________________________
295void
296AliMUONPainterDataSourceFrame::HistogramButtonClicked()
297{
298 /// Histogram button was clicked.
299
300 if ( fHistogramButton->IsOn() )
301 {
302 fHistoMin->SetState(kTRUE);
303 fHistoMax->SetState(kTRUE);
304 }
305 else
306 {
307 fHistoMin->SetState(kFALSE);
308 fHistoMax->SetState(kFALSE);
8741815f 309 }
310}
311
1286237e 312//_____________________________________________________________________________
313void
314AliMUONPainterDataSourceFrame::CreateACFDataSource()
315{
316 /// Create an ACF data source (using information from the widgets)
317
318 TString acfPath = fACFPath->GetText();
319 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fACFTypes->GetSelectedEntry());
320 TString type = t->GetText()->GetString();
321
322 CreateACFDataSource(acfPath,type);
323
324 fACFPath->SetText("");
325}
326
327
0145e89a 328//_____________________________________________________________________________
329void
330AliMUONPainterDataSourceFrame::CreateOCDBDataSource()
331{
332 /// Create an OCDB data source (using information from the widgets)
333
334 TString cdbPath = fOCDBPath->GetText();
335 Int_t runNumber = fRunSelector->GetIntNumber();
336 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fOCDBTypes->GetSelectedEntry());
337 TString type = t->GetText()->GetString();
338
339 CreateOCDBDataSource(cdbPath,runNumber,type);
340
341 fOCDBPath->SetText("");
342 fRunSelector->SetNumber(0);
343}
344
1286237e 345//_____________________________________________________________________________
346void
347AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& uri)
348{
349 /// Create an ACF data source, given it's URI
350
351 TObjArray* a = uri.Tokenize(";");
352 TString acfPath = static_cast<TObjString*>(a->At(1))->String();
353 TString type = static_cast<TObjString*>(a->At(2))->String();
354
355 CreateACFDataSource(acfPath,type);
356
357 delete a;
358}
359
360
0145e89a 361//_____________________________________________________________________________
362void
363AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& uri)
364{
365 /// Create an OCDB data source, given it's URI
366
367 TObjArray* a = uri.Tokenize(";");
368 TString cdbPath = static_cast<TObjString*>(a->At(1))->String();
369 TString srun = static_cast<TObjString*>(a->At(2))->String();
370 TString type = static_cast<TObjString*>(a->At(3))->String();
371
372 CreateOCDBDataSource(cdbPath,atoi(srun.Data()),type);
373
374 delete a;
375}
376
1286237e 377//_____________________________________________________________________________
378void
379AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& acfPath, const TString& type)
380{
381 /// Create an ACF data source for a given (path,type)
382
383 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerACFDataMaker(acfPath.Data(),
384 type.Data());
385
386 if ( reader->IsValid() )
387 {
8f0acce4 388 AliMUONPainterDataRegistry::Instance()->Register(reader);
1286237e 389
390 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
391
392 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
393
394 env->Set(fgkNumberOfDataSourcesKey,n+1);
395
396 TString ds(Form("ACF;%s;%s",acfPath.Data(),type.Data()));
397
398 env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
399
400 env->Save();
401
402 AddRecentSource(ds.Data());
403 }
404
405}
406
0145e89a 407//_____________________________________________________________________________
408void
409AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& cdbPath,
410 Int_t runNumber,
411 const TString& type)
412{
413 /// Create an OCDB data source for a given (path,runnumber,type) triplet
414
415 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerOCDBDataMaker(cdbPath.Data(),
416 runNumber,
417 type.Data());
418
419 if ( reader->IsValid() )
420 {
8f0acce4 421 AliMUONPainterDataRegistry::Instance()->Register(reader);
0145e89a 422
423 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
424
425 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
426
427 env->Set(fgkNumberOfDataSourcesKey,n+1);
428
429 TString ds(Form("OCDB;%s;%d;%s",cdbPath.Data(),runNumber,type.Data()));
430
431 env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
432
433 env->Save();
434
435 AddRecentSource(ds.Data());
436 }
437}
438
439//_____________________________________________________________________________
440void
441AliMUONPainterDataSourceFrame::CreateRawDataSource()
442{
443 /// Create a new raw data source (using info from the widgets)
444
445 TString uri(gSystem->ExpandPathName(fFilePath->GetText()));
b6f591ae 446
447 TString name("RAW");
448 Bool_t fromMemory(kFALSE);
0145e89a 449
b6f591ae 450 if ( uri.Contains(TRegexp("^mem")) )
0145e89a 451 {
b6f591ae 452 fromMemory = kTRUE;
453 }
454 else
455 {
456 if ( gSystem->AccessPathName(uri.Data()) )
457 {
458 AliError(Form("File %s does not exist",uri.Data()));
459 fFilePath->SetText("");
460 return;
461 }
0145e89a 462 }
463
10eb3d17 464 TString calibMode("");
10eb3d17 465
466 if ( fCalibrateGain->IsOn() )
467 {
468 calibMode = "GAIN";
469 name = "CALC";
470 }
471
472 if ( fCalibrateGainConstantCapa->IsOn() )
473 {
474 calibMode = "GAINCONSTANTCAPA";
475 name = "CALG";
476 }
477
478 if ( fCalibrateNoGain->IsOn() )
479 {
480 calibMode = "NOGAIN";
481 name = "CALZ";
482 }
483
b6f591ae 484 uri = Form("%s%s%s;%s;%s;%s;%s;%s",
10eb3d17 485 ( fHistogramButton->IsOn() ? "H":""),
b6f591ae 486 ( fromMemory ? "M" : ""),
10eb3d17 487 name.Data(),uri.Data(),
488 ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
489 ( calibMode.Length() > 0 ? calibMode.Data() : " "),
490 Form("%e",fHistoMin->GetNumber()),
491 Form("%e",fHistoMax->GetNumber()));
0145e89a 492
493 if ( CreateRawDataSource(uri) )
494 {
495 fFilePath->SetText("");
496 fRawOCDBPath->SetText("");
497 }
498}
499
500//_____________________________________________________________________________
501Bool_t
502AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
503{
504 /// Create a new raw data source, given its URI
505
506 TString filename;
507 TString ocdbPath;
10eb3d17 508 TString calibMode;
509 TString sxmin("0.0");
510 TString sxmax("4096.0");
0145e89a 511
512 TObjArray* a = uri.Tokenize(";");
513
514 filename = static_cast<TObjString*>(a->At(1))->String();
515
516 if ( a->GetLast() > 1 )
517 {
518 ocdbPath = static_cast<TObjString*>(a->At(2))->String();
10eb3d17 519 if ( ocdbPath == " " ) ocdbPath = "";
520 }
521
522 if ( a->GetLast() > 2 )
523 {
524 calibMode = static_cast<TObjString*>(a->At(3))->String();
525 if ( calibMode == " " ) calibMode = "";
526 }
527
528 if ( a->GetLast() > 3 )
529 {
530 sxmin = static_cast<TObjString*>(a->At(4))->String();
531 }
532
533 if ( a->GetLast() > 4 )
534 {
535 sxmax = static_cast<TObjString*>(a->At(5))->String();
0145e89a 536 }
537
538 AliRawReader* rawReader = 0x0;
539
0b376ef1 540 if ( filename.Contains(TRegexp("^alien")) )
0145e89a 541 {
0b376ef1 542 // insure we've initialized the grid...
543 if (!gGrid)
0145e89a 544 {
0b376ef1 545 TGrid::Connect("alien://");
0145e89a 546 }
0145e89a 547 }
0b376ef1 548
549 rawReader = AliRawReader::Create(filename.Data());
550
551 if (!rawReader)
0145e89a 552 {
0b376ef1 553 AliError(Form("Could not open file %s",filename.Data()));
554 fFilePath->SetText("");
555 return kFALSE;
0145e89a 556 }
0b376ef1 557
10eb3d17 558 /// Basic test to see if the file is correct
559 Bool_t ok = rawReader->NextEvent();
560 if (!ok)
0145e89a 561 {
10eb3d17 562 AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
563 fFilePath->SetText("");
0145e89a 564 return kFALSE;
565 }
566
10eb3d17 567 rawReader->RewindEvents();
568
8741815f 569 AliMUONVTrackerDataMaker* reader(0x0);
570 Bool_t histogram(kFALSE);
571
10eb3d17 572 if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
573
8741815f 574 if ( ocdbPath.Length() > 0 )
575 {
a0dc65b4 576 AliMUONRecoParam* recoParam = AliMUONRecoParam::GetCosmicParam();
577
578 // FIXME: where to get the reco params from in reality ?
579
b6f591ae 580 reader = new AliMUONTrackerDataMaker(recoParam,
581 rawReader,
582 ocdbPath.Data(),
583 calibMode.Data(),
584 histogram,
585 sxmin.Atof(),
586 sxmax.Atof());
8741815f 587 }
588 else
589 {
b6f591ae 590 reader = new AliMUONTrackerDataMaker(rawReader,histogram);
8741815f 591 }
0145e89a 592
593 reader->SetSource(filename.Data());
594
8f0acce4 595 AliMUONPainterDataRegistry::Instance()->Register(reader);
0145e89a 596
597 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
598
599 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
600
601 env->Set(fgkNumberOfDataSourcesKey,n+1);
602
10eb3d17 603 env->Set(Form(fgkDataSourceURIKey,n),uri.Data());
0145e89a 604
10eb3d17 605 AddRecentSource(uri.Data());
0145e89a 606
607 env->Save();
608
609 return kTRUE;
610}
611
612//_____________________________________________________________________________
613void
49419555 614AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
0145e89a 615{
616 /// Update ourselves as a new data reader was created
617
0145e89a 618 AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
619
10eb3d17 620 item->Connect("StartRunning()",
621 "AliMUONPainterDataSourceFrame",
622 this,
b0cbe180 623 "StartRunning()");
10eb3d17 624
625 item->Connect("StopRunning()",
626 "AliMUONPainterDataSourceFrame",
627 this,
b0cbe180 628 "StopRunning()");
10eb3d17 629
0145e89a 630 fDataReaders->AddFrame(item);
631
632 fItems->Add(item);
633
634 fDataReaders->MapSubwindows();
635 fDataReaders->Resize();
636}
637
638//_____________________________________________________________________________
639void
49419555 640AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(AliMUONVTrackerDataMaker* maker)
0145e89a 641{
49419555 642 /// Update ourselves as a data reader was deleted
0145e89a 643
49419555 644 AliMUONPainterDataSourceItem* theItem(0x0);
10eb3d17 645
49419555 646 TIter next(fItems);
647 AliMUONPainterDataSourceItem* item;
648
649 while ( ( item = static_cast<AliMUONPainterDataSourceItem*>(next()) ) && !theItem )
650 {
651 if ( item->DataMaker() == maker )
652 {
653 theItem = item;
654 }
655 }
656
657 if (!theItem) return;
658
659 fDataReaders->RemoveFrame(theItem);
660 fItems->Remove(theItem);
661 theItem->DestroyWindow();
662 delete theItem;
663
664 fDataReaders->MapSubwindows();
665 fDataReaders->Resize();
666
0145e89a 667}
668
669//_____________________________________________________________________________
670void
671AliMUONPainterDataSourceFrame::OpenFileDialog()
672{
673 /// Open a file dialog to select a file to be read
674
675 TGFileInfo fileInfo;
676
10eb3d17 677 const char* fileTypes[] = {
678 "ROOT files","*.root",
679 "DATE files","*.raw",
680 "All files","*",
681 0,0 };
682
683 fileInfo.fFileTypes = fileTypes;
49419555 684 delete[] fileInfo.fIniDir;
685
686 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
687
688 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
10eb3d17 689
0145e89a 690 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
691 kFDOpen,&fileInfo);
692
0145e89a 693 fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
49419555 694
695 env->Set("LastOpenDir",fileInfo.fIniDir);
696 env->Save();
0145e89a 697}
698
699
1286237e 700//_____________________________________________________________________________
701void
702AliMUONPainterDataSourceFrame::OpenFileDialogACF()
703{
704 /// Open a file dialog to select an ASCII calibration file to be read
705
706 TGFileInfo fileInfo;
707
708 const char* fileTypes[] = {
709 "All files","*",
710 0,0 };
711
712 fileInfo.fFileTypes = fileTypes;
713 delete[] fileInfo.fIniDir;
714
715 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
716
717 fileInfo.fIniDir = StrDup(env->String("LastOpenDirACF","."));
718
719 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
720 kFDOpen,&fileInfo);
721
722 fACFPath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
723
724 env->Set("LastOpenDirACF",fileInfo.fIniDir);
725 env->Save();
726}
727
728
0145e89a 729//_____________________________________________________________________________
730void
731AliMUONPainterDataSourceFrame::OpenRecentSource()
732{
733 /// Open one source from the recently used ones
734
735 TGTextLBEntry* t = (TGTextLBEntry*)fRecentSources->GetSelectedEntry();
736
737 TString uri(t->GetText()->GetString());
738
10eb3d17 739 if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) ||
b6f591ae 740 uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) ||
741 uri.Contains(TRegexp("^MEM")) )
0145e89a 742 {
743 CreateRawDataSource(uri);
744 }
745 else if ( uri.Contains(TRegexp("^OCDB")) )
746 {
747 CreateOCDBDataSource(uri);
748 }
1286237e 749 else if ( uri.Contains(TRegexp("^ACF")) )
750 {
751 CreateACFDataSource(uri);
752 }
0145e89a 753
754 fRecentSources->Select(-1);
755}
756
10eb3d17 757//_____________________________________________________________________________
758void
b0cbe180 759AliMUONPainterDataSourceFrame::StartRunning()
10eb3d17 760{
761 /// One data source starts running. Disable the Run button of the other ones
b0cbe180 762
763 AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
764
765 AliInfo("");
766
10eb3d17 767 TIter next(fItems);
768 AliMUONPainterDataSourceItem* o;
769 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
770 {
771 if ( o != item )
772 {
773 o->DisableRun();
774 }
775 }
776}
777
778//_____________________________________________________________________________
779void
b0cbe180 780AliMUONPainterDataSourceFrame::StopRunning()
10eb3d17 781{
782 /// One data source stops running. Enable the Run button of all items
b0cbe180 783
10eb3d17 784 TIter next(fItems);
785 AliMUONPainterDataSourceItem* o;
786 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
787 {
788 o->EnableRun();
789 }
790}
791