From 72d0ab7ee750e4b9c329fa5203ad13071dd38bd4 Mon Sep 17 00:00:00 2001 From: marian Date: Mon, 19 Nov 2007 10:58:02 +0000 Subject: [PATCH] Adding new functionality to the AliTPCCalibViewer (L.Bozyk) --- TPC/AliTPCCalPad.cxx | 217 +------ TPC/AliTPCCalPad.h | 4 +- TPC/AliTPCCalibViewer.cxx | 864 ++++++++++++++++++++++------ TPC/AliTPCCalibViewer.h | 33 +- TPC/AliTPCCalibViewerGUI.cxx | 1035 +++++++++++++++++++++++++--------- TPC/AliTPCCalibViewerGUI.h | 105 +++- 6 files changed, 1600 insertions(+), 658 deletions(-) diff --git a/TPC/AliTPCCalPad.cxx b/TPC/AliTPCCalPad.cxx index 10f33d93a80..8d8f5f18541 100644 --- a/TPC/AliTPCCalPad.cxx +++ b/TPC/AliTPCCalPad.cxx @@ -32,6 +32,7 @@ #include "TTreeStream.h" #include "TFile.h" #include "TKey.h" +#include ClassImp(AliTPCCalPad) @@ -140,6 +141,7 @@ void AliTPCCalPad::SetCalROC(AliTPCCalROC* roc, Int_t sector){ // else sector specified in 'roc' is ignored and specified sector is filled // if (sector == -1) sector = roc->GetSector(); + if (!fROC[sector]) fROC[sector] = new AliTPCCalROC(sector); for (UInt_t ichannel = 0; ichannel < roc->GetNchannels(); ichannel++) fROC[sector]->SetValue(ichannel, roc->GetValue(ichannel)); } @@ -447,7 +449,7 @@ TH2F *AliTPCCalPad::MakeHisto2D(Int_t side){ } -AliTPCCalPad* AliTPCCalPad::LocalFit(const char* padName, Int_t rowRadius, Int_t padRadius, AliTPCCalPad* PadOutliers, Bool_t robust, Double_t chi2Threshold, Double_t robustFraction){ +AliTPCCalPad* AliTPCCalPad::LocalFit(const char* padName, Int_t rowRadius, Int_t padRadius, AliTPCCalPad* PadOutliers, Bool_t robust, Double_t chi2Threshold, Double_t robustFraction, Bool_t printCurrentSector) const { // // Loops over all AliTPCCalROCs and performs a localFit in each ROC // AliTPCCalPad with fit-data is returned @@ -465,10 +467,11 @@ AliTPCCalPad* AliTPCCalPad::LocalFit(const char* padName, Int_t rowRadius, Int_t // AliTPCCalPad* pad = new AliTPCCalPad(padName, padName); for (Int_t isec = 0; isec < 72; isec++){ + if (printCurrentSector) std::cout << "LocalFit in sector " << isec << "\r" << std::flush; if (PadOutliers) - SetCalROC(GetCalROC(isec)->LocalFit(rowRadius, padRadius, PadOutliers->GetCalROC(isec), robust, chi2Threshold, robustFraction)); + pad->SetCalROC(GetCalROC(isec)->LocalFit(rowRadius, padRadius, PadOutliers->GetCalROC(isec), robust, chi2Threshold, robustFraction)); else - SetCalROC(GetCalROC(isec)->LocalFit(rowRadius, padRadius, 0, robust, chi2Threshold, robustFraction)); + pad->SetCalROC(GetCalROC(isec)->LocalFit(rowRadius, padRadius, 0, robust, chi2Threshold, robustFraction)); } return pad; } @@ -638,211 +641,3 @@ void AliTPCCalPad::GlobalSidesFit(const AliTPCCalPad* PadOutliers, TVectorD &fit } -void AliTPCCalPad::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) { - // - // Write a tree with all available information - // im mapFileName is speciefied, the Map information are also written to the tree - // pads specified in outlierPad are not used for calculating statistics - // - this function will be moved to AliTPCCalibViewer - - // - DO NOT USE THIS FUNCTION ANY MORE - - // - AliTPCROC* tpcROCinstance = AliTPCROC::Instance(); - - TObjArray* mapIROCs = 0; - TObjArray* mapOROCs = 0; - TVectorF *mapIROCArray = 0; - TVectorF *mapOROCArray = 0; - Int_t mapEntries = 0; - TString* mapNames = 0; - - if (mapFileName) { - TFile mapFile(mapFileName, "read"); - - TList* listOfROCs = mapFile.GetListOfKeys(); - mapEntries = listOfROCs->GetEntries()/2; - mapIROCs = new TObjArray(mapEntries*2); - mapOROCs = new TObjArray(mapEntries*2); - mapIROCArray = new TVectorF[mapEntries]; - mapOROCArray = new TVectorF[mapEntries]; - - mapNames = new TString[mapEntries]; - for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { - TString ROCname(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); - ROCname.Remove(ROCname.Length()-4, 4); - mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "IROC").Data()), ivalue); - mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "OROC").Data()), ivalue); - mapNames[ivalue].Append(ROCname); - } - - for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { - mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0)); - mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36)); - - for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++) - (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel); - for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++) - (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel); - } - - } // if (mapFileName) - - TTreeSRedirector cstream(fileName); - Int_t arrayEntries = array->GetEntries(); - - TString* names = new TString[arrayEntries]; - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) - names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName()); - - for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) { - // - // get statistic for given sector - // - TVectorF median(arrayEntries); - TVectorF mean(arrayEntries); - TVectorF rms(arrayEntries); - TVectorF ltm(arrayEntries); - TVectorF ltmrms(arrayEntries); - TVectorF medianWithOut(arrayEntries); - TVectorF meanWithOut(arrayEntries); - TVectorF rmsWithOut(arrayEntries); - TVectorF ltmWithOut(arrayEntries); - TVectorF ltmrmsWithOut(arrayEntries); - - TVectorF *vectorArray = new TVectorF[arrayEntries]; - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) - vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); - - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { - AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); - AliTPCCalROC* calROC = calPad->GetCalROC(isector); - AliTPCCalROC* outlierROC = 0; - if (outlierPad) outlierROC = outlierPad->GetCalROC(isector); - if (calROC) { - median[ivalue] = calROC->GetMedian(); - mean[ivalue] = calROC->GetMean(); - rms[ivalue] = calROC->GetRMS(); - Double_t ltmrmsValue = 0; - ltm[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction); - ltmrms[ivalue] = ltmrmsValue; - if (outlierROC) { - medianWithOut[ivalue] = calROC->GetMedian(outlierROC); - meanWithOut[ivalue] = calROC->GetMean(outlierROC); - rmsWithOut[ivalue] = calROC->GetRMS(outlierROC); - ltmrmsValue = 0; - ltmWithOut[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction, outlierROC); - ltmrmsWithOut[ivalue] = ltmrmsValue; - } - } - else { - median[ivalue] = 0.; - mean[ivalue] = 0.; - rms[ivalue] = 0.; - ltm[ivalue] = 0.; - ltmrms[ivalue] = 0.; - medianWithOut[ivalue] = 0.; - meanWithOut[ivalue] = 0.; - rmsWithOut[ivalue] = 0.; - ltmWithOut[ivalue] = 0.; - ltmrmsWithOut[ivalue] = 0.; - } - } - - // - // fill vectors of variable per pad - // - TVectorF *posArray = new TVectorF[8]; - for (Int_t ivalue = 0; ivalue < 8; ivalue++) - posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); - - Float_t posG[3] = {0}; - Float_t posL[3] = {0}; - Int_t ichannel = 0; - for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) { - for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) { - tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL); - tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG); - posArray[0][ichannel] = irow; - posArray[1][ichannel] = ipad; - posArray[2][ichannel] = posL[0]; - posArray[3][ichannel] = posL[1]; - posArray[4][ichannel] = posG[0]; - posArray[5][ichannel] = posG[1]; - posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2); - posArray[7][ichannel] = ichannel; - - // loop over array containing AliTPCCalPads - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { - AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); - AliTPCCalROC* calROC = calPad->GetCalROC(isector); - if (calROC) - (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad); - else - (vectorArray[ivalue])[ichannel] = 0; - } - ichannel++; - } - } - - cstream << "calPads" << - "sector=" << isector; - - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { - cstream << "calPads" << - (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] << - (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] << - (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] << - (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] << - (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue]; - if (outlierPad) { - cstream << "calPads" << - (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] << - (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] << - (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] << - (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] << - (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue]; - } - } - - for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { - cstream << "calPads" << - (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue]; - } - - if (mapFileName) { - for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { - if (isector < 36) - cstream << "calPads" << - (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue]; - else - cstream << "calPads" << - (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue]; - } - } - - cstream << "calPads" << - "row.=" << &posArray[0] << - "pad.=" << &posArray[1] << - "lx.=" << &posArray[2] << - "ly.=" << &posArray[3] << - "gx.=" << &posArray[4] << - "gy.=" << &posArray[5] << - "rpad.=" << &posArray[6] << - "channel.=" << &posArray[7]; - - cstream << "calPads" << - "\n"; - - delete[] posArray; - delete[] vectorArray; - } - delete[] names; - if (mapFileName) { - delete mapIROCs; - delete mapOROCs; - delete[] mapIROCArray; - delete[] mapOROCArray; - delete[] mapNames; - } -} - - diff --git a/TPC/AliTPCCalPad.h b/TPC/AliTPCCalPad.h index 9b52ca81afa..d2a5fbbae96 100644 --- a/TPC/AliTPCCalPad.h +++ b/TPC/AliTPCCalPad.h @@ -55,12 +55,10 @@ class AliTPCCalPad : public TNamed { TH2F *MakeHisto2D(Int_t side=0); TH1F *MakeHisto1D(Float_t min=4, Float_t max=-4, Int_t type=0); - AliTPCCalPad* LocalFit(const char* padName, Int_t rowRadius, Int_t padRadius, AliTPCCalPad* Padoutliers = 0, Bool_t robust = kFALSE, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7); + AliTPCCalPad* LocalFit(const char* padName, Int_t rowRadius, Int_t padRadius, AliTPCCalPad* Padoutliers = 0, Bool_t robust = kFALSE, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7, Bool_t printCurrentSector = kFALSE) const; AliTPCCalPad* GlobalFit(const char* padName, AliTPCCalPad* Padoutliers = 0, Bool_t robust = kFALSE, Int_t fitType = 1, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7); void GlobalSidesFit(const AliTPCCalPad* PadOutliers, TVectorD &fitParamSideA, TVectorD &fitParamSideC, TMatrixD &covMatrixSideA, TMatrixD &covMatrixSideC, Float_t &chi2SideA, Float_t &chi2SideC, Int_t fitType = 1, Bool_t robust = kFALSE, Double_t chi2Threshold = 5, Double_t robustFraction = 0.7); - - static void MakeTree(const char * fileName, TObjArray * array, const char * mapFileName = 0, AliTPCCalPad* outlierPad = 0, Float_t ltmFraction = 0.9); protected: AliTPCCalROC *fROC[kNsec]; // Array of ROC objects which contain the values per pad ClassDef(AliTPCCalPad,1) // TPC calibration class for parameters which are saved per pad diff --git a/TPC/AliTPCCalibViewer.cxx b/TPC/AliTPCCalibViewer.cxx index fd06aae0962..676db68293a 100644 --- a/TPC/AliTPCCalibViewer.cxx +++ b/TPC/AliTPCCalibViewer.cxx @@ -18,6 +18,19 @@ // // // Class for viewing/visualizing TPC calibration data // // base on TTree functionality for visualization // +// // +// Create a list of AliTPCCalPads, arrange them in an TObjArray. // +// Pass this TObjArray to MakeTree and create the calibration Tree // +// While craating this tree some statistical information are calculated // +// Open the viewer with this Tree: AliTPCCalibViewer v("CalibTree.root") // +// Have fun! // +// EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0") // +// // +// If you like to click, we recommand you the // +// AliTPCCalibViewerGUI // +// // +// THE DOCUMENTATION IS STILL NOT COMPLETED !!!! // +// // /////////////////////////////////////////////////////////////////////////////// // @@ -31,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -179,15 +193,20 @@ Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, const char* sector, c // drawOptions: draw options like 'same' // writeDrawCommand: write the command, that is passed to TTree::Draw // + TString drawStr(drawCommand); TString sectorStr(sector); sectorStr.ToUpper(); TString cutStr(""); - TString drawOptionsStr("profcolz "); + //TString drawOptionsStr("profcolz "); + TString drawOptionsStr(""); TRandom rnd(0); Int_t rndNumber = rnd.Integer(10000); - if (drawOptions && drawOptions != "") + + if (drawOptions && strcmp(drawOptions, "") != 0) drawOptionsStr += drawOptions; + else + drawOptionsStr += "profcolz"; if (sectorStr == "A") { drawStr += ":gy.fElements:gx.fElements>>prof"; @@ -235,6 +254,7 @@ Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, const char* sector, c return fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data()); } + Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, Int_t sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { // // easy drawing of data, use '~' for abbreviation of '.fElements' @@ -253,6 +273,7 @@ Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, Int_t sector, const c return -1; } + //_____________________________________________________________________________ Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, const char* sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { // @@ -300,6 +321,7 @@ Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, const char* sector, return fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data()); } + Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, Int_t sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { // // easy drawing of data, use '~' for abbreviation of '.fElements' @@ -319,236 +341,739 @@ Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, Int_t sector, const return -1; } -//_____________________________________________________________________________ -Int_t AliTPCCalibViewer::DrawHisto1D(const char* type, Int_t sector, TVectorF& nsigma, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { - // - // draws a 1-dimensional histogram of 'type' for sector 'sector' - // TVectorF nsigma: Specifies, for which distances from the mean/median/LTM lines should be drawn, in units of sigma - // example: nsigma={2, 4, 6}: Three lines will be drawn, distance to mean/median/LTM: 2, 3 and 6 sigma - // plotMean, plotMedian, plotLTM: specifies, if mean, median and LTM should be drawn as lines into the histogram - // - TString typeStr(type); - TString sectorStr("sector=="); - sectorStr += sector; +Int_t AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, Int_t sector, const char* cuts, const char *sigmas, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { + // + // Easy drawing of data, in principle the same as EasyDraw1D + // Difference: A line for the mean / median / LTM is drawn + // in 'sigmas' you can specify in which distance to the mean/median/LTM you want to see a line in sigma-units, separated by ';' + // example: sigmas = "2; 4; 6;" at Begin_Latex 2 #sigma End_Latex, Begin_Latex 4 #sigma End_Latex and Begin_Latex 6 #sigma End_Latex a line is drawn. + // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see? + // + if (sector >= 0 && sector < 72) { + char sectorChr[3]; + sprintf(sectorChr, "%i", sector); + return DrawHisto1D(drawCommand, sectorChr, cuts, sigmas, plotMean, plotMedian, plotLTM); + } + Error("DrawHisto1D","The TPC contains only sectors between 0 and 71."); + return -1; +} - TCanvas* canvas = ((TCanvas*)gROOT->GetListOfCanvases()->Last()); + +Int_t AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* sector, const char* cuts, const char *sigmas, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { + // + // Easy drawing of data, in principle the same as EasyDraw1D + // Difference: A line for the mean / median / LTM is drawn + // in 'sigmas' you can specify in which distance to the mean/median/LTM you want to see a line in sigma-units, separated by ';' + // example: sigmas = "2; 4; 6;" at Begin_Latex 2 #sigma End_Latex, Begin_Latex 4 #sigma End_Latex and Begin_Latex 6 #sigma End_Latex a line is drawn. + // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see? + // Int_t oldOptStat = gStyle->GetOptStat(); gStyle->SetOptStat(0000000); - - if (!canvas) { - canvas = new TCanvas(); - fListOfObjectsToBeDeleted->Add(canvas); + Double_t ltmFraction = 0.8; + + TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); + TVectorF nsigma(sigmasTokens->GetEntriesFast()); + for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { + TString str(((TObjString*)sigmasTokens->At(i))->GetString()); + Double_t sig = (str.IsFloat()) ? str.Atof() : 0; + nsigma[i] = sig; } + TString drawStr(drawCommand); + drawStr += " >> tempHist"; + Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts); + TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); + // FIXME is this histogram deleted automatically? + Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers + + Double_t mean = TMath::Mean(entries, values); + Double_t median = TMath::Median(entries, values); + Double_t sigma = TMath::RMS(entries, values); + Double_t maxY = htemp->GetMaximum(); + char c[500]; - sprintf(c, "%s, sector: %i", type, sector); - TLegend * legend = new TLegend(.8,.6, .99, .99, c); + TLegend * legend = new TLegend(.7,.7, .99, .99, "Statistical information"); +// sprintf(c, "%s, sector: %i", type, sector); fListOfObjectsToBeDeleted->Add(legend); - Int_t nentries = fTree->Draw((typeStr+".fElements").Data(), sectorStr.Data(), ""); - ((TH1F*)canvas->GetPrimitive("htemp"))->SetTitle(""); - - //**************************************************************** - //!!!!!!!!!!!!!!!!! Needs further investigaton !!!!!!!!!!!!!!!!!!! - //**************************************************************** - //fListOfObjectsToBeDeleted->Add(canvas->GetPrimitive("htemp")); -/* - By default the temporary histogram created is called "htemp", but only in - the one dimensional Draw("e1") it contains the TTree's data points. For - a two dimensional Draw, the data is filled into a TGraph which is named - "Graph". They can be retrieved by calling - TH1F *htemp = (TH1F*)gPad->GetPrimitive("htemp"); // 1D - TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph"); // 2D -*/ - - canvas->Update(); - Double_t sigma = 0; - if (plotMean) { - fTree->Draw((typeStr+"_Mean").Data(), sectorStr.Data(), "goff"); - Double_t lineX = fTree->GetV1()[0]; - fTree->Draw((typeStr+"_RMS").Data(), sectorStr.Data(), "goff"); - sigma = fTree->GetV1()[0]; - TLine* line = new TLine(lineX, 0, lineX, canvas->GetUymax()); + // draw Mean + TLine* line = new TLine(mean, 0, mean, maxY); fListOfObjectsToBeDeleted->Add(line); line->SetLineColor(kRed); line->SetLineWidth(2); line->SetLineStyle(1); line->Draw(); - sprintf(c, "Mean: %f", lineX); + sprintf(c, "Mean: %f", mean); legend->AddEntry(line, c, "l"); - + // draw sigma lines for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { - TLine* linePlusSigma = new TLine(lineX+nsigma[i]*sigma, 0, lineX+nsigma[i]*sigma, canvas->GetUymax()); + TLine* linePlusSigma = new TLine(mean + nsigma[i] * sigma, 0, mean + nsigma[i] * sigma, maxY); fListOfObjectsToBeDeleted->Add(linePlusSigma); linePlusSigma->SetLineColor(kRed); - linePlusSigma->SetLineStyle(2+i); + linePlusSigma->SetLineStyle(2 + i); linePlusSigma->Draw(); - - TLine* lineMinusSigma = new TLine(lineX-nsigma[i]*sigma, 0, lineX-nsigma[i]*sigma, canvas->GetUymax()); + TLine* lineMinusSigma = new TLine(mean - nsigma[i] * sigma, 0, mean - nsigma[i] * sigma, maxY); fListOfObjectsToBeDeleted->Add(lineMinusSigma); lineMinusSigma->SetLineColor(kRed); - lineMinusSigma->SetLineStyle(2+i); + lineMinusSigma->SetLineStyle(2 + i); lineMinusSigma->Draw(); - sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i]*sigma)); - std::cout << "nsigma-char*: " << c << std::endl; + sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)); legend->AddEntry(lineMinusSigma, c, "l"); } } - if (plotMedian) { - fTree->Draw((typeStr+"_Median").Data(), sectorStr.Data(), "goff"); - Double_t lineX = fTree->GetV1()[0]; - fTree->Draw((typeStr+"_RMS").Data(), sectorStr.Data(), "goff"); - sigma = fTree->GetV1()[0]; - TLine* line = new TLine(lineX, 0, lineX, canvas->GetUymax()); + // draw median + TLine* line = new TLine(median, 0, median, maxY); fListOfObjectsToBeDeleted->Add(line); line->SetLineColor(kBlue); line->SetLineWidth(2); line->SetLineStyle(1); line->Draw(); - sprintf(c, "Median: %f", lineX); + sprintf(c, "Median: %f", median); legend->AddEntry(line, c, "l"); - + // draw sigma lines for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { - TLine* linePlusSigma = new TLine(lineX+nsigma[i]*sigma, 0, lineX+nsigma[i]*sigma, canvas->GetUymax()); + TLine* linePlusSigma = new TLine(median + nsigma[i] * sigma, 0, median + nsigma[i]*sigma, maxY); fListOfObjectsToBeDeleted->Add(linePlusSigma); linePlusSigma->SetLineColor(kBlue); - linePlusSigma->SetLineStyle(2+i); + linePlusSigma->SetLineStyle(2 + i); linePlusSigma->Draw(); - - TLine* lineMinusSigma = new TLine(lineX-nsigma[i]*sigma, 0, lineX-nsigma[i]*sigma, canvas->GetUymax()); + TLine* lineMinusSigma = new TLine(median - nsigma[i] * sigma, 0, median - nsigma[i]*sigma, maxY); fListOfObjectsToBeDeleted->Add(lineMinusSigma); lineMinusSigma->SetLineColor(kBlue); - lineMinusSigma->SetLineStyle(2+i); + lineMinusSigma->SetLineStyle(2 + i); lineMinusSigma->Draw(); - sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i]*sigma)); + sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)); legend->AddEntry(lineMinusSigma, c, "l"); } } - if (plotLTM) { - fTree->Draw((typeStr+"_LTM").Data(), sectorStr.Data(), "goff"); - Double_t lineX = fTree->GetV1()[0]; - fTree->Draw((typeStr+"_RMS_LTM").Data(), sectorStr.Data(), "goff"); - sigma = fTree->GetV1()[0]; - TLine* line = new TLine(lineX, 0, lineX, canvas->GetUymax()); + // draw LTM + Double_t ltmRms = 0; + Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); + TLine* line = new TLine(ltm, 0, ltm, maxY); fListOfObjectsToBeDeleted->Add(line); line->SetLineColor(kGreen+2); line->SetLineWidth(2); line->SetLineStyle(1); line->Draw(); - sprintf(c, "LTM: %f", lineX); + sprintf(c, "LTM: %f", ltm); legend->AddEntry(line, c, "l"); - + // draw sigma lines for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { - TLine* linePlusSigma = new TLine(lineX+nsigma[i]*sigma, 0, lineX+nsigma[i]*sigma, canvas->GetUymax()); + TLine* linePlusSigma = new TLine(ltm + nsigma[i] * ltmRms, 0, ltm + nsigma[i] * ltmRms, maxY); fListOfObjectsToBeDeleted->Add(linePlusSigma); linePlusSigma->SetLineColor(kGreen+2); linePlusSigma->SetLineStyle(2+i); linePlusSigma->Draw(); - TLine* lineMinusSigma = new TLine(lineX-nsigma[i]*sigma, 0, lineX-nsigma[i]*sigma, canvas->GetUymax()); + TLine* lineMinusSigma = new TLine(ltm - nsigma[i] * ltmRms, 0, ltm - nsigma[i] * ltmRms, maxY); fListOfObjectsToBeDeleted->Add(lineMinusSigma); lineMinusSigma->SetLineColor(kGreen+2); lineMinusSigma->SetLineStyle(2+i); lineMinusSigma->Draw(); - sprintf(c, "%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i]*sigma)); + sprintf(c, "%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms)); legend->AddEntry(lineMinusSigma, c, "l"); } } + if (!plotMean && !plotMedian && !plotLTM) return -1; legend->Draw(); gStyle->SetOptStat(oldOptStat); - return nentries; + return 1; } -//_____________________________________________________________________________ -void AliTPCCalibViewer::SigmaCut(const char* type, Int_t sector, Float_t sigmaMax, Float_t sigmaStep, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { - // - // Creates a histogram, where you can see, how much of the data are inside sigma-intervals around the mean/median/LTM - // type: For which type of data the histogram is generated, e.g. 'CEQmean' - // sector: For which sector the histogram is generated - // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated - // sigmaStep: the binsize of the generated histogram - // plotMean/plotMedian/plotLTM: specifies where to put the center - // - Int_t oldOptStat = gStyle->GetOptStat(); - gStyle->SetOptStat(0000000); - TString typeStr(type); - TString sectorStr("sector=="); - sectorStr += sector; - Int_t entries = fTree->Draw((typeStr+".fElements").Data(), sectorStr.Data(), "goff"); - char headline[500]; - sprintf(headline, "%s in sector %i; Multiples of #sigma; Fraction of used pads", type, sector); - TH1F *histMean = new TH1F("histMean",headline, (Int_t)(sigmaMax/sigmaStep+1), 0, sigmaMax+sigmaStep); - sprintf(headline, "%s in sector %i; Multiples of #sigma; Fraction of used pads", type, sector); - TH1F *histMedian = new TH1F("histMedian",headline, (Int_t)(sigmaMax/sigmaStep+1), 0, sigmaMax+sigmaStep); - sprintf(headline, "%s in sector %i; Multiples of #sigma; Fraction of used pads", type, sector); - TH1F *histLTM = new TH1F("histLTM",headline, (Int_t)(sigmaMax/sigmaStep+1), 0, sigmaMax+sigmaStep); - histMean->SetDirectory(0); - histMedian->SetDirectory(0); - histLTM->SetDirectory(0); - fListOfObjectsToBeDeleted->Add(histMean); - fListOfObjectsToBeDeleted->Add(histMedian); - fListOfObjectsToBeDeleted->Add(histLTM); +Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, Int_t sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, const char *sigmas, Float_t sigmaStep) const { + // + // Creates a histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value + // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'array', 'n' specifies the length of the array + // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'array', to be specified by the user + // 'nbins': number of bins, 'binLow': first bin, 'binUp': last bin + // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) + // sigmaStep: the binsize of the generated histogram + // Begin_Latex + // f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx + #int_{#mu}^{#mu - t #sigma} f(x, #mu, #sigma) dx }{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } + // End_Latex + // + // + // Creates a histogram, where you can see, how much of the data are inside sigma-intervals + // around the mean/median/LTM + // with drawCommand, sector and cuts you specify your input data, see EasyDraw + // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma) + // sigmaStep: the binsize of the generated histogram + // plotMean/plotMedian/plotLTM: specifies where to put the center + // + if (sector >= 0 && sector < 72) { + char sectorChr[3]; + sprintf(sectorChr, "%i", sector); + return SigmaCut(drawCommand, sectorChr, cuts, sigmaMax, plotMean, plotMedian, plotLTM, pm, sigmas, sigmaStep); + } + Error("SigmaCut","The TPC contains only sectors between 0 and 71."); + return -1; +} + +Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, const char *sigmas, Float_t sigmaStep) const { + // + // Creates a histogram, where you can see, how much of the data are inside sigma-intervals + // around the mean/median/LTM + // with drawCommand, sector and cuts you specify your input data, see EasyDraw + // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma) + // sigmaStep: the binsize of the generated histogram + // plotMean/plotMedian/plotLTM: specifies where to put the center + // + + Double_t ltmFraction = 0.8; - // example-cut: sector==34 && TMath::Abs(CEQmean.fElements - CEQmean_Mean) < nsigma * CEQmean_RMS - for (Float_t nsigma = 0; nsigma <= sigmaMax; nsigma += sigmaStep) { - std::cout << "Calculating histograms, step: " << (Int_t)(nsigma/sigmaStep) << " of: " << (Int_t)(sigmaMax/sigmaStep) << "\r" << std::flush; - char cuts[5000]; - - if (plotMean) { - sprintf(cuts, "sector==%i && ( %s.fElements - %s_Median) < %f * %s_RMS", sector, type, type, nsigma, type ); - sprintf(cuts, "%s && (-%s.fElements + %s_Median) < %f * %s_RMS", cuts, type, type, nsigma, type ); - Float_t value = (Float_t)fTree->Draw((typeStr+".fElements").Data(), cuts, "goff")/entries; - histMean->Fill(nsigma, value); + TString drawStr(drawCommand); + drawStr += " >> tempHist"; + + Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); + TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); + // FIXME is this histogram deleted automatically? + Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers + + Double_t mean = TMath::Mean(entries, values); + Double_t median = TMath::Median(entries, values); + Double_t sigma = TMath::RMS(entries, values); + + TLegend * legend = new TLegend(.7,.7, .99, .99, "Cumulative"); + fListOfObjectsToBeDeleted->Add(legend); + TH1F *cutHistoMean = 0; + TH1F *cutHistoMedian = 0; + TH1F *cutHistoLTM = 0; + + TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); + TVectorF nsigma(sigmasTokens->GetEntriesFast()); + for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { + TString str(((TObjString*)sigmasTokens->At(i))->GetString()); + Double_t sig = (str.IsFloat()) ? str.Atof() : 0; + nsigma[i] = sig; + } + + if (plotMean) { + cutHistoMean = AliTPCCalibViewer::SigmaCut(htemp, mean, sigma, sigmaMax, sigmaStep, pm); + if (cutHistoMean) { + fListOfObjectsToBeDeleted->Add(cutHistoMean); + cutHistoMean->SetLineColor(kRed); + legend->AddEntry(cutHistoMean, "Mean", "l"); + cutHistoMean->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + cutHistoMean->Draw(); + DrawLines(cutHistoMean, nsigma, legend, kRed, pm); + } // if (cutHistoMean) + + } + if (plotMedian) { + cutHistoMedian = AliTPCCalibViewer::SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm); + if (cutHistoMedian) { + fListOfObjectsToBeDeleted->Add(cutHistoMedian); + cutHistoMedian->SetLineColor(kBlue); + legend->AddEntry(cutHistoMedian, "Median", "l"); + cutHistoMedian->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + if (plotMean && cutHistoMean) cutHistoMedian->Draw("same"); + else cutHistoMedian->Draw(); + DrawLines(cutHistoMedian, nsigma, legend, kBlue, pm); + } // if (cutHistoMedian) + } + if (plotLTM) { + Double_t ltmRms = 0; + Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); + cutHistoLTM = AliTPCCalibViewer::SigmaCut(htemp, ltm, ltmRms, sigmaMax, sigmaStep, pm); + if (cutHistoLTM) { + fListOfObjectsToBeDeleted->Add(cutHistoLTM); + cutHistoLTM->SetLineColor(kGreen+2); + legend->AddEntry(cutHistoLTM, "LTM", "l"); + cutHistoLTM->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + if (plotMean && cutHistoMean || plotMedian && cutHistoMedian) cutHistoLTM->Draw("same"); + else cutHistoLTM->Draw(); + DrawLines(cutHistoLTM, nsigma, legend, kGreen+2, pm); } - if (plotMedian) { - sprintf(cuts, "sector==%i && ( %s.fElements - %s_Mean) < %f * %s_RMS", sector, type, type, nsigma, type ); - sprintf(cuts, "%s && (-%s.fElements + %s_Mean) < %f * %s_RMS", cuts, type, type, nsigma, type ); - Float_t value = (Float_t)fTree->Draw((typeStr+".fElements").Data(), cuts, "goff")/entries; - histMedian->Fill(nsigma, value); + } + if (!plotMean && !plotMedian && !plotLTM) return -1; + legend->Draw(); + return 1; +} + + + + +Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, Int_t sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t sigmaStep) const { + // + // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" + // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user + // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate + // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated + // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used + // The actual work is done on the array. + /* Begin_Latex + f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } + End_Latex + */ + if (sector >= 0 && sector < 72) { + char sectorChr[3]; + sprintf(sectorChr, "%i", sector); + return Integrate(drawCommand, sectorChr, cuts, sigmaMax, plotMean, plotMedian, plotLTM, sigmas, sigmaStep); + } + Error("Integrate","The TPC contains only sectors between 0 and 71."); + return -1; + +} + + +Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t sigmaStep) const { + // + // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" + // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user + // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate + // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated + // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used + // The actual work is done on the array. + /* Begin_Latex + f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } + End_Latex + */ + + Double_t ltmFraction = 0.8; + + TString drawStr(drawCommand); + drawStr += " >> tempHist"; + + Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); + TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); + // FIXME is this histogram deleted automatically? + Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers + + Double_t mean = TMath::Mean(entries, values); + Double_t median = TMath::Median(entries, values); + Double_t sigma = TMath::RMS(entries, values); + + TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); + TVectorF nsigma(sigmasTokens->GetEntriesFast()); + for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { + TString str(((TObjString*)sigmasTokens->At(i))->GetString()); + Double_t sig = (str.IsFloat()) ? str.Atof() : 0; + nsigma[i] = sig; + } + + TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram"); + fListOfObjectsToBeDeleted->Add(legend); + TH1F *integralHistoMean = 0; + TH1F *integralHistoMedian = 0; + TH1F *integralHistoLTM = 0; + + if (plotMean) { + integralHistoMean = AliTPCCalibViewer::Integrate(htemp, mean, sigma, sigmaMax, sigmaStep); + if (integralHistoMean) { + fListOfObjectsToBeDeleted->Add(integralHistoMean); + integralHistoMean->SetLineColor(kRed); + legend->AddEntry(integralHistoMean, "Mean", "l"); + integralHistoMean->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + integralHistoMean->Draw(); + DrawLines(integralHistoMean, nsigma, legend, kRed, kTRUE); + } + } + if (plotMedian) { + integralHistoMedian = AliTPCCalibViewer::Integrate(htemp, median, sigma, sigmaMax, sigmaStep); + if (integralHistoMedian) { + fListOfObjectsToBeDeleted->Add(integralHistoMedian); + integralHistoMedian->SetLineColor(kBlue); + legend->AddEntry(integralHistoMedian, "Median", "l"); + integralHistoMedian->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + if (plotMean && integralHistoMean) integralHistoMedian->Draw("same"); + else integralHistoMedian->Draw(); + DrawLines(integralHistoMedian, nsigma, legend, kBlue, kTRUE); } - if (plotLTM) { - sprintf(cuts, "sector==%i && ( %s.fElements - %s_LTM) < %f * %s_RMS_LTM", sector, type, type, nsigma, type ); - sprintf(cuts, "%s && (-%s.fElements + %s_LTM) < %f * %s_RMS_LTM", cuts, type, type, nsigma, type ); - Float_t value = (Float_t)fTree->Draw((typeStr+".fElements").Data(), cuts, "goff")/entries; - histLTM->Fill(nsigma, value); + } + if (plotLTM) { + Double_t ltmRms = 0; + Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); + integralHistoLTM = AliTPCCalibViewer::Integrate(htemp, ltm, ltmRms, sigmaMax, sigmaStep); + if (integralHistoLTM) { + fListOfObjectsToBeDeleted->Add(integralHistoLTM); + integralHistoLTM->SetLineColor(kGreen+2); + legend->AddEntry(integralHistoLTM, "LTM", "l"); + integralHistoLTM->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); + if (plotMean && integralHistoMean || plotMedian && integralHistoMedian) integralHistoLTM->Draw("same"); + else integralHistoLTM->Draw(); + DrawLines(integralHistoLTM, nsigma, legend, kGreen+2, kTRUE); } } + if (!plotMean && !plotMedian && !plotLTM) return -1; + legend->Draw(); + return 1; +} + + +void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const { + // + // Private function for SigmaCut(...) and Integrate(...) + // Draws lines into the given histogram, specified by "nsigma", the lines are addeed to the legend + // + // start to draw the lines, loop over requested sigmas char c[500]; - sprintf(c, "Sigma Cut"); - TLegend * legend = new TLegend(.85,.8, .99, .99, c); - fListOfObjectsToBeDeleted->Add(legend); + for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { + if (!pm) { + Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]); + TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineUp); + lineUp->SetLineColor(color); + lineUp->SetLineStyle(2 + i); + lineUp->Draw(); + TLine* lineLeft = new TLine(nsigma[i], histogram->GetBinContent(bin), 0, histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineLeft); + lineLeft->SetLineColor(color); + lineLeft->SetLineStyle(2 + i); + lineLeft->Draw(); + sprintf(c, "Fraction(%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)); + legend->AddEntry(lineLeft, c, "l"); + } + else { // if (pm) + Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]); + TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineUp1); + lineUp1->SetLineColor(color); + lineUp1->SetLineStyle(2 + i); + lineUp1->Draw(); + TLine* lineLeft1 = new TLine(nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineLeft1); + lineLeft1->SetLineColor(color); + lineLeft1->SetLineStyle(2 + i); + lineLeft1->Draw(); + sprintf(c, "Fraction(+%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)); + legend->AddEntry(lineLeft1, c, "l"); + bin = histogram->GetXaxis()->FindBin(-nsigma[i]); + TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineUp2); + lineUp2->SetLineColor(color); + lineUp2->SetLineStyle(2 + i); + lineUp2->Draw(); + TLine* lineLeft2 = new TLine(-nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin)); + fListOfObjectsToBeDeleted->Add(lineLeft2); + lineLeft2->SetLineColor(color); + lineLeft2->SetLineStyle(2 + i); + lineLeft2->Draw(); + sprintf(c, "Fraction(-%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)); + legend->AddEntry(lineLeft2, c, "l"); + } + } // for (Int_t i = 0; i < nsigma.GetNoElements(); i++) +} + + + + + + +///////////////// +// Array tools // +///////////////// + + +Int_t AliTPCCalibViewer::GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp){ + // Returns the 'bin' for 'value' + // The interval between 'binLow' and 'binUp' is divided into 'nbins' equidistant bins + // avoid index out of bounds error: 'if (bin < binLow) bin = binLow' and vice versa + /* Begin_Latex + GetBin(value) = #frac{nbins - 1}{binUp - binLow} #upoint (value - binLow) +1 + End_Latex + */ + + Int_t bin = TMath::Nint( (Float_t)(value - binLow) / (Float_t)(binUp - binLow) * (nbins-1) ) + 1; + // avoid index out of bounds: + if (value < binLow) bin = 0; + if (value > binUp) bin = nbins + 1; + return bin; - if (plotMean){ - histMean->SetLineColor(kBlack); - sprintf(c, "Mean"); - legend->AddEntry(histMean, c, "l"); - histMean->Draw(); +} + + +Double_t AliTPCCalibViewer::GetLTM(Int_t n, Double_t *array, Double_t *sigma, Double_t fraction){ + // + // returns the LTM and sigma + // + Double_t *ddata = new Double_t[n]; + Double_t mean = 0, lsigma = 0; + UInt_t nPoints = 0; + for (UInt_t i = 0; i < (UInt_t)n; i++) { + ddata[nPoints]= array[nPoints]; + nPoints++; } - if (plotMedian){ - histMedian->SetLineColor(kRed); - sprintf(c, "Median"); - legend->AddEntry(histMedian, c, "l"); - histMedian->Draw("same"); + Int_t hh = TMath::Min(TMath::Nint(fraction * nPoints), Int_t(n)); + AliMathBase::EvaluateUni(nPoints, ddata, mean, lsigma, hh); + if (sigma) *sigma = lsigma; + delete [] ddata; + return mean; +} + + +TH1F* AliTPCCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm) { + // + // Creates a cumulative histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value + // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'histogram' + // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'histogram', to be specified by the user + // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) + // sigmaStep: the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used + // pm: Decide weather Begin_Latex t > 0 End_Latex (first case) or Begin_Latex t End_Latex arbitrary (secound case) + // The actual work is done on the array. + /* Begin_Latex + f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx + #int_{#mu}^{#mu - t #sigma} f(x, #mu, #sigma) dx }{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } , for t > 0 + or + f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } + End_Latex + begin_macro(source) + { + Float_t mean = 0; + Float_t sigma = 1.5; + Float_t sigmaMax = 4; + gROOT->SetStyle("Plain"); + TH1F *distribution = new TH1F("Distribution", "Distribution f(x, #mu, #sigma)", 1000,-5,5); + TRandom rand(23); + for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma)); + Float_t *ar = distribution->GetArray(); + + TCanvas* macro_example_canvas = new TCanvas("macro_example_canvas", "", 350, 350); + macro_example_canvas->Divide(0,3); + TVirtualPad *pad1 = macro_example_canvas->cd(1); + pad1->SetGridy(); + pad1->SetGridx(); + distribution->Draw(); + TVirtualPad *pad2 = macro_example_canvas->cd(2); + pad2->SetGridy(); + pad2->SetGridx(); + + TH1F *shist = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax); + shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)"); + shist->Draw(); + TVirtualPad *pad3 = macro_example_canvas->cd(3); + pad3->SetGridy(); + pad3->SetGridx(); + TH1F *shistPM = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax, -1, kTRUE); + shistPM->Draw(); + return macro_example_canvas; + } + end_macro + */ + + Float_t *array = histogram->GetArray(); + Int_t nbins = histogram->GetXaxis()->GetNbins(); + Float_t binLow = histogram->GetXaxis()->GetXmin(); + Float_t binUp = histogram->GetXaxis()->GetXmax(); + return AliTPCCalibViewer::SigmaCut(nbins, array, mean, sigma, nbins, binLow, binUp, sigmaMax, sigmaStep, pm); +} + + + +TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm){ + // + // Creates a histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value + // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'array', 'n' specifies the length of the array + // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'array', to be specified by the user + // 'nbins': number of bins, 'binLow': first bin, 'binUp': last bin + // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) + // sigmaStep: the binsize of the generated histogram + // Here the actual work is done. + + if (sigma == 0) return 0; + Float_t binWidth = (binUp-binLow)/(nbins - 1); + if (sigmaStep <= 0) sigmaStep = binWidth; + Int_t kbins = (Int_t)(sigmaMax * sigma / sigmaStep) + 1; // + 1 due to overflow bin in histograms + if (pm) kbins = 2 * (Int_t)(sigmaMax * sigma / sigmaStep) + 1; + Float_t kbinLow = !pm ? 0 : -sigmaMax; + Float_t kbinUp = sigmaMax; + TH1F *hist = new TH1F("sigmaCutHisto","Cumulative; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); + hist->SetDirectory(0); + hist->Reset(); + + // calculate normalization + Double_t normalization = 0; + for (Int_t i = 0; i <= n; i++) { + normalization += array[i]; } - if (plotLTM){ - histLTM->SetLineColor(kBlue); - sprintf(c, "LTM"); - legend->AddEntry(histLTM, c, "l"); - histLTM->Draw("same"); - } + + // given units: units from given histogram + // sigma units: in units of sigma + // iDelta: integrate in interval (mean +- iDelta), given units + // x: ofset from mean for integration, given units + // hist: needs + +// printf("nbins: %i, binLow: %f, binUp: %f \n", nbins, binLow, binUp); + // fill histogram + for (Float_t iDelta = 0; iDelta <= sigmaMax * sigma; iDelta += sigmaStep) { + // integrate array + Double_t valueP = array[GetBin(mean, nbins, binLow, binUp)]; + Double_t valueM = array[GetBin(mean-binWidth, nbins, binLow, binUp)]; + // add bin of mean value only once to the histogram +// printf("++ adding bins: "); + for (Float_t x = binWidth; x <= iDelta; x += binWidth) { + valueP += (mean + x <= binUp) ? array[GetBin(mean + x, nbins, binLow, binUp)] : 0; + valueM += (mean-binWidth - x >= binLow) ? array[GetBin(mean-binWidth - x, nbins, binLow, binUp)] : 0; +// printf("%i, ", GetBin(mean + x, nbins, binLow, binUp)); + } +// printf("\n"); + if (valueP / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", valueP, normalization); + if (valueP / normalization > 100) return hist; + if (valueM / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", valueM, normalization); + if (valueM / normalization > 100) return hist; + valueP = (valueP / normalization); + valueM = (valueM / normalization); + if (pm) { + Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); + hist->SetBinContent(bin, valueP); + bin = GetBin(-iDelta/sigma, kbins, kbinLow, kbinUp); + hist->SetBinContent(bin, valueM); + } + else { // if (!pm) + Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); + hist->SetBinContent(bin, valueP + valueM); +// printf(" first integration bin: %i, last integration bin in + direction: %i \n", GetBin(mean+binWidth, nbins, binLow, binUp), GetBin(iDelta, nbins, binLow, binUp)); +// printf(" first integration bin: %i, last integration bin in - direction: %i \n", GetBin(mean+binWidth, nbins, binLow, binUp), GetBin(-iDelta, nbins, binLow, binUp)); +// printf(" value: %f, normalization: %f, iDelta: %f, Bin: %i \n", valueP+valueM, normalization, iDelta, bin); + } + } + //hist->SetMaximum(0.7); + if (!pm) hist->SetMaximum(1.2); + return hist; +} - legend->Draw(); - gStyle->SetOptStat(oldOptStat); + +TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma, Int_t nbins, Double_t *xbins, Double_t sigmaMax){ + // + // SigmaCut for variable binsize + // NOT YET IMPLEMENTED !!! + // + printf("SigmaCut with variable binsize, Not yet implemented\n"); + // avoid compiler warnings: + n=n; + mean=mean; + sigma=sigma; + nbins=nbins; + sigmaMax=sigmaMax; + array=array; + xbins=xbins; + + return 0; +} + + +TH1F* AliTPCCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){ + // + // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" + // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user + // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate + // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated + // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used + // The actual work is done on the array. + /* Begin_Latex + f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #frac{#int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } + End_Latex + begin_macro(source) + { + Float_t mean = 0; + Float_t sigma = 1.5; + Float_t sigmaMax = 4; + gROOT->SetStyle("Plain"); + TH1F *distribution = new TH1F("Distribution", "Distribution f(x, #mu, #sigma)", 1000,-5,5); + TRandom rand(23); + for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma)); + Float_t *ar = distribution->GetArray(); + + TCanvas* macro_example_canvas = new TCanvas("macro_example_canvas", "", 350, 350); + macro_example_canvas->Divide(0,2); + TVirtualPad *pad1 = macro_example_canvas->cd(1); + pad1->SetGridy(); + pad1->SetGridx(); + distribution->Draw(); + TVirtualPad *pad2 = macro_example_canvas->cd(2); + pad2->SetGridy(); + pad2->SetGridx(); + TH1F *shist = AliTPCCalibViewer::Integrate(distribution, mean, sigma, sigmaMax); + shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)"); + shist->Draw(); + + return macro_example_canvas; + } + end_macro + */ + + + Float_t *array = histogram->GetArray(); + Int_t nbins = histogram->GetXaxis()->GetNbins(); + Float_t binLow = histogram->GetXaxis()->GetXmin(); + Float_t binUp = histogram->GetXaxis()->GetXmax(); + return AliTPCCalibViewer::Integrate(nbins, array, nbins, binLow, binUp, mean, sigma, sigmaMax, sigmaStep); +} + + +TH1F* AliTPCCalibViewer::Integrate(Int_t n, Float_t *array, Int_t nbins, Float_t binLow, Float_t binUp, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){ + // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" + // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user + // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate + // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated + // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used + // Here the actual work is done. + + Bool_t givenUnits = kTRUE; + if (sigma != 0 && sigmaMax != 0) givenUnits = kFALSE; + if (givenUnits) { + sigma = 1; + sigmaMax = (binUp - binLow) / 2.; + } + + Float_t binWidth = (binUp-binLow)/(nbins - 1); + if (sigmaStep <= 0) sigmaStep = binWidth; + Int_t kbins = (Int_t)(sigmaMax * sigma / sigmaStep) + 1; // + 1 due to overflow bin in histograms + Float_t kbinLow = givenUnits ? binLow : -sigmaMax; + Float_t kbinUp = givenUnits ? binUp : sigmaMax; + TH1F *hist = 0; + if (givenUnits) hist = new TH1F("integratedHisto","Integrated Histogram; Given x; Fraction of included data", kbins, kbinLow, kbinUp); + if (!givenUnits) hist = new TH1F("integratedHisto","Integrated Histogram; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); + hist->SetDirectory(0); + hist->Reset(); + + // calculate normalization + // printf("calculating normalization, integrating from bin 1 to %i \n", n); + Double_t normalization = 0; + for (Int_t i = 1; i <= n; i++) { + normalization += array[i]; + } + // printf("normalization: %f \n", normalization); + + // given units: units from given histogram + // sigma units: in units of sigma + // iDelta: integrate in interval (mean +- iDelta), given units + // x: ofset from mean for integration, given units + // hist: needs + + // fill histogram + for (Float_t iDelta = mean - sigmaMax * sigma; iDelta <= mean + sigmaMax * sigma; iDelta += sigmaStep) { + // integrate array + Double_t value = 0; + for (Float_t x = mean - sigmaMax * sigma; x <= iDelta; x += binWidth) { + value += (x <= binUp && x >= binLow) ? array[GetBin(x, nbins, binLow, binUp)] : 0; + } + if (value / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", value, normalization); + if (value / normalization > 100) return hist; + Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); + // printf("first integration bin: %i, last integration bin: %i \n", GetBin(mean - sigmaMax * sigma, nbins, binLow, binUp), GetBin(iDelta, nbins, binLow, binUp)); + // printf("value: %f, normalization: %f, normalized value: %f, iDelta: %f, Bin: %i \n", value, normalization, value/normalization, iDelta, bin); + value = (value / normalization); + hist->SetBinContent(bin, value); + } + return hist; } + + + +//////////////////////// +// end of Array tools // +//////////////////////// + + + //_____________________________________________________________________________ AliTPCCalPad* AliTPCCalibViewer::GetCalPad(const char* desiredData, char* cuts, char* calPadName) const { // @@ -625,7 +1150,7 @@ TObjArray* AliTPCCalibViewer::GetListOfVariables(Bool_t printList) { } -TObjArray* AliTPCCalibViewer::GetListOfNormalizationVariables(Bool_t printList) { +TObjArray* AliTPCCalibViewer::GetListOfNormalizationVariables(Bool_t printList) const{ // // produces a list of available variables for normalization in the tree // printList: print the list to the screen, after the scan is done @@ -642,6 +1167,8 @@ TObjArray* AliTPCCalibViewer::GetListOfNormalizationVariables(Bool_t printList) arr->Add(new TObjString("GFitIntern_Par.fElements")); arr->Add(new TObjString("FitLinLocal")); arr->Add(new TObjString("FitLinGlobal")); + arr->Add(new TObjString("FitParLocal")); + arr->Add(new TObjString("FitParGlobal")); if (printList) { TIterator* iter = arr->MakeIterator(); @@ -759,7 +1286,6 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co } - void AliTPCCalibViewer::MakeTreeWithObjects(const char * fileName, TObjArray * array, const char * mapFileName) { // // Write tree with all available information @@ -788,11 +1314,11 @@ void AliTPCCalibViewer::MakeTreeWithObjects(const char * fileName, TObjArray * a mapNames = new TString[mapEntries]; for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { - TString ROCname(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); - ROCname.Remove(ROCname.Length()-4, 4); - mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "IROC").Data()), ivalue); - mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "OROC").Data()), ivalue); - mapNames[ivalue].Append(ROCname); + TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); + rocName.Remove(rocName.Length()-4, 4); + mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue); + mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue); + mapNames[ivalue].Append(rocName); } for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { @@ -908,13 +1434,20 @@ void AliTPCCalibViewer::MakeTreeWithObjects(const char * fileName, TObjArray * a } } + void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) { // // Write a tree with all available information - // im mapFileName is speciefied, the Map information are also written to the tree + // if mapFileName is speciefied, the Map information are also written to the tree // pads specified in outlierPad are not used for calculating statistics - // - the same function as AliTPCCalPad::MakeTree - - // + // The following statistical information on the basis of a ROC are calculated: + // "_Median", "_Mean", "_LTM", "_RMS_LTM" + // "_Median_OutlierCutted", "_Mean_OutlierCutted", "_RMS_OutlierCutted", "_LTM_OutlierCutted", "_RMS_LTM_OutlierCutted" + // The following position variables are available: + // "row", "pad", "lx", "ly", "gx", "gy", "rpad", "channel" + // + // The tree out of this function is the basis for the AliTPCCalibViewer and the AliTPCCalibViewerGUI. + AliTPCROC* tpcROCinstance = AliTPCROC::Instance(); TObjArray* mapIROCs = 0; @@ -936,11 +1469,11 @@ void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const mapNames = new TString[mapEntries]; for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { - TString ROCname(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); - ROCname.Remove(ROCname.Length()-4, 4); - mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "IROC").Data()), ivalue); - mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((ROCname + "OROC").Data()), ivalue); - mapNames[ivalue].Append(ROCname); + TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); + rocName.Remove(rocName.Length()-4, 4); + mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue); + mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue); + mapNames[ivalue].Append(rocName); } for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { @@ -956,7 +1489,8 @@ void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const } // if (mapFileName) TTreeSRedirector cstream(fileName); - Int_t arrayEntries = array->GetEntries(); + Int_t arrayEntries = 0; + if (array) arrayEntries = array->GetEntries(); TString* names = new TString[arrayEntries]; for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) diff --git a/TPC/AliTPCCalibViewer.h b/TPC/AliTPCCalibViewer.h index 3100a11dfad..8971cf8a465 100644 --- a/TPC/AliTPCCalibViewer.h +++ b/TPC/AliTPCCalibViewer.h @@ -18,6 +18,9 @@ #include "AliTPCCalROC.h" #include "TFriendElement.h" +#include "AliMathBase.h" +class TLegend; + class AliTPCCalibViewer : public TObject { public: @@ -37,15 +40,20 @@ public: Int_t EasyDraw(const char* drawCommand, Int_t sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const; // easy drawing of data, use '~' for abbreviation of '.fElements' Int_t EasyDraw1D(const char* drawCommand, const char* sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const; // easy drawing of data, use '~' for abbreviation of '.fElements' Int_t EasyDraw1D(const char* drawCommand, Int_t sector, const char* cuts = 0, const char* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const; // easy drawing of data, use '~' for abbreviation of '.fElements' - Int_t DrawHisto1D(const char* type, Int_t sector, TVectorF& nsigma, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts - void SigmaCut(const char* type, Int_t sector, Float_t sigmaMax = 5, Float_t sigmaStep = 0.5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws fraction of used pads over different sigma cuts + + Int_t DrawHisto1D(const char* drawCommand, Int_t sector, const char* cuts = 0, const char *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts + Int_t DrawHisto1D(const char* drawCommand, const char* sector, const char* cuts = 0, const char *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE) const; // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts + Int_t SigmaCut(const char* drawCommand, Int_t sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const char *sigmas = "", Float_t sigmaStep = -1) const; // draws fraction of used pads over different sigma cuts + Int_t SigmaCut(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const char *sigmas = "", Float_t sigmaStep = -1) const; // draws fraction of used pads over different sigma cuts + Int_t Integrate(const char* drawCommand, const char* sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, const char *sigmas = "", Float_t sigmaStep = -1) const; // draws an integrated histogram + Int_t Integrate(const char* drawCommand, Int_t sector, const char* cuts = 0, Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, Bool_t plotLTM = kTRUE, const char *sigmas = "", Float_t sigmaStep = -1) const; // draws an integrated histogram AliTPCCalPad* GetCalPad(const char* desiredData, char* cuts = "", char* calPadName = "NoName") const; // returns an AliTPCCalPad object containing the specified data with cuts applied AliTPCCalROC* GetCalROC(const char* desiredData, UInt_t sector, char* cuts = "") const; // returns an AliTPCCalROC object containing the specified data for sector with cuts applied TObjArray* GetArrayOfCalPads(); TObjArray* GetListOfVariables(Bool_t printList = kFALSE); - TObjArray* GetListOfNormalizationVariables(Bool_t printList = kFALSE); + TObjArray* GetListOfNormalizationVariables(Bool_t printList = kFALSE) const; static void MakeTreeWithObjects(const char * fileName, TObjArray * array, const char * mapFileName = 0); static void MakeTree(const char * fileName, TObjArray * array, const char * mapFileName = 0, AliTPCCalPad* outlierPad = 0, Float_t ltmFraction = 0.9); @@ -57,13 +65,30 @@ public: TTree * GetTree() { return fTree;} TString* Fit(const char* drawCommand, const char* formula, const char* cuts, Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix); - + + // + // Array tools + // + static Double_t GetLTM(Int_t n, Double_t *array, Double_t *sigma = 0, Double_t fraction = 0.9); + static Int_t GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp); + static TH1F* SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE); + static TH1F* SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE); + static TH1F* Integrate(TH1F *histogram, Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1); + static TH1F* Integrate(Int_t n, Float_t *array, Int_t nbins, Float_t binLow, Float_t binUp, Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1); + + static TH1F* SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma, Int_t nbins, Double_t *xbins, Double_t sigmaMax); + + + protected: TTree* fTree; // tree containing visualization data (e.g. written by AliTPCCalPad::MakeTree(...) TFile* fFile; // file that contains a calPads tree (e.g. written by AliTPCCalPad::MakeTree(...) TObjArray* fListOfObjectsToBeDeleted; //Objects, that will be deleted when the destructor ist called Bool_t fTreeMustBeDeleted; // decides weather the tree must be deleted in destructor or not + void DrawLines(TH1F *cutHistoMean, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const; + + ClassDef(AliTPCCalibViewer,1) // TPC calibration viewer class }; diff --git a/TPC/AliTPCCalibViewerGUI.cxx b/TPC/AliTPCCalibViewerGUI.cxx index f2480fa76b4..baf2cc98df3 100644 --- a/TPC/AliTPCCalibViewerGUI.cxx +++ b/TPC/AliTPCCalibViewerGUI.cxx @@ -18,17 +18,50 @@ // // // GUI for the AliTPCCalibViewer // // used for the calibration monitor // +// All functionalities of the AliTPCCalibViewer are here available +// // Example usage: // /* aliroot - AliTPCCalibViewerGUI::showGUI("allInOne22.root") + AliTPCCalibViewerGUI::ShowGUI("CalibTree.root") + Begin_macro(source,gui) + { + char* fileName = "CalibTreeEmpty.root"; + AliTPCCalibViewer::MakeTree(fileName, 0, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root"); + gROOT->SetStyle("Plain"); + // content of AliTPCCalibViewerGUI::ShowGUI(...) + TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); + frmMain->SetWindowName("AliTPCCalibViewer GUI"); + frmMain->SetCleanup(kDeepCleanup); + + TGTab* tabMain = new TGTab(frmMain, 1000, 600); + frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + + TGCompositeFrame* tabCont1 = tabMain->AddTab("Viewer 1"); + TGCompositeFrame* tabCont2 = tabMain->AddTab("Viewer 2"); + + AliTPCCalibViewerGUI* calibViewer1 = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, fileName); + tabCont1->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + + AliTPCCalibViewerGUI* calibViewer2 = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, fileName); + tabCont2->AddFrame(calibViewer2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + + frmMain->MapSubwindows(); + frmMain->Resize(); + frmMain->MapWindow(); + + return frmMain; + + } + End_macro */ -// - Resize windows - (BUG to BE FIXED -> ROOT bug) // +// // // // /////////////////////////////////////////////////////////////////////////////// #include "AliTPCCalibViewerGUI.h" +#include #include #include @@ -39,6 +72,23 @@ #include #include #include +#include "TStyle.h" +#include "AliTPCCalibViewer.h" + +// #include "TGListBox.h" +// #include "TGNumberEntry" +// #include "TGSplitter" +// #include "TGTab" +// #include "TGLabel" +// #include "TGButtonGroup" +// #include "TGComboBox" +// #include "TRootEmbeddedCanvas" +// #include "TGButton" +// #include "TGRadioButton" +// #include "GTCheckButton" +// #include "TGTextEntry" + + ClassImp(AliTPCCalibViewerGUI) @@ -49,6 +99,9 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fContTopBottom(0), fContLCR(0), fContLeft(0), + ftabLeft(0), + ftabLeft0(0), + ftabLeft1(0), fContRight(0), fContCenter(0), fContPlotOpt(0), @@ -64,6 +117,7 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fContScaling(0), fContSetMax(0), fContSetMin(0), + fContAddDrawOpt(0), fListVariables(0), fBtnDraw(0), fBtnFit(0), @@ -80,12 +134,15 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fRadioSideA(0), fRadioSideC(0), fRadioSector(0), + fComboAddDrawOpt(0), fChkAuto(0), fComboMethod(0), fListNormalization(0), fComboCustom(0), + fChkAddDrawOpt(0), fNmbSector(0), fLblSector(0), + fChkCutZero(0), fChkAddCuts(0), fComboAddCuts(0), fComboCustomFit(0), @@ -93,14 +150,52 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fChkSetMin(0), fChkGetMinMaxAuto(0), fTxtSetMax(0), - fTxtSetMin(0) -// -// AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing -// + fTxtSetMin(0) , + fContDrawOpt1D(0), + fcontDrawOpt1DSubLR(0), + fContDrawOpt1DSubNSC(0), + fRadioNorm(0), + fRadioSigma(0), + fTxtSigmas(0), + fContCumuLR(0), + fContCumLeft(0), + fContCumRight(0), + fLblSigmaMax(0), + fTxtSigmaMax(0), + fRadioCumulative(0), + fCheckCumulativePM(0), + fRadioIntegrate(0), + fContDrawOpt1DSubMML(0), + fChkMean(0), + fChkMedian(0), + fChkLTM(0), + fContStatOpt(0), + fChkStatName(0), + fChkStatEntries(0), + fContStatMean(0), + fChkStatMean(0), + fChkStatMeanPM(0), + fContStatRMS(0), + fChkStatRMS(0), + fChkStatRMSPM(0), + fChkStatUnderflow(0), + fChkStatOverflow(0), + fChkStatIntegral(0), + fContStatSkew(0), + fChkStatSkewness(0), + fChkStatSkewnessPM(0), + fContStatKurt(0), + fChkStatKurtosis(0), + fChkStatKurtosisPM(0) { + // + // AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing + // SetCleanup(kDeepCleanup); + // ***************************************************************************** // ************************* content of this MainFrame ************************* + // ***************************************************************************** // top level container with horizontal layout fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight); AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); @@ -108,8 +203,9 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight); fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); - + // *********************************************************************** // ************************* content of fContLCR ************************* + // *********************************************************************** // left container fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight); fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3)); @@ -132,241 +228,466 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h splitRight->SetFrame(fContRight, kFALSE); fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0)); + + // ======================================================================== // ************************* content of fContLeft ************************* + // ======================================================================== + // --- draw button and tabLeft --- // draw button fBtnDraw = new TGTextButton(fContLeft, "&Draw"); fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0)); //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")"); fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoDraw()"); - // draw options container - fContDrawOpt = new TGGroupFrame(fContLeft, "Plot options", kVerticalFrame | kFitWidth | kFitHeight); - fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); - fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 20, kHorizontalFrame | kFitWidth | kFixedHeight); - fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + // three tabs on the left side: + ftabLeft = new TGTab(fContLeft); + fContLeft->AddFrame(ftabLeft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0)); + ftabLeft0 = ftabLeft->AddTab("General"); + ftabLeft1 = ftabLeft->AddTab("More plot options"); + + // **************************** content of tabLeft0 ******************************* + + // draw options container *** fcontDrawOpt *** " Plot options " + fContDrawOpt = new TGGroupFrame(ftabLeft0, "Plot options", kVerticalFrame | kFitWidth | kFitHeight); + ftabLeft0->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); + fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight); + fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ------------------------- content of fContDrawOpt ------------------------- + // -- radio1D, radio2D, chkAuto + // 1D radio button + fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30); + fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); + fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // 2D radio button + fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31); + fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); + fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // additional draw options container + fContAddDrawOpt = new TGCompositeFrame(fContDrawOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContDrawOpt->AddFrame(fContAddDrawOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + + // content of --- fContAddDrawOpt --- + // addition draw options label + fChkAddDrawOpt = new TGCheckButton(fContAddDrawOpt, "Draw options:"); + //fChkAddDrawOpt->SetTextJustify(kTextLeft); + fContAddDrawOpt->AddFrame(fChkAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); + fChkAddDrawOpt->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // additional draw options combo box + fComboAddDrawOpt = new TGComboBox(fContAddDrawOpt); + fComboAddDrawOpt->Resize(0, fBtnDraw->GetDefaultHeight()); + fComboAddDrawOpt->EnableTextInput(kTRUE); + fContAddDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // automatic redraw check button + fChkAuto = new TGCheckButton(fContDrawOpt, "auto redraw"); + fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); + + + // *** predefined radio button *** " Predefined " + fRadioPredefined = new TGRadioButton(ftabLeft0, "Predefined: ", 13); + ftabLeft0->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioPredefined->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // list of variables + fListVariables = new TGListBox(ftabLeft0); + ftabLeft0->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0)); + fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - // predefined radio button - fRadioPredefined = new TGRadioButton(fContLeft, "Predefined: ", 13); - fContLeft->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioPredefined->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); + + // normalization options container *** fContPlotOpt *** + //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContPlotOpt = new TGGroupFrame(ftabLeft0, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight); + ftabLeft0->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0)); + + // ------------------------- content of fContPlotOpt ------------------------- + // raw radio button + fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10); + fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // normalized radio button + fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11); + fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // normalized options container *** fContNormalized *** + fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0)); + + // --- content of fContNormalized --- + // --- combo box to select 'subtract' or 'divide', list of normalization variables + // method drop down combo box + fComboMethod = new TGComboBox(fContNormalized); + fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight()); + fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // list of normalization variables + fListNormalization = new TGListBox(fContNormalized); + fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // custom radio button + fRadioCustom = new TGRadioButton(ftabLeft0, "Custom: ", 12); + ftabLeft0->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioCustom->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()"); + + // custom options container + // --- fComboCustom --- the custom draw line + fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); - // list of variables - fListVariables = new TGListBox(fContLeft); - fContLeft->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0)); - fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + // ------------------------- content of fContCustom ------------------------- + // text field for custom draw command + fComboCustom = new TGComboBox(fContCustom); + fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight()); + fComboCustom->EnableTextInput(kTRUE); + fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fComboCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=42)"); + fComboCustom->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + - // plot options container - //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContPlotOpt = new TGGroupFrame(fContLeft, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight); - fContLeft->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0)); - - // custom radio button - fRadioCustom = new TGRadioButton(fContLeft, "Custom: ", 12); - fContLeft->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioCustom->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); + + // **************************** content of tabLeft1 ******************************* + + // draw options container *** fcontDrawOpt1D *** " Plot options " + fContDrawOpt1D = new TGGroupFrame(ftabLeft1, "1D Plot options", kVerticalFrame | kFitWidth | kFitHeight); + ftabLeft1->AddFrame(fContDrawOpt1D, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); + + fcontDrawOpt1DSubLR = new TGCompositeFrame(fContDrawOpt1D, 1, 1, kVerticalFrame | kFitWidth | kFitHeight); + fContDrawOpt1D->AddFrame(fcontDrawOpt1DSubLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ***** content of fContDrawOpt1DSubLR ***** + fContDrawOpt1DSubNSC = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight); + fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubNSC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // --------------------------- content of fContDrawOpt1DSubNSC ----------------- + fRadioNorm = new TGRadioButton(fContDrawOpt1DSubNSC, "Normal", 110); + fContDrawOpt1DSubNSC->AddFrame(fRadioNorm, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fRadioNorm->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fRadioSigma = new TGRadioButton(fContDrawOpt1DSubNSC, "Sigma", 111); + fContDrawOpt1DSubNSC->AddFrame(fRadioSigma, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); + fRadioSigma->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fTxtSigmas = new TGTextEntry(fContDrawOpt1DSubNSC, "2; 4; 6", 111); + fContDrawOpt1DSubNSC->AddFrame(fTxtSigmas, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0)); + fTxtSigmas->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons1D(=111)"); + + fContCumuLR = new TGCompositeFrame(fContDrawOpt1DSubNSC, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight); + fContDrawOpt1DSubNSC->AddFrame(fContCumuLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0)); + + fContCumLeft = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight); + fContCumuLR->AddFrame(fContCumLeft, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fRadioCumulative = new TGRadioButton(fContCumLeft, "Cumulative", 112); + fContCumLeft->AddFrame(fRadioCumulative, new TGLayoutHints(kLHintsNormal, 0, 10, 0, 0)); + fRadioCumulative->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fCheckCumulativePM = new TGCheckButton(fContCumLeft, "Plus/Minus"); + fContCumLeft->AddFrame(fCheckCumulativePM, new TGLayoutHints(kLHintsNormal, 10, 15, 0, 0)); + fCheckCumulativePM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fRadioIntegrate = new TGRadioButton(fContCumLeft, "Integrate", 113); + fContCumLeft->AddFrame(fRadioIntegrate, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); + fRadioIntegrate->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fContCumRight = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight); + fContCumuLR->AddFrame(fContCumRight, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fLblSigmaMax = new TGLabel(fContCumRight, "SigmaMax:"); + fLblSigmaMax->SetTextJustify(kTextLeft); + fContCumRight->AddFrame(fLblSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0)); + + fTxtSigmaMax = new TGTextEntry(fContCumRight, "5", 112); + fContCumRight->AddFrame(fTxtSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0)); + fTxtSigmaMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons1D(=112)"); + + + fContDrawOpt1DSubMML = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight); + fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubMML, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0)); + + // -------------- content of fcontDrawOpt1DSubLR + fChkMean = new TGCheckButton(fContDrawOpt1DSubMML, "Mean"); + fContDrawOpt1DSubMML->AddFrame(fChkMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkMean->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fChkMedian = new TGCheckButton(fContDrawOpt1DSubMML, "Median"); + fContDrawOpt1DSubMML->AddFrame(fChkMedian, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkMedian->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + fChkLTM = new TGCheckButton(fContDrawOpt1DSubMML, "LTM"); + fContDrawOpt1DSubMML->AddFrame(fChkLTM, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkLTM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()"); + + + // statistic options container *** fcontStatOpt1D *** " Statistic options " + fContStatOpt = new TGGroupFrame(ftabLeft1, "Statistic options", kVerticalFrame | kFitWidth | kFitHeight); + ftabLeft1->AddFrame(fContStatOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); + + fChkStatName = new TGCheckButton(fContStatOpt, "Name"); + fContStatOpt->AddFrame(fChkStatName, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatName->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatEntries = new TGCheckButton(fContStatOpt, "Entries"); + fContStatOpt->AddFrame(fChkStatEntries, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatEntries->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fContStatMean = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight); + fContStatOpt->AddFrame(fContStatMean, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fChkStatMean = new TGCheckButton(fContStatMean, "Mean"); + fContStatMean->AddFrame(fChkStatMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatMean->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatMeanPM = new TGCheckButton(fContStatMean, "+- Error"); + fContStatMean->AddFrame(fChkStatMeanPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0)); + fChkStatMeanPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fContStatRMS = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight); + fContStatOpt->AddFrame(fContStatRMS, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fChkStatRMS = new TGCheckButton(fContStatRMS, "RMS"); + fContStatRMS->AddFrame(fChkStatRMS, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatRMS->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatRMSPM = new TGCheckButton(fContStatRMS, "+- Error"); + fContStatRMS->AddFrame(fChkStatRMSPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0)); + fChkStatRMSPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatUnderflow = new TGCheckButton(fContStatOpt, "Underflow"); + fContStatOpt->AddFrame(fChkStatUnderflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatUnderflow->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatOverflow = new TGCheckButton(fContStatOpt, "Overflow"); + fContStatOpt->AddFrame(fChkStatOverflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatOverflow->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatIntegral = new TGCheckButton(fContStatOpt, "Integral"); + fContStatOpt->AddFrame(fChkStatIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatIntegral->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fContStatSkew = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight); + fContStatOpt->AddFrame(fContStatSkew, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fChkStatSkewness = new TGCheckButton(fContStatSkew, "Skewness"); + fContStatSkew->AddFrame(fChkStatSkewness, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatSkewness->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatSkewnessPM = new TGCheckButton(fContStatSkew, "+- Error"); + fContStatSkew->AddFrame(fChkStatSkewnessPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0)); + fChkStatSkewnessPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fContStatKurt = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight); + fContStatOpt->AddFrame(fContStatKurt, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + fChkStatKurtosis = new TGCheckButton(fContStatKurt, "Kurtosis"); + fContStatKurt->AddFrame(fChkStatKurtosis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkStatKurtosis->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); + + fChkStatKurtosisPM = new TGCheckButton(fContStatKurt, "+- Error"); + fContStatKurt->AddFrame(fChkStatKurtosisPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0)); + fChkStatKurtosisPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()"); - // custom options container - fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); + + + + // ========================================================================== + // ************************* content of fContCenter ************************* + // ======================================================================== + // main drawing canvas + fCanvMain = new TRootEmbeddedCanvas("Main Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight); + fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + + + + + // ========================================================================= // ************************* content of fContRight ************************* + // ======================================================================== // cut options container //fContCuts = new TGCompositeFrame(fContRight, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); fContCuts = new TGGroupFrame(fContRight, "Cuts", kVerticalFrame | kFitWidth | kFitHeight); fContRight->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - // Fit options container - fContFit = new TGGroupFrame(fContRight, "Custom Fit", kVerticalFrame | kFitWidth | kFitHeight); - fContRight->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ************************* content of fContCuts ************************* + // TPC radio button + fRadioTPC = new TGRadioButton(fContCuts, "whole TPC", 20); + fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // side A radio button + fRadioSideA = new TGRadioButton(fContCuts, "side A", 21); + fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // side C radio button + fRadioSideC = new TGRadioButton(fContCuts, "side C", 22); + fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // sector radio button + fRadioSector = new TGRadioButton(fContCuts, "sector", 23); + fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // sector options container + fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); + fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0)); + + // ------------------------- content of fContSector ------------------------- + // sector number entry + fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71); + fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "ChangeSector()"); + + // sector number label + fLblSector = new TGLabel(fContSector, "IROC, A"); + fLblSector->SetTextJustify(kTextLeft); + fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0)); + + // additional cuts check button + fChkCutZero = new TGCheckButton(fContCuts, "Cut zeros"); + fContCuts->AddFrame(fChkCutZero, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkCutZero->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // additional cuts check button + fChkAddCuts = new TGCheckButton(fContCuts, "additional cuts"); + fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // additional cuts container + fContAddCuts = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContCuts->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0)); + + // ------------------------- content of fContAddCuts ------------------------- + // combo text field for additional cuts + fComboAddCuts = new TGComboBox(fContAddCuts); + fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight()); + fComboAddCuts->EnableTextInput(kTRUE); + fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fComboAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + fComboAddCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + // Scaling options container fContScaling = new TGGroupFrame(fContRight, "Scaling", kVerticalFrame | kFitWidth | kFitHeight); fContRight->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ************************* content of fContScaling ************************* + // SetMaximum container + fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ------------------------- content of fContSetMax ------------------------- + // SetMaximum - checkbox + fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max."); + fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkSetMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // text field for maximum value + fTxtSetMax = new TGTextEntry(fContSetMax, "", 41); + fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fTxtSetMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); - // ************************* content of fContCenter ************************* - // main drawing canvas - fCanvMain = new TRootEmbeddedCanvas("Main Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight); - fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + // SetMinimum container + fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ------------------------- content of fContSetMin ------------------------- + // SetMinimum - checkbox + fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min."); + fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkSetMin->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + // text field for minimum value + fTxtSetMin = new TGTextEntry(fContSetMin, "", 40); + fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fTxtSetMin->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsRight()"); + + // get Min & Max from Plot - button + fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot"); + fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fBtnGetMinMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "GetMinMax()"); + + // GetMinMaxAuto - checkbox + fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto."); + fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); + fChkGetMinMaxAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); + + + // Fit options container + fContFit = new TGGroupFrame(fContRight, "Custom Fit", kVerticalFrame | kFitWidth | kFitHeight); + fContRight->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + + // ------------------------- content of fContFit ------------------------- + // container for additional fits + fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); + fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0)); + + // --- content of fContAddFit --- + // text field for custom fit + fComboCustomFit = new TGComboBox(fContAddFit); + fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight()); + fComboCustomFit->EnableTextInput(kTRUE); + fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); + fComboCustomFit->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoFit()"); + fComboCustomFit->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoFit()"); + + // fit button + fBtnFit = new TGTextButton(fContAddFit, "&Fit"); + fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + fBtnFit->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoFit()"); + + // add fit function button + //fBtnAddFitFunction = new TGTextButton(fContAddFit, "&Add fit function to normalization"); + //fContAddFit->AddFrame(fBtnAddFitFunction, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); + //fBtnAddFitFunction->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "AddFitFunction()"); + + // set default button states + fRadioPredefined->SetState(kButtonDown); + fRadioRaw->SetState(kButtonDown); + fRadioTPC->SetState(kButtonDown); + fRadio1D->SetState(kButtonDown); + fChkAuto->SetState(kButtonDown); + fChkAddCuts->SetState(kButtonUp); + fChkGetMinMaxAuto->SetState(kButtonDown); + fChkSetMin->SetState(kButtonUp); + fChkSetMax->SetState(kButtonUp); + fRadioNorm->SetState(kButtonDown); + fRadioSigma->SetState(kButtonUp); + fRadioCumulative->SetState(kButtonUp); + fChkMean->SetState(kButtonDown); + fCheckCumulativePM->SetState(kButtonUp); + fChkStatName->SetState(kButtonDown); + fChkStatEntries->SetState(kButtonDown); + fChkStatMean->SetState(kButtonDown); + fChkStatRMS->SetState(kButtonDown); +// fChkStatMeanPM->SetState(kButtonUp); +// fChkStatRMSPM->SetState(kButtonUp); +// fChkStatUnderflow->SetState(kButtonUp); +// fChkStatOverflow->SetState(kButtonUp); +// fChkStatIntegral->SetState(kButtonUp); +// fChkStatSkewness->SetState(kButtonUp); +// fChkStatSkewnessPM->SetState(kButtonUp); +// fChkStatKurtosis->SetState(kButtonUp); +// fChkStatKurtosisPM->SetState(kButtonUp); + + // ====================================================================== + // ************************* Display everything ************************* + // ====================================================================== - // ************************* content of fContPlotOpt ************************* - //TGButtonGroup *fBtngrpPlotOpt = new TGButtonGroup(fContPlotOpt, "Plot options", - // raw radio button - fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10); - fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // normalized radio button - fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11); - fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - //fContPlotOpt->Show(); - - // normalized options container - fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0)); - - // ************************* content of fContDrawOpt ************************* - // 1D radio button - fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30); -// fContDrawOpt->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); - fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); - fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // 2D radio button - fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31); - fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); - fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // automatic redraw check button - fChkAuto = new TGCheckButton(fContDrawOpt, "auto redraw"); - fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); - - // ************************* content of fContCuts ************************* - // TPC radio button - fRadioTPC = new TGRadioButton(fContCuts, "whole TPC", 20); - fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // side A radio button - fRadioSideA = new TGRadioButton(fContCuts, "side A", 21); - fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // side C radio button - fRadioSideC = new TGRadioButton(fContCuts, "side C", 22); - fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // sector radio button - fRadioSector = new TGRadioButton(fContCuts, "sector", 23); - fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // sector options container - fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); - fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0)); - - // additional cuts check button - fChkAddCuts = new TGCheckButton(fContCuts, "additional cuts"); - fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); - fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // additional cuts container - fContAddCuts = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContCuts->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0)); - - // ************************* content of fContNormalized ************************* - // method drop down combo box - fComboMethod = new TGComboBox(fContNormalized); - fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight()); - fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // list of normalization variables - fListNormalization = new TGListBox(fContNormalized); - fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); - fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // ************************* content of fContCustom ************************* - // text field for custom draw command - fComboCustom = new TGComboBox(fContCustom); - fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight()); - fComboCustom->EnableTextInput(kTRUE); - fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fComboCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons(=42)"); - fComboCustom->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // ************************* content of fContSector ************************* - // sector number entry - fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71); - fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "ChangeSector()"); - - // sector number label - fLblSector = new TGLabel(fContSector, "IROC, A"); - fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); - - // ************************* content of fContAddCuts ************************* - // combo text field for additional cuts - fComboAddCuts = new TGComboBox(fContAddCuts); - fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight()); - fComboAddCuts->EnableTextInput(kTRUE); - fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fComboAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - fComboAddCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // ************************* content of fContFit ************************* - // container for additional fits - fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0)); - - // ************************* content of fContAddFit ************************* - // text field for custom fit - fComboCustomFit = new TGComboBox(fContAddFit); - fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight()); - fComboCustomFit->EnableTextInput(kTRUE); - fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fComboCustomFit->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoFit()"); - fComboCustomFit->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoFit()"); - - // fit button - fBtnFit = new TGTextButton(fContAddFit, "&Fit"); - fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fBtnFit->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoFit()"); - - // add fit function button - //fBtnAddFitFunction = new TGTextButton(fContAddFit, "&Add fit function to normalization"); - //fContAddFit->AddFrame(fBtnAddFitFunction, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - //fBtnAddFitFunction->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "AddFitFunction()"); - - // ************************* content of fContScaling ************************* - // SetMaximum container - fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - - // SetMinimum container - fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight); - fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - - // get Min & Max from Plot - button - fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot"); - fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); - fBtnGetMinMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "GetMinMax()"); - - // GetMinMaxAuto - checkbox - fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto."); - fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); - fChkGetMinMaxAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - - // ************************* content of fContSetMax ************************* - // SetMaximum - checkbox - fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max."); - fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); - fChkSetMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // text field for maximum value - fTxtSetMax = new TGTextEntry(fContSetMax, "", 41); - fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fTxtSetMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - // ************************* content of fContSetMin ************************* - // SetMinimum - checkbox - fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min."); - fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); - fChkSetMin->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); - - // text field for minimum value - fTxtSetMin = new TGTextEntry(fContSetMin, "", 40); - fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); - fTxtSetMin->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()"); - - - // Display everything - Initialize(fileName); + if (fileName) Initialize(fileName); SetWindowName("AliTPCCalibViewer GUI"); MapSubwindows(); Resize(GetDefaultSize()); @@ -379,6 +700,9 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c) fContTopBottom(0), fContLCR(0), fContLeft(0), + ftabLeft(0), + ftabLeft0(0), + ftabLeft1(0), fContRight(0), fContCenter(0), fContPlotOpt(0), @@ -394,6 +718,7 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c) fContScaling(0), fContSetMax(0), fContSetMin(0), + fContAddDrawOpt(0), fListVariables(0), fBtnDraw(0), fBtnFit(0), @@ -410,12 +735,15 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c) fRadioSideA(0), fRadioSideC(0), fRadioSector(0), + fComboAddDrawOpt(0), fChkAuto(0), fComboMethod(0), fListNormalization(0), fComboCustom(0), + fChkAddDrawOpt(0), fNmbSector(0), fLblSector(0), + fChkCutZero(0), fChkAddCuts(0), fComboAddCuts(0), fComboCustomFit(0), @@ -423,7 +751,43 @@ AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c) fChkSetMin(0), fChkGetMinMaxAuto(0), fTxtSetMax(0), - fTxtSetMin(0) + fTxtSetMin(0), + fContDrawOpt1D(0), + fcontDrawOpt1DSubLR(0), + fContDrawOpt1DSubNSC(0), + fRadioNorm(0), + fRadioSigma(0), + fTxtSigmas(0), + fContCumuLR(0), + fContCumLeft(0), + fContCumRight(0), + fLblSigmaMax(0), + fTxtSigmaMax(0), + fRadioCumulative(0), + fCheckCumulativePM(0), + fRadioIntegrate(0), + fContDrawOpt1DSubMML(0), + fChkMean(0), + fChkMedian(0), + fChkLTM(0), + fContStatOpt(0), + fChkStatName(0), + fChkStatEntries(0), + fContStatMean(0), + fChkStatMean(0), + fChkStatMeanPM(0), + fContStatRMS(0), + fChkStatRMS(0), + fChkStatRMSPM(0), + fChkStatUnderflow(0), + fChkStatOverflow(0), + fChkStatIntegral(0), + fContStatSkew(0), + fChkStatSkewness(0), + fChkStatSkewnessPM(0), + fContStatKurt(0), + fChkStatKurtosis(0), + fChkStatKurtosisPM(0) { // // dummy AliTPCCalibViewerGUI copy constructor @@ -438,6 +802,9 @@ AliTPCCalibViewerGUI & AliTPCCalibViewerGUI::operator =(const AliTPCCalibViewerG } AliTPCCalibViewerGUI::~AliTPCCalibViewerGUI() { + // + // Destructor + // if (fCanvMain && fCanvMain->GetCanvas()) { for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) { if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0) @@ -495,19 +862,28 @@ void AliTPCCalibViewerGUI::Initialize(char* fileName) { arr->Delete(); delete arr; - // set default button states - fRadioPredefined->SetState(kButtonDown); - fRadioRaw->SetState(kButtonDown); - fRadioTPC->SetState(kButtonDown); - fRadio1D->SetState(kButtonDown); - fChkAuto->SetState(kButtonDown); - fChkAddCuts->SetState(kButtonUp); + // fill fComboAddDrawOpt with some additional drawing options + fComboAddDrawOpt->AddEntry("profbox", 0); + fComboAddDrawOpt->AddEntry("profcolz", 1); + fComboAddDrawOpt->AddEntry("profcont0", 2); + fComboAddDrawOpt->AddEntry("proflego", 3); + fComboAddDrawOpt->AddEntry("proflego2", 4); + fComboAddDrawOpt->AddEntry("profsurf", 5); + fComboAddDrawOpt->AddEntry("profsurf1", 6); + fComboAddDrawOpt->AddEntry("profsurf2", 7); + fComboAddDrawOpt->AddEntry("box", 8); + fComboAddDrawOpt->AddEntry("colz", 9); + fComboAddDrawOpt->AddEntry("cont0", 10); + fComboAddDrawOpt->AddEntry("lego", 11); + fComboAddDrawOpt->AddEntry("lego2", 12); + fComboAddDrawOpt->AddEntry("surf", 13); + fComboAddDrawOpt->AddEntry("surf1", 14); + fComboAddDrawOpt->AddEntry("surf2", 15); + + fListVariables->Select(0); fListNormalization->Select(0); fComboMethod->Select(0); - fChkGetMinMaxAuto->SetState(kButtonDown); - fChkSetMin->SetState(kButtonUp); - fChkSetMax->SetState(kButtonUp); //fCanvMain->GetCanvas()->ToggleEventStatus(); // klappt nicht //fCanvMain->GetCanvas()->GetCanvasImp()->ShowStatusBar(kTRUE); // klappt auch nicht @@ -516,9 +892,12 @@ void AliTPCCalibViewerGUI::Initialize(char* fileName) { DoDraw(); } -void AliTPCCalibViewerGUI::HandleButtons(Int_t id) { + + +void AliTPCCalibViewerGUI::HandleButtonsGeneral(Int_t id) { // // handles mutual radio button exclusions + // for general Tab // if (id == -1) { TGButton *btn = (TGButton *) gTQSender; @@ -530,8 +909,8 @@ void AliTPCCalibViewerGUI::HandleButtons(Int_t id) { fRadioNormalized->SetState(kButtonUp); fRadioPredefined->SetState(kButtonDown); fRadioCustom->SetState(kButtonUp); - //fComboMethod->UnmapWindow(); - //fListNormalization->UnmapWindow(); + // fComboMethod->UnmapWindow(); + // fListNormalization->UnmapWindow(); break; case 11: // fRadioNormalized fRadioRaw->SetState(kButtonUp); @@ -540,13 +919,127 @@ void AliTPCCalibViewerGUI::HandleButtons(Int_t id) { break; case 12: // fRadioCustom fRadioPredefined->SetState(kButtonUp); - //fRadioNormalized->SetState(kButtonUp); + // fComboCustom->SetEnabled(kFALSE); + // fRadioNormalized->SetState(kButtonUp); + break; + case 42: // fComboCustom + fRadioCustom->SetState(kButtonDown); + fRadioPredefined->SetState(kButtonUp); break; case 13: // fRadioPredefined fRadioCustom->SetState(kButtonUp); - //fRadioNormalized->SetState(kButtonUp); + // fComboCustom->SetEnabled(kTRUE); + //f RadioNormalized->SetState(kButtonUp); break; //-------- + case 30: // fRadio1D + fRadio2D->SetState(kButtonUp); + break; + case 31: // fRadio2D + fRadio1D->SetState(kButtonUp); + break; + } + DoNewSelection(); +} + + +void AliTPCCalibViewerGUI::HandleButtons1D(Int_t id) { + // + // handles mutual radio button exclusions + // 1D-Tab buttons + // + + if (id == -1) { + TGButton *btn = (TGButton *) gTQSender; + id = btn->WidgetId(); + } + switch (id) { + case 110: // 1D draw normal + fRadioNorm->SetState(kButtonDown); + fRadioSigma->SetState(kButtonUp); + fRadioCumulative->SetState(kButtonUp); + fRadioIntegrate->SetState(kButtonUp); + break; + case 111: // 1D draw sigma + fRadioNorm->SetState(kButtonUp); + fRadioSigma->SetState(kButtonDown); + fRadioCumulative->SetState(kButtonUp); + fRadioIntegrate->SetState(kButtonUp); + break; + case 112: // 1D draw cumulative + fRadioNorm->SetState(kButtonUp); + fRadioSigma->SetState(kButtonUp); + fRadioCumulative->SetState(kButtonDown); + fRadioIntegrate->SetState(kButtonUp); + break; + case 113: // 1D draw integral + fRadioNorm->SetState(kButtonUp); + fRadioSigma->SetState(kButtonUp); + fRadioCumulative->SetState(kButtonUp); + fRadioIntegrate->SetState(kButtonDown); + break; + } + DoNewSelection(); +} + + +void AliTPCCalibViewerGUI::HandleButtons2D(Int_t id) { + // + // handles mutual radio button exclusions + // 2D-Tab buttons + // + if (id == -1) { + TGButton *btn = (TGButton *) gTQSender; + id = btn->WidgetId(); + } + + switch (id) { + case 211: + break; + } + DoNewSelection(); +} + + +void AliTPCCalibViewerGUI::HandleButtonsStat(Int_t id) { + // + // handles statistic check boxes + // checks each checkbox if checked + // if the checkbox is checked, appends 'n' for name, 'e' for entries, ... + // to a TString, passes this TString to gStyle->SetOptStat(...) + // + id = id; // to avoid compiler warnings + TString statOpt(""); + if (fChkStatName->GetState() == kButtonDown) statOpt.Append("n"); + if (fChkStatEntries->GetState() == kButtonDown) statOpt.Append("e"); + if (fChkStatMean->GetState() == kButtonDown && fChkStatMeanPM->GetState() == kButtonUp) statOpt.Append("m"); + if (fChkStatMeanPM->GetState() == kButtonDown) statOpt.Append("M"); + if (fChkStatRMS->GetState() == kButtonDown && fChkStatRMSPM->GetState() == kButtonUp) statOpt.Append("r"); + if (fChkStatRMSPM->GetState() == kButtonDown) statOpt.Append("R"); + if (fChkStatUnderflow->GetState() == kButtonDown) statOpt.Append("u"); + if (fChkStatOverflow->GetState() == kButtonDown) statOpt.Append("o"); + if (fChkStatIntegral->GetState() == kButtonDown) statOpt.Append("i"); + if (fChkStatSkewness->GetState() == kButtonDown && fChkStatSkewnessPM->GetState() == kButtonUp) statOpt.Append("s"); + if (fChkStatSkewnessPM->GetState() == kButtonDown) statOpt.Append("S"); + if (fChkStatKurtosis->GetState() == kButtonDown && fChkStatKurtosisPM->GetState() == kButtonUp) statOpt.Append("k"); + if (fChkStatKurtosisPM->GetState() == kButtonDown) statOpt.Append("K"); + + gStyle->SetOptStat(statOpt); + DoNewSelection(); +} + + +void AliTPCCalibViewerGUI::HandleButtonsRight(Int_t id) { + // + // handles mutual radio button exclusions + // right side buttons + // + if (id == -1) { + TGButton *btn = (TGButton *) gTQSender; + id = btn->WidgetId(); + } + + switch (id) { case 20: // fRadioTPC fRadioSideA->SetState(kButtonUp); fRadioSideC->SetState(kButtonUp); @@ -567,28 +1060,18 @@ void AliTPCCalibViewerGUI::HandleButtons(Int_t id) { fRadioSideA->SetState(kButtonUp); fRadioSideC->SetState(kButtonUp); break; - //-------- - case 30: // fRadio1D - fRadio2D->SetState(kButtonUp); - break; - case 31: // fRadio2D - fRadio1D->SetState(kButtonUp); - break; - //-------- case 40: // fTxtSetMin fChkSetMin->SetState(kButtonDown); break; case 41: // fTxtSetMax fChkSetMax->SetState(kButtonDown); break; - case 42: // fComboCustom - fRadioCustom->SetState(kButtonDown); - fRadioPredefined->SetState(kButtonUp); - break; } DoNewSelection(); } + + void AliTPCCalibViewerGUI::DoNewSelection() { // // decides whether to redraw if user makes another selection @@ -597,6 +1080,7 @@ void AliTPCCalibViewerGUI::DoNewSelection() { if (fChkAuto->GetState() == kButtonDown) DoDraw(); } + void AliTPCCalibViewerGUI::DoDraw() { // // main method for drawing according to user selection @@ -606,7 +1090,7 @@ void AliTPCCalibViewerGUI::DoDraw() { TString desiredData(""); if (!fListVariables->GetSelectedEntry()) return; desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); - desiredData += ".fElements"; + desiredData += "~"; // specify normalization if (fRadioPredefined->GetState() == kButtonDown && fRadioNormalized->GetState() == kButtonDown) { @@ -650,6 +1134,10 @@ void AliTPCCalibViewerGUI::DoDraw() { formulaStr = "lx~ ++ ly~"; if (normalizationData.CompareTo("FitLinGlobal") == 0) formulaStr = "gx~ ++ gy~"; + if (normalizationData.CompareTo("FitParLocal") == 0) + formulaStr = "lx~ ++ ly~ ++ lx~^2 ++ ly~^2 ++ lx~*ly~"; + if (normalizationData.CompareTo("FitParGlobal") == 0) + formulaStr = "gx~ ++ gy~ ++ gx~^2 ++ gy~^2 ++ gx~*gy~"; normalizationData = *fViewer->Fit(desiredData.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix); } @@ -676,8 +1164,19 @@ void AliTPCCalibViewerGUI::DoDraw() { sectorStr += sector; //cuts += "sector=="; } TString cutsStr(""); + + + if (fChkCutZero->GetState() == kButtonDown) { + cutsStr += desiredData.Data(); + cutsStr += "!=0"; + if (fChkAddCuts->GetState() == kButtonDown) cutsStr += " && "; + } if (fChkAddCuts->GetState() == kButtonDown) cutsStr += fComboAddCuts->GetTextEntry()->GetText(); + + TString addDrawOpt(""); + if (fChkAddDrawOpt->GetState() == kButtonDown) + addDrawOpt += fComboAddDrawOpt->GetTextEntry()->GetText(); // draw finally for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) { @@ -687,27 +1186,57 @@ void AliTPCCalibViewerGUI::DoDraw() { //fCanvMain->GetCanvas()->Clear(); fCanvMain->GetCanvas()->cd(); Int_t entries = -1; - if (fRadio1D->GetState() == kButtonDown) - entries = fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data()); - else if (fRadio2D->GetState() == kButtonDown) - entries = fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data()); - if (entries == -1) return; + if (fRadio1D->GetState() == kButtonDown){ + // 1D-Drawing + TString strSigmaMax(fTxtSigmaMax->GetText()); // get sigmaMax from text enty + Double_t sigmaMax = (strSigmaMax.IsFloat()) ? strSigmaMax.Atof() : 5; // convert to double, if not convertable, set to 5 + Bool_t plotMean = fChkMean->GetState() == kButtonDown; + Bool_t plotMedian = fChkMedian->GetState() == kButtonDown; + Bool_t plotLTM = fChkLTM->GetState() == kButtonDown; + if (fRadioNorm->GetState() == kButtonDown) // normal 1D drawing + entries = fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data()); + if (fRadioSigma->GetState() == kButtonDown) // sigma 1D drawing + entries = fViewer->DrawHisto1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // + fTxtSigmas->GetText(), plotMean, plotMedian, plotLTM); + if (fRadioCumulative->GetState() == kButtonDown) // cumulative 1D drawing + entries = fViewer->SigmaCut(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // + sigmaMax, plotMean, plotMedian, plotLTM, // + fCheckCumulativePM->GetState() == kButtonDown, fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1); + if (fRadioIntegrate->GetState() == kButtonDown) // integral 1D drawing + entries = fViewer->Integrate(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // + sigmaMax, plotMean, plotMedian, plotLTM, // + fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1); + } + else if (fRadio2D->GetState() == kButtonDown) { + // 2D-Drawing + entries = fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data()); + } + if (entries == -1) return; // nothing was drawn, there is no histogram to get min and max + + // get or set Min & Max + // + // search for histogram TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives(); TObject* ptr = 0; for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) { 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 == 0 || !ptr->InheritsFrom("TH1") ) { // if the loop did not find a TH1 + fCanvMain->GetCanvas()->Update(); + return; + // unable to find histogram, no min and max wil be read out + } TH1 *hist = (TH1*)ptr; TString minTxt(fTxtSetMin->GetText()); TString maxTxt(fTxtSetMax->GetText()); + // set min and max according to specified values, if checkbox is checked if (fChkSetMax->GetState() == kButtonDown && (maxTxt.IsDigit() || maxTxt.IsFloat()) ) hist->SetMaximum(maxTxt.Atof()); if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) ) hist->SetMinimum(minTxt.Atof()); - + // get min and max from plot if (fChkGetMinMaxAuto->GetState() == kButtonDown) { if (fChkSetMax->GetState() == kButtonUp) fTxtSetMax->SetText(Form("%f", hist->GetMaximum())); @@ -828,7 +1357,7 @@ void AliTPCCalibViewerGUI::ChangeSector(){ DoNewSelection(); } -void AliTPCCalibViewerGUI::AddFitFunction(){ +void AliTPCCalibViewerGUI::AddFitFunction() const { // // adds the last fit function to the normalization list // diff --git a/TPC/AliTPCCalibViewerGUI.h b/TPC/AliTPCCalibViewerGUI.h index 2e432fb0d4a..1acc2515f8c 100644 --- a/TPC/AliTPCCalibViewerGUI.h +++ b/TPC/AliTPCCalibViewerGUI.h @@ -1,5 +1,5 @@ -#ifndef ALITPCCALIBVIEWERGUI -#define ALITPCCALIBVIEWERGUI +#ifndef ALITPCCALIBVIEWERGUI_H +#define ALITPCCALIBVIEWERGUI_H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ @@ -29,19 +29,57 @@ #include #include #include +class AliTPCCalibViewer; -#include -#include "AliTPCCalibViewer.h" +// class TGListBox; +// class TGNumberEntry; +// class TGSplitter; +// class TGTab; +// class TGWidget; // ??? +// class TGLabel; +// class TGButtonGroup; +// class TGComboBox; +// class TRootEmbeddedCanvas; +// class TGButton; +// class TGRadioButton; +// class TGCheckButton; +// class TGTextEntry; + + +class AliTPCCalibViewerGUI : public TGCompositeFrame { + +public: + AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName); // constructor; fileName specifies the ROOT tree used for drawing + AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c); // copy constructor + AliTPCCalibViewerGUI &operator = (const AliTPCCalibViewerGUI ¶m); // assignment operator + virtual ~AliTPCCalibViewerGUI(); + // virtual void CloseWindow(); -class AliTPCCalibViewerGUI : public TGCompositeFrame { + void HandleButtonsGeneral(Int_t id = -1); // handles mutual radio button exclusions for general Tab + void HandleButtons1D(Int_t id = -1); // handles mutual radio button exclusions for 1D Tab + void HandleButtons2D(Int_t id = -1); // handles mutual radio button exclusions for 2D Tab + void HandleButtonsStat(Int_t id = -1); // handles statistic check boxes + void HandleButtonsRight(Int_t id = -1); // handles mutual radio button exclusions for right side + void DoNewSelection(); // decides whether to redraw if user makes another selection + void DoDraw(); // main method for drawing according to user selection + void DoFit(); // main method for fitting + void GetMinMax(); // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax + void ChangeSector(); // function that is called, when the number of the sector is changed + void AddFitFunction() const; // adds the last fit function to the normalization list + static void ShowGUI(const char* fileName); //initialize and show GUI for presentation + + protected: AliTPCCalibViewer *fViewer; // CalibViewer object used for drawing TGCompositeFrame *fContTopBottom; // container for all GUI elements, vertical divided TGCompositeFrame *fContLCR; // container for all GUI elements, horizontal divided TGCompositeFrame *fContLeft; // container for GUI elements on left side + TGTab *ftabLeft; // Tabs on the left side for plot options + TGCompositeFrame *ftabLeft0; // Tab 0 on the left side for general plot options + TGCompositeFrame *ftabLeft1; // Tab 1 on the left side for 1D plot options TGCompositeFrame *fContRight; // container for GUI elements on right side TGCompositeFrame *fContCenter; // container for GUI elements at the center TGCompositeFrame *fContPlotOpt; // container for plot options GUI elements @@ -57,6 +95,7 @@ protected: TGCompositeFrame *fContScaling; // container for scaling GUI elements TGCompositeFrame *fContSetMax; // container for SetMaximum elements TGCompositeFrame *fContSetMin; // container for SetMinimum elements + TGCompositeFrame *fContAddDrawOpt; // additional draw options container TGListBox *fListVariables; // listbox with possible variables TGTextButton *fBtnDraw; // draw button TGTextButton *fBtnFit; // fit button @@ -73,12 +112,15 @@ protected: TGRadioButton *fRadioSideA; // side A radio button TGRadioButton *fRadioSideC; // side C radio button TGRadioButton *fRadioSector; // sector radio button + TGComboBox *fComboAddDrawOpt; // additional draw options combo box TGCheckButton *fChkAuto; // automatic redraw checkbox TGComboBox *fComboMethod; // normalization methods dropdown box TGListBox *fListNormalization; // listbox with possible normalization variables TGComboBox *fComboCustom; // combo box for custom draw commands + TGCheckButton *fChkAddDrawOpt; // additional draw options check box TGNumberEntry *fNmbSector; // number entry box for specifying the sector TGLabel *fLblSector; // label that shows the active sector + TGCheckButton *fChkCutZero; // cut zeros check box TGCheckButton *fChkAddCuts; // additional cuts check box TGComboBox *fComboAddCuts; // additional cuts combo box TGComboBox *fComboCustomFit; // custom fit combo box @@ -87,26 +129,45 @@ protected: TGCheckButton *fChkGetMinMaxAuto; // Get Min & Max automatically from plot TGTextEntry *fTxtSetMax; // custom maximum text box TGTextEntry *fTxtSetMin; // custom minimum text box + TGGroupFrame *fContDrawOpt1D; // container in tabLeft1 + TGCompositeFrame *fcontDrawOpt1DSubLR; // container in tabLeft1 to divide L/R + TGCompositeFrame *fContDrawOpt1DSubNSC; // container in tabLeft1 for following radio buttons + TGRadioButton *fRadioNorm; // radio button for normal 1D drawing + TGRadioButton *fRadioSigma; // radio button for sigma 1D drawing + TGTextEntry *fTxtSigmas; // text box to specify sigmas + TGCompositeFrame *fContCumuLR; // container in tabLeft1 for two colums for cumulative and integrative + TGCompositeFrame *fContCumLeft; // container in tabLeft1 for cumulative, left + TGCompositeFrame *fContCumRight; // container in tabLeft1 for cumulative, right + TGLabel *fLblSigmaMax; // label to indicate sigmaMax + TGTextEntry *fTxtSigmaMax; // text box to specify sigmaMax + TGRadioButton *fRadioCumulative; // radio button for cumulative 1D drawing + TGCheckButton *fCheckCumulativePM; // checkbox for plus/minus cumulative 1D drawing + TGRadioButton *fRadioIntegrate; // radio button for integral 1D drawing + TGCompositeFrame *fContDrawOpt1DSubMML; // container in tabLeft1 for following check boxes + TGCheckButton *fChkMean; // checkbox to plot mean + TGCheckButton *fChkMedian; // checkbox to plot median + TGCheckButton *fChkLTM; // checkbox to plot LTM + TGGroupFrame *fContStatOpt; // container for statistic options in tabLeft1 + TGCheckButton *fChkStatName; // checkbox to display histogram name in statistic legend + TGCheckButton *fChkStatEntries; // checkbox to display entries in statistic legend + TGCompositeFrame *fContStatMean; // container for mean and its error in stat opt + TGCheckButton *fChkStatMean; // checkbox to display mean in statistic legend + TGCheckButton *fChkStatMeanPM; // checkbox to display mean error in statistic legend + TGCompositeFrame *fContStatRMS; // container for RMS and its error in stat opt + TGCheckButton *fChkStatRMS; // checkbox to display RMS in statistic legend + TGCheckButton *fChkStatRMSPM; // checkbox to display RMS error in statistic legend + TGCheckButton *fChkStatUnderflow; // checkbox to display underflow error in statistic legend + TGCheckButton *fChkStatOverflow; // checkbox to display overflow error in statistic legend + TGCheckButton *fChkStatIntegral; // checkbox to display integral in statistic legend + TGCompositeFrame *fContStatSkew; // container for skewness and its error in stat opt + TGCheckButton *fChkStatSkewness; // checkbox to display skewness in statistic legend + TGCheckButton *fChkStatSkewnessPM; // checkbox to display skewness error in statistic legend + TGCompositeFrame *fContStatKurt; // container for kurtosis and its error in stat opt + TGCheckButton *fChkStatKurtosis; // checkbox to display kurtosis in statistic legend + TGCheckButton *fChkStatKurtosisPM; // checkbox to display kurtosis error in statistic legend - void Initialize(char* fileName); // initializes the GUI with default settings and opens tree for drawing -public: - AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName); // constructor; fileName specifies the ROOT tree used for drawing - AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c); // copy constructor - AliTPCCalibViewerGUI &operator = (const AliTPCCalibViewerGUI ¶m); // assignment operator - - virtual ~AliTPCCalibViewerGUI(); - // virtual void CloseWindow(); - - void HandleButtons(Int_t id = -1); // handles mutual radio button exclusions - void DoNewSelection(); // decides whether to redraw if user makes another selection - void DoDraw(); // main method for drawing according to user selection - void DoFit(); // main method for fitting - void GetMinMax(); // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax - void ChangeSector(); // function that is called, when the number of the sector is changed - void AddFitFunction(); // adds the last fit function to the normalization list - static void ShowGUI(const char* fileName); //initialize and show GUI for presentation ClassDef(AliTPCCalibViewerGUI, 0) }; -- 2.43.0