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