1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include "AliMUONPainterDataSourceFrame.h"
22 #include "AliMUONChamberPainter.h"
23 #include "AliMUONMchViewApplication.h"
24 #include "AliMUONPainterDataRegistry.h"
25 #include "AliMUONPainterDataSourceItem.h"
26 #include "AliMUONPainterEnv.h"
27 #include "AliMUONPainterHelper.h"
28 #include "AliMUONPainterMatrix.h"
29 #include "AliMUONPainterRegistry.h"
30 #include "AliMUONRecoParam.h"
31 #include "AliMUONTrackerConditionDataMaker.h"
32 #include "AliMUONTrackerDataMaker.h"
33 #include "AliRawReader.h"
36 #include <TGComboBox.h>
37 #include <TGFileDialog.h>
38 #include <TGNumberEntry.h>
39 #include <TGTextEntry.h>
41 #include <TObjArray.h>
42 #include <TObjString.h>
48 ///\class AliMUONPainterDataSourceFrame
50 /// A complete frame to select and display various data sources to
51 /// be displayed : either raw data or OCDB data.
52 /// Later on we might add digits and clusters for instance.
54 ///\author Laurent Aphecetche, Subatech
56 const char* AliMUONPainterDataSourceFrame::fgkNumberOfDataSourcesKey = "NumberOfDataSources";
57 const char* AliMUONPainterDataSourceFrame::fgkDataSourceURIKey = "DataSourceURI.%d";
60 ClassImp(AliMUONPainterDataSourceFrame)
63 //_____________________________________________________________________________
64 AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, UInt_t w, UInt_t h)
65 : TGCompositeFrame(p,w,h,kVerticalFrame),
66 fRecentSourceSelector(new TGGroupFrame(this,"Recent sources",kHorizontalFrame)),
67 fRawSelector(new TGGroupFrame(this,"Raw file URI",kHorizontalFrame)),
68 fRawSelector2(new TGCompositeFrame(fRawSelector,w,h,kVerticalFrame)),
69 fRawSelector21(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
70 fRawSelector22(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
71 fRawSelector23(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
72 fCalibrateNoGain(new TGCheckButton(fRawSelector22,"Ped sub")),
73 fCalibrateGainConstantCapa(new TGCheckButton(fRawSelector22,"Ped sub+gain (capa cste)")),
74 fCalibrateGain(new TGCheckButton(fRawSelector22,"Full calib (Ped sub+gain w/ capa)")),
75 fCalibrateEmelecGain(new TGCheckButton(fRawSelector22,"Full calib (Ped sub+inj gain w/ capa)")),
76 fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")),
77 fHistoMin(new TGNumberEntry(fRawSelector23,0)),
78 fHistoMax(new TGNumberEntry(fRawSelector23,4096)),
79 fEventRangeButton(new TGCheckButton(fRawSelector23,"Event range")),
80 fEventMin(new TGNumberEntry(fRawSelector23,-1,10)),
81 fEventMax(new TGNumberEntry(fRawSelector23,-1,10)),
82 fRawOCDBPath(new TGTextEntry(fRawSelector22,"")),
83 fOCDBSelector(new TGGroupFrame(this,"OCDB Path",kHorizontalFrame)),
84 fDataReaders(new TGGroupFrame(this,"Data sources")),
85 fFilePath(new TGTextEntry(fRawSelector21,"")),
86 fOCDBPath(new TGTextEntry(fOCDBSelector,"alien://folder=/alice/data/2010/OCDB")),
87 fRunSelector(new TGNumberEntry(fOCDBSelector,0,10)),
88 fOCDBTypes(new TGComboBox(fOCDBSelector)),
89 fRecentSources(new TGComboBox(fRecentSourceSelector)),
90 fItems(new TObjArray),
91 fACFSelector(new TGGroupFrame(this,"ASCII Calib File",kHorizontalFrame)),
92 fACFPath(new TGTextEntry(fACFSelector,"")),
93 fACFTypes(new TGComboBox(fACFSelector))
97 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
99 reg->Connect("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",
100 "AliMUONPainterDataSourceFrame",
102 "DataMakerWasRegistered(AliMUONVTrackerDataMaker*)");
104 reg->Connect("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",
105 "AliMUONPainterDataSourceFrame",
107 "DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)");
109 fItems->SetOwner(kFALSE);
111 /// Recent source selection
113 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
115 Int_t nsources = env->Integer(fgkNumberOfDataSourcesKey);
117 for ( Int_t i = 0; i < nsources; ++i )
119 AddRecentSource(env->String(Form(fgkDataSourceURIKey,i)));
122 fRecentSources->Resize(100,20);
124 TGButton* createRecentButton = new TGTextButton(fRecentSourceSelector,"Create data source");
125 createRecentButton->Connect("Clicked()",
126 "AliMUONPainterDataSourceFrame",
128 "OpenRecentSource()");
130 fRecentSourceSelector->AddFrame(fRecentSources,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
131 fRecentSourceSelector->AddFrame(createRecentButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
133 /// Raw file selection
135 TGButton* openButton = new TGPictureButton(fRawSelector21,
136 gClient->GetPicture("fileopen.xpm"));
137 openButton->SetToolTipText("Click to open file dialog");
139 fRawSelector2->AddFrame(fRawSelector21, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
140 fRawSelector2->AddFrame(fRawSelector22, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
141 fRawSelector2->AddFrame(fRawSelector23, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
143 fRawSelector21->AddFrame(openButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
144 fRawSelector21->AddFrame(fFilePath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
146 fRawSelector22->AddFrame(fCalibrateNoGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
147 fRawSelector22->AddFrame(fCalibrateGainConstantCapa, new TGLayoutHints(kLHintsTop,5,5,5,5));
148 fRawSelector22->AddFrame(fCalibrateGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
149 fRawSelector22->AddFrame(fCalibrateEmelecGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
150 fRawSelector22->AddFrame(fRawOCDBPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
151 fRawOCDBPath->SetEnabled(kFALSE);
153 fRawSelector23->AddFrame(fHistogramButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
154 fHistogramButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"HistogramButtonClicked()");
155 fHistoMin->SetState(kFALSE);
156 fHistoMax->SetState(kFALSE);
157 fRawSelector23->AddFrame(fHistoMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
158 fRawSelector23->AddFrame(fHistoMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
161 fRawSelector23->AddFrame(fEventRangeButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
162 fEventRangeButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"EventRangeButtonClicked()");
163 fEventMin->SetState(kFALSE);
164 fEventMax->SetState(kFALSE);
166 fEventMin->SetFormat(TGNumberFormat::kNESInteger);
167 fEventMax->SetFormat(TGNumberFormat::kNESInteger);
169 fRawSelector23->AddFrame(fEventMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
170 fRawSelector23->AddFrame(fEventMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
172 TGButton* createRawButton = new TGTextButton(fRawSelector,"Create data source");
174 fRawSelector->AddFrame(fRawSelector2, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
175 fRawSelector->AddFrame(createRawButton, new TGLayoutHints(kLHintsCenterY,5,5,5,5));
177 fCalibrateNoGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
178 fCalibrateGainConstantCapa->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
179 fCalibrateGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
180 fCalibrateEmelecGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
182 openButton->Connect("Clicked()",
183 "AliMUONPainterDataSourceFrame",
187 createRawButton->Connect("Clicked()",
188 "AliMUONPainterDataSourceFrame",
190 "CreateRawDataSource()");
194 fOCDBTypes->AddEntry("Config",7);
195 fOCDBTypes->AddEntry("Occupancy",4);
196 fOCDBTypes->AddEntry("HV",3);
197 fOCDBTypes->AddEntry("Pedestals",0);
198 fOCDBTypes->AddEntry("Gains",1);
199 fOCDBTypes->AddEntry("StatusMap",5);
200 fOCDBTypes->AddEntry("Status",6);
201 fOCDBTypes->AddEntry("Capacitances",2);
202 fOCDBTypes->Select(0);
203 fOCDBTypes->Resize(80,20);
205 TGButton* createOCDBButton = new TGTextButton(fOCDBSelector,"Create data source");
206 createOCDBButton->Connect("Clicked()",
207 "AliMUONPainterDataSourceFrame",
209 "CreateOCDBDataSource()");
211 const char* ocdbToolTip = "Use URL style for either alien or local OCDB (foo://bar). For example :\n"
212 "alien://folder=/alice/data.../OCDB\n"
213 "or\nlocal:///home/user/aliroot (mind the 3 slashes there !)";
215 fRawOCDBPath->SetToolTipText(ocdbToolTip);
216 fOCDBPath->SetToolTipText(ocdbToolTip);
218 fOCDBSelector->AddFrame(fOCDBPath,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
219 fOCDBSelector->AddFrame(fRunSelector,new TGLayoutHints(kLHintsTop,5,5,5,5));
220 fOCDBSelector->AddFrame(fOCDBTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
221 fOCDBSelector->AddFrame(createOCDBButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
224 /// ASCII calibration file selection
226 TGButton* openButtonACF = new TGPictureButton(fACFSelector,
227 gClient->GetPicture("fileopen.xpm"));
228 openButtonACF->SetToolTipText("Click to open file dialog");
230 fACFTypes->AddEntry("Config",7);
231 fACFTypes->AddEntry("Occupancy",4);
232 fACFTypes->AddEntry("Pedestals",0);
233 fACFTypes->AddEntry("Gains",1);
234 fACFTypes->AddEntry("Capacitances",2);
235 fACFTypes->Select(0);
236 fACFTypes->Resize(100,20);
238 fACFSelector->AddFrame(openButtonACF,new TGLayoutHints(kLHintsTop,5,5,5,5));
239 fACFSelector->AddFrame(fACFPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
240 fACFSelector->AddFrame(fACFTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
242 TGButton* createACFButton = new TGTextButton(fACFSelector,"Create data source");
243 createACFButton->Connect("Clicked()",
244 "AliMUONPainterDataSourceFrame",
246 "CreateACFDataSource()");
248 openButtonACF->Connect("Clicked()",
249 "AliMUONPainterDataSourceFrame",
251 "OpenFileDialogACF()");
253 fACFSelector->AddFrame(createACFButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
255 AddFrame(fRecentSourceSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
257 AddFrame(fRawSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
259 AddFrame(fOCDBSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
261 AddFrame(fACFSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
263 AddFrame(fDataReaders, new TGLayoutHints(kLHintsExpandX,10,10,10,10));
267 //_____________________________________________________________________________
268 AliMUONPainterDataSourceFrame::~AliMUONPainterDataSourceFrame()
275 //_____________________________________________________________________________
277 AliMUONPainterDataSourceFrame::AddRecentSource(const char* name)
279 /// Add a source to the list of recently used sources
281 TGListBox* lb = fRecentSources->GetListBox();
283 for ( Int_t i = 0; i < lb->GetNumberOfEntries(); ++i )
285 TGTextLBEntry* t = (TGTextLBEntry*)lb->GetEntry(i);
286 TString s(t->GetText()->GetString());
293 fRecentSources->AddEntry(name,lb->GetNumberOfEntries());
294 fRecentSources->MapSubwindows();
295 fRecentSources->Layout();
298 //_____________________________________________________________________________
300 AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
302 /// Calibrate button was clicked.
304 if ( fCalibrateNoGain->IsOn() ||
305 fCalibrateGainConstantCapa->IsOn() ||
306 fCalibrateGain->IsOn() ||
307 fCalibrateEmelecGain->IsOn() )
309 fRawOCDBPath->SetEnabled(kTRUE);
310 fRawOCDBPath->SetFocus();
314 fRawOCDBPath->SetEnabled(kFALSE);
318 //_____________________________________________________________________________
320 AliMUONPainterDataSourceFrame::HistogramButtonClicked()
322 /// Histogram button was clicked.
324 if ( fHistogramButton->IsOn() )
326 fHistoMin->SetState(kTRUE);
327 fHistoMax->SetState(kTRUE);
331 fHistoMin->SetState(kFALSE);
332 fHistoMax->SetState(kFALSE);
336 //_____________________________________________________________________________
338 AliMUONPainterDataSourceFrame::EventRangeButtonClicked()
340 /// EventRange button was clicked.
342 if ( fEventRangeButton->IsOn() )
344 fEventMin->SetState(kTRUE);
345 fEventMax->SetState(kTRUE);
349 fEventMin->SetIntNumber(-1);
350 fEventMax->SetIntNumber(-1);
351 fEventMin->SetState(kFALSE);
352 fEventMax->SetState(kFALSE);
356 //_____________________________________________________________________________
358 AliMUONPainterDataSourceFrame::CreateACFDataSource()
360 /// Create an ACF data source (using information from the widgets)
362 TString acfPath = fACFPath->GetText();
363 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fACFTypes->GetSelectedEntry());
364 TString type = t->GetText()->GetString();
366 CreateACFDataSource(acfPath,type);
368 fACFPath->SetText("");
372 //_____________________________________________________________________________
374 AliMUONPainterDataSourceFrame::CreateOCDBDataSource()
376 /// Create an OCDB data source (using information from the widgets)
378 TString cdbPath = fOCDBPath->GetText();
379 Int_t runNumber = fRunSelector->GetIntNumber();
380 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fOCDBTypes->GetSelectedEntry());
381 TString type = t->GetText()->GetString();
383 CreateOCDBDataSource(cdbPath,runNumber,type);
386 //_____________________________________________________________________________
388 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& uri)
390 /// Create an ACF data source, given it's URI
392 TObjArray* a = uri.Tokenize(";");
393 TString acfPath = static_cast<TObjString*>(a->At(1))->String();
394 TString type = static_cast<TObjString*>(a->At(2))->String();
396 CreateACFDataSource(acfPath,type);
402 //_____________________________________________________________________________
404 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& uri)
406 /// Create an OCDB data source, given it's URI
408 TObjArray* a = uri.Tokenize(";");
409 TString cdbPath = static_cast<TObjString*>(a->At(1))->String();
410 TString srun = static_cast<TObjString*>(a->At(2))->String();
411 TString type = static_cast<TObjString*>(a->At(3))->String();
413 CreateOCDBDataSource(cdbPath,atoi(srun.Data()),type);
418 //_____________________________________________________________________________
420 AliMUONPainterDataSourceFrame::RegisterDataSource(AliMUONVTrackerDataMaker* reader,
423 /// Register a new data source
425 if ( reader && reader->IsValid() )
427 AliMUONMchViewApplication* app = dynamic_cast<AliMUONMchViewApplication*>(gApplication);
430 AliError("Could not cast application to the expected type ! CHECK THAT !");
433 AliMUONPainterDataRegistry::Instance()->Register(reader);
435 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
437 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
439 env->Set(fgkNumberOfDataSourcesKey,n+1);
441 env->Set(Form(fgkDataSourceURIKey,n),dsName);
445 AddRecentSource(dsName);
450 TString name(dsName);
453 if ( name.Contains("PED") )
455 CreatePedestalCanvases(reader->Data());
461 //_____________________________________________________________________________
463 AliMUONPainterDataSourceFrame::CreatePedestalCanvases(AliMUONVTrackerData* data,
464 Double_t pedMin, Double_t pedMax,
465 Double_t sigmaMin, Double_t sigmaMax)
467 /// Create 4 canvases with the pedestals contained in data
468 /// to show mean and sigma, for bending and non bending, with given limits
472 AliMUONAttPainter att[2];
474 att[0].SetViewPoint(kTRUE,kFALSE);
475 att[0].SetCathode(kFALSE,kFALSE);
476 att[0].SetPlane(kTRUE,kFALSE);
478 att[1].SetViewPoint(kTRUE,kFALSE);
479 att[1].SetCathode(kFALSE,kFALSE);
480 att[1].SetPlane(kFALSE,kTRUE);
482 for ( Int_t iatt = 0; iatt < 2; ++iatt )
484 matrices.Add(CreateFullTracker(data,0,pedMin,pedMax,att[iatt]));
485 matrices.Add(CreateFullTracker(data,1,sigmaMin,sigmaMax,att[iatt]));
488 TIter next(&matrices);
489 AliMUONPainterMatrix* matrix;
491 Int_t w = TMath::Nint(gClient->GetDisplayWidth()*0.9);
492 Int_t h = TMath::Nint(gClient->GetDisplayHeight()*0.9);
494 Int_t x[] = { 0, 0, 20 + w/2, 20 + w/2 };
495 Int_t y[] = { 0, h/2+30, 0, h/2+30 };
499 while ( ( matrix = static_cast<AliMUONPainterMatrix*>(next())) )
501 TCanvas* c = matrix->CreateCanvas(x[i],y[i],w/2,h/2);
503 c->SaveAs(Form("%s.png",c->GetName()));
508 //_____________________________________________________________________________
509 AliMUONPainterMatrix*
510 AliMUONPainterDataSourceFrame::CreateFullTracker(AliMUONVTrackerData* data,
512 Double_t xmin, Double_t xmax,
513 const AliMUONAttPainter& att)
515 /// Generate, draw and register a matrix of 10 painters to show all the tracker
518 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
520 for ( Int_t ichamber = 0; ichamber < 10; ++ichamber )
522 AliMUONVPainter* painter = new AliMUONChamberPainter(att,ichamber);
524 painter->SetResponder("BUSPATCH");
526 painter->SetOutlined("*",kFALSE);
528 matrix->Adopt(painter);
531 matrix->SetData("MANU",data,dim);
532 matrix->SetDataRange(xmin,xmax);
534 AliMUONPainterRegistry::Instance()->Register(matrix);
540 //_____________________________________________________________________________
542 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& acfPath, const TString& type)
544 /// Create an ACF data source for a given (path,type)
546 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerConditionDataMaker(acfPath.Data(),
549 RegisterDataSource(reader,Form("ACF;%s;%s",acfPath.Data(),type.Data()));
552 //_____________________________________________________________________________
554 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& cdbPath,
558 /// Create an OCDB data source for a given (path,runnumber,type) triplet
560 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerConditionDataMaker(runNumber,
564 RegisterDataSource(reader,Form("OCDB;%s;%d;%s",cdbPath.Data(),runNumber,type.Data()));
567 //_____________________________________________________________________________
569 AliMUONPainterDataSourceFrame::CreateRawDataSource()
571 /// Create a new raw data source (using info from the widgets)
573 TString uri(gSystem->ExpandPathName(fFilePath->GetText()));
576 Bool_t fromMemory(kFALSE);
578 if ( uri.Contains(TRegexp("^mem")) )
584 if ( gSystem->AccessPathName(uri.Data()) )
586 AliError(Form("File %s does not exist",uri.Data()));
587 fFilePath->SetText("");
592 TString calibMode("");
594 if ( fCalibrateGain->IsOn() )
600 if ( fCalibrateGainConstantCapa->IsOn() )
602 calibMode = "GAINCONSTANTCAPA";
606 if ( fCalibrateEmelecGain->IsOn() )
608 calibMode = "INJECTIONGAIN";
612 if ( fCalibrateNoGain->IsOn() )
614 calibMode = "NOGAIN";
618 uri = Form("%s%s%s;%s;%s;%s;%s;%s;%s;%s",
619 ( fHistogramButton->IsOn() ? "H":""),
620 ( fromMemory ? "M" : ""),
621 name.Data(),uri.Data(),
622 ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
623 ( calibMode.Length() > 0 ? calibMode.Data() : " "),
624 Form("%e",fHistoMin->GetNumber()),
625 Form("%e",fHistoMax->GetNumber()),
626 Form("%d",(Int_t)(fEventMin->GetIntNumber())),
627 Form("%d",(Int_t)(fEventMax->GetIntNumber())));
629 if ( CreateRawDataSource(uri) )
631 fFilePath->SetText("");
632 fRawOCDBPath->SetText("");
636 //_____________________________________________________________________________
638 AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
640 /// Create a new raw data source, given its URI
645 TString sxmin("0.0");
646 TString sxmax("4096.0");
650 TObjArray* a = uri.Tokenize(";");
652 filename = static_cast<TObjString*>(a->At(1))->String();
654 if ( a->GetLast() > 1 )
656 ocdbPath = static_cast<TObjString*>(a->At(2))->String();
657 if ( ocdbPath == " " ) ocdbPath = "";
660 if ( a->GetLast() > 2 )
662 calibMode = static_cast<TObjString*>(a->At(3))->String();
663 if ( calibMode == " " ) calibMode = "";
666 if ( a->GetLast() > 3 )
668 sxmin = static_cast<TObjString*>(a->At(4))->String();
671 if ( a->GetLast() > 4 )
673 sxmax = static_cast<TObjString*>(a->At(5))->String();
676 if ( a->GetLast() > 5 )
678 emin = static_cast<TObjString*>(a->At(6))->String();
681 if ( a->GetLast() > 6 )
683 emax = static_cast<TObjString*>(a->At(7))->String();
686 AliRawReader* rawReader = 0x0;
688 if ( filename.Contains(TRegexp("^alien")) )
690 // insure we've initialized the grid...
693 TGrid::Connect("alien://");
697 rawReader = AliRawReader::Create(filename.Data());
701 AliError(Form("Could not open file %s",filename.Data()));
702 fFilePath->SetText("");
706 /// Basic test to see if the file is correct
707 Bool_t ok = rawReader->NextEvent();
710 AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
711 fFilePath->SetText("");
715 rawReader->RewindEvents();
717 AliMUONVTrackerDataMaker* reader(0x0);
718 Bool_t histogram(kFALSE);
720 if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
722 if ( ocdbPath.Length() > 0 )
724 AliMUONRecoParam* recoParam = AliMUONRecoParam::GetCosmicParam();
726 // FIXME: where to get the reco params from in reality ?
728 reader = new AliMUONTrackerDataMaker(recoParam,
738 reader = new AliMUONTrackerDataMaker(rawReader,histogram);
741 reader->SetEventRange(emin.Atoi(),emax.Atoi());
743 reader->SetSource(filename.Data());
747 if ( emin.Atoi() <= emax.Atoi() )
749 // we have an event range
750 if ( emin.Atoi() == emax.Atoi())
752 dsName += Form("[%d]",emin.Atoi());
756 dsName += Form("[%d,%d]",emin.Atoi(),emax.Atoi());
760 RegisterDataSource(reader,dsName.Data());
765 //_____________________________________________________________________________
767 AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
769 /// Update ourselves as a new data reader was created
771 AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
773 item->Connect("StartRunning()",
774 "AliMUONPainterDataSourceFrame",
778 item->Connect("StopRunning()",
779 "AliMUONPainterDataSourceFrame",
783 fDataReaders->AddFrame(item);
787 fDataReaders->MapSubwindows();
788 fDataReaders->Resize();
791 //_____________________________________________________________________________
793 AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(const AliMUONVTrackerDataMaker* maker)
795 /// Update ourselves as a data reader was deleted
797 AliMUONPainterDataSourceItem* theItem(0x0);
800 AliMUONPainterDataSourceItem* item;
802 while ( ( item = static_cast<AliMUONPainterDataSourceItem*>(next()) ) && !theItem )
804 if ( item->DataMaker() == maker )
810 if (!theItem) return;
812 fDataReaders->RemoveFrame(theItem);
813 fItems->Remove(theItem);
814 theItem->DestroyWindow();
817 fDataReaders->MapSubwindows();
818 fDataReaders->Resize();
822 //_____________________________________________________________________________
824 AliMUONPainterDataSourceFrame::OpenFileDialog()
826 /// Open a file dialog to select a file to be read
830 const char* fileTypes[] = {
831 "ROOT files","*.root",
832 "DATE files","*.raw",
836 fileInfo.fFileTypes = fileTypes;
837 delete[] fileInfo.fIniDir;
839 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
841 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
843 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
846 fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
848 env->Set("LastOpenDir",fileInfo.fIniDir);
853 //_____________________________________________________________________________
855 AliMUONPainterDataSourceFrame::OpenFileDialogACF()
857 /// Open a file dialog to select an ASCII calibration file to be read
861 const char* fileTypes[] = {
865 fileInfo.fFileTypes = fileTypes;
866 delete[] fileInfo.fIniDir;
868 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
870 fileInfo.fIniDir = StrDup(env->String("LastOpenDirACF","."));
872 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
875 fACFPath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
877 env->Set("LastOpenDirACF",fileInfo.fIniDir);
882 //_____________________________________________________________________________
884 AliMUONPainterDataSourceFrame::OpenRecentSource()
886 /// Open one source from the recently used ones
888 TGTextLBEntry* t = (TGTextLBEntry*)fRecentSources->GetSelectedEntry();
890 TString uri(t->GetText()->GetString());
892 if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) ||
893 uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) ||
894 uri.Contains(TRegexp("^MEM")) )
896 CreateRawDataSource(uri);
898 else if ( uri.Contains(TRegexp("^OCDB")) )
900 CreateOCDBDataSource(uri);
902 else if ( uri.Contains(TRegexp("^ACF")) )
904 CreateACFDataSource(uri);
907 fRecentSources->Select(-1);
910 //_____________________________________________________________________________
912 AliMUONPainterDataSourceFrame::StartRunning()
914 /// One data source starts running. Disable the Run button of the other ones
916 AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
921 AliMUONPainterDataSourceItem* o;
922 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
931 //_____________________________________________________________________________
933 AliMUONPainterDataSourceFrame::StopRunning()
935 /// One data source stops running. Enable the Run button of all items
938 AliMUONPainterDataSourceItem* o;
939 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )