Functions | Variables
AnaPlotMaker.h File Reference
#include <fstream>
#include <TH1F.h>
#include <TH2F.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <TTree.h>
#include <TCanvas.h>
#include <TFile.h>
#include <TPaveText.h>
#include <TLegend.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TDatime.h>
#include <TMultiGraph.h>
#include <TGaxis.h>
#include <TPaveStats.h>
#include <TSQLServer.h>
#include <TSQLResult.h>
#include <TSQLStatement.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>

Go to the source code of this file.

Functions

void eff_plots (unsigned int, string, string, string, string)
 

Variables

ifstream inFile
 
const unsigned int Npar = 5
 
TDatime * TNowGMT
 
TDatime * TNow
 
TDatime * SRtime
 
Int_t GMToffset
 
unsigned int run
 
unsigned int subrun
 
UInt_t par
 
UInt_t LastRun
 
UInt_t LastSR
 
UInt_t Last_Run [Npar]
 
UInt_t Last_SR [Npar]
 
TH2F * hHitsVwcellDay [Npar]
 
TH2F * hCellsVwcellDay [Npar]
 

Function Documentation

void eff_plots ( unsigned  int,
string  ,
string  ,
string  ,
string   
)

Definition at line 3332 of file AnaPlotMaker.C.

References demo5::c1, demo5::c2, chisquared::c3, chisquared::c4, getBrightness::cell, nd_projection_maker::eff, allTimeWatchdog::endl, copy_new_pkl_files::f_name, GMToffset, hCellsVwcellDay, hHitsVwcellDay, Last_Run, Last_SR, new_module::module, NDAPDHVSetting::plane, PLOT_DIR, std::sqrt(), UpdateText, POTSpillRate::view, and w.

Referenced by AnaPlotMaker().

3332  {
3333 
3334 
3335  // Output file list of low efficiency modules.
3336  ofstream modules;
3337 
3338  int ncellbins_local = 344065;
3339  double cellmin_local = -0.5;
3340  double cellmax_local = 344064.5;
3341  int nwbins_local = 32;
3342  double wmin_local = -800;
3343  double wmax_local = 800;
3344 
3345  double wavglength = 200.0; // low w length to average cell/module efficiencies over
3346  int wbinlow = 1;
3347  int wbinhigh = 5;
3348 
3349  char f_name[56];
3350  char hmod_name[56];
3351 
3352  // Defing binning for histograms that will be made here
3353  int neffbins = 101;
3354  double effmin = -0.05;
3355  double effmax = 1.05;
3356  int nplbins = 897;
3357  double plmin = -0.5;
3358  double plmax = nplbins-0.5;
3359  int nmodbins = 12;
3360  double modmin = 0;
3361  double modmax = 12;
3362 
3363 // TH1F* mod_Eff[12];
3364 // for(int imod=0;imod<12;imod++){
3365 // sprintf(hmod_name,"mod%ieffperplane",imod);
3366 // mod_Eff[imod] = new TH1F(hmod_name,hmod_name,nplbins,0,nplbins);
3367 // }
3368 
3369  TH2F* moduleEfficiencyAverage = new TH2F("moduleEfficiencyAverage",";Plane;Module",
3370  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3371  TH2F* moduleEfficiencyRMS = new TH2F("moduleEfficiencyRMS",";Plane;Module",
3372  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3373  TH2F* moduleEfficiencyAverageXView = new TH2F("moduleEfficiencyAverageXView",";Plane;Module",
3374  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3375  TH2F* moduleEfficiencyRMSXView = new TH2F("moduleEfficiencyRMSXView",";Plane;Module",
3376  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3377 
3378  TH2F* moduleEfficiencyAverageYView = new TH2F("moduleEfficiencyAverageYView",";Plane;Module",
3379  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3380  TH2F* moduleEfficiencyRMSYView = new TH2F("moduleEfficiencyRMSYView",";Plane;Module",
3381  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3382 
3383  // Histogram of efficiency for a module
3384  TH1F* modeff = new TH1F("modeff",";Efficiency;NCells",neffbins,effmin,effmax);
3385 
3386  // Histogram of efficiency vs w for one cell
3387  TH1F* eff = new TH1F("eff","",nwbins_local,wmin_local,wmax_local);
3388 
3389  int currmodule = 0;
3390  int currplane = 0;
3391  int currview = 0; // View convention y = 0, x = 1
3392 
3393  // loop over every cell in each partition
3394  if(par_eff==1 && period=="Month"){
3395  char lowEffFile[150];
3396  sprintf(lowEffFile, "%s/low_eff_modules.txt", PLOT_DIR.c_str());
3397  modules.open(lowEffFile);
3398  modules<<"Partition "<<par_eff<<std::endl;
3399  modules<<std::endl;
3400  }
3401  for(int icell = 1; icell <= ncellbins_local; ++icell){
3402 
3403  // convert this to a plane and cell number
3404  int cell = (icell-1)%384;
3405  int plane = (icell-1-cell)/384;
3406  int modcell = cell%32;
3407  int module = (cell-modcell)/32;
3408  int view = plane%2; // view = 0 y, view = 1 x
3409 
3410  if(plane != currplane || module != currmodule){
3411  // fill in the histogram of average efficiency and rms of average for the last module
3412  double effavg = modeff->GetMean();
3413  double effrms = modeff->GetRMS();
3414  //double effavg_far = modeff_far->GetMean();
3415  int planebin = moduleEfficiencyAverage->GetXaxis()->FindFixBin(currplane);
3416  int modulebin = moduleEfficiencyAverage->GetYaxis()->FindFixBin((double)currmodule + 0.5);
3417 
3418  if(par_eff==1 && period=="Month"){
3419  if(effavg<0.3){
3420  modules<<"module: "<<modulebin<<" plane: "<<planebin<<" efficiency: "<<effavg<<std::endl;
3421  }
3422  }
3423  //mod_Eff[modulebin-1]->Fill(planebin,effavg);
3424  moduleEfficiencyAverage->SetBinContent(planebin,modulebin,effavg);
3425  moduleEfficiencyRMS->SetBinContent(planebin,modulebin,effrms);
3426  if(currview){
3427  // x view
3428  moduleEfficiencyAverageXView->SetBinContent(planebin,modulebin,effavg);
3429  moduleEfficiencyRMSXView->SetBinContent(planebin,modulebin,effrms);
3430  }
3431  else{
3432  // y view
3433  moduleEfficiencyAverageYView->SetBinContent(planebin,modulebin,effavg);
3434  moduleEfficiencyRMSYView->SetBinContent(planebin,modulebin,effrms);
3435  }
3436  // reset things for the new module
3437  modeff->Reset("ICES");
3438  currmodule = module;
3439  currplane = plane;
3440  currview = view;
3441  }
3442 
3443 
3444  // need to switch the module in cell for x view
3445 
3446  if(view){ modcell = 31-modcell; }
3447 
3448  // loop over every w bin
3449  double totcell = 0.0;
3450  double tothit = 0.0;
3451 
3452  // Calculate the cell efficiency vs w
3453  for(int iw = 1; iw <= nwbins_local; ++iw){
3454  // get the efficiency at this cell/w, eff = k/n
3455  double k = hHitsVwcellDay[par_eff]->GetBinContent(icell,iw);
3456  double n = hCellsVwcellDay[par_eff]->GetBinContent(icell,iw);
3457 
3458  totcell+=n;
3459  tothit+=k;
3460  double ef = k/n;
3461  if(n == 0){ ef = 0; }
3462 
3463  // calculate the variance of this
3464  double var = (k+1)*(k+2)/((n+2)*(n+3)) - (k+1)*(k+1)/((n+2)*(n+2));
3465 
3466  double w = hHitsVwcellDay[par_eff]->GetYaxis()->GetBinCenter(iw);
3467 
3468  eff->SetBinContent(iw,ef);
3469  eff->SetBinError(iw,sqrt(var));
3470 
3471  }
3472 
3473 
3474  // Average over the last 200 cm of the cell
3475  double efftot = eff->Integral(wbinlow,wbinhigh);
3476  double navgbins = wbinhigh-wbinlow+1.0;
3477 
3478  modeff->Fill(efftot/navgbins);
3479 
3480  }
3481  if(par_eff==1 && period=="Month") modules.close();
3482 
3483  char title_buff[128];
3484 
3485  gStyle->SetTimeOffset(0);
3486  string t_title;
3487  if(period == "Day") t_title = "(past 24 hrs.)";
3488  if(period == "Week") t_title = "(past week)";
3489  if(period == "Month") t_title = "(past month)";
3490  if(period == "6Months") t_title = "(past 26 weeks)";
3491  if(period == "Month") t_title = "(past 52 weeks)";
3492 
3493  TDatime *Ttemp = new TDatime; // finish time
3494  int Xfin = Ttemp->Convert() - GMToffset;
3495  TDatime *Tfinish = new TDatime(Xfin); // finish time
3496  TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
3497  UpdateText->SetLineColor(0);
3498  UpdateText->SetFillColor(0);
3499  UpdateText->SetBorderSize(1);
3500  UpdateText->SetMargin(0.0);
3501  UpdateText->SetTextAlign(11);
3502  char buff1[256];
3503  sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
3504  UpdateText->AddText(buff1);
3505  char buff2[256];
3506  sprintf(buff2, "Last run / subrun: %d / %d", Last_Run[par_eff], Last_SR[par_eff]);
3507  UpdateText->AddText(buff2);
3508 
3509  TPaveText *StatusText = new TPaveText(0.1, 0.1, 0.9, 0.9, "NDC");
3510  StatusText->SetLineColor(1);
3511  StatusText->SetFillColor(0);
3512  StatusText->SetBorderSize(1);
3513  // StatusText->SetMargin(0.0);
3514  StatusText->AddText(buff1);
3515  StatusText->AddText(buff2);
3516 
3517  TCanvas* c1 = new TCanvas("c1","c1",1200,800);
3518  gStyle->SetOptStat(0);
3519  sprintf(title_buff,"Average Module Efficiency %s - partition %.1u",t_title.c_str(),par_eff);
3520  moduleEfficiencyAverage->SetTitle(title_buff);
3521  moduleEfficiencyAverage->Draw("colz");
3522  //moduleEfficiencyAverage->GetXaxis()->SetRangeUser(0.,300.);
3523  gPad->Update();
3524 // TPaveStats *stats1 = (TPaveStats*)moduleEfficiencyAverage->FindObject("stats");
3525 // stats1->SetX1NDC(0.65);
3526 // stats1->SetY1NDC(0.65);
3527 // stats1->SetX2NDC(0.90);
3528 // stats1->SetY2NDC(0.90);
3529  c1->Modified();
3530  c1->Update();
3531  UpdateText->Draw();
3532  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3533  c1->Print(f_name);
3534  delete c1;
3535  c1 = 0;
3536 
3537  //////////////////////////////////////////////////////////////////////
3538  // Creating list of low efficiency modules and corresponding planes.//
3539  //////////////////////////////////////////////////////////////////////
3540  /* TFile *test_out = new TFile("testout.root","RECREATE");
3541  modules.open("low_eff_modules.txt");
3542  //int Nbinsy = moduleEfficiencyAverage->GetNbinsY();
3543  //int Nbinsx = moduleEfficiencyAverage->GetNbinsX();
3544  if(det=="FarDet" && period=="Day"){
3545  for(int i=1;i<257;i++){
3546  for(int j=1;j<13;j++){
3547  //Int_t bin_num = moduleEfficiencyAverage->FindFixBin(double(i)+0.5,j);
3548  //Int_t bin_num = moduleEfficiencyAverage->GetBin(i+1,j+1);
3549  Double_t eff_mod = moduleEfficiencyAverage->GetBinContent(i,j);
3550  //std::cout<<bin_num<<" "<<eff_mod<<std::endl;
3551  //if(eff_mod<0.6){
3552  //modules<<" plane: "<<i<<" module: "<<j<<" efficiency: "<<eff_mod<<std::endl;
3553  modules << moduleEfficiencyAverage->GetBinContent(i,j)<<std::endl;
3554  //}
3555  }
3556  }
3557  }
3558  modules.close();
3559  test_out->cd();
3560  for(int ii=0;ii<12;ii++){
3561  mod_Eff[ii]->Write();
3562  }
3563  //moduleEfficiencyAverage->Write();
3564  //test_out->Close();
3565  */
3566 
3567  TCanvas* c2 = new TCanvas("c2","c2",1200,800);
3568  gStyle->SetOptStat(0);
3569  sprintf(title_buff,"%s Average Module Efficiency RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3570  moduleEfficiencyRMS->SetTitle(title_buff);
3571  moduleEfficiencyRMS->Draw("colz");
3572  //moduleEfficiencyRMS->GetXaxis()->SetRangeUser(0.,300.);
3573  gPad->Update();
3574 // TPaveStats *stats2 = (TPaveStats*)moduleEfficiencyRMS->FindObject("stats");
3575 // stats2->SetX1NDC(0.65);
3576 // stats2->SetY1NDC(0.65);
3577 // stats2->SetX2NDC(0.90);
3578 // stats2->SetY2NDC(0.90);
3579  c2->Modified();
3580  c2->Update();
3581  UpdateText->Draw();
3582  sprintf(f_name,"%s/%s-%s-P%.1uModuleEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3583  c2->Print(f_name);
3584  delete c2;
3585  c2 = 0;
3586 
3587  TCanvas* c3 = new TCanvas("c3","c3",1200,800);
3588  gStyle->SetOptStat(0);
3589  sprintf(title_buff,"%s Average Module Efficiency In X-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3590  moduleEfficiencyAverageXView->SetTitle(title_buff);
3591  moduleEfficiencyAverageXView->Draw("colz");
3592  moduleEfficiencyAverageXView->RebinX(2);
3593  //moduleEfficiencyAverageXView->GetXaxis()->SetRangeUser(0.,300.);
3594  gPad->Update();
3595 // TPaveStats *stats3 = (TPaveStats*)moduleEfficiencyAverageXView->FindObject("stats");
3596 // stats3->SetX1NDC(0.65);
3597 // stats3->SetY1NDC(0.65);
3598 // stats3->SetX2NDC(0.90);
3599 // stats3->SetY2NDC(0.90);
3600  c3->Modified();
3601  c3->Update();
3602  UpdateText->Draw();
3603  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleXEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3604  c3->Print(f_name);
3605  delete c3;
3606  c3 = 0;
3607 
3608  TCanvas* c4 = new TCanvas("c4","c4",1200,800);
3609  gStyle->SetOptStat(0);
3610  sprintf(title_buff,"%s Average Module Efficiency In X-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3611  moduleEfficiencyRMSXView->SetTitle(title_buff);
3612  moduleEfficiencyRMSXView->Draw("colz");
3613  moduleEfficiencyRMSXView->RebinX(2);
3614  //moduleEfficiencyRMSXView->GetXaxis()->SetRangeUser(0.,300.);
3615  gPad->Update();
3616 // TPaveStats *stats4 = (TPaveStats*)moduleEfficiencyRMSXView->FindObject("stats");
3617 // stats4->SetX1NDC(0.65);
3618 // stats4->SetY1NDC(0.65);
3619 // stats4->SetX2NDC(0.90);
3620 // stats4->SetY2NDC(0.90);
3621  c4->Modified();
3622  c4->Update();
3623  UpdateText->Draw();
3624  sprintf(f_name,"%s/%s-%s-P%.1uModuleXEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3625  c4->Print(f_name);
3626  delete c4;
3627  c4 = 0;
3628 
3629  TCanvas* c5 = new TCanvas("c5","c5",1200,800);
3630  gStyle->SetOptStat(0);
3631  sprintf(title_buff,"%s Average Module Efficiency In Y-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3632  moduleEfficiencyAverageYView->SetTitle(title_buff);
3633  moduleEfficiencyAverageYView->Draw("colz");
3634  moduleEfficiencyAverageYView->RebinX(2);
3635  //moduleEfficiencyAverageYView->GetXaxis()->SetRangeUser(0.,300.);
3636  gPad->Update();
3637 // TPaveStats *stats5 = (TPaveStats*)moduleEfficiencyAverageYView->FindObject("stats");
3638 // stats5->SetX1NDC(0.65);
3639 // stats5->SetY1NDC(0.65);
3640 // stats5->SetX2NDC(0.90);
3641 // stats5->SetY2NDC(0.90);
3642  c5->Modified();
3643  c5->Update();
3644  UpdateText->Draw();
3645  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleYEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3646  c5->Print(f_name);
3647  delete c5;
3648  c5 = 0;
3649 
3650  TCanvas* c6 = new TCanvas("c6","c6",1200,800);
3651  gStyle->SetOptStat(0);
3652  sprintf(title_buff,"%s Average Module Efficiency In Y-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3653  moduleEfficiencyRMSYView->SetTitle(title_buff);
3654  moduleEfficiencyRMSYView->Draw("colz");
3655  moduleEfficiencyRMSYView->RebinX(2);
3656  //moduleEfficiencyRMSYView->GetXaxis()->SetRangeUser(0.,300.);
3657  gPad->Update();
3658 // TPaveStats *stats6 = (TPaveStats*)moduleEfficiencyRMSYView->FindObject("stats");
3659 // stats6->SetX1NDC(0.65);
3660 // stats6->SetY1NDC(0.65);
3661 // stats6->SetX2NDC(0.90);
3662 // stats6->SetY2NDC(0.90);
3663  c6->Modified();
3664  c6->Update();
3665  UpdateText->Draw();
3666  sprintf(f_name,"%s/%s-%s-P%.1uModuleYEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3667  c6->Print(f_name);
3668  delete c6;
3669  c6 = 0;
3670 
3671 }
TH2F * hHitsVwcellDay[Npar]
Definition: AnaPlotMaker.h:70
TPaveText * UpdateText
Definition: DCSPlotMaker.C:18
T sqrt(T number)
Definition: d0nt_math.hpp:156
UInt_t Last_SR[Npar]
Definition: AnaPlotMaker.h:54
var_value< double > var
Definition: StanTypedefs.h:14
c2
Definition: demo5.py:33
std::void_t< T > n
const std::string PLOT_DIR
Definition: AnaPlotMaker.C:8
UInt_t Last_Run[Npar]
Definition: AnaPlotMaker.h:53
Int_t GMToffset
Definition: AnaPlotMaker.h:43
c1
Definition: demo5.py:24
Float_t w
Definition: plot.C:20
TH2F * hCellsVwcellDay[Npar]
Definition: AnaPlotMaker.h:71

Variable Documentation

Int_t GMToffset
TH2F* hCellsVwcellDay[Npar]

Definition at line 71 of file AnaPlotMaker.h.

Referenced by AnaPlotMaker(), and eff_plots().

TH2F* hHitsVwcellDay[Npar]

Definition at line 70 of file AnaPlotMaker.h.

Referenced by AnaPlotMaker(), and eff_plots().

ifstream inFile

Definition at line 34 of file AnaPlotMaker.h.

Referenced by AnalyzeNus18Systs(), AnalyzeSysts(), AnaPlotMaker(), append(), calculateWrongSignNue(), calculateWrongSignNumuQ1(), calculateWrongSignNumuQ2(), calculateWrongSignNumuQ3(), calculateWrongSignNumuQ4(), Compare_NoExtrap(), Compare_Spectra(), ComparisonPlots_Data(), ComparisonPlots_MC(), CutFlow_NearDet(), DCMOffsetCalculator(), DDTOnMonPlotMaker(), demo2p5b(), DoTraining(), DrawCovMx(), DrawExtrapSurface(), EnergyCont_macro(), example_plot(), getData(), GetExtrapolationDefs(), ana::GetNueQuantCuts2020(), ana::GetNumuEhadFracQuantCuts2020(), ana::GetNumuPtQuantCuts2020(), getPredictions(), GetQuantileCuts(), hadEFrac_nd_data_mc_systs(), HtmlCosmic(), HtmlGenie(), hyperon_macro(), hyperon_nom_macro(), daq2raw::TestBeamRawInputDriver::loadBeamlineEvent(), ana::LoadSystsFromFile(), make_dst_cosrejbdttrain(), make_eff_plots_areaNorm(), make_prediction_extrap(), make_prediction_noextrap(), make_starplots(), make_xsec_tuning_hists_mp5(), make_xsec_wgts_2018_hists(), MakeCovMx(), ana::MakeCutVec(), MakeISysts(), meanWeight_plot(), mec_nux_tester_2020(), mec_tuning_fitter_2020(), MergePredictions(), mlpPIDelecallEetot(), mlpPIDelecallEtot(), multiverse_efficiency_plot(), ND_DataMC_Comp_Systs(), neutKEsyst(), neutronE_macro(), NoExtrap(), NuSCalculateCorr(), NuSTreeMaker(), OnMonPlotMaker(), plot_DataMCComp_numu(), plot_pi0_xcheck(), plot_pid(), daq2raw::TestBeamRawInputDriver::readBeamline(), resolution2018(), SystematicComp(), and TrimCAFs().

UInt_t Last_Run[Npar]

Definition at line 53 of file AnaPlotMaker.h.

Referenced by AnaPlotMaker(), and eff_plots().

UInt_t Last_SR[Npar]

Definition at line 54 of file AnaPlotMaker.h.

Referenced by AnaPlotMaker(), and eff_plots().

UInt_t LastRun
UInt_t LastSR
const unsigned int Npar = 5

Definition at line 38 of file AnaPlotMaker.h.

Referenced by AnaPlotMaker(), and OnMonPlotMaker().

UInt_t par

Definition at line 47 of file AnaPlotMaker.h.

unsigned int run

Definition at line 45 of file AnaPlotMaker.h.

TDatime* SRtime
unsigned int subrun

Definition at line 46 of file AnaPlotMaker.h.

TDatime* TNow
TDatime* TNowGMT