#include "AliTPCCalibViewerGUI.h"
+#include "AliTPCCalPad.h"
#include <iostream>
#include <TCanvas.h>
#include <TVirtualPad.h>
#include <TROOT.h>
+#include <TMath.h>
#include <TObjArray.h>
#include <TObjString.h>
#include <TVector.h>
fRadioTPC(0),
fRadioSideA(0),
fRadioSideC(0),
+ fRadioROC(0),
fRadioSector(0),
fComboAddDrawOpt(0),
fChkAuto(0),
}
-void AliTPCCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) {
+void AliTPCCalibViewerGUI::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
//
// draw the GUI
//
// ======================================================================
SetCleanup(kDeepCleanup);
- p = p; // to avoid compiler warnings
// *****************************************************************************
// ************************* content of this MainFrame *************************
fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
fRadioSideC->SetToolTipText("Use only side C.");
- // sector radio button
- fRadioSector = new TGRadioButton(fContCuts, "ROC", 23);
+ // roc radio button
+ fRadioROC = new TGRadioButton(fContCuts, "ROC", 23);
+ fContCuts->AddFrame(fRadioROC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+ fRadioROC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
+ fRadioROC->SetToolTipText("Use only one ROC (readout chamber).");
+
+ // sector radio button
+ fRadioSector = new TGRadioButton(fContCuts, "Sector", 24);
fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
- fRadioSector->SetToolTipText("Use only one ROC (readout chamber).");
+ fRadioSector->SetToolTipText("Use only one Sector (0-17 A-Side, 18-35 C-Side).");
// sector options container
fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
fRadioTPC(0),
fRadioSideA(0),
fRadioSideC(0),
+ fRadioROC(0),
fRadioSector(0),
fComboAddDrawOpt(0),
fChkAuto(0),
*/
-void AliTPCCalibViewerGUI::Initialize(char* fileName, char* treeName) {
+void AliTPCCalibViewerGUI::Initialize(const char* fileName, const char* treeName) {
//
// initialize the GUI with a calibrationTree from fileName
//
if (fInitialized && currentStr->GetString() == selectedVariable) variableId = id;
id++;
}
- delete iter;
- arr->Delete();
- delete arr;
// fill fListNorm, list of normalization variables:
- arr = fViewer->GetListOfNormalizationVariables();
- iter = arr->MakeIterator();
- iter->Reset();
+ TObjArray *arrNorm = fViewer->GetListOfNormalizationVariables();
+ TIterator *iterNorm = arrNorm->MakeIterator();
+ iterNorm->Reset();
currentStr = 0;
id = 0;
fListNormalization->RemoveAll();
+ while ((currentStr = (TObjString*)(iterNorm->Next()))) {
+ fListNormalization->AddEntry(currentStr->GetString().Data(), id);
+ if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id;
+ id++;
+ }
+ currentStr = 0;
+ iter->Reset();
+ //Add draw variables to the list of normalisation
while ((currentStr = (TObjString*)(iter->Next()))) {
+ if (currentStr->GetString().BeginsWith("Map")) continue; //don't add mapping information
fListNormalization->AddEntry(currentStr->GetString().Data(), id);
if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id;
id++;
}
+
+ delete iterNorm;
+ arrNorm->Delete();
+ delete arrNorm;
+
delete iter;
arr->Delete();
delete arr;
}
+void AliTPCCalibViewerGUI::Reset(){
+ //
+ // reset variables, delete calib viewer
+ //
+ if (fViewer) delete fViewer;
+ fListVariables->RemoveAll();
+ fListNormalization->RemoveAll();
+ fInitialized = kFALSE;
+}
void AliTPCCalibViewerGUI::HandleButtonsGeneral(Int_t id) {
//
case 20: // fRadioTPC
fRadioSideA->SetState(kButtonUp);
fRadioSideC->SetState(kButtonUp);
+ fRadioROC->SetState(kButtonUp);
fRadioSector->SetState(kButtonUp);
break;
case 21: // fRadioSideA
fRadioTPC->SetState(kButtonUp);
fRadioSideC->SetState(kButtonUp);
+ fRadioROC->SetState(kButtonUp);
fRadioSector->SetState(kButtonUp);
break;
case 22: // fRadioSideC
fRadioTPC->SetState(kButtonUp);
fRadioSideA->SetState(kButtonUp);
+ fRadioROC->SetState(kButtonUp);
fRadioSector->SetState(kButtonUp);
break;
- case 23: // fRadioSector
+ case 23: // fRadioROC
fRadioTPC->SetState(kButtonUp);
fRadioSideA->SetState(kButtonUp);
fRadioSideC->SetState(kButtonUp);
+ fRadioSector->SetState(kButtonUp);
+ break;
+ case 24: // fRadioSector
+ fRadioTPC->SetState(kButtonUp);
+ fRadioSideA->SetState(kButtonUp);
+ fRadioSideC->SetState(kButtonUp);
+ fRadioROC->SetState(kButtonUp);
break;
case 31: // fComboAddCuts
fChkAddCuts->SetState(kButtonDown);
SetMinMaxLabel();
}
+void AliTPCCalibViewerGUI::ReplacePlaceHolders(TString &str)
+{
+ //
+ // replace the defined placeholders in the custom draw string and cut string
+ //
+ TString drawPlaceHolder("#draw#");
+ TString normPlaceHolder("#norm#");
+
+ //current draw variable
+ TString desiredData("");
+ if (fListVariables->GetSelectedEntry()){
+ desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+ str.ReplaceAll(drawPlaceHolder,desiredData);
+ }
+// desiredData += fViewer->GetAbbreviation();
+
+ //current normalisation
+ TString normalizationData("");
+ if (fListNormalization->GetSelectedEntry()){
+ normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
+ if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
+ if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData;
+ if ( fListVariables->FindEntry(normalizationData.Data()) )
+ normalizationData+="~";
+ str.ReplaceAll(normPlaceHolder,normalizationData);
+ }
+}
void AliTPCCalibViewerGUI::DoNewSelection() {
//
cutStr += "(sector/18)%2==0"; // side A
if (fRadioSideC->GetState() == kButtonDown)
cutStr+= "(sector/18)%2==1"; // side C
- if (fRadioSector->GetState() == kButtonDown) {
+ if (fRadioROC->GetState() == kButtonDown) {
Int_t sector = (Int_t)(fNmbSector->GetNumber());
cutStr += "sector==";
cutStr += sector;
}
+ if (fRadioSector->GetState() == kButtonDown) {
+ Int_t sector = ((Int_t)(fNmbSector->GetNumber()))%36;
+ cutStr += "sector%36==";
+ cutStr += sector;
+ }
if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
cutStr += fComboAddCuts->GetTextEntry()->GetText();
desiredData += op;
if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
- desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+ if ( normalizationData.BeginsWith("_") ) desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+ if ( fListVariables->FindEntry(normalizationData.Data()) )
+ normalizationData+="~";
desiredData += normalizationData;
}
else if (fRadioCustom->GetState() == kButtonDown) {
desiredData = fComboCustom->GetTextEntry()->GetText();
if (desiredData == "") return 0;
+ ReplacePlaceHolders(desiredData);
}
// try to add forgotten '~'
sectorStr += "A"; //cuts += "(sector/18)%2==0";
if (fRadioSideC->GetState() == kButtonDown)
sectorStr+= "C"; //cuts += "(sector/18)%2==1";
- if (fRadioSector->GetState() == kButtonDown) {
+ if (fRadioROC->GetState() == kButtonDown) {
Int_t sector = (Int_t)(fNmbSector->GetNumber());
sectorStr += sector; //cuts += "sector==";
}
+ if (fRadioSector->GetState() == kButtonDown) {
+ Int_t sector = ((Int_t)(fNmbSector->GetNumber()))%36;
+ sectorStr += "S";
+ sectorStr += sector; //cuts += "sector%36==";
+ }
return new TString(sectorStr.Data());
}
cutsStr += "!=0";
if (fChkAddCuts->GetState() == kButtonDown) cutsStr += " && ";
}
- if (fChkAddCuts->GetState() == kButtonDown)
- cutsStr += fComboAddCuts->GetTextEntry()->GetText();
+ if (fChkAddCuts->GetState() == kButtonDown){
+ cutsStr += fComboAddCuts->GetTextEntry()->GetText();
+ ReplacePlaceHolders(cutsStr);
+ }
+
// try to add forgotten '~'
if (fChkAutoAppend->GetState() == kButtonDown)
TMatrixD covMatrix(0,0);
TString cutStr("");
TString formulaStr("");
- TString *returnStr = new TString("");
// specify data to plot:
TString drawStr(GetDrawString()->Data());
cutStr += "(sector/18)%2==0"; // side A
if (fRadioSideC->GetState() == kButtonDown)
cutStr+= "(sector/18)%2==1"; // side C
- if (fRadioSector->GetState() == kButtonDown) {
+ if (fRadioROC->GetState() == kButtonDown) {
Int_t sector = (Int_t)(fNmbSector->GetNumber());
cutStr += "sector==";
cutStr += sector;
}
+ if (fRadioSector->GetState() == kButtonDown) {
+ Int_t sector = (Int_t)(fNmbSector->GetNumber())%36;
+ cutStr += "sector%36==";
+ cutStr += sector;
+ }
if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
cutStr += fComboAddCuts->GetTextEntry()->GetText();
formulaStr = TString(fViewer->AddAbbreviations((char*)formulaStr.Data()));
// ********** call AliTPCCalibViewer's fit-function
- returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
+ ReplacePlaceHolders(drawStr);
+ ReplacePlaceHolders(cutStr);
+ TString *returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
std::cout << std::endl;
std::cout << "Your fit formula reads as follows:" << std::endl;
std::cout << returnStr->Data() << std::endl;
std::cout << "chi2 = " << chi2 << std::endl;
+
+ delete returnStr;
}
// create calPad according to drawCommand and cuts
AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)calPadName);
// finally export calPad to Cint:
- gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad));
+ gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, (ULong_t)calPad));
fPreprocessor->AddComponent(calPad);
Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName);
}
}
Error("DoExportNorm", "Not yet implemented.");
+/*
return;
// specify data to plot:
// create calPad according to drawCommand and cuts
AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)fComboExportName->GetTextEntry()->GetText());
// finally export calPad to Cint:
- gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad));
+ gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, (ULong_t) calPad));
Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName);
+ */
}
ptr = listOfPrimitives->At(i);
if ( ptr->InheritsFrom("TH1") ) break;
}
- if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
+ if ( !ptr || !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
TH1 *hist = (TH1*)ptr;
// Double_t histMax = hist->GetMaximum();
//
// function that is called, when the number of the sector is changed
// to change the sector label
- //
+ //
+ if ( fRadioROC->GetState()!=kButtonDown && fRadioSector->GetState()!=kButtonDown ){
+ fLblSector->SetText("not used");
+ return;
+ }
+
Int_t sector = (Int_t)(fNmbSector->GetNumber());
- char* secLabel = "";
- if (sector >= 0 && sector <= 17) // IROC, Side A
- secLabel = "IROC, A";
- if (sector >= 18 && sector <= 35) // IROC, Side C
- secLabel = "IROC, C";
- if (sector >= 36 && sector <= 53) // OROC, Side A
- secLabel = "OROC, A";
- if (sector >= 54 && sector <= 71) // OROC, Side C
- secLabel = "OROC, C";
+ TString secLabel = "";
+ if ( sector < 36 )
+ secLabel = "IROC";
+ else
+ secLabel = "OROC";
+
+ if (fRadioSector->GetState()==kButtonDown)
+ secLabel="Sector";
+
+ if ( sector%36<18 ) //A-Side
+ secLabel += ", A";
+ else
+ secLabel += ", C";
+
+ secLabel += Form("%02d",sector%18);
+
fLblSector->SetText(secLabel);
DoNewSelection();
}
if (!selectedObject->InheritsFrom("TH2")) return;
// zoom to sector works ONLY in 2D mode, if one side is specified
if (fRadio2D->GetState() == kButtonUp) return;
- if (fRadioSector->GetState() == kButtonDown) { // return to full side view
+ if (fRadioROC->GetState() == kButtonDown) { // return to full side view
// return to full side view
Int_t sector = (Int_t)(fNmbSector->GetNumber());
if ( (sector >= 0 && sector <= 17) || (sector >= 36 && sector <= 53) ) {
if (quadrant == 3) phi = pi + phi;
if (quadrant == 4) phi = 2 * pi - phi;
Double_t phiGrad = phi / pi * 180;
- Int_t sector = (Int_t) phiGrad / 20; // one sector coresponds to 20°
+ Int_t sector = (Int_t) phiGrad / 20; // one sector coresponds to 20�
// IROC starts at 84.5 cm
// IROC ends at 135.5 cm, OROC begins
// OROC ends at 250 cm
}
// printf("r: %f, phi: %f, phiGrad: %f, gy/gx: %f, quadrant: %i, sector: %i \n", r, phi, phiGrad, gy/gx, quadrant, sector);
fNmbSector->SetNumber(sector);
- fRadioSector->Clicked();
- fRadioSector->SetState(kButtonDown);
+ fRadioROC->Clicked();
+ fRadioROC->SetState(kButtonDown);
ChangeSector();
}
new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
if (fi.fFilename && strlen(fi.fFilename)) {
fPreprocessor->DumpToFile(fi.fFilename);
- Info("DumpToFile", Form("New CalibTree has been writen to file '%s'", fi.fFilename));
+ Info("DumpToFile","New CalibTree has been writen to file '%s'", fi.fFilename);
}
}