FEDRA emulsion software from the OPERA Collaboration
emthickness.cpp File Reference
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <utility>
#include <TROOT.h>
#include <TRint.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TCanvas.h>
#include <TEnv.h>
#include <TFile.h>
#include <TTree.h>
#include <TProfile2D.h>
#include <TMath.h>
#include <TCut.h>
#include <TText.h>
#include <TLine.h>
#include <TPaveText.h>
#include "ERTools.h"
#include "EdbLog.h"
Include dependency graph for emthickness.cpp:

Functions

TEnv cenv ("qualityenv")
 
void define_steps (TTree *tree)
 
void draw_frame_align ()
 
void generate_json_report (TH2 *h, std::ofstream &report, bool first_plot)
 
TH1D * get_step_fft (TH1D *h)
 
int main (int argc, char *argv[])
 
void make_canvas (const char *nameo="ccc")
 
void make_histos (TTree *tree)
 
int make_report (const char *output_file)
 
void make_snd_profiles (const char *nameo="snd_profiles")
 
void print_help_message ()
 
int process_file (const char *input_file, const char *output_file)
 
void set_default_env ()
 
void SetLargeLabelsStyle ()
 

Variables

struct {
   float   areaR
 
   float   areaS
 
   float   fraction
 
   float   fractionS
 
   float   xmaxR
 
   float   xmaxS
 
   float   xminR
 
   float   xminS
 
   float   ymaxR
 
   float   ymaxS
 
   float   yminR
 
   float   yminS
 
AREA
 
struct {
   int   nx
 
   int   ny
 
   float   xbin
 
   float   xmax
 
   float   xmin
 
   float   ybin
 
   float   ymax
 
   float   ymin
 
B
 
struct {
   bool   interactive = false
 
   bool   process = false
 
DO
 
struct {
   float   bin = 20
 
FFT
 
struct {
   TProfile2D *   glass
 
   TProfile2D *   nseg_bot
 
   TProfile2D *   nseg_top
 
   TH2D *   thick_base
 
   TProfile2D *   thick_bot
 
   TProfile2D *   thick_top
 
H
 
struct {
   int   prof = 1
 
   float   width = 1000
 
   float   X0 = 100000
 
   float   Y0 = 100000
 
P
 
struct {
   float   covered_area
 
   float   density_bot
 
   float   density_top
 
   float   empty_frac_bot
 
   float   empty_frac_top
 
   TDatime   file_creation_date
 
   TDatime   file_modification_date
 
   Long_t   file_size
 
   string   filename
 
   float   requested_area
 
   float   scan_time
 
   float   scanned_area
 
RES
 
struct {
   float   dzx1
 
   float   dzx2
 
   float   dzy1
 
   float   dzy2
 
   float   szx1
 
   float   szx2
 
   float   szy1
 
   float   szy2
 
Z
 

Function Documentation

◆ cenv()

TEnv cenv ( "qualityenv"  )

◆ define_steps()

void define_steps ( TTree *  tree)
249 {
250  TH1D *hx = get_h_var(tree, "headers.eXview", "hx", FFT.bin, "!(eXview==0&&eYview==0)");
251  TH1D *hy = get_h_var(tree, "headers.eYview", "hy", FFT.bin, "!(eXview==0&&eYview==0)");
252  // hx->Draw();
253 
254  TH1D *hstepx = get_step_fft(hx);
255  TH1D *hstepy = get_step_fft(hy);
256  B.nx = hstepx->GetXaxis()->GetNbins();
257  B.xmin = hstepx->GetXaxis()->GetXmin();
258  B.xmax = hstepx->GetXaxis()->GetXmax();
259  B.xbin = (B.xmax - B.xmin) / B.nx;
260  B.xmin -= 5 * B.xbin;
261  B.nx += 5;
262  B.xmax += 5 * B.xbin;
263  B.nx += 5;
264  B.ny = hstepy->GetXaxis()->GetNbins();
265  B.ymin = hstepy->GetXaxis()->GetXmin();
266  B.ymax = hstepy->GetXaxis()->GetXmax();
267  B.ybin = (B.ymax - B.ymin) / B.ny;
268  B.ymin -= 5 * B.ybin;
269  B.ny += 5;
270  B.ymax += 5 * B.ybin;
271  B.ny += 5;
272 
273  AREA.xminS = hx->GetXaxis()->GetXmin() - B.xbin;
274  AREA.xmaxS = hx->GetXaxis()->GetXmax() + B.xbin;
275  AREA.yminS = hy->GetXaxis()->GetXmin() - B.ybin;
276  AREA.ymaxS = hy->GetXaxis()->GetXmax() + B.ybin;
277  AREA.areaS = (AREA.xmaxS - AREA.xminS) * (AREA.ymaxS - AREA.yminS);
278  AREA.fractionS = AREA.areaS / AREA.areaR;
279  Log(1, "define_steps",
280  "Determined step sizes: B.xbin= %.1f B.ybin= %.1f\n"
281  "Scanned area: X: %.1f , %.1f Y: %.1f , %.1f Area= %.1f cm2 Fraction= %.3f",
282  B.xbin, B.ybin,
283  AREA.xminS, AREA.xmaxS, AREA.yminS, AREA.ymaxS, AREA.areaS / 10000. / 10000., AREA.fractionS);
284 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
struct @6 B
TH1D * get_step_fft(TH1D *h)
Definition: emthickness.cpp:206
struct @5 AREA
struct @10 FFT
TH1D * get_h_var(TTree *tree, const char *var, const char *hname, double bin, const char *cut)
Definition: ERTools.cpp:93

◆ draw_frame_align()

void draw_frame_align ( )
437 {
438  TCut cut("cut", "nsg>2000");
439  TTree *tfa = (TTree *)gFile->Get("FrameAlign");
440  if (tfa)
441  {
442  TH1D *z1s1 = get_h_var(tfa, "z1", "z1s1", 1., "side==0");
443  TH1D *z1s2 = get_h_var(tfa, "z1", "z1s2", 1., "side==1");
444 
445  TH2D *dxs1 = new TH2D("dxs1", "dx:z side1", 1000, z1s1->GetXaxis()->GetXmin(), z1s1->GetXaxis()->GetXmax(), 500, -2., 2.);
446  TH2D *dxs2 = new TH2D("dxs2", "dx:z side2", 1000, z1s2->GetXaxis()->GetXmin(), z1s2->GetXaxis()->GetXmax(), 500, -2., 2.);
447  TH2D *dys1 = new TH2D("dys1", "dy:z side1", 1000, z1s1->GetXaxis()->GetXmin(), z1s1->GetXaxis()->GetXmax(), 500, -2., 2.);
448  TH2D *dys2 = new TH2D("dys2", "dy:z side2", 1000, z1s2->GetXaxis()->GetXmin(), z1s2->GetXaxis()->GetXmax(), 500, -2., 2.);
449 
450  TCanvas *c = new TCanvas("fral", "frames align", 1000, 800);
451  c->Divide(2, 2);
452  c->cd(1)->SetGrid();
453  tfa->Draw("dx:z1>>dxs1", cut && "side==0", "colz");
454  c->cd(2)->SetGrid();
455  tfa->Draw("dy:z1>>dys1", cut && "side==0", "colz");
456  c->cd(3)->SetGrid();
457  tfa->Draw("dx:z1>>dxs2", cut && "side==1", "colz");
458  c->cd(4)->SetGrid();
459  tfa->Draw("dy:z1>>dys2", cut && "side==1", "colz");
460  }
461 }
TCut cut
Definition: check_shower.C:6
new TCanvas()

◆ generate_json_report()

void generate_json_report ( TH2 *  h,
std::ofstream &  report,
bool  first_plot 
)
141 {
142  if (!first_plot)
143  report << ",\n";
144 
145  // Calculate statistics
146  double sum = 0, sum2 = 0;
147  int total_bins = h->GetNbinsX() * h->GetNbinsY();
148  int empty_bins = 0;
149  int count = 0;
150 
151  for (int binx = 1; binx <= h->GetNbinsX(); ++binx)
152  {
153  for (int biny = 1; biny <= h->GetNbinsY(); ++biny)
154  {
155  if (h->GetBinContent(binx, biny) == 0)
156  {
157  empty_bins++;
158  continue;
159  }
160  double val = h->GetBinContent(binx, biny);
161  sum += val;
162  sum2 += val * val;
163  count++;
164  }
165  }
166 
167  double mean = (count > 0) ? sum / count : 0;
168  double rms = (count > 0) ? TMath::Sqrt(sum2 / count - mean * mean) : 0;
169  double empty_frac = (double)empty_bins / total_bins;
170  double density = mean / B.xbin / B.ybin * 1000 * 1000; // density in mm2
171 
172  if (!strcmp(h->GetName(), "nseg_top"))
173  {
174  RES.empty_frac_top = empty_frac;
175  RES.density_top = density;
176  }
177  if (!strcmp(h->GetName(), "nseg_bot"))
178  {
179  RES.empty_frac_bot = empty_frac;
180  RES.density_bot = density;
181  }
182 
183  int nsig = 6;
184 // h->GetZaxis()->SetRangeUser(TMath::Max(0., TMath::Max(mean - nsig/2 * rms, h->GetMinimum())),
185 // TMath::Min(3 * mean, TMath::Min(mean + nsig * rms, h->GetMaximum())));
186  h->GetZaxis()->SetRangeUser(TMath::Max(mean - nsig/2 * rms, h->GetMinimum()),
187  TMath::Min(mean + nsig * rms, h->GetMaximum()));
188 
189  h->SetTitle(Form("%s: mean = %.2f RMS = %.2f", h->GetTitle(), mean, rms));
190 
191  // JSON Output
192  report << " {\n";
193  report << " \"name\": \"" << h->GetName() << "\",\n";
194  report << " \"title\": \"" << h->GetTitle() << "\",\n";
195  report << " \"statistics\": {\n";
196  report << " \"mean\": " << mean << ",\n";
197  report << " \"rms\": " << rms << ",\n";
198  report << " \"empty_bins\": " << empty_bins << ",\n";
199  report << " \"total_bins\": " << total_bins << ",\n";
200  report << " \"empty_fraction\": " << empty_frac << "\n";
201  report << " }\n";
202  report << " }";
203 }
struct @4 RES

◆ get_step_fft()

TH1D* get_step_fft ( TH1D *  h)
207 {
208  // Perform the Fourier Transform
209  TH1 *h_fft = h->FFT(nullptr, Form("MAG_%s", h->GetName())); // Compute magnitude of FFT
210  h_fft->SetTitle("Fourier Transform;Frequency;Magnitude");
211 
212  auto peaks = FindPeaksWithIntegral(h_fft, 5, 0.1, 2, h_fft->GetNbinsX() / 2); // 5-bin window
213 
214  // Convert bin to frequency
215  double frequency = peaks[0].peak_position;
216  float xmin = h->GetXaxis()->GetXmin();
217  float xmax = h->GetXaxis()->GetXmax();
218  double step_size = (xmax - xmin) / (frequency - 1); // Step size
219  if (gEDBDEBUGLEVEL > 1)
220  {
221  for (int i = 0; i < 3; i++)
222  printf("%d %f %f %f\n",
223  i, peaks[i].peak_position, peaks[i].peak_height, peaks[i].window_integral);
224  std::cout << "Estimated step size: " << step_size << std::endl;
225  }
226 
227  int n = TMath::Ceil((xmax - xmin) / step_size);
228  xmin -= step_size / 2;
229  xmax += step_size / 2;
230  n += 1;
231 
232  TH1D *hstep = new TH1D(Form("hstep_%s", h->GetName()), "hstep", n, xmin, xmax);
233 
234  if (0)
235  {
236  // Visualize the results
237  TCanvas *c = new TCanvas(h->GetName(), "Step Size Estimation with FFT", 1200, 600);
238  c->Divide(2, 1);
239  c->cd(1);
240  h->Draw(); // Original binned data
241  c->cd(2);
242  h_fft->Draw(); // Fourier Transform
243  }
244  return hstep;
245 }
float xmin
Definition: emthickness.cpp:61
float xmax
Definition: emthickness.cpp:61
gEDBDEBUGLEVEL
Definition: energy.C:7
std::vector< PeakInfo > FindPeaksWithIntegral(TH1 *hist, int window_size, double threshold, int from_bin, int to_bin)
Definition: ERTools.cpp:9

◆ main()

int main ( int  argc,
char *  argv[] 
)
676 {
677  if (argc < 2)
678  {
680  return 0;
681  }
682 
683  set_default_env();
684  gEDBDEBUGLEVEL = cenv.GetValue("quality.EdbDebugLevel", 1);
685 
686  const char *input_file = "";
687  const char *output_file = cenv.GetValue("quality.output", "quality_report.json");
688 
689  for (int i = 1; i < argc; i++)
690  {
691  char *key = argv[i];
692  if (!strncmp(key, "-input=", 7))
693  {
694  input_file = key + 7;
695  DO.process = true;
696  }
697  if (!strncmp(key, "-out=", 5))
698  {
699  output_file = key + 5;
700  }
701  if (!strncmp(key, "-I", 2))
702  {
703  DO.interactive = true;
704  }
705  if (!strncmp(key, "-v=", 3))
706  {
707  gEDBDEBUGLEVEL = atoi(key + 3);
708  }
709  }
710 
711  cenv.ReadFile("quality.rootrc", kEnvLocal);
712  cenv.WriteFile("quality.save.rootrc");
713 
714  if (DO.interactive)
715  {
716  gROOT->SetBatch(false);
717  if (!gApplication)
718  {
719  int dummy_argc = 1;
720  char *dummy_argv[] = {"-l"};
721  new TRint("APP", &dummy_argc, dummy_argv);
722  }
723  }
724 
725  int iproc = 0;
726  if (DO.process)
727  {
728  iproc = process_file(input_file, output_file);
729  }
730  else
731  {
733  return 0;
734  }
735 
736  if (DO.interactive)
737  {
738  gApplication->Run();
739  }
740  cenv.WriteFile("quality.save.rootrc");
741  return iproc;
742 }
void set_default_env()
Definition: emthickness.cpp:118
void print_help_message()
Definition: emthickness.cpp:106
int process_file(const char *input_file, const char *output_file)
Definition: emthickness.cpp:629
struct @3 DO
TEnv cenv("qualityenv")

◆ make_canvas()

void make_canvas ( const char *  nameo = "ccc")
330 {
331  gStyle->SetNumberContours(256);
332  gStyle->SetPalette(107);
333  gStyle->SetOptStat("");
334  gStyle->SetPadRightMargin(0.12);
335 
336  TCanvas *cc = new TCanvas("thickness", Form("thickness at %s", nameo), 1920, 1080);
337 
338  TPad *header = new TPad("header", "Header", 0.0, 0.91, 1, 1); // xlow, ylow, xup, yup
339  header->Draw();
340  header->cd();
341  TPaveText *tp = new TPaveText(0.01, 0.01, 0.99, 0.99, "NDC");
342  tp->AddText(Form("%s of %s %.1f GB",
343  RES.filename.c_str(),
344  RES.file_creation_date.AsString(),
345  RES.file_size / 1024. / 1024. / 1024.));
346  tp->AddText(Form("Xrange: %.1f %.1f Yrange: %.1f %.1f Step: %.1f %.1f ScanTime: %.2f h",
347  B.xmin, B.xmax, B.ymin, B.ymax, B.xbin, B.ybin, RES.scan_time / 60. / 60.));
348  tp->AddText(Form(
349  "Requested/Scanned: %.1f / %.1f cm2 EmptyTop: %.2f %% EmptyBot: %.2f %% Density/mm2: Top = %.1f Bot = %.1f",
350  RES.requested_area, RES.scanned_area, RES.empty_frac_top * 100, RES.empty_frac_bot * 100, RES.density_top, RES.density_bot));
351  if (AREA.fractionS * (1. - RES.empty_frac_top) < AREA.fraction || AREA.fractionS * (1. - RES.empty_frac_bot) < AREA.fraction)
352  {
353  tp->SetTextColor(kRed);
354  // tp->AddText("WARNING: Scanned area or empty fraction below requested!");
355  }
356  tp->Draw();
357 
358  cc->cd(0);
359  TPad *pad = new TPad("pad", "", 0., 0., 1., 0.9);
360  pad->Draw();
361  pad->cd();
362  pad->Divide(3, 2, 0.01, 0.01);
363 
364  pad->cd(1);
365  H.nseg_top->Draw("prof colz");
366  pad->cd(4);
367  H.nseg_bot->Draw("prof colz");
368  pad->cd(2);
369  H.thick_top->Draw("prof colz");
370  pad->cd(5);
371  H.thick_bot->Draw("prof colz");
372  pad->cd(3);
373  H.thick_base->Draw("prof colz");
374  pad->cd(6);
375  H.glass->Draw("prof colz");
376  pad->cd(0);
377  TDatime time;
378  TText *t = new TText();
379  t->SetTextSize(0.015);
380  t->DrawText(0.25, 0.0001, Form("%s/%s %s", gSystem->WorkingDirectory(), RES.filename.c_str(), time.AsString()));
381  if (gROOT->IsBatch())
382  cc->SaveAs(Form("%s.png", nameo));
383 }
TTree * t
Definition: check_shower.C:4
struct @9 H

◆ make_histos()

void make_histos ( TTree *  tree)
288 {
289  TCut sideTop = "eNframesTop>0";
290  TCut sideBot = "eNframesBot>0";
291  TProfile2D *hview = new TProfile2D("hview", "hview", B.nx, B.xmin, B.xmax, B.ny, B.ymin, B.ymax);
292 
293  H.nseg_top = (TProfile2D *)(hview->Clone("nseg_top"));
294  H.nseg_top->SetTitle("nseg_top");
295  H.nseg_bot = (TProfile2D *)(hview->Clone("nseg_bot"));
296  H.nseg_bot->SetTitle("nseg_bot");
297  H.thick_top = (TProfile2D *)(hview->Clone("thick_top"));
298  H.thick_top->SetTitle("thick_top");
299  H.thick_bot = (TProfile2D *)(hview->Clone("thick_bot"));
300  H.thick_bot->SetTitle("thick_bot");
301  H.glass = (TProfile2D *)(hview->Clone("glass"));
302  H.glass->SetTitle("glass");
303  TProfile2D *hz2 = (TProfile2D *)(hview->Clone("hz2"));
304  TProfile2D *hz3 = (TProfile2D *)(hview->Clone("hz3"));
305  H.thick_base = new TH2D("thick_base", "thick_base", B.nx, B.xmin, B.xmax, B.ny, B.ymin, B.ymax);
306 
307  tree->Draw("eNsegments:eYview:eXview>>nseg_top", sideTop, "goff prof colz");
308  tree->Draw("eNsegments:eYview:eXview>>nseg_bot", sideBot, "goff prof colz");
309  tree->Draw("eZ1-eZ2:eYview:eXview>>thick_top", sideTop, "goff prof colz");
310  tree->Draw("eZ3-eZ4:eYview:eXview>>thick_bot", sideBot, "goff prof colz");
311  tree->Draw("eZ2:eYview:eXview>>hz2", sideTop, "goff prof colz");
312  tree->Draw("eZ3:eYview:eXview>>hz3", sideBot, "goff prof colz");
313  tree->Draw("eZ4:eYview:eXview>>glass", sideBot, "goff prof colz");
314 
315  DiffProfile2D(hz2, hz3, H.thick_base);
316 
317  RES.scanned_area = AREA.areaS / 10000. / 10000.; // cm2
318 
319  tree->Draw("eEvent>>htime(10000)", "eViewID>0", "goff");
320  TH1 *htime = (TH1 *)(gDirectory->Get("htime"));
321  if (htime)
322  RES.scan_time = htime->Integral() * htime->GetMean() / 1000.; // scan time in seconds
323 
324  SafeDelete(hview);
325  SafeDelete(hz2);
326  SafeDelete(hz3);
327 }
void DiffProfile2D(const TProfile2D *prof1, const TProfile2D *prof2, TH2D *hDiff)
Definition: ERTools.cpp:76

◆ make_report()

int make_report ( const char *  output_file)
386 {
387  // Open JSON report
388  std::ofstream report(Form("%s.json", output_file));
389  if (!report.is_open())
390  {
391  Log(1, "quality_report", "Error opening output file: %s", output_file);
392  return 3;
393  }
394 
395  RES.requested_area = AREA.areaR / 10000. / 10000.; // cm2
396  RES.covered_area = AREA.areaS / 10000. / 10000.; // cm2
397 
398  report << "{\n";
399  report << " \"metadata\": {\n";
400  report << " \"input_file\": \"" << RES.filename << "\",\n";
401  report << " \"file_creation_date\": \"" << RES.file_creation_date.AsString() << "\",\n";
402  report << " \"file_modification_date\": \"" << RES.file_modification_date.AsString() << "\",\n";
403  report << " \"file_size\": \"" << RES.file_size << "\",\n";
404  report << " \"timestamp\": \"" << TDatime().AsString() << "\"\n";
405  report << " },\n";
406  report << " \"plots\": [\n";
407 
408  // Process all 2D histograms
409  bool first_plot = true;
410  TIter next(gDirectory->GetList());
411  while (TObject *obj = next())
412  {
413  if (obj->InheritsFrom("TH2") || obj->InheritsFrom("TProfile2D"))
414  {
415  generate_json_report((TH2 *)obj, report, first_plot);
416  first_plot = false;
417  }
418  }
419  report << "\n ],\n";
420  report << " \"result\": {\n";
421  report << " \"scan_time\": \"" << RES.scan_time << "\",\n";
422  report << " \"scanned_area\": \"" << RES.scanned_area << "\",\n";
423  report << " \"empty_frac_top\": \"" << RES.empty_frac_top << "\",\n";
424  report << " \"empty_frac_bot\": \"" << RES.empty_frac_bot << "\",\n";
425  report << " \"density_top\": \"" << RES.density_top << "\",\n";
426  report << " \"density_bot\": \"" << RES.density_bot << "\"\n";
427  report << " }\n";
428  report << "}\n";
429  report.close();
430 
431  Log(2, "quality_report", "Report generated: %s", output_file);
432  return 0;
433 }
void generate_json_report(TH2 *h, std::ofstream &report, bool first_plot)
Definition: emthickness.cpp:140

◆ make_snd_profiles()

void make_snd_profiles ( const char *  nameo = "snd_profiles")
480 {
481  gStyle->SetNumberContours(256);
482  gStyle->SetPalette(1);
483  gStyle->SetOptStat("");
484  gStyle->SetPadRightMargin(0.12);
485  // gStyle->SetPadTopMargin(0.12);
486 
487  P.X0 = cenv.GetValue("quality.prof.X0", 100000);
488  P.Y0 = cenv.GetValue("quality.prof.Y0", 100000);
489  P.width = cenv.GetValue("quality.prof.width", 1000);
490 
491  TTree *Views = (TTree *)gFile->Get("Views");
492  TH1D *hz4 = get_h_var(Views, "headers.eZ4", "hz4", 1, "eNframesBot>0");
493  float z4mean = hz4->GetMean();
494  float glassmin = z4mean - 100;
495  float glassmax = z4mean + 500;
496 
497  cout << "Check scanned data surface and profiles" << endl;
498 
499  TCut cTop = "eNframesTop!=0";
500  TCut cBot = "eNframesBot!=0";
501  TCut cutXline = Form("abs(eYview-%.1f)<%.1f", P.Y0, P.width);
502  TCut cutYline = Form("abs(eXview-%.1f)<%.1f", P.X0, P.width);
503 
504  TCanvas *cc = new TCanvas("check_snd", gFile->GetName(), 1920, 1080);
505  TPad *header = new TPad("header", "Header", 0.005, 0.94, 1, 1); // xlow, ylow, xup, yup
506  header->Draw();
507  header->cd();
508  TPaveText *tp = new TPaveText(0.01, 0.01, 0.99, 0.99, "NDC");
509  tp->AddText(Form("%s of %s", RES.filename.c_str(), RES.file_creation_date.AsString()));
510  tp->AddText(Form("profiles at %.1f %.1f +- %.1f ", P.X0, P.Y0, P.width));
511  tp->Draw();
512 
513  cc->cd(0);
514  TPad *pad = new TPad("pad", "", 0., 0., 1., 0.94);
515  pad->Draw();
516  pad->cd();
517  pad->Divide(3, 2, 0.01, 0.01);
518 
519  TLine *lineX1 = new TLine(B.xmin, P.Y0 - P.width, B.xmax, P.Y0 - P.width);
520  lineX1->SetLineStyle(3);
521  TLine *lineX2 = new TLine(B.xmin, P.Y0 + P.width, B.xmax, P.Y0 + P.width);
522  lineX2->SetLineStyle(3);
523  TLine *lineY1 = new TLine(P.X0 - P.width, B.ymin, P.X0 - P.width, B.ymax);
524  lineY1->SetLineStyle(3);
525  TLine *lineY2 = new TLine(P.X0 + P.width, B.ymin, P.X0 + P.width, B.ymax);
526  lineY2->SetLineStyle(3);
527  pad->cd(1);
528  Views->Draw(Form("eNsegments:eYview:eXview>>hxy1(%d,%f,%f,%d,%f,%f)", B.nx, B.xmin, B.xmax, B.ny, B.ymin, B.ymax), cTop, "prof colz");
529  lineX1->Draw();
530  lineX2->Draw();
531  lineY1->Draw();
532  lineY2->Draw();
533  pad->cd(4);
534  Views->Draw(Form("eNsegments:eYview:eXview>>hxy2(%d,%f,%f,%d,%f,%f)", B.nx, B.xmin, B.xmax, B.ny, B.ymin, B.ymax), cBot, "prof colz");
535  lineX1->Draw();
536  lineX2->Draw();
537  lineY1->Draw();
538  lineY2->Draw();
539 
540  gStyle->SetOptStat("n");
541  pad->cd(2)->SetGrid();
542  Views->Draw(Form("eNcl:eZframe:eXview>>hpx(%d,%f,%f,%d,%f,%f)", B.nx, B.xmin, B.xmax, 1200, glassmin, glassmax), cutXline, "prof colz");
543  Views->SetMarkerColor(6);
544  Views->SetMarkerStyle(7);
545  Views->Draw("eZ1:eXview", cTop && cutXline, "same");
546  Views->Draw("eZ2:eXview", cTop && cutXline, "same");
547  Views->Draw("eZ3:eXview", cBot && cutXline, "same");
548  Views->Draw("eZ4:eXview", cBot && cutXline, "same");
549  Views->SetMarkerColor(kBlack);
550  pad->cd(3)->SetGrid();
551  Views->Draw(Form("eNcl:eZframe:eYview>>hpy(%d,%f,%f,%d,%f,%f)", B.ny, B.ymin, B.ymax, 1200, glassmin, glassmax), cutYline, "prof colz");
552  Views->SetMarkerColor(6);
553  Views->SetMarkerStyle(7);
554  Views->Draw("eZ1:eYview", cTop && cutYline, "same");
555  Views->Draw("eZ2:eYview", cTop && cutYline, "same");
556  Views->Draw("eZ3:eYview", cBot && cutYline, "same");
557  Views->Draw("eZ4:eYview", cBot && cutYline, "same");
558  // Views->SetMarkerColor(kBlack);
559 
561 
562  TVirtualPad *px = pad->cd(5);
563  px->Divide(1, 2);
564  px->cd(1);
565  Views->Draw(Form("segments.eDz:eXview>>hdz51(%d,%f,%f,90,0,90)", B.nx, B.xmin, B.xmax), cTop && cutXline, "colz");
566  Views->Draw(Form("eZ1-eZ2:eXview>>hdz510(%d,%f,%f,90,0,90)", B.nx, B.xmin, B.xmax), cTop && cutXline, "same");
567  Views->Draw("eZ1-eZ2>>hdz511(90,0,90)", cTop && cutYline, "goff");
568  TH2F *hdz51 = (TH2F *)gDirectory->Get("hdz51");
569  Z.dzx1 = hdz51->GetMean(2);
570  TH1F *hdz511 = (TH1F *)gDirectory->Get("hdz511");
571  Z.szx1 = hdz511->GetMean();
572  TText *t51 = new TText(0.15, 0.2, Form("surf_dZ - seg_dZ = %.1f - %.1f = %.1f um", Z.szx1, Z.dzx1, Z.szx1 - Z.dzx1));
573  t51->SetNDC();
574  t51->SetTextSize(0.07);
575  t51->Draw();
576 
577  px->cd(2);
578  Views->Draw(Form("segments.eDz:eXview>>hdz52(%d,%f,%f,90,0,90)", B.nx, B.xmin, B.xmax), cBot && cutXline, "colz");
579  Views->Draw(Form("eZ3-eZ4:eXview>>hdz520(%d,%f,%f,90,0,90)", B.nx, B.xmin, B.xmax), cBot && cutXline, "same");
580  Views->Draw("eZ1-eZ2>>hdz521(90,0,90)", cTop && cutYline, "goff");
581  TH2F *hdz52 = (TH2F *)gDirectory->Get("hdz52");
582  Z.dzx2 = hdz52->GetMean(2);
583  TH1F *hdz521 = (TH1F *)gDirectory->Get("hdz521");
584  Z.szx2 = hdz521->GetMean();
585  TText *t52 = new TText(0.15, 0.2, Form("surf_dZ - seg_dZ = %.1f - %.1f = %.1f um", Z.szx2, Z.dzx2, Z.szx2 - Z.dzx2));
586  t52->SetNDC();
587  t52->SetTextSize(0.07);
588  t52->Draw();
589 
590  TVirtualPad *py = pad->cd(6);
591  py->Divide(1, 2);
592  py->cd(1);
593  Views->Draw(Form("segments.eDz:eYview>>hdz61(%d,%f,%f,90,0,90)", B.ny, B.ymin, B.ymax), cTop && cutYline, "colz");
594  Views->Draw(Form("eZ1-eZ2:eYview>>hdz610(%d,%f,%f,90,0,90)", B.ny, B.ymin, B.ymax), cTop && cutYline, "same");
595  Views->Draw("eZ1-eZ2>>hdz611(90,0,90)", cTop && cutYline, "goff");
596  TH2F *hdz61 = (TH2F *)gDirectory->Get("hdz61");
597  Z.dzy1 = hdz61->GetMean(2);
598  TH1F *hdz611 = (TH1F *)gDirectory->Get("hdz611");
599  Z.szy1 = hdz611->GetMean();
600  TText *t61 = new TText(0.15, 0.2, Form("surf_dZ - seg_dZ = %.1f - %.1f = %.1f um", Z.szy1, Z.dzy1, Z.szy1 - Z.dzy1));
601  t61->SetNDC();
602  t61->SetTextSize(0.07);
603  t61->Draw();
604 
605  py->cd(2);
606  Views->Draw(Form("segments.eDz:eYview>>hdz62(%d,%f,%f,90,0,90)", B.ny, B.ymin, B.ymax), cBot && cutYline, "colz");
607  Views->Draw(Form("eZ3-eZ4:eYview>>hdz620(%d,%f,%f,90,0,90)", B.ny, B.ymin, B.ymax), cBot && cutYline, "same");
608  Views->Draw("eZ3-eZ4>>hdz621(90,0,90)", cBot && cutYline, "goff");
609  TH2F *hdz62 = (TH2F *)gDirectory->Get("hdz62");
610  Z.dzy2 = hdz62->GetMean(2);
611  TH1F *hdz621 = (TH1F *)gDirectory->Get("hdz621");
612  Z.szy2 = hdz621->GetMean();
613  TText *t62 = new TText(0.15, 0.2, Form("surf_dZ - seg_dZ = %.1f - %.1f = %.1f um", Z.szy2, Z.dzy2, Z.szy2 - Z.dzy2));
614  t62->SetNDC();
615  t62->SetTextSize(0.07);
616  t62->Draw();
617 
618  pad->cd(0);
619  TDatime time;
620  TText *t = new TText();
621  t->SetTextSize(0.015);
622  t->DrawText(0.25, 0.0001, Form("%s/%s %s", gSystem->WorkingDirectory(), RES.filename.c_str(), time.AsString()));
623 
624  if (gROOT->IsBatch())
625  cc->SaveAs(Form("%s.prof.png", nameo));
626 }
struct @7 P
struct @8 Z
void SetLargeLabelsStyle()
Definition: emthickness.cpp:463

◆ print_help_message()

void print_help_message ( )
107 {
108  cout << "\nUsage: \n\t emthickness -input=file.raw.root [ -out=report -I -v=DEBUG] \n";
109  cout << "\t Generate quality report for raw data\n";
110  cout << "\t\t -input - input raw root file with tracks\n";
111  cout << "\t\t -out - output report filename (default: raw_quality_report[.json],[.png] )\n";
112  cout << "\t\t -I - open interactive root session\n";
113  cout << "\t\t -v - verbosity level\n";
114  cout << endl;
115 }

◆ process_file()

int process_file ( const char *  input_file,
const char *  output_file 
)
630 {
631  TFile *file = TFile::Open(input_file);
632  if (!file || file->IsZombie())
633  {
634  Log(1, "process_file", "Error opening input file: %s", input_file);
635  return 1;
636  }
637  RES.filename = input_file;
638 
639  Long_t id, flags, time;
640  gSystem->GetPathInfo(input_file, &id, &(RES.file_size), &flags, &time);
641  RES.file_modification_date.Set(time);
642  RES.file_creation_date = file->GetCreationDate();
643  std::cout << "File: " << input_file << "\n";
644 
645  TTree *tree = (TTree *)file->Get("Views");
646  if (!tree)
647  {
648  Log(1, "process_file", "Error: No 'Views' tree found in file");
649  return 2;
650  }
651 
652  AREA.xmaxR = cenv.GetValue("quality.request.Xmax", 185000.);
653  AREA.xminR = cenv.GetValue("quality.request.Xmin", 5000.);
654  AREA.ymaxR = cenv.GetValue("quality.request.Ymax", 185000.);
655  AREA.yminR = cenv.GetValue("quality.request.Ymin", 5000.);
656  AREA.fraction = cenv.GetValue("quality.request.fraction", 0.9);
657  AREA.areaR = (AREA.xmaxR - AREA.xminR) * (AREA.ymaxR - AREA.yminR);
658 
659  define_steps(tree);
660 
661  P.prof = cenv.GetValue("quality.prof", 1);
662 
663  make_histos(tree);
664  if (P.prof)
665  make_snd_profiles(output_file);
666  make_report(output_file);
667  make_canvas(output_file);
668  if (DO.interactive)
670 
671  return 0;
672 }
void make_histos(TTree *tree)
Definition: emthickness.cpp:287
void make_snd_profiles(const char *nameo="snd_profiles")
Definition: emthickness.cpp:479
void define_steps(TTree *tree)
Definition: emthickness.cpp:248
void make_canvas(const char *nameo="ccc")
Definition: emthickness.cpp:329
void draw_frame_align()
Definition: emthickness.cpp:436
int make_report(const char *output_file)
Definition: emthickness.cpp:385
UInt_t id
Definition: tlg2pattern.C:118
TFile * file
Definition: write_pvr.C:3

◆ set_default_env()

void set_default_env ( )
119 {
120  cenv.SetValue("quality.input", "");
121  cenv.SetValue("quality.output", "raw_quality_report");
122 
123  cenv.SetValue("quality.request.Xmin", 5000.);
124  cenv.SetValue("quality.request.Ymin", 5000.);
125  cenv.SetValue("quality.request.Xmax", 185000.);
126  cenv.SetValue("quality.request.Ymax", 185000.);
127  cenv.SetValue("quality.request.fraction", 0.9);
128 
129  cenv.SetValue("quality.prof", 1);
130  cenv.SetValue("quality.prof.X0", 100000);
131  cenv.SetValue("quality.prof.Y0", 100000);
132  cenv.SetValue("quality.prof.width", 1000);
133 
134  cenv.SetValue("quality.frameal", 1);
135 
136  cenv.SetValue("quality.EdbDebugLevel", 1);
137 }

◆ SetLargeLabelsStyle()

void SetLargeLabelsStyle ( )
464 {
465  gStyle->SetOptStat("e");
466  // Axis titles and labels
467  gStyle->SetTitleSize(0.06, "XYZ");
468  gStyle->SetLabelSize(0.06, "XYZ");
469  gStyle->SetLabelFont(42, "XYZ");
470  // Statistics box (if enabled)
471  gStyle->SetStatFontSize(0.05);
472  gStyle->SetStatFont(42);
473  // Legend
474  gStyle->SetLegendTextSize(0.05);
475  gStyle->SetLegendFont(42);
476 }

Variable Documentation

◆ 

struct { ... } AREA

◆ areaR

float areaR

◆ areaS

float areaS

◆ 

struct { ... } B

◆ bin

float bin = 20

◆ covered_area

float covered_area

◆ density_bot

float density_bot

◆ density_top

float density_top

◆ 

struct { ... } DO

◆ dzx1

float dzx1

◆ dzx2

float dzx2

◆ dzy1

float dzy1

◆ dzy2

float dzy2

◆ empty_frac_bot

float empty_frac_bot

◆ empty_frac_top

float empty_frac_top

◆ 

struct { ... } FFT

◆ file_creation_date

TDatime file_creation_date

◆ file_modification_date

TDatime file_modification_date

◆ file_size

Long_t file_size

◆ filename

string filename

◆ fraction

float fraction

◆ fractionS

float fractionS

◆ glass

TProfile2D* glass

◆ 

struct { ... } H

◆ interactive

bool interactive = false

◆ nseg_bot

TProfile2D* nseg_bot

◆ nseg_top

TProfile2D* nseg_top

◆ nx

int nx

◆ ny

int ny

◆ 

struct { ... } P

◆ process

bool process = false

◆ prof

int prof = 1

◆ requested_area

float requested_area

◆ 

struct { ... } RES

◆ scan_time

float scan_time

◆ scanned_area

float scanned_area

◆ szx1

float szx1

◆ szx2

float szx2

◆ szy1

float szy1

◆ szy2

float szy2

◆ thick_base

TH2D* thick_base

◆ thick_bot

TProfile2D* thick_bot

◆ thick_top

TProfile2D* thick_top

◆ width

float width = 1000

◆ X0

float X0 = 100000

◆ xbin

float xbin

◆ xmax

float xmax

◆ xmaxR

float xmaxR

◆ xmaxS

float xmaxS

◆ xmin

float xmin

◆ xminR

float xminR

◆ xminS

float xminS

◆ Y0

float Y0 = 100000

◆ ybin

float ybin

◆ ymax

float ymax

◆ ymaxR

float ymaxR

◆ ymaxS

float ymaxS

◆ ymin

float ymin

◆ yminR

float yminR

◆ yminS

float yminS

◆ 

struct { ... } Z