Skip to content

Commit

Permalink
apply code-checks to trackSplitPlot.C
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Jan 12, 2024
1 parent 856fc05 commit db560d2
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions Alignment/OfflineValidation/macros/trackSplitPlot.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TCanvas *trackSplitPlot(Int_t nFiles,
stufftodelete->SetOwner(true);
cout << xvar << " " << yvar << endl;
if (xvar == "" && yvar == "")
return 0;
return nullptr;

PlotType type;
if (xvar == "")
Expand Down Expand Up @@ -160,7 +160,7 @@ TCanvas *trackSplitPlot(Int_t nFiles,

TFile *f = TFile::Open(files[i]);
TTree *tree = (TTree *)f->Get("cosmicValidation/splitterTree");
if (tree == 0)
if (tree == nullptr)
tree = (TTree *)f->Get("splitterTree");

lengths[i] = tree->GetEntries();
Expand Down Expand Up @@ -438,16 +438,16 @@ TCanvas *trackSplitPlot(Int_t nFiles,
}
}

TH1 *firstp = 0;
TH1 *firstp = nullptr;
for (int i = 0; i < n; i++) {
if (used[i]) {
firstp = p[i];
break;
}
}
if (firstp == 0) {
if (firstp == nullptr) {
stufftodelete->Clear();
return 0;
return nullptr;
}

TCanvas *c1 = TCanvas::MakeDefCanvas();
Expand Down Expand Up @@ -546,13 +546,13 @@ TCanvas *trackSplitPlot(Int_t nFiles,
p[i]->Draw("same hist");
legend->AddEntry(p[i], names[i], "l");
}
legend->AddEntry((TObject *)0, meansrmss[i], "");
legend->AddEntry((TObject *)nullptr, meansrmss[i], "");
}
}
if (legend->GetListOfPrimitives()->At(0) == 0) {
if (legend->GetListOfPrimitives()->At(0) == nullptr) {
stufftodelete->Clear();
deleteCanvas(c1);
return 0;
return nullptr;
}

c1->Update();
Expand Down Expand Up @@ -639,7 +639,7 @@ void saveplot(TCanvas *c1, TString saveas) {
}

void deleteCanvas(TObject *canvas) {
if (canvas == 0)
if (canvas == nullptr)
return;
if (!canvas->InheritsFrom("TCanvas")) {
delete canvas;
Expand Down Expand Up @@ -730,7 +730,7 @@ void misalignmentDependence(TCanvas *c1old,
Bool_t resolution,
Bool_t pull,
TString saveas) {
if (c1old == 0)
if (c1old == nullptr)
return;
c1old = (TCanvas *)c1old->Clone("c1old");
if (misalignment == "" || yvar == "")
Expand Down Expand Up @@ -761,9 +761,9 @@ void misalignmentDependence(TCanvas *c1old,
s0 << "p" << i;
TString pname = s0.str();
p[i] = (TH1 *)list->/*At(i+1+(xvar == ""))*/ FindObject(pname);
used[i] = (p[i] != 0);
used[i] = (p[i] != nullptr);
if (used[i])
p[i]->SetDirectory(0);
p[i]->SetDirectory(nullptr);
if (xvar == "")
continue;
stringstream s;
Expand Down Expand Up @@ -862,12 +862,12 @@ void misalignmentDependence(TCanvas *c1old,
legend->SetFillStyle(0);
legend->Draw();
} else {
if (values == 0)
if (values == nullptr)
return;

Bool_t phasesmatter = false;
if (misalignment == "elliptical" || misalignment == "sagitta" || misalignment == "skew") {
if (phases == 0) {
if (phases == nullptr) {
cout << "This misalignment has a phase, but you didn't supply the phases!" << endl
<< "Can't produce plots depending on the misalignment value." << endl;
return;
Expand All @@ -884,7 +884,7 @@ void misalignmentDependence(TCanvas *c1old,
}

if (!phasesmatter) {
TGraphErrors *g = new TGraphErrors(nFiles, values, result, (Double_t *)0, error);
TGraphErrors *g = new TGraphErrors(nFiles, values, result, (Double_t *)nullptr, error);
g->SetName("");
stufftodelete->Add(g);

Expand Down Expand Up @@ -918,7 +918,7 @@ void misalignmentDependence(TCanvas *c1old,
xvalues[i] = values[i] * cos(phases[i]);
yvalues[i] = values[i] * sin(phases[i]);
}
TGraph2DErrors *g = new TGraph2DErrors(nFiles, xvalues, yvalues, result, (Double_t *)0, (Double_t *)0, error);
TGraph2DErrors *g = new TGraph2DErrors(nFiles, xvalues, yvalues, result, (Double_t *)nullptr, (Double_t *)nullptr, error);
g->SetName("");
stufftodelete->Add(g);
delete[] xvalues; //A TGraph2DErrors has its own copy of xvalues and yvalues, so it's ok to delete these copies.
Expand Down Expand Up @@ -1255,7 +1255,7 @@ Bool_t misalignmentDependence(TCanvas *c1old,
Bool_t pull,
TString saveas) {
if (xvar == "") {
if (c1old == 0 || misalignment == "" || values == 0)
if (c1old == nullptr || misalignment == "" || values == nullptr)
return false;
misalignmentDependence(c1old,
nFiles,
Expand All @@ -1265,7 +1265,7 @@ Bool_t misalignmentDependence(TCanvas *c1old,
phases,
xvar,
yvar,
(TF1 *)0,
(TF1 *)nullptr,
0,
"",
"",
Expand All @@ -1275,7 +1275,7 @@ Bool_t misalignmentDependence(TCanvas *c1old,
saveas);
return true;
}
TF1 *f = 0;
TF1 *f = nullptr;
TString functionname = "";

//if only one parameter is of interest
Expand All @@ -1284,8 +1284,8 @@ Bool_t misalignmentDependence(TCanvas *c1old,

//if multiple parameters are of interest
Int_t nParameters = -1;
TString *parameternames = 0;
Int_t *parameters = 0;
TString *parameternames = nullptr;
Int_t *parameters = nullptr;

if (misalignment == "sagitta") {
if (xvar == "phi" && yvar == "phi" && !resolution && !pull) {
Expand Down Expand Up @@ -1556,12 +1556,12 @@ Bool_t misalignmentDependence(Int_t nFiles,
}

Bool_t hasFit(TString misalignment, TString xvar, TString yvar, Bool_t relative, Bool_t resolution, Bool_t pull) {
return misalignmentDependence((TCanvas *)0,
return misalignmentDependence((TCanvas *)nullptr,
0,
(TString *)0,
(TString *)nullptr,
misalignment,
(Double_t *)0,
(Double_t *)0,
(Double_t *)nullptr,
(Double_t *)nullptr,
xvar,
yvar,
false,
Expand All @@ -1586,15 +1586,15 @@ void makePlots(Int_t nFiles,
stufftodelete->SetOwner(true);

for (Int_t i = 0, totaltime = 0; i < nFiles; i++) {
TFile *f = 0;
TFile *f = nullptr;
bool exists = false;
if (files[i] == "")
exists = true;

for (int j = 1; j <= 60 * 24 && !exists; j++, totaltime++) //wait up to 1 day for the validation to be finished
{
f = TFile::Open(files[i]);
if (f != 0)
if (f != nullptr)
exists = f->IsOpen();
delete f;
if (exists)
Expand Down Expand Up @@ -1859,7 +1859,7 @@ void makePlots(Int_t nFiles,
}

void makePlots(Int_t nFiles, TString *files, TString *names, TString directory, Bool_t matrix[xsize][ysize]) {
makePlots(nFiles, files, names, "", (Double_t *)0, (Double_t *)0, directory, matrix);
makePlots(nFiles, files, names, "", (Double_t *)nullptr, (Double_t *)nullptr, directory, matrix);
}

void makePlots(TString file,
Expand Down Expand Up @@ -1903,7 +1903,7 @@ void makePlots(TString file,
}

void makePlots(TString file, TString directory, Bool_t matrix[xsize][ysize]) {
makePlots(file, "", (Double_t *)0, (Double_t *)0, directory, matrix);
makePlots(file, "", (Double_t *)nullptr, (Double_t *)nullptr, directory, matrix);
}

//***************************************************************************
Expand Down Expand Up @@ -1940,7 +1940,7 @@ void makePlots(Int_t nFiles,
}

void makePlots(Int_t nFiles, TString *files, TString *names, TString directory, TString xvar, TString yvar) {
makePlots(nFiles, files, names, "", (Double_t *)0, (Double_t *)0, directory, xvar, yvar);
makePlots(nFiles, files, names, "", (Double_t *)nullptr, (Double_t *)nullptr, directory, xvar, yvar);
}

void makePlots(TString file,
Expand Down Expand Up @@ -1985,7 +1985,7 @@ void makePlots(TString file,
}

void makePlots(TString file, TString directory, TString xvar, TString yvar) {
makePlots(file, "", (Double_t *)0, (Double_t *)0, directory, xvar, yvar);
makePlots(file, "", (Double_t *)nullptr, (Double_t *)nullptr, directory, xvar, yvar);
}

//***************************
Expand All @@ -2003,7 +2003,7 @@ void makePlots(Int_t nFiles,
}

void makePlots(Int_t nFiles, TString *files, TString *names, TString directory) {
makePlots(nFiles, files, names, "", (Double_t *)0, (Double_t *)0, directory);
makePlots(nFiles, files, names, "", (Double_t *)nullptr, (Double_t *)nullptr, directory);
}

void makePlots(TString file, TString misalignment, Double_t *values, Double_t *phases, TString directory) {
Expand Down Expand Up @@ -2041,7 +2041,7 @@ void makePlots(TString file, TString misalignment, Double_t *values, Double_t *p
styles = tempstyles;
}

void makePlots(TString file, TString directory) { makePlots(file, "", (Double_t *)0, (Double_t *)0, directory); }
void makePlots(TString file, TString directory) { makePlots(file, "", (Double_t *)nullptr, (Double_t *)nullptr, directory); }

//=============
//3. Axis Label
Expand Down Expand Up @@ -2108,7 +2108,7 @@ TString latexunits(TString variable, char axis) {
TString axislabel(TString variable, Char_t axis, Bool_t relative, Bool_t resolution, Bool_t pull) {
if (axis == 'X' || axis == 'Y') {
double min, max, bins;
axislimits(0, 0, variable, tolower(axis), relative, pull, min, max, bins);
axislimits(0, nullptr, variable, tolower(axis), relative, pull, min, max, bins);

if (variable.BeginsWith("nHits"))
return "fraction of tracks";
Expand Down Expand Up @@ -2284,7 +2284,7 @@ Double_t findStatistic(
continue;
TFile *f = TFile::Open(files[j]);
TTree *tree = (TTree *)f->Get("cosmicValidation/splitterTree");
if (tree == 0)
if (tree == nullptr)
tree = (TTree *)f->Get("splitterTree");
Int_t length = tree->GetEntries();

Expand Down Expand Up @@ -2576,9 +2576,9 @@ Double_t placeLegend(
Bool_t fitsHere(TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2) {
Bool_t fits = true;
TList *list = l->GetListOfPrimitives();
for (Int_t k = 0; list->At(k) != 0 && fits; k++) {
for (Int_t k = 0; list->At(k) != nullptr && fits; k++) {
TObject *obj = ((TLegendEntry *)(list->At(k)))->GetObject();
if (obj == 0)
if (obj == nullptr)
continue;
TClass *cl = obj->IsA();

Expand Down

0 comments on commit db560d2

Please sign in to comment.