str.ReplaceAll(removeString, "");
if (printDrawCommand) std::cout << "The string looks now like: " << str.Data() << std::endl;
+ delete [] varLengths;
+ delete [] normLengths;
delete [] varSort;
delete [] normSort;
return str.Data();
// writeDrawCommand: write the command, that is passed to TTree::Draw
//
if (sector >= 0 && sector < 72) {
- char sectorChr[3];
- sprintf(sectorChr, "%i", sector);
- return EasyDraw(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
+ return EasyDraw(drawCommand, Form("%i", sector), cuts, drawOptions, writeDrawCommand);
}
Error("EasyDraw","The TPC contains only sectors between 0 and 71.");
return -1;
//
if (sector >= 0 && sector < 72) {
- char sectorChr[3];
- sprintf(sectorChr, "%i", sector);
- return EasyDraw1D(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
+ return EasyDraw1D(drawCommand, Form("%i",sector), cuts, drawOptions, writeDrawCommand);
}
Error("EasyDraw","The TPC contains only sectors between 0 and 71.");
return -1;
// "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);
+ return DrawHisto1D(drawCommand, Form("%i", sector), cuts, sigmas, plotMean, plotMedian, plotLTM);
}
Error("DrawHisto1D","The TPC contains only sectors between 0 and 71.");
return -1;
Double_t sigma = TMath::RMS(entries, values);
Double_t maxY = htemp->GetMaximum();
- char c[500];
TLegend * legend = new TLegend(.7,.7, .99, .99, "Statistical information");
-// sprintf(c, "%s, sector: %i", type, sector);
//fListOfObjectsToBeDeleted->Add(legend);
if (plotMean) {
line->SetLineWidth(2);
line->SetLineStyle(1);
line->Draw();
- sprintf(c, "Mean: %f", mean);
- legend->AddEntry(line, c, "l");
+ legend->AddEntry(line, Form("Mean: %f", mean), "l");
// draw sigma lines
for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
TLine* linePlusSigma = new TLine(mean + nsigma[i] * sigma, 0, mean + nsigma[i] * sigma, maxY);
lineMinusSigma->SetLineColor(kRed);
lineMinusSigma->SetLineStyle(2 + i);
lineMinusSigma->Draw();
- sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma));
- legend->AddEntry(lineMinusSigma, c, "l");
+ legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l");
}
}
if (plotMedian) {
line->SetLineWidth(2);
line->SetLineStyle(1);
line->Draw();
- sprintf(c, "Median: %f", median);
- legend->AddEntry(line, c, "l");
+ legend->AddEntry(line, Form("Median: %f", median), "l");
// draw sigma lines
for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
TLine* linePlusSigma = new TLine(median + nsigma[i] * sigma, 0, median + nsigma[i]*sigma, maxY);
lineMinusSigma->SetLineColor(kBlue);
lineMinusSigma->SetLineStyle(2 + i);
lineMinusSigma->Draw();
- sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma));
- legend->AddEntry(lineMinusSigma, c, "l");
+ legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l");
}
}
if (plotLTM) {
line->SetLineWidth(2);
line->SetLineStyle(1);
line->Draw();
- sprintf(c, "LTM: %f", ltm);
- legend->AddEntry(line, c, "l");
+ legend->AddEntry(line, Form("LTM: %f", ltm), "l");
// draw sigma lines
for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
TLine* linePlusSigma = new TLine(ltm + nsigma[i] * ltmRms, 0, ltm + nsigma[i] * ltmRms, maxY);
lineMinusSigma->SetLineColor(kGreen+2);
lineMinusSigma->SetLineStyle(2+i);
lineMinusSigma->Draw();
- sprintf(c, "%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms));
- legend->AddEntry(lineMinusSigma, c, "l");
+ legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms)), "l");
}
}
if (!plotMean && !plotMedian && !plotLTM) return -1;
// 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 }
+ // f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = (#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
//
//
// 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);
+ return SigmaCut(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, pm, sigmas, sigmaStep);
}
Error("SigmaCut","The TPC contains only sectors between 0 and 71.");
return -1;
DrawLines(cutGraphMean, nsigma, legend, kRed, kTRUE);
}
}
+ delete [] index;
+ delete [] xarray;
+ delete [] yarray;
/*
if (plotMedian) {
cutHistoMedian = AliTPCCalibViewer::SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm);
// "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 }
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #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);
+ return Integrate(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, sigmas, sigmaStep);
}
Error("Integrate","The TPC contains only sectors between 0 and 71.");
return -1;
// "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 }
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
End_Latex
*/
// "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 }
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
End_Latex
*/
DrawLines(integralGraphLTM, nsigma, legend, kGreen+2, kTRUE);
}
}
+ delete [] index;
+ delete [] xarray;
+ delete [] yarray;
+
if (!plotMean && !plotMedian && !plotLTM) return -1;
legend->Draw();
return entries;
//
// start to draw the lines, loop over requested sigmas
- char c[500];
for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
if (!pm) {
Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
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");
+ legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
}
else { // if (pm)
Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
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");
+ legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
bin = histogram->GetXaxis()->FindBin(-nsigma[i]);
TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], histogram->GetBinContent(bin));
//fListOfObjectsToBeDeleted->Add(lineUp2);
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");
+ legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
}
} // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)
}
//
// start to draw the lines, loop over requested sigmas
- char c[500];
for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
if (!pm) {
TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i]));
lineLeft->SetLineColor(color);
lineLeft->SetLineStyle(2 + i);
lineLeft->Draw();
- sprintf(c, "Fraction(%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i]));
- legend->AddEntry(lineLeft, c, "l");
+ legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l");
}
else { // if (pm)
TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i]));
lineLeft1->SetLineColor(color);
lineLeft1->SetLineStyle(2 + i);
lineLeft1->Draw();
- sprintf(c, "Fraction(+%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i]));
- legend->AddEntry(lineLeft1, c, "l");
+ legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l");
TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], graph->Eval(-nsigma[i]));
//fListOfObjectsToBeDeleted->Add(lineUp2);
lineUp2->SetLineColor(color);
lineLeft2->SetLineColor(color);
lineLeft2->SetLineStyle(2 + i);
lineLeft2->Draw();
- sprintf(c, "Fraction(-%f #sigma) = %f",nsigma[i], graph->Eval(-nsigma[i]));
- legend->AddEntry(lineLeft2, c, "l");
+ legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], graph->Eval(-nsigma[i])), "l");
}
} // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)
}
// 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
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = (#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 }
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
End_Latex
- begin_macro(source)
+ Begin_Macro(source)
{
Float_t mean = 0;
Float_t sigma = 1.5;
Float_t sigmaMax = 4;
gROOT->SetStyle("Plain");
- TH1F *distribution = new TH1F("Distribution1", "Distribution f(x, #mu, #sigma)", 1000,-5,5);
+ TH1F *distribution = new TH1F("Distrib1", "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_SigmaCut", "", 350, 350);
+ TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer1", "", 350, 350);
macro_example_canvas->Divide(0,3);
TVirtualPad *pad1 = macro_example_canvas->cd(1);
pad1->SetGridy();
shistPM->Draw();
return macro_example_canvas;
}
- end_macro
+ End_Macro
*/
Float_t *array = histogram->GetArray();
// "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 }
+ f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
End_Latex
- begin_macro(source)
+ Begin_Macro(source)
{
Float_t mean = 0;
Float_t sigma = 1.5;
Float_t sigmaMax = 4;
gROOT->SetStyle("Plain");
- TH1F *distribution = new TH1F("Distribution2", "Distribution f(x, #mu, #sigma)", 1000,-5,5);
+ TH1F *distribution = new TH1F("Distrib2", "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_Integrate", "", 350, 350);
+ TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer2", "", 350, 350);
macro_example_canvas->Divide(0,2);
TVirtualPad *pad1 = macro_example_canvas->cd(1);
pad1->SetGridy();
return macro_example_canvas_Integrate;
}
- end_macro
+ End_Macro
*/
if (i < dim) centries = fTree->Draw(((TObjString*)formulaTokens->At(i))->GetName(), cutStr.Data(), "goff");
else centries = fTree->Draw(drawStr.Data(), cutStr.Data(), "goff");
- if (entries != centries) return new TString("An ERROR has occured during fitting!");
+ if (entries != centries) {
+ delete [] values;
+ return new TString("An ERROR has occured during fitting!");
+ }
values[i] = new Double_t[entries];
memcpy(values[i], fTree->GetV1(), entries*sizeof(Double_t));
}
fitter->GetParameters(fitParam);
fitter->GetCovarianceMatrix(covMatrix);
chi2 = fitter->GetChisquare();
- chi2 = chi2;
+// chi2 = chi2;
TString *preturnFormula = new TString(Form("( %e+",fitParam[0])), &returnFormula = *preturnFormula;
returnFormula.Append(" )");
delete formulaTokens;
delete fitter;
- delete[] values;
+ for (Int_t i = 0; i < dim + 1; i++){
+ delete [] values[i];
+ }
+ delete [] values;
return preturnFormula;
}