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