#define MAXRUNS 50 int MeasN[MAXRUNS]; double PosZ[MAXRUNS]; int nRuns = 0; int nRebin = 5; /* ======================================================== */ void CfrData(const char *dir, const char *prefix, const char *suffix) { /* Comparison of the spots for various measurments of one mirror dir = directory with the root files prefix = prefix of the root file names before the measurement # suffix = suffix of the root file names after the measurement # EXAMPLE: .x PlotData.C ("5C/2021-10-05/horizontal/no_ambient/D0Log.dat","5C/2021-10-05/horizontal/no_ambient","2ms_corr") The script assumes to have: - a log file of the measurements called D0Log.dat - that the root files are called "prefix"N_"suffix".root where N is the measurement number */ char fname[200]; char hname[200]; char file[200]; /*******************************************/ /* Reading the log od the measurements */ sprintf(file, "%s/D0Log.dat", dir); FILE *fLog = fopen(&file[0], "r"); if (fLog) { printf("Reading log file %s\n", file); char str[100]; int mis, z; fgets(str, sizeof(str), fLog); while(fscanf(fLog, "%d %d", &z, &mis) != EOF) { //printf("mis %d z=%d\n", mis, z); MeasN[nRuns] = mis; PosZ[nRuns] = z; nRuns++; } fclose(fLog); } else { printf("ERROR: cannot open log file %s, stop\n", file); return; } printf("Number of measurements: %d\n", nRuns); /********************************************/ /* Ordering the data with increasing Z */ int *Index = new int[nRuns]; TMath::Sort(nRuns, PosZ, Index, false); /********************************************/ /* Root canvas */ TCanvas *c1 = new TCanvas("c1", "", 700, 700); int nx = 6; int ny = 6; c1->Divide(nx, ny); /*******************************************************/ /* file pdf */ sprintf(fname, "%s/D0Log.dat.pdf", dir); c1->Print(Form("%s[", fname)); /*******************************************/ /* Opening the root files */ int iplot = 0; TFile *fRoot[MAXRUNS]; //nRuns = 3; for (int r1=0; r1Get(hname); c1->cd(iplot); cSpot->SetLogz(); //cSpot->DrawClonePad(); gStyle->SetOptStat(0); TH2F *Spot = (TH2F*)cSpot->GetPrimitive("Spot"); Spot->RebinX(nRebin); Spot->RebinY(nRebin); Spot->SetTitle(Form("Z=%5.1f", PosZ[r])); Spot->Draw("colz"); /*TEllipse *Circle = (TEllipse*)cSpot->GetPrimitive("TEllipse;2"); if (Circle) { printf(" TEllipse ok\n"); Circle->Draw("same"); }*/ /* Getting the canvas of the D0 */ iplot++; sprintf(hname, "grD0"); TCanvas *cD0 = (TCanvas*)fRoot[r]->Get(hname); c1->cd(iplot); cD0->SetGrid(); cD0->DrawClonePad(); if ( (iplot == (nx*ny) ) || (r == (nRuns-1) ) ) { c1->Print(Form("%s", fname)); c1->Clear(); c1->Divide(nx, ny); iplot = 0; } } /*******************************************/ /* END */ c1->Print(Form("%s]", fname)); c1->Close(); for (int r=0; rClose(); return; }