X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TPC%2FAliTPCCalibViewerGUI.cxx;h=837f83428c6e92d5112e5a669209369d023f9eaf;hb=65a299717558835820893f69085727d492279563;hp=68387ea9a79d8d324a153fa7457a03c870860a3f;hpb=2c632057b20a755472de41d084d02d410a4d451d;p=u%2Fmrichter%2FAliRoot.git diff --git a/TPC/AliTPCCalibViewerGUI.cxx b/TPC/AliTPCCalibViewerGUI.cxx index 68387ea9a79..837f83428c6 100644 --- a/TPC/AliTPCCalibViewerGUI.cxx +++ b/TPC/AliTPCCalibViewerGUI.cxx @@ -32,6 +32,7 @@ #include "AliTPCCalibViewerGUI.h" +#include "AliTPCCalPad.h" #include #include @@ -39,6 +40,7 @@ #include #include +#include #include #include #include @@ -112,6 +114,7 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fRadioTPC(0), fRadioSideA(0), fRadioSideC(0), + fRadioROC(0), fRadioSector(0), fComboAddDrawOpt(0), fChkAuto(0), @@ -211,7 +214,7 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h } -void AliTPCCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) { +void AliTPCCalibViewerGUI::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) { // // draw the GUI // @@ -220,7 +223,6 @@ void AliTPCCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) { // ====================================================================== SetCleanup(kDeepCleanup); - p = p; // to avoid compiler warnings // ***************************************************************************** // ************************* content of this MainFrame ************************* @@ -635,11 +637,17 @@ void AliTPCCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) { fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()"); fRadioSideC->SetToolTipText("Use only side C."); - // sector radio button - fRadioSector = new TGRadioButton(fContCuts, "ROC", 23); + // roc radio button + fRadioROC = new TGRadioButton(fContCuts, "ROC", 23); + fContCuts->AddFrame(fRadioROC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioROC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()"); + fRadioROC->SetToolTipText("Use only one ROC (readout chamber)."); + + // sector radio button + fRadioSector = new TGRadioButton(fContCuts, "Sector", 24); fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()"); - fRadioSector->SetToolTipText("Use only one ROC (readout chamber)."); + fRadioSector->SetToolTipText("Use only one Sector (0-17 A-Side, 18-35 C-Side)."); // sector options container fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); @@ -1095,6 +1103,7 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c) fRadioTPC(0), fRadioSideA(0), fRadioSideC(0), + fRadioROC(0), fRadioSector(0), fComboAddDrawOpt(0), fChkAuto(0), @@ -1215,7 +1224,7 @@ void AliTPCCalibViewerGUI::CloseWindow() { */ -void AliTPCCalibViewerGUI::Initialize(char* fileName, char* treeName) { +void AliTPCCalibViewerGUI::Initialize(const char* fileName, const char* treeName) { // // initialize the GUI with a calibrationTree from fileName // @@ -1256,22 +1265,33 @@ void AliTPCCalibViewerGUI::Initialize(AliTPCCalibViewer *viewer) { if (fInitialized && currentStr->GetString() == selectedVariable) variableId = id; id++; } - delete iter; - arr->Delete(); - delete arr; // fill fListNorm, list of normalization variables: - arr = fViewer->GetListOfNormalizationVariables(); - iter = arr->MakeIterator(); - iter->Reset(); + TObjArray *arrNorm = fViewer->GetListOfNormalizationVariables(); + TIterator *iterNorm = arrNorm->MakeIterator(); + iterNorm->Reset(); currentStr = 0; id = 0; fListNormalization->RemoveAll(); + while ((currentStr = (TObjString*)(iterNorm->Next()))) { + fListNormalization->AddEntry(currentStr->GetString().Data(), id); + if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id; + id++; + } + currentStr = 0; + iter->Reset(); + //Add draw variables to the list of normalisation while ((currentStr = (TObjString*)(iter->Next()))) { + if (currentStr->GetString().BeginsWith("Map")) continue; //don't add mapping information fListNormalization->AddEntry(currentStr->GetString().Data(), id); if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id; id++; } + + delete iterNorm; + arrNorm->Delete(); + delete arrNorm; + delete iter; arr->Delete(); delete arr; @@ -1293,6 +1313,15 @@ void AliTPCCalibViewerGUI::Initialize(AliTPCCalibViewer *viewer) { } +void AliTPCCalibViewerGUI::Reset(){ + // + // reset variables, delete calib viewer + // + if (fViewer) delete fViewer; + fListVariables->RemoveAll(); + fListNormalization->RemoveAll(); + fInitialized = kFALSE; +} void AliTPCCalibViewerGUI::HandleButtonsGeneral(Int_t id) { // @@ -1435,22 +1464,32 @@ void AliTPCCalibViewerGUI::HandleButtonsCuts(Int_t id) { case 20: // fRadioTPC fRadioSideA->SetState(kButtonUp); fRadioSideC->SetState(kButtonUp); + fRadioROC->SetState(kButtonUp); fRadioSector->SetState(kButtonUp); break; case 21: // fRadioSideA fRadioTPC->SetState(kButtonUp); fRadioSideC->SetState(kButtonUp); + fRadioROC->SetState(kButtonUp); fRadioSector->SetState(kButtonUp); break; case 22: // fRadioSideC fRadioTPC->SetState(kButtonUp); fRadioSideA->SetState(kButtonUp); + fRadioROC->SetState(kButtonUp); fRadioSector->SetState(kButtonUp); break; - case 23: // fRadioSector + case 23: // fRadioROC fRadioTPC->SetState(kButtonUp); fRadioSideA->SetState(kButtonUp); fRadioSideC->SetState(kButtonUp); + fRadioSector->SetState(kButtonUp); + break; + case 24: // fRadioSector + fRadioTPC->SetState(kButtonUp); + fRadioSideA->SetState(kButtonUp); + fRadioSideC->SetState(kButtonUp); + fRadioROC->SetState(kButtonUp); break; case 31: // fComboAddCuts fChkAddCuts->SetState(kButtonDown); @@ -1490,6 +1529,33 @@ void AliTPCCalibViewerGUI::HandleButtonsNoRedraw(Int_t id) { SetMinMaxLabel(); } +void AliTPCCalibViewerGUI::ReplacePlaceHolders(TString &str) +{ + // + // replace the defined placeholders in the custom draw string and cut string + // + TString drawPlaceHolder("#draw#"); + TString normPlaceHolder("#norm#"); + + //current draw variable + TString desiredData(""); + if (fListVariables->GetSelectedEntry()){ + desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); + str.ReplaceAll(drawPlaceHolder,desiredData); + } +// desiredData += fViewer->GetAbbreviation(); + + //current normalisation + TString normalizationData(""); + if (fListNormalization->GetSelectedEntry()){ + normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle(); + if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit")) + if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData; + if ( fListVariables->FindEntry(normalizationData.Data()) ) + normalizationData+="~"; + str.ReplaceAll(normPlaceHolder,normalizationData); + } +} void AliTPCCalibViewerGUI::DoNewSelection() { // @@ -1535,11 +1601,16 @@ TString* AliTPCCalibViewerGUI::GetDrawString() { cutStr += "(sector/18)%2==0"; // side A if (fRadioSideC->GetState() == kButtonDown) cutStr+= "(sector/18)%2==1"; // side C - if (fRadioSector->GetState() == kButtonDown) { + if (fRadioROC->GetState() == kButtonDown) { Int_t sector = (Int_t)(fNmbSector->GetNumber()); cutStr += "sector=="; cutStr += sector; } + if (fRadioSector->GetState() == kButtonDown) { + Int_t sector = ((Int_t)(fNmbSector->GetNumber()))%36; + cutStr += "sector%36=="; + cutStr += sector; + } if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){ if (fRadioTPC->GetState() != kButtonDown) cutStr += " && "; cutStr += fComboAddCuts->GetTextEntry()->GetText(); @@ -1562,12 +1633,15 @@ TString* AliTPCCalibViewerGUI::GetDrawString() { desiredData += op; if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit")) - desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); + if ( normalizationData.BeginsWith("_") ) desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); + if ( fListVariables->FindEntry(normalizationData.Data()) ) + normalizationData+="~"; desiredData += normalizationData; } else if (fRadioCustom->GetState() == kButtonDown) { desiredData = fComboCustom->GetTextEntry()->GetText(); if (desiredData == "") return 0; + ReplacePlaceHolders(desiredData); } // try to add forgotten '~' @@ -1589,10 +1663,15 @@ TString* AliTPCCalibViewerGUI::GetSectorString() { sectorStr += "A"; //cuts += "(sector/18)%2==0"; if (fRadioSideC->GetState() == kButtonDown) sectorStr+= "C"; //cuts += "(sector/18)%2==1"; - if (fRadioSector->GetState() == kButtonDown) { + if (fRadioROC->GetState() == kButtonDown) { Int_t sector = (Int_t)(fNmbSector->GetNumber()); sectorStr += sector; //cuts += "sector=="; } + if (fRadioSector->GetState() == kButtonDown) { + Int_t sector = ((Int_t)(fNmbSector->GetNumber()))%36; + sectorStr += "S"; + sectorStr += sector; //cuts += "sector%36=="; + } return new TString(sectorStr.Data()); } @@ -1615,8 +1694,11 @@ TString* AliTPCCalibViewerGUI::GetSectorString() { cutsStr += "!=0"; if (fChkAddCuts->GetState() == kButtonDown) cutsStr += " && "; } - if (fChkAddCuts->GetState() == kButtonDown) - cutsStr += fComboAddCuts->GetTextEntry()->GetText(); + if (fChkAddCuts->GetState() == kButtonDown){ + cutsStr += fComboAddCuts->GetTextEntry()->GetText(); + ReplacePlaceHolders(cutsStr); + } + // try to add forgotten '~' if (fChkAutoAppend->GetState() == kButtonDown) @@ -1694,7 +1776,6 @@ void AliTPCCalibViewerGUI::DoFit() { TMatrixD covMatrix(0,0); TString cutStr(""); TString formulaStr(""); - TString *returnStr = new TString(""); // specify data to plot: TString drawStr(GetDrawString()->Data()); @@ -1706,11 +1787,16 @@ void AliTPCCalibViewerGUI::DoFit() { cutStr += "(sector/18)%2==0"; // side A if (fRadioSideC->GetState() == kButtonDown) cutStr+= "(sector/18)%2==1"; // side C - if (fRadioSector->GetState() == kButtonDown) { + if (fRadioROC->GetState() == kButtonDown) { Int_t sector = (Int_t)(fNmbSector->GetNumber()); cutStr += "sector=="; cutStr += sector; } + if (fRadioSector->GetState() == kButtonDown) { + Int_t sector = (Int_t)(fNmbSector->GetNumber())%36; + cutStr += "sector%36=="; + cutStr += sector; + } if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){ if (fRadioTPC->GetState() != kButtonDown) cutStr += " && "; cutStr += fComboAddCuts->GetTextEntry()->GetText(); @@ -1725,12 +1811,16 @@ void AliTPCCalibViewerGUI::DoFit() { formulaStr = TString(fViewer->AddAbbreviations((char*)formulaStr.Data())); // ********** call AliTPCCalibViewer's fit-function - returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix); + ReplacePlaceHolders(drawStr); + ReplacePlaceHolders(cutStr); + TString *returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix); std::cout << std::endl; std::cout << "Your fit formula reads as follows:" << std::endl; std::cout << returnStr->Data() << std::endl; std::cout << "chi2 = " << chi2 << std::endl; + + delete returnStr; } @@ -1751,7 +1841,7 @@ void AliTPCCalibViewerGUI::DoExport() { // create calPad according to drawCommand and cuts AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)calPadName); // finally export calPad to Cint: - gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad)); + gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, (ULong_t)calPad)); fPreprocessor->AddComponent(calPad); Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName); } @@ -1768,6 +1858,7 @@ void AliTPCCalibViewerGUI::DoExportNorm() { } Error("DoExportNorm", "Not yet implemented."); +/* return; // specify data to plot: @@ -1782,8 +1873,9 @@ void AliTPCCalibViewerGUI::DoExportNorm() { // create calPad according to drawCommand and cuts AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)fComboExportName->GetTextEntry()->GetText()); // finally export calPad to Cint: - gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad)); + gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, (ULong_t) calPad)); Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName); + */ } @@ -1798,7 +1890,7 @@ void AliTPCCalibViewerGUI::GetMinMax() { ptr = listOfPrimitives->At(i); if ( ptr->InheritsFrom("TH1") ) break; } - if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1 + if ( !ptr || !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1 TH1 *hist = (TH1*)ptr; // Double_t histMax = hist->GetMaximum(); @@ -1892,17 +1984,29 @@ void AliTPCCalibViewerGUI::ChangeSector(){ // // function that is called, when the number of the sector is changed // to change the sector label - // + // + if ( fRadioROC->GetState()!=kButtonDown && fRadioSector->GetState()!=kButtonDown ){ + fLblSector->SetText("not used"); + return; + } + Int_t sector = (Int_t)(fNmbSector->GetNumber()); - char* secLabel = ""; - if (sector >= 0 && sector <= 17) // IROC, Side A - secLabel = "IROC, A"; - if (sector >= 18 && sector <= 35) // IROC, Side C - secLabel = "IROC, C"; - if (sector >= 36 && sector <= 53) // OROC, Side A - secLabel = "OROC, A"; - if (sector >= 54 && sector <= 71) // OROC, Side C - secLabel = "OROC, C"; + TString secLabel = ""; + if ( sector < 36 ) + secLabel = "IROC"; + else + secLabel = "OROC"; + + if (fRadioSector->GetState()==kButtonDown) + secLabel="Sector"; + + if ( sector%36<18 ) //A-Side + secLabel += ", A"; + else + secLabel += ", C"; + + secLabel += Form("%02d",sector%18); + fLblSector->SetText(secLabel); DoNewSelection(); } @@ -1949,7 +2053,7 @@ void AliTPCCalibViewerGUI::MouseMove(Int_t event, Int_t x, Int_t y, TObject *sel if (!selectedObject->InheritsFrom("TH2")) return; // zoom to sector works ONLY in 2D mode, if one side is specified if (fRadio2D->GetState() == kButtonUp) return; - if (fRadioSector->GetState() == kButtonDown) { // return to full side view + if (fRadioROC->GetState() == kButtonDown) { // return to full side view // return to full side view Int_t sector = (Int_t)(fNmbSector->GetNumber()); if ( (sector >= 0 && sector <= 17) || (sector >= 36 && sector <= 53) ) { @@ -1987,7 +2091,7 @@ void AliTPCCalibViewerGUI::MouseMove(Int_t event, Int_t x, Int_t y, TObject *sel if (quadrant == 3) phi = pi + phi; if (quadrant == 4) phi = 2 * pi - phi; Double_t phiGrad = phi / pi * 180; - Int_t sector = (Int_t) phiGrad / 20; // one sector coresponds to 20° + Int_t sector = (Int_t) phiGrad / 20; // one sector coresponds to 20� // IROC starts at 84.5 cm // IROC ends at 135.5 cm, OROC begins // OROC ends at 250 cm @@ -2001,8 +2105,8 @@ void AliTPCCalibViewerGUI::MouseMove(Int_t event, Int_t x, Int_t y, TObject *sel } // printf("r: %f, phi: %f, phiGrad: %f, gy/gx: %f, quadrant: %i, sector: %i \n", r, phi, phiGrad, gy/gx, quadrant, sector); fNmbSector->SetNumber(sector); - fRadioSector->Clicked(); - fRadioSector->SetState(kButtonDown); + fRadioROC->Clicked(); + fRadioROC->SetState(kButtonDown); ChangeSector(); } @@ -2093,7 +2197,7 @@ void AliTPCCalibViewerGUI::DoDumpToFile() { new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi); if (fi.fFilename && strlen(fi.fFilename)) { fPreprocessor->DumpToFile(fi.fFilename); - Info("DumpToFile", Form("New CalibTree has been writen to file '%s'", fi.fFilename)); + Info("DumpToFile","New CalibTree has been writen to file '%s'", fi.fFilename); } }