]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterDataSourceFrame.cxx
Fixing compiler warnings
[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
bd9314b2 339 CreateOCDBDataSource(cdbPath,runNumber,type);
0145e89a 340}
341
1286237e 342//_____________________________________________________________________________
343void
344AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& uri)
345{
346 /// Create an ACF data source, given it's URI
347
348 TObjArray* a = uri.Tokenize(";");
349 TString acfPath = static_cast<TObjString*>(a->At(1))->String();
350 TString type = static_cast<TObjString*>(a->At(2))->String();
351
352 CreateACFDataSource(acfPath,type);
353
354 delete a;
355}
356
357
0145e89a 358//_____________________________________________________________________________
359void
360AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& uri)
361{
362 /// Create an OCDB data source, given it's URI
363
364 TObjArray* a = uri.Tokenize(";");
365 TString cdbPath = static_cast<TObjString*>(a->At(1))->String();
366 TString srun = static_cast<TObjString*>(a->At(2))->String();
367 TString type = static_cast<TObjString*>(a->At(3))->String();
368
369 CreateOCDBDataSource(cdbPath,atoi(srun.Data()),type);
370
371 delete a;
372}
373
1286237e 374//_____________________________________________________________________________
375void
376AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& acfPath, const TString& type)
377{
378 /// Create an ACF data source for a given (path,type)
379
380 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerACFDataMaker(acfPath.Data(),
381 type.Data());
382
383 if ( reader->IsValid() )
384 {
8f0acce4 385 AliMUONPainterDataRegistry::Instance()->Register(reader);
1286237e 386
387 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
388
389 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
390
391 env->Set(fgkNumberOfDataSourcesKey,n+1);
392
393 TString ds(Form("ACF;%s;%s",acfPath.Data(),type.Data()));
394
395 env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
396
397 env->Save();
398
399 AddRecentSource(ds.Data());
400 }
401
402}
403
0145e89a 404//_____________________________________________________________________________
405void
406AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& cdbPath,
407 Int_t runNumber,
408 const TString& type)
409{
410 /// Create an OCDB data source for a given (path,runnumber,type) triplet
411
412 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerOCDBDataMaker(cdbPath.Data(),
413 runNumber,
414 type.Data());
415
416 if ( reader->IsValid() )
417 {
8f0acce4 418 AliMUONPainterDataRegistry::Instance()->Register(reader);
0145e89a 419
420 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
421
422 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
423
424 env->Set(fgkNumberOfDataSourcesKey,n+1);
425
426 TString ds(Form("OCDB;%s;%d;%s",cdbPath.Data(),runNumber,type.Data()));
427
428 env->Set(Form(fgkDataSourceURIKey,n),ds.Data());
429
430 env->Save();
431
432 AddRecentSource(ds.Data());
433 }
434}
435
436//_____________________________________________________________________________
437void
438AliMUONPainterDataSourceFrame::CreateRawDataSource()
439{
440 /// Create a new raw data source (using info from the widgets)
441
442 TString uri(gSystem->ExpandPathName(fFilePath->GetText()));
b6f591ae 443
444 TString name("RAW");
445 Bool_t fromMemory(kFALSE);
0145e89a 446
b6f591ae 447 if ( uri.Contains(TRegexp("^mem")) )
0145e89a 448 {
b6f591ae 449 fromMemory = kTRUE;
450 }
451 else
452 {
453 if ( gSystem->AccessPathName(uri.Data()) )
454 {
455 AliError(Form("File %s does not exist",uri.Data()));
456 fFilePath->SetText("");
457 return;
458 }
0145e89a 459 }
460
10eb3d17 461 TString calibMode("");
10eb3d17 462
463 if ( fCalibrateGain->IsOn() )
464 {
465 calibMode = "GAIN";
466 name = "CALC";
467 }
468
469 if ( fCalibrateGainConstantCapa->IsOn() )
470 {
471 calibMode = "GAINCONSTANTCAPA";
472 name = "CALG";
473 }
474
475 if ( fCalibrateNoGain->IsOn() )
476 {
477 calibMode = "NOGAIN";
478 name = "CALZ";
479 }
480
b6f591ae 481 uri = Form("%s%s%s;%s;%s;%s;%s;%s",
10eb3d17 482 ( fHistogramButton->IsOn() ? "H":""),
b6f591ae 483 ( fromMemory ? "M" : ""),
10eb3d17 484 name.Data(),uri.Data(),
485 ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
486 ( calibMode.Length() > 0 ? calibMode.Data() : " "),
487 Form("%e",fHistoMin->GetNumber()),
488 Form("%e",fHistoMax->GetNumber()));
0145e89a 489
490 if ( CreateRawDataSource(uri) )
491 {
492 fFilePath->SetText("");
493 fRawOCDBPath->SetText("");
494 }
495}
496
497//_____________________________________________________________________________
498Bool_t
499AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
500{
501 /// Create a new raw data source, given its URI
502
503 TString filename;
504 TString ocdbPath;
10eb3d17 505 TString calibMode;
506 TString sxmin("0.0");
507 TString sxmax("4096.0");
0145e89a 508
509 TObjArray* a = uri.Tokenize(";");
510
511 filename = static_cast<TObjString*>(a->At(1))->String();
512
513 if ( a->GetLast() > 1 )
514 {
515 ocdbPath = static_cast<TObjString*>(a->At(2))->String();
10eb3d17 516 if ( ocdbPath == " " ) ocdbPath = "";
517 }
518
519 if ( a->GetLast() > 2 )
520 {
521 calibMode = static_cast<TObjString*>(a->At(3))->String();
522 if ( calibMode == " " ) calibMode = "";
523 }
524
525 if ( a->GetLast() > 3 )
526 {
527 sxmin = static_cast<TObjString*>(a->At(4))->String();
528 }
529
530 if ( a->GetLast() > 4 )
531 {
532 sxmax = static_cast<TObjString*>(a->At(5))->String();
0145e89a 533 }
534
535 AliRawReader* rawReader = 0x0;
536
0b376ef1 537 if ( filename.Contains(TRegexp("^alien")) )
0145e89a 538 {
0b376ef1 539 // insure we've initialized the grid...
540 if (!gGrid)
0145e89a 541 {
0b376ef1 542 TGrid::Connect("alien://");
0145e89a 543 }
0145e89a 544 }
0b376ef1 545
546 rawReader = AliRawReader::Create(filename.Data());
547
548 if (!rawReader)
0145e89a 549 {
0b376ef1 550 AliError(Form("Could not open file %s",filename.Data()));
551 fFilePath->SetText("");
552 return kFALSE;
0145e89a 553 }
0b376ef1 554
10eb3d17 555 /// Basic test to see if the file is correct
556 Bool_t ok = rawReader->NextEvent();
557 if (!ok)
0145e89a 558 {
10eb3d17 559 AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
560 fFilePath->SetText("");
0145e89a 561 return kFALSE;
562 }
563
10eb3d17 564 rawReader->RewindEvents();
565
8741815f 566 AliMUONVTrackerDataMaker* reader(0x0);
567 Bool_t histogram(kFALSE);
568
10eb3d17 569 if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
570
8741815f 571 if ( ocdbPath.Length() > 0 )
572 {
a0dc65b4 573 AliMUONRecoParam* recoParam = AliMUONRecoParam::GetCosmicParam();
574
575 // FIXME: where to get the reco params from in reality ?
576
b6f591ae 577 reader = new AliMUONTrackerDataMaker(recoParam,
578 rawReader,
579 ocdbPath.Data(),
580 calibMode.Data(),
581 histogram,
582 sxmin.Atof(),
583 sxmax.Atof());
8741815f 584 }
585 else
586 {
b6f591ae 587 reader = new AliMUONTrackerDataMaker(rawReader,histogram);
8741815f 588 }
0145e89a 589
590 reader->SetSource(filename.Data());
591
8f0acce4 592 AliMUONPainterDataRegistry::Instance()->Register(reader);
0145e89a 593
594 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
595
596 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
597
598 env->Set(fgkNumberOfDataSourcesKey,n+1);
599
10eb3d17 600 env->Set(Form(fgkDataSourceURIKey,n),uri.Data());
0145e89a 601
10eb3d17 602 AddRecentSource(uri.Data());
0145e89a 603
604 env->Save();
605
606 return kTRUE;
607}
608
609//_____________________________________________________________________________
610void
49419555 611AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
0145e89a 612{
613 /// Update ourselves as a new data reader was created
614
0145e89a 615 AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
616
10eb3d17 617 item->Connect("StartRunning()",
618 "AliMUONPainterDataSourceFrame",
619 this,
b0cbe180 620 "StartRunning()");
10eb3d17 621
622 item->Connect("StopRunning()",
623 "AliMUONPainterDataSourceFrame",
624 this,
b0cbe180 625 "StopRunning()");
10eb3d17 626
0145e89a 627 fDataReaders->AddFrame(item);
628
629 fItems->Add(item);
630
631 fDataReaders->MapSubwindows();
632 fDataReaders->Resize();
633}
634
635//_____________________________________________________________________________
636void
49419555 637AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(AliMUONVTrackerDataMaker* maker)
0145e89a 638{
49419555 639 /// Update ourselves as a data reader was deleted
0145e89a 640
49419555 641 AliMUONPainterDataSourceItem* theItem(0x0);
10eb3d17 642
49419555 643 TIter next(fItems);
644 AliMUONPainterDataSourceItem* item;
645
646 while ( ( item = static_cast<AliMUONPainterDataSourceItem*>(next()) ) && !theItem )
647 {
648 if ( item->DataMaker() == maker )
649 {
650 theItem = item;
651 }
652 }
653
654 if (!theItem) return;
655
656 fDataReaders->RemoveFrame(theItem);
657 fItems->Remove(theItem);
658 theItem->DestroyWindow();
659 delete theItem;
660
661 fDataReaders->MapSubwindows();
662 fDataReaders->Resize();
663
0145e89a 664}
665
666//_____________________________________________________________________________
667void
668AliMUONPainterDataSourceFrame::OpenFileDialog()
669{
670 /// Open a file dialog to select a file to be read
671
672 TGFileInfo fileInfo;
673
10eb3d17 674 const char* fileTypes[] = {
675 "ROOT files","*.root",
676 "DATE files","*.raw",
677 "All files","*",
678 0,0 };
679
680 fileInfo.fFileTypes = fileTypes;
49419555 681 delete[] fileInfo.fIniDir;
682
683 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
684
685 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
10eb3d17 686
0145e89a 687 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
688 kFDOpen,&fileInfo);
689
0145e89a 690 fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
49419555 691
692 env->Set("LastOpenDir",fileInfo.fIniDir);
693 env->Save();
0145e89a 694}
695
696
1286237e 697//_____________________________________________________________________________
698void
699AliMUONPainterDataSourceFrame::OpenFileDialogACF()
700{
701 /// Open a file dialog to select an ASCII calibration file to be read
702
703 TGFileInfo fileInfo;
704
705 const char* fileTypes[] = {
706 "All files","*",
707 0,0 };
708
709 fileInfo.fFileTypes = fileTypes;
710 delete[] fileInfo.fIniDir;
711
712 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
713
714 fileInfo.fIniDir = StrDup(env->String("LastOpenDirACF","."));
715
716 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
717 kFDOpen,&fileInfo);
718
719 fACFPath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
720
721 env->Set("LastOpenDirACF",fileInfo.fIniDir);
722 env->Save();
723}
724
725
0145e89a 726//_____________________________________________________________________________
727void
728AliMUONPainterDataSourceFrame::OpenRecentSource()
729{
730 /// Open one source from the recently used ones
731
732 TGTextLBEntry* t = (TGTextLBEntry*)fRecentSources->GetSelectedEntry();
733
734 TString uri(t->GetText()->GetString());
735
10eb3d17 736 if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) ||
b6f591ae 737 uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) ||
738 uri.Contains(TRegexp("^MEM")) )
0145e89a 739 {
740 CreateRawDataSource(uri);
741 }
742 else if ( uri.Contains(TRegexp("^OCDB")) )
743 {
744 CreateOCDBDataSource(uri);
745 }
1286237e 746 else if ( uri.Contains(TRegexp("^ACF")) )
747 {
748 CreateACFDataSource(uri);
749 }
0145e89a 750
751 fRecentSources->Select(-1);
752}
753
10eb3d17 754//_____________________________________________________________________________
755void
b0cbe180 756AliMUONPainterDataSourceFrame::StartRunning()
10eb3d17 757{
758 /// One data source starts running. Disable the Run button of the other ones
b0cbe180 759
760 AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
761
762 AliInfo("");
763
10eb3d17 764 TIter next(fItems);
765 AliMUONPainterDataSourceItem* o;
766 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
767 {
768 if ( o != item )
769 {
770 o->DisableRun();
771 }
772 }
773}
774
775//_____________________________________________________________________________
776void
b0cbe180 777AliMUONPainterDataSourceFrame::StopRunning()
10eb3d17 778{
779 /// One data source stops running. Enable the Run button of all items
b0cbe180 780
10eb3d17 781 TIter next(fItems);
782 AliMUONPainterDataSourceItem* o;
783 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
784 {
785 o->EnableRun();
786 }
787}
788