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 "AliCDBEntry.h"
23 #include "AliCDBManager.h"
24 #include "AliMUONChamberPainter.h"
25 #include "AliMUONMchViewApplication.h"
26 #include "AliMUONPainterDataRegistry.h"
27 #include "AliMUONPainterDataSourceItem.h"
28 #include "AliMUONPainterEnv.h"
29 #include "AliMUONPainterHelper.h"
30 #include "AliMUONPainterMatrix.h"
31 #include "AliMUONPainterRegistry.h"
32 #include "AliMUONRecoParam.h"
33 #include "AliMUONTrackerConditionDataMaker.h"
34 #include "AliMUONTrackerDataMaker.h"
35 #include "AliRawReader.h"
38 #include <TGComboBox.h>
39 #include <TGFileDialog.h>
40 #include <TGNumberEntry.h>
41 #include <TGTextEntry.h>
43 #include <TObjArray.h>
44 #include <TObjString.h>
50 ///\class AliMUONPainterDataSourceFrame
52 /// A complete frame to select and display various data sources to
53 /// be displayed : either raw data or OCDB data.
54 /// Later on we might add digits and clusters for instance.
56 ///\author Laurent Aphecetche, Subatech
58 const char* AliMUONPainterDataSourceFrame::fgkNumberOfDataSourcesKey = "NumberOfDataSources";
59 const char* AliMUONPainterDataSourceFrame::fgkDataSourceURIKey = "DataSourceURI.%d";
62 ClassImp(AliMUONPainterDataSourceFrame)
65 //_____________________________________________________________________________
66 AliMUONPainterDataSourceFrame::AliMUONPainterDataSourceFrame(const TGWindow* p, UInt_t w, UInt_t h)
67 : TGCompositeFrame(p,w,h,kVerticalFrame),
68 fRecentSourceSelector(new TGGroupFrame(this,"Recent sources",kHorizontalFrame)),
69 fRawSelector(new TGGroupFrame(this,"Raw file URI",kHorizontalFrame)),
70 fRawSelector2(new TGCompositeFrame(fRawSelector,w,h,kVerticalFrame)),
71 fRawSelector21(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
72 fRawSelector22(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
73 fRawSelector24(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
74 fRawSelector23(new TGCompositeFrame(fRawSelector2,w,h,kHorizontalFrame)),
75 fCalibrateNoGain(new TGCheckButton(fRawSelector22,"Ped sub")),
76 fCalibrateGainConstantCapa(new TGCheckButton(fRawSelector22,"Ped sub+gain (capa cste)")),
77 fCalibrateGain(new TGCheckButton(fRawSelector22,"Full calib (Ped sub+gain w/ capa)")),
78 fCalibrateEmelecGain(new TGCheckButton(fRawSelector22,"Full calib (Ped sub+inj gain w/ capa)")),
79 fHistogramButton(new TGCheckButton(fRawSelector23,"Histogram")),
80 fHistoMin(new TGNumberEntry(fRawSelector23,0)),
81 fHistoMax(new TGNumberEntry(fRawSelector23,4096)),
82 fEventRangeButton(new TGCheckButton(fRawSelector23,"Event range")),
83 fEventMin(new TGNumberEntry(fRawSelector23,-1,10)),
84 fEventMax(new TGNumberEntry(fRawSelector23,-1,10)),
85 fRawOCDBPath(new TGTextEntry(fRawSelector24,"alien://folder=/alice/data/2013/OCDB")),
86 fOCDBSelector(new TGGroupFrame(this,"OCDB Path",kHorizontalFrame)),
87 fDataReaders(new TGGroupFrame(this,"Data sources")),
88 fFilePath(new TGTextEntry(fRawSelector21,"")),
89 fOCDBPath(new TGTextEntry(fOCDBSelector,"alien://folder=/alice/data/2013/OCDB")),
90 fRunSelector(new TGNumberEntry(fOCDBSelector,0,10)),
91 fOCDBTypes(new TGComboBox(fOCDBSelector)),
92 fRecentSources(new TGComboBox(fRecentSourceSelector)),
93 fItems(new TObjArray),
94 fACFSelector(new TGGroupFrame(this,"ASCII Calib File",kHorizontalFrame)),
95 fACFPath(new TGTextEntry(fACFSelector,"")),
96 fACFTypes(new TGComboBox(fACFSelector))
100 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
102 reg->Connect("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",
103 "AliMUONPainterDataSourceFrame",
105 "DataMakerWasRegistered(AliMUONVTrackerDataMaker*)");
107 reg->Connect("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",
108 "AliMUONPainterDataSourceFrame",
110 "DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)");
112 fItems->SetOwner(kFALSE);
114 /// Recent source selection
116 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
118 Int_t nsources = env->Integer(fgkNumberOfDataSourcesKey);
120 for ( Int_t i = 0; i < nsources; ++i )
122 AddRecentSource(env->String(Form(fgkDataSourceURIKey,i)));
125 fRecentSources->Resize(100,20);
127 TGButton* createRecentButton = new TGTextButton(fRecentSourceSelector,"Create data source");
128 createRecentButton->Connect("Clicked()",
129 "AliMUONPainterDataSourceFrame",
131 "OpenRecentSource()");
133 fRecentSourceSelector->AddFrame(fRecentSources,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
134 fRecentSourceSelector->AddFrame(createRecentButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
136 /// Raw file selection
138 TGButton* openButton = new TGPictureButton(fRawSelector21,
139 gClient->GetPicture("fileopen.xpm"));
140 openButton->SetToolTipText("Click to open file dialog");
142 fRawSelector2->AddFrame(fRawSelector21, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
143 fRawSelector2->AddFrame(fRawSelector22, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
144 fRawSelector2->AddFrame(fRawSelector24, new TGLayoutHints(kLHintsTop,5,5,5,5));
145 fRawSelector2->AddFrame(fRawSelector23, new TGLayoutHints(kLHintsExpandX,5,5,5,5));
147 fRawSelector21->AddFrame(openButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
148 fRawSelector21->AddFrame(fFilePath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
150 fRawSelector22->AddFrame(fCalibrateNoGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
151 fRawSelector22->AddFrame(fCalibrateGainConstantCapa, new TGLayoutHints(kLHintsTop,5,5,5,5));
152 fRawSelector22->AddFrame(fCalibrateGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
153 fRawSelector22->AddFrame(fCalibrateEmelecGain, new TGLayoutHints(kLHintsTop,5,5,5,5));
155 fRawSelector24->AddFrame(fRawOCDBPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
156 fRawOCDBPath->SetEnabled(kFALSE);
158 fRawSelector23->AddFrame(fHistogramButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
159 fHistogramButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"HistogramButtonClicked()");
160 fHistoMin->SetState(kFALSE);
161 fHistoMax->SetState(kFALSE);
162 fRawSelector23->AddFrame(fHistoMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
163 fRawSelector23->AddFrame(fHistoMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
166 fRawSelector23->AddFrame(fEventRangeButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
167 fEventRangeButton->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"EventRangeButtonClicked()");
168 fEventMin->SetState(kFALSE);
169 fEventMax->SetState(kFALSE);
171 fEventMin->SetFormat(TGNumberFormat::kNESInteger);
172 fEventMax->SetFormat(TGNumberFormat::kNESInteger);
174 fRawSelector23->AddFrame(fEventMin,new TGLayoutHints(kLHintsTop,5,5,5,5));
175 fRawSelector23->AddFrame(fEventMax,new TGLayoutHints(kLHintsTop,5,5,5,5));
177 TGButton* createRawButton = new TGTextButton(fRawSelector,"Create data source");
179 fRawSelector->AddFrame(fRawSelector2, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
180 fRawSelector->AddFrame(createRawButton, new TGLayoutHints(kLHintsCenterY,5,5,5,5));
182 fCalibrateNoGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
183 fCalibrateGainConstantCapa->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
184 fCalibrateGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
185 fCalibrateEmelecGain->Connect("Clicked()","AliMUONPainterDataSourceFrame",this,"CalibrateButtonClicked()");
187 openButton->Connect("Clicked()",
188 "AliMUONPainterDataSourceFrame",
192 createRawButton->Connect("Clicked()",
193 "AliMUONPainterDataSourceFrame",
195 "CreateRawDataSource()");
199 fOCDBTypes->AddEntry("Config",7);
200 fOCDBTypes->AddEntry("Occupancy",4);
201 fOCDBTypes->AddEntry("HV",3);
202 fOCDBTypes->AddEntry("Pedestals",0);
203 fOCDBTypes->AddEntry("Gains",1);
204 fOCDBTypes->AddEntry("StatusMap",5);
205 fOCDBTypes->AddEntry("Status",6);
206 fOCDBTypes->AddEntry("Capacitances",2);
207 fOCDBTypes->AddEntry("RejectList",8);
208 fOCDBTypes->Select(0);
209 fOCDBTypes->Resize(80,20);
211 TGButton* createOCDBButton = new TGTextButton(fOCDBSelector,"Create data source");
212 createOCDBButton->Connect("Clicked()",
213 "AliMUONPainterDataSourceFrame",
215 "CreateOCDBDataSource()");
217 const char* ocdbToolTip = "Use URL style for either alien or local OCDB (foo://bar). For example :\n"
218 "alien://folder=/alice/data.../OCDB\n"
219 "or\nlocal:///home/user/aliroot (mind the 3 slashes there !)";
221 fRawOCDBPath->SetToolTipText(ocdbToolTip);
222 fOCDBPath->SetToolTipText(ocdbToolTip);
224 fOCDBSelector->AddFrame(fOCDBPath,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
225 fOCDBSelector->AddFrame(fRunSelector,new TGLayoutHints(kLHintsTop,5,5,5,5));
226 fOCDBSelector->AddFrame(fOCDBTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
227 fOCDBSelector->AddFrame(createOCDBButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
230 /// ASCII calibration file selection
232 TGButton* openButtonACF = new TGPictureButton(fACFSelector,
233 gClient->GetPicture("fileopen.xpm"));
234 openButtonACF->SetToolTipText("Click to open file dialog");
236 fACFTypes->AddEntry("Config",7);
237 fACFTypes->AddEntry("Occupancy",4);
238 fACFTypes->AddEntry("Pedestals",0);
239 fACFTypes->AddEntry("Gains",1);
240 fACFTypes->AddEntry("Capacitances",2);
241 fACFTypes->Select(0);
242 fACFTypes->Resize(100,20);
244 fACFSelector->AddFrame(openButtonACF,new TGLayoutHints(kLHintsTop,5,5,5,5));
245 fACFSelector->AddFrame(fACFPath, new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
246 fACFSelector->AddFrame(fACFTypes,new TGLayoutHints(kLHintsExpandX | kLHintsTop,5,5,5,5));
248 TGButton* createACFButton = new TGTextButton(fACFSelector,"Create data source");
249 createACFButton->Connect("Clicked()",
250 "AliMUONPainterDataSourceFrame",
252 "CreateACFDataSource()");
254 openButtonACF->Connect("Clicked()",
255 "AliMUONPainterDataSourceFrame",
257 "OpenFileDialogACF()");
259 fACFSelector->AddFrame(createACFButton,new TGLayoutHints(kLHintsTop,5,5,5,5));
261 AddFrame(fRecentSourceSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
263 AddFrame(fRawSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
265 AddFrame(fOCDBSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
267 AddFrame(fACFSelector,new TGLayoutHints(kLHintsExpandX,10,10,10,10));
269 AddFrame(fDataReaders, new TGLayoutHints(kLHintsExpandX,10,10,10,10));
273 //_____________________________________________________________________________
274 AliMUONPainterDataSourceFrame::~AliMUONPainterDataSourceFrame()
281 //_____________________________________________________________________________
283 AliMUONPainterDataSourceFrame::AddRecentSource(const char* name)
285 /// Add a source to the list of recently used sources
287 TGListBox* lb = fRecentSources->GetListBox();
289 for ( Int_t i = 0; i < lb->GetNumberOfEntries(); ++i )
291 TGTextLBEntry* t = (TGTextLBEntry*)lb->GetEntry(i);
292 TString s(t->GetText()->GetString());
299 fRecentSources->AddEntry(name,lb->GetNumberOfEntries());
300 fRecentSources->MapSubwindows();
301 fRecentSources->Layout();
304 //_____________________________________________________________________________
306 AliMUONPainterDataSourceFrame::CalibrateButtonClicked()
308 /// Calibrate button was clicked.
310 if ( fCalibrateNoGain->IsOn() ||
311 fCalibrateGainConstantCapa->IsOn() ||
312 fCalibrateGain->IsOn() ||
313 fCalibrateEmelecGain->IsOn() )
315 fRawOCDBPath->SetEnabled(kTRUE);
316 fRawOCDBPath->SetFocus();
320 fRawOCDBPath->SetEnabled(kFALSE);
324 //_____________________________________________________________________________
326 AliMUONPainterDataSourceFrame::HistogramButtonClicked()
328 /// Histogram button was clicked.
330 if ( fHistogramButton->IsOn() )
332 fHistoMin->SetState(kTRUE);
333 fHistoMax->SetState(kTRUE);
337 fHistoMin->SetState(kFALSE);
338 fHistoMax->SetState(kFALSE);
342 //_____________________________________________________________________________
344 AliMUONPainterDataSourceFrame::EventRangeButtonClicked()
346 /// EventRange button was clicked.
348 if ( fEventRangeButton->IsOn() )
350 fEventMin->SetState(kTRUE);
351 fEventMax->SetState(kTRUE);
355 fEventMin->SetIntNumber(-1);
356 fEventMax->SetIntNumber(-1);
357 fEventMin->SetState(kFALSE);
358 fEventMax->SetState(kFALSE);
362 //_____________________________________________________________________________
364 AliMUONPainterDataSourceFrame::CreateACFDataSource()
366 /// Create an ACF data source (using information from the widgets)
368 TString acfPath = fACFPath->GetText();
369 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fACFTypes->GetSelectedEntry());
370 TString type = t->GetText()->GetString();
372 CreateACFDataSource(acfPath,type);
374 fACFPath->SetText("");
378 //_____________________________________________________________________________
380 AliMUONPainterDataSourceFrame::CreateOCDBDataSource()
382 /// Create an OCDB data source (using information from the widgets)
384 TString cdbPath = fOCDBPath->GetText();
385 Int_t runNumber = fRunSelector->GetIntNumber();
386 TGTextLBEntry* t = static_cast<TGTextLBEntry*>(fOCDBTypes->GetSelectedEntry());
387 TString type = t->GetText()->GetString();
389 CreateOCDBDataSource(cdbPath,runNumber,type);
392 //_____________________________________________________________________________
394 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& uri)
396 /// Create an ACF data source, given it's URI
398 TObjArray* a = uri.Tokenize(";");
399 TString acfPath = static_cast<TObjString*>(a->At(1))->String();
400 TString type = static_cast<TObjString*>(a->At(2))->String();
402 CreateACFDataSource(acfPath,type);
408 //_____________________________________________________________________________
410 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& uri)
412 /// Create an OCDB data source, given it's URI
414 TObjArray* a = uri.Tokenize(";");
415 TString cdbPath = static_cast<TObjString*>(a->At(1))->String();
416 TString srun = static_cast<TObjString*>(a->At(2))->String();
417 TString type = static_cast<TObjString*>(a->At(3))->String();
419 CreateOCDBDataSource(cdbPath,atoi(srun.Data()),type);
424 //_____________________________________________________________________________
426 AliMUONPainterDataSourceFrame::RegisterDataSource(AliMUONVTrackerDataMaker* reader,
429 /// Register a new data source
431 if ( reader && reader->IsValid() )
433 AliMUONMchViewApplication* app = dynamic_cast<AliMUONMchViewApplication*>(gApplication);
436 AliError("Could not cast application to the expected type ! CHECK THAT !");
439 AliMUONPainterDataRegistry::Instance()->Register(reader);
441 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
443 Int_t n = env->Integer(fgkNumberOfDataSourcesKey);
445 env->Set(fgkNumberOfDataSourcesKey,n+1);
447 env->Set(Form(fgkDataSourceURIKey,n),dsName);
451 AddRecentSource(dsName);
456 TString name(dsName);
459 if ( name.Contains("PED") )
461 CreatePedestalCanvases(reader->Data());
467 //_____________________________________________________________________________
469 AliMUONPainterDataSourceFrame::CreatePedestalCanvases(AliMUONVTrackerData* data,
470 Double_t pedMin, Double_t pedMax,
471 Double_t sigmaMin, Double_t sigmaMax)
473 /// Create 4 canvases with the pedestals contained in data
474 /// to show mean and sigma, for bending and non bending, with given limits
478 AliMUONAttPainter att[2];
480 att[0].SetViewPoint(kTRUE,kFALSE);
481 att[0].SetCathode(kFALSE,kFALSE);
482 att[0].SetPlane(kTRUE,kFALSE);
484 att[1].SetViewPoint(kTRUE,kFALSE);
485 att[1].SetCathode(kFALSE,kFALSE);
486 att[1].SetPlane(kFALSE,kTRUE);
488 for ( Int_t iatt = 0; iatt < 2; ++iatt )
490 matrices.Add(CreateFullTracker(data,0,pedMin,pedMax,att[iatt]));
491 matrices.Add(CreateFullTracker(data,1,sigmaMin,sigmaMax,att[iatt]));
494 TIter next(&matrices);
495 AliMUONPainterMatrix* matrix;
497 Int_t w = TMath::Nint(gClient->GetDisplayWidth()*0.9);
498 Int_t h = TMath::Nint(gClient->GetDisplayHeight()*0.9);
500 Int_t x[] = { 0, 0, 20 + w/2, 20 + w/2 };
501 Int_t y[] = { 0, h/2+30, 0, h/2+30 };
505 while ( ( matrix = static_cast<AliMUONPainterMatrix*>(next())) )
507 TCanvas* c = matrix->CreateCanvas(x[i],y[i],w/2,h/2);
509 c->SaveAs(Form("%s.png",c->GetName()));
514 //_____________________________________________________________________________
515 AliMUONPainterMatrix*
516 AliMUONPainterDataSourceFrame::CreateFullTracker(AliMUONVTrackerData* data,
518 Double_t xmin, Double_t xmax,
519 const AliMUONAttPainter& att)
521 /// Generate, draw and register a matrix of 10 painters to show all the tracker
524 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
526 for ( Int_t ichamber = 0; ichamber < 10; ++ichamber )
528 AliMUONVPainter* painter = new AliMUONChamberPainter(att,ichamber);
530 painter->SetResponder("BUSPATCH");
532 painter->SetOutlined("*",kFALSE);
534 matrix->Adopt(painter);
537 matrix->SetData("MANU",data,dim);
538 matrix->SetDataRange(xmin,xmax);
540 AliMUONPainterRegistry::Instance()->Register(matrix);
546 //_____________________________________________________________________________
548 AliMUONPainterDataSourceFrame::CreateACFDataSource(const TString& acfPath, const TString& type)
550 /// Create an ACF data source for a given (path,type)
552 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerConditionDataMaker(acfPath.Data(),
555 RegisterDataSource(reader,Form("ACF;%s;%s",acfPath.Data(),type.Data()));
558 //_____________________________________________________________________________
560 AliMUONPainterDataSourceFrame::CreateOCDBDataSource(const TString& cdbPath,
564 /// Create an OCDB data source for a given (path,runnumber,type) triplet
566 AliMUONVTrackerDataMaker* reader = new AliMUONTrackerConditionDataMaker(runNumber,
570 RegisterDataSource(reader,Form("OCDB;%s;%d;%s",cdbPath.Data(),runNumber,type.Data()));
573 //_____________________________________________________________________________
575 AliMUONPainterDataSourceFrame::CreateRawDataSource()
577 /// Create a new raw data source (using info from the widgets)
579 TString uri(gSystem->ExpandPathName(fFilePath->GetText()));
582 Bool_t fromMemory(kFALSE);
584 if ( uri.Contains(TRegexp("^mem")) )
590 if ( gSystem->AccessPathName(uri.Data()) )
592 AliError(Form("File %s does not exist",uri.Data()));
593 fFilePath->SetText("");
598 TString calibMode("");
600 if ( fCalibrateGain->IsOn() )
606 if ( fCalibrateGainConstantCapa->IsOn() )
608 calibMode = "GAINCONSTANTCAPA";
612 if ( fCalibrateEmelecGain->IsOn() )
614 calibMode = "INJECTIONGAIN";
618 if ( fCalibrateNoGain->IsOn() )
620 calibMode = "NOGAIN";
624 uri = Form("%s%s%s;%s;%s;%s;%s;%s;%s;%s",
625 ( fHistogramButton->IsOn() ? "H":""),
626 ( fromMemory ? "M" : ""),
627 name.Data(),uri.Data(),
628 ( strlen(fRawOCDBPath->GetText()) > 0 ? fRawOCDBPath->GetText() : " "),
629 ( calibMode.Length() > 0 ? calibMode.Data() : " "),
630 Form("%e",fHistoMin->GetNumber()),
631 Form("%e",fHistoMax->GetNumber()),
632 Form("%d",(Int_t)(fEventMin->GetIntNumber())),
633 Form("%d",(Int_t)(fEventMax->GetIntNumber())));
635 if ( CreateRawDataSource(uri) )
637 fFilePath->SetText("");
638 fRawOCDBPath->SetText("");
642 //_____________________________________________________________________________
644 AliMUONPainterDataSourceFrame::CreateRawDataSource(const TString& uri)
646 /// Create a new raw data source, given its URI
651 TString sxmin("0.0");
652 TString sxmax("4096.0");
656 TObjArray* a = uri.Tokenize(";");
658 filename = static_cast<TObjString*>(a->At(1))->String();
660 if ( a->GetLast() > 1 )
662 ocdbPath = static_cast<TObjString*>(a->At(2))->String();
663 if ( ocdbPath == " " ) ocdbPath = "";
666 if ( a->GetLast() > 2 )
668 calibMode = static_cast<TObjString*>(a->At(3))->String();
669 if ( calibMode == " " ) calibMode = "";
672 if ( a->GetLast() > 3 )
674 sxmin = static_cast<TObjString*>(a->At(4))->String();
677 if ( a->GetLast() > 4 )
679 sxmax = static_cast<TObjString*>(a->At(5))->String();
682 if ( a->GetLast() > 5 )
684 emin = static_cast<TObjString*>(a->At(6))->String();
687 if ( a->GetLast() > 6 )
689 emax = static_cast<TObjString*>(a->At(7))->String();
694 AliRawReader* rawReader = 0x0;
696 if ( filename.Contains(TRegexp("^alien")) )
698 // insure we've initialized the grid...
701 TGrid::Connect("alien://");
705 rawReader = AliRawReader::Create(filename.Data());
709 AliError(Form("Could not open file %s",filename.Data()));
710 fFilePath->SetText("");
714 /// Basic test to see if the file is correct
715 /// and to get run numbre
717 Bool_t ok = rawReader->NextEvent();
720 AliError(Form("File %s does not seem to be a raw data file",filename.Data()));
721 fFilePath->SetText("");
726 runNumber = rawReader->GetRunNumber();
729 rawReader->RewindEvents();
731 AliMUONVTrackerDataMaker* reader(0x0);
732 Bool_t histogram(kFALSE);
734 if ( uri.Contains(TRegexp("^H")) ) histogram = kTRUE;
736 if ( ocdbPath.Length() > 0 )
739 AliMUONRecoParam* recoParam(0x0);
741 AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam",runNumber);
744 TObject* o = e->GetObject();
745 if ( o->IsA() == TObjArray::Class() )
747 TIter next(static_cast<TObjArray*>(o));
749 while ( ( p = static_cast<AliMUONRecoParam*>(next()) ))
751 if ( p->IsDefault()) recoParam = p;
756 recoParam = static_cast<AliMUONRecoParam*>(o);
760 reader = new AliMUONTrackerDataMaker(recoParam,
770 reader = new AliMUONTrackerDataMaker(rawReader,histogram);
773 reader->SetEventRange(emin.Atoi(),emax.Atoi());
775 reader->SetSource(filename.Data());
779 if ( emin.Atoi() <= emax.Atoi() )
781 // we have an event range
782 if ( emin.Atoi() == emax.Atoi())
784 dsName += Form("[%d]",emin.Atoi());
788 dsName += Form("[%d,%d]",emin.Atoi(),emax.Atoi());
792 RegisterDataSource(reader,dsName.Data());
797 //_____________________________________________________________________________
799 AliMUONPainterDataSourceFrame::DataMakerWasRegistered(AliMUONVTrackerDataMaker* reader)
801 /// Update ourselves as a new data reader was created
803 AliMUONPainterDataSourceItem* item = new AliMUONPainterDataSourceItem(fDataReaders,100,20,reader);
805 item->Connect("StartRunning()",
806 "AliMUONPainterDataSourceFrame",
810 item->Connect("StopRunning()",
811 "AliMUONPainterDataSourceFrame",
815 fDataReaders->AddFrame(item);
819 fDataReaders->MapSubwindows();
820 fDataReaders->Resize();
823 //_____________________________________________________________________________
825 AliMUONPainterDataSourceFrame::DataMakerWasUnregistered(const AliMUONVTrackerDataMaker* maker)
827 /// Update ourselves as a data reader was deleted
829 AliMUONPainterDataSourceItem* theItem(0x0);
832 AliMUONPainterDataSourceItem* item;
834 while ( ( item = static_cast<AliMUONPainterDataSourceItem*>(next()) ) && !theItem )
836 if ( item->DataMaker() == maker )
842 if (!theItem) return;
844 fDataReaders->RemoveFrame(theItem);
845 fItems->Remove(theItem);
846 theItem->DestroyWindow();
849 fDataReaders->MapSubwindows();
850 fDataReaders->Resize();
854 //_____________________________________________________________________________
856 AliMUONPainterDataSourceFrame::OpenFileDialog()
858 /// Open a file dialog to select a file to be read
862 const char* fileTypes[] = {
863 "ROOT files","*.root",
864 "DATE files","*.raw",
868 fileInfo.fFileTypes = fileTypes;
869 delete[] fileInfo.fIniDir;
871 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
873 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
875 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
878 fFilePath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
880 env->Set("LastOpenDir",fileInfo.fIniDir);
885 //_____________________________________________________________________________
887 AliMUONPainterDataSourceFrame::OpenFileDialogACF()
889 /// Open a file dialog to select an ASCII calibration file to be read
893 const char* fileTypes[] = {
897 fileInfo.fFileTypes = fileTypes;
898 delete[] fileInfo.fIniDir;
900 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
902 fileInfo.fIniDir = StrDup(env->String("LastOpenDirACF","."));
904 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
907 fACFPath->SetText(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
909 env->Set("LastOpenDirACF",fileInfo.fIniDir);
914 //_____________________________________________________________________________
916 AliMUONPainterDataSourceFrame::OpenRecentSource()
918 /// Open one source from the recently used ones
920 TGTextLBEntry* t = (TGTextLBEntry*)fRecentSources->GetSelectedEntry();
922 TString uri(t->GetText()->GetString());
924 if ( uri.Contains(TRegexp("^RAW")) || uri.Contains(TRegexp("^HRAW")) ||
925 uri.Contains(TRegexp("^CAL")) || uri.Contains(TRegexp("^HCAL")) ||
926 uri.Contains(TRegexp("^MEM")) )
928 CreateRawDataSource(uri);
930 else if ( uri.Contains(TRegexp("^OCDB")) )
932 CreateOCDBDataSource(uri);
934 else if ( uri.Contains(TRegexp("^ACF")) )
936 CreateACFDataSource(uri);
939 fRecentSources->Select(-1);
942 //_____________________________________________________________________________
944 AliMUONPainterDataSourceFrame::StartRunning()
946 /// One data source starts running. Disable the Run button of the other ones
948 AliMUONPainterDataSourceItem* item = reinterpret_cast<AliMUONPainterDataSourceItem*> (gTQSender);
953 AliMUONPainterDataSourceItem* o;
954 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )
963 //_____________________________________________________________________________
965 AliMUONPainterDataSourceFrame::StopRunning()
967 /// One data source stops running. Enable the Run button of all items
970 AliMUONPainterDataSourceItem* o;
971 while ( ( o = static_cast<AliMUONPainterDataSourceItem*>(next()) ) )