X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TPC%2FAliTPCCalibViewerGUItime.cxx;h=9ff9b906568b50ef6431142cb2b1ed2ace34d707;hb=65a299717558835820893f69085727d492279563;hp=ddeee140f0648b7960d9d559767bf73599cf9813;hpb=949d8707637f39ffe6d4066688bd58c9f21c4893;p=u%2Fmrichter%2FAliRoot.git diff --git a/TPC/AliTPCCalibViewerGUItime.cxx b/TPC/AliTPCCalibViewerGUItime.cxx index ddeee140f06..9ff9b906568 100644 --- a/TPC/AliTPCCalibViewerGUItime.cxx +++ b/TPC/AliTPCCalibViewerGUItime.cxx @@ -103,6 +103,7 @@ TGCompositeFrame(p,w,h), fContLeft(0x0), fContDrawOpt(0x0), fChkDrawOptSame(0x0), + fChkDrawOptSparse(0x0), fComboAddDrawOpt(0x0), fContDrawSel(0x0), fContDrawSelSubRunTime(0x0), @@ -215,9 +216,19 @@ void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h // draw options fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight); fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); - fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same"); - fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); + + TGCompositeFrame *cfr = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight); + fContDrawOpt->AddFrame(cfr, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0)); + + fChkDrawOptSame = new TGCheckButton(cfr, "Same"); + cfr->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); fChkDrawOptSame->SetToolTipText("Add draw option 'same'"); + + fChkDrawOptSparse = new TGCheckButton(cfr, "Sparse"); + cfr->AddFrame(fChkDrawOptSparse, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); + fChkDrawOptSparse->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoNewSelection()"); + fChkDrawOptSparse->SetToolTipText("In case of run trending only plot runs with information"); + // additional draw options combo box fComboAddDrawOpt = new TGComboBox(fContDrawOpt); fComboAddDrawOpt->Resize(0, 22); @@ -225,6 +236,7 @@ void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); // fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)"); // fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + fComboAddDrawOpt->GetTextEntry()->SetText("",kFALSE); // draw selection group fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight); @@ -325,7 +337,7 @@ void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h fLblRunNumber->SetTextJustify(kTextLeft); fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); //run number - fLblRunNumberVal = new TGLabel(fContValues, "00000"); + fLblRunNumberVal = new TGLabel(fContValues, "000000"); fLblRunNumberVal->SetTextJustify(kTextLeft); fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); //time stamp label @@ -410,7 +422,7 @@ void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); - + fComboCustomDraw->GetTextEntry()->SetText("",kFALSE); // additional cuts container fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); @@ -428,7 +440,8 @@ void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); - + fComboCustomCuts->GetTextEntry()->SetText("",kFALSE); + SetWindowName("AliTPCCalibViewer GUI - Time"); MapSubwindows(); Resize(GetDefaultSize()); @@ -448,9 +461,21 @@ void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeNam // // retrieve tree from file // - TString s=gSystem->GetFromPipe(Form("ls %s",fileName)); -// TString s(fileName); - TObjArray *arr=s.Tokenize("\n"); + TObjArray *arr=0x0; + TString file(fileName); + if (file.Contains("://")) { + if (file.Contains(";")) { + arr=file.Tokenize(";"); + } else { + arr=new TObjArray; + arr->Add(new TObjString(fileName)); + } + } else { + TString s=gSystem->GetFromPipe(Form("ls %s",fileName)); + arr=s.Tokenize("\n"); + } + + if (!arr) return; TIter next(arr); TObject *o=0; if (fTree) delete fTree; @@ -458,6 +483,7 @@ void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeNam while ( (o=next()) ){ fTree->AddFile(o->GetName()); } + arr->SetOwner(); delete arr; if (!CheckChain()) return; UseConfigFile(fConfigFile.Data()); @@ -465,7 +491,7 @@ void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeNam } //______________________________________________________________________________ -void AliTPCCalibViewerGUItime::UseChain(TChain* chain = 0) +void AliTPCCalibViewerGUItime::UseChain(TChain *const chain = 0) { // // @@ -548,14 +574,14 @@ void AliTPCCalibViewerGUItime::FillCalibTypes() if (type.IsNull()) type="UNSPECIFIED"; // printf("CalibType: '%s'\n",type.Data()); if (!fListCalibType->FindEntry(type.Data())) { - fListCalibType->AddEntry(type,id); + fListCalibType->AddEntry(type.Data(),id); fListCalibType->Select(id++); } } //add type for unspecified calibration type type="UNSPECIFIED"; if (!fListCalibType->FindEntry(type.Data())) { - fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id); + fListCalibType->AddEntry(type.Data(),id); fListCalibType->Select(id++); } } @@ -650,7 +676,7 @@ void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const } //______________________________________________________________________________ -const char* AliTPCCalibViewerGUItime::GetDrawString(){ +const TString AliTPCCalibViewerGUItime::GetDrawString(){ // // create draw string for ttree by combining the user requestsa // @@ -662,8 +688,10 @@ const char* AliTPCCalibViewerGUItime::GetDrawString(){ id=fListVariables->GetSelectedEntry()->EntryId(); // printf("id: %d\n",id); TString branchName=selectedVariable; - const TObject *key=(*fConfigParser)(id); - if (key) branchName=(*fConfigParser)(id)->GetName(); + if (fConfigParser){ + const TObject *key=(*fConfigParser)(id); + if (key) branchName=(*fConfigParser)(id)->GetName(); + } //treat case of TVector if (branchName.EndsWith(".")){ Int_t par = (Int_t)(fNmbPar->GetNumber()); @@ -674,10 +702,10 @@ const char* AliTPCCalibViewerGUItime::GetDrawString(){ // if (fRadioXtime->GetState()==kButtonDown) // selectedVariable.Append(":time"); - return branchName.Data(); + return branchName; } //______________________________________________________________________________ -const char* AliTPCCalibViewerGUItime::GetDrawOptionString(){ +const TString AliTPCCalibViewerGUItime::GetDrawOptionString(){ // // get user selected draw options // @@ -685,7 +713,7 @@ const char* AliTPCCalibViewerGUItime::GetDrawOptionString(){ if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle(); if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase)) drawOpt+="same"; - return drawOpt.Data(); + return drawOpt; } //______________________________________________________________________________ void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){ @@ -699,7 +727,7 @@ void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){ cutStr=cuts.GetTitle(); } //______________________________________________________________________________ -void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph) +void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr) { // // @@ -710,13 +738,57 @@ void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph) fRunNumbers.ResizeTo(1); fTimeStamps.ResizeTo(1); } else { - fValuesX.ResizeTo(fTree->GetSelectedRows()); - fValuesY.ResizeTo(fTree->GetSelectedRows()); - fRunNumbers.ResizeTo(fTree->GetSelectedRows()); - fTimeStamps.ResizeTo(fTree->GetSelectedRows()); - fValuesY.SetElements(fTree->GetV3()); - fRunNumbers.SetElements(fTree->GetV1()); - fTimeStamps.SetElements(fTree->GetV2()); + const Long64_t nrows=fTree->GetSelectedRows(); + fValuesX.ResizeTo(nrows); + fValuesY.ResizeTo(nrows); + fRunNumbers.ResizeTo(nrows); + fTimeStamps.ResizeTo(nrows); + long long *index=new long long[nrows]; + + //sort data + Int_t nTime0=0; + for (Int_t i=0;iGetSelectedRows();++i){ + if (fTree->GetV2()[i]<1) ++nTime0; + } + + if (nTime0==fTree->GetSelectedRows()){ + TMath::Sort(nrows,fTree->GetV1(),index,kFALSE); + } else { + TMath::Sort(nrows,fTree->GetV2(),index,kFALSE); + } + + Double_t lastRun=-1.; + Int_t entries=0; + const Bool_t drawSparse=(fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown); + for (Long64_t i=0; iGetV1()[index[i]]; + Double_t xval = xArr[index[i]]; + + if (drawSparse){ + if (TMath::Abs(lastRun-run)<.1) { + lastRun=run; + continue; + } + xval=entries+0.5; + } + fValuesX.GetMatrixArray()[entries]=xval; + fValuesY.GetMatrixArray()[entries]=fTree->GetV3()[index[i]]; + fRunNumbers.GetMatrixArray()[entries]=run; + fTimeStamps.GetMatrixArray()[entries]=fTree->GetV2()[index[i]]; + lastRun=run; + ++entries; + } + + if (drawSparse){ + fValuesX.ResizeTo(entries); + fValuesY.ResizeTo(entries); + fRunNumbers.ResizeTo(entries); + fTimeStamps.ResizeTo(entries); + // printf("entries: %d\n",entries); + } + + delete [] index; } } //______________________________________________________________________________ @@ -773,7 +845,8 @@ void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title) } } } - varName=SubstituteUnderscores(branchTitle.Data()); + varName=branchTitle; + SubstituteUnderscores(varName); } } title+=varName; @@ -788,11 +861,11 @@ void AliTPCCalibViewerGUItime::AdjustYRange() // TIter nextGraphicObject(fTrashBox); TObject *o=0x0; - Float_t min=0,max=0; + Float_t min=1,max=0; while ( (o=nextGraphicObject()) ){ if (o->IsA()==TGraph::Class()){ TGraph *gr=(TGraph*)o; - if (min==max) { + if (min>max) { min=TMath::MinElement(gr->GetN(),gr->GetY()); max=TMath::MaxElement(gr->GetN(),gr->GetY()); } else { @@ -848,27 +921,33 @@ void AliTPCCalibViewerGUItime::DoDraw() { fCurrentGraph=0x0; fCurrentHist=0x0; } +// printf("%s (%s) [%s]\n",drawString.Data(), cutString.Data(), optString.Data()); //select data fTree->Draw(drawString.Data(),cutString.Data(),optString.Data()); if (fTree->GetSelectedRows()==-1) return; - UpdateValueArrays(graphOutput); + TString title; GetHistogramTitle(title); Bool_t drawGraph=kFALSE; + Double_t *xArr=0; if (graphOutput){ drawGraph=kTRUE; if (fIsCustomDraw&&fDrawString.Contains(":")){ - fValuesX.SetElements(fTree->GetV4()); +// fValuesX.SetElements(fTree->GetV4()); + xArr=fTree->GetV4(); }else{ if (fRadioXrun->GetState()==kButtonDown){ - fValuesX.SetElements(fTree->GetV1()); +// fValuesX.SetElements(fTree->GetV1()); + xArr=fTree->GetV1(); } else if (fRadioXtime->GetState()==kButtonDown){ - fValuesX.SetElements(fTree->GetV2()); +// fValuesX.SetElements(fTree->GetV2()); + xArr=fTree->GetV2(); } else { drawGraph=kFALSE; } } } + if (xArr) UpdateValueArrays(graphOutput, xArr); // if (graphOutput){ // if (fIsCustomDraw){ // if (fDrawString.Contains(":")){ @@ -891,9 +970,21 @@ void AliTPCCalibViewerGUItime::DoDraw() { //create graph according to selection if (drawGraph){ TGraph *graph=new TGraph(fValuesX,fValuesY); +// graph->Sort(); TString grDraw="p"; if (!drawSame) grDraw+="a"; if (!fIsCustomDraw) grDraw+="l"; + // sparse drawing, set bin labels + if (fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown){ + Int_t nrows=fValuesX.GetNrows(); + Double_t *newBins = new Double_t[nrows+1]; + for (Int_t ibin=0; ibinGetXaxis()->Set(nrows,newBins); + graph->GetXaxis()->LabelsOption("v"); + for (Int_t i=0; iGetXaxis()->SetBinLabel(i+1,Form("%.0f",fRunNumbers.GetMatrixArray()[i])); + delete [] newBins; + } graph->Draw(grDraw.Data()); graph->SetEditable(kFALSE); TH1 *hist=graph->GetHistogram(); @@ -952,7 +1043,7 @@ void AliTPCCalibViewerGUItime::DoDumpRuns() if (run!=prevRun) std::cout << Form("%d",run) << std::endl; prevRun=run; } - delete sortIndex; + delete [] sortIndex; } //______________________________________________________________________________ void AliTPCCalibViewerGUItime::DoParLimitChange() @@ -1128,7 +1219,7 @@ void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0; Double_t valx=0.,valy=0.; if (!fCurrentGraph) { - fLblRunNumberVal->SetText(Form("%05u",run)); + fLblRunNumberVal->SetText(Form("%06u",run)); fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS)); fLblValueXVal->SetText(Form("%.3e", valx)); fLblValueYVal->SetText(Form("%.3e", valy)); @@ -1163,7 +1254,7 @@ void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject valx=0.; valy=0.; } - fLblRunNumberVal->SetText(Form("%05u",run)); + fLblRunNumberVal->SetText(Form("%06u",run)); fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS)); if (fIsCustomDraw){ fLblValueXVal->SetText(Form("%.3e", valx)); @@ -1238,16 +1329,14 @@ void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run) fCalibViewerGUI->Reload(); } //______________________________________________________________________________ -const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in) +void AliTPCCalibViewerGUItime::SubstituteUnderscores(TString &s) { // // // - TString s(in); s.ReplaceAll("_{","|{"); s.ReplaceAll("_"," "); s.ReplaceAll("|{","_{"); - return s.Data(); } //______________________________________________________________________________