Classes | Typedefs | Functions | Variables
hadEFrac_nd_data_mc_systs.C File Reference
#include "CAFAna/Cuts/Cuts.h"
#include "3FlavorAna/Cuts/NumuCuts.h"
#include "3FlavorAna/Cuts/NumuCuts2017.h"
#include "3FlavorAna/Cuts/QuantileCuts.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/Var.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Systs/Systs.h"
#include "3FlavorAna/Systs/NumuSysts.h"
#include "CAFAna/Systs/XSecSystLists.h"
#include "3FlavorAna/Vars/NumuVars.h"
#include "3FlavorAna/Vars/HistAxes.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Analysis/Style.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TGraph.h"
#include "TH1.h"
#include "TH2.h"
#include "TMath.h"
#include "TGaxis.h"
#include "TMultiGraph.h"
#include "TLegend.h"
#include "TLegendEntry.h"
#include "TLatex.h"
#include "TStyle.h"
#include "THStack.h"
#include "TPaveText.h"
#include "TList.h"
#include "TAttLine.h"
#include "TAttMarker.h"
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <sstream>
#include <string>
#include <fstream>
#include <iomanip>

Go to the source code of this file.

Classes

class  Tangible< T >
 
class  DataMCPair
 

Typedefs

typedef Tangible< CutSelection
 
typedef Tangible< HistAxisTangibleAxis
 

Functions

void Preliminary ()
 
void CenterTitles ()
 
void RedrawAxes ()
 
TCanvas * LogClone (const TCanvas *can)
 
DataMCPairfindPair (std::vector< DataMCPair > &list, std::vector< std::string > keys)
 Get a vector of all the numu group systs. More...
 
void WriteBlurb (const DataMCPair &pair, std::string dir, std::string name, std::string extra="", std::string beginning="")
 
void MakeTextFile (std::string OutName)
 
void hadEFrac_nd_data_mc_systs (bool RunBinNorm=false, bool IsTest=false)
 

Variables

const Var kBinWidthWeight ([](const caf::SRProxy *sr){const double Enu=kCCE(sr); if(Enu< 0.75) return 0.1/0.75;if(Enu >=0.75 &&Enu< 1) return 0.1/0.25;if(Enu >=1 &&Enu< 2) return 0.1/0.1;if(Enu >=2 &&Enu< 3) return 0.1/0.25;if(Enu >=3 &&Enu< 4) return 0.1/0.5;if(Enu >=4 &&Enu< 5) return 0.1/1;else return 1.;})
 

Typedef Documentation

Definition at line 187 of file hadEFrac_nd_data_mc_systs.C.

Definition at line 188 of file hadEFrac_nd_data_mc_systs.C.

Function Documentation

void CenterTitles ( )

Definition at line 91 of file hadEFrac_nd_data_mc_systs.C.

References ana::CenterTitles().

92 {
93  for(const auto& obj:*(gPad->GetListOfPrimitives()))
94  {
95 
96  if(obj->InheritsFrom("TH1")) CenterTitles((TH1*)obj);
97  }
98 }
void CenterTitles()
DataMCPair* findPair ( std::vector< DataMCPair > &  list,
std::vector< std::string keys 
)

Get a vector of all the numu group systs.

Return an iterator if all keys are found in only one entry

Assume we're going to find it, innocent until guilty

Definition at line 624 of file hadEFrac_nd_data_mc_systs.C.

References om::cout, allTimeWatchdog::endl, HTMLTools::entry(), modifyFHiCL::found, it, and findDuplicateFiles::key.

626 {
627  int nFound = 0;
628 
629  std::vector<DataMCPair>::iterator it = list.end();
630 
631  for(std::vector<DataMCPair>::iterator entry = list.begin();
632  entry != list.end();
633  ++entry)
634  {
635  /// Assume we're going to find it, innocent until guilty
636  bool found = true;
637  for(const auto& key:keys)
638  {
639  std::cout << entry->ShortName() << " " << key << " " << found << std::endl;
640  std::cout << (entry->ShortName().find(key) == std::string::npos) << " " << entry->ShortName().find(key) << " " << std::string::npos << std::endl;
641  // If any key is not present, this isn't the one.
642  if(entry->ShortName().find(key) == std::string::npos)
643  {
644 
645  found = false;
646  std::cout << entry->ShortName() << " " << key << " " << found << " " <<entry->ShortName().find(key) << std::endl;
647  break;
648 
649  }
650 
651  }
652  if(found)
653  {
654  it = entry;
655  nFound += 1;
656  }
657 
658  }
659  std::cout << "nFound: "<< nFound << std::endl;
660  if(nFound == 0) throw "Failed to find match.";
661  if(nFound > 1) throw "Found too many matches.";
662 
663  return &(*it);
664 }
keys
Reco plots.
Definition: caf_analysis.py:46
set< int >::iterator it
OStream cout
Definition: OStream.cxx:6
def entry(str)
Definition: HTMLTools.py:26
void hadEFrac_nd_data_mc_systs ( bool  RunBinNorm = false,
bool  IsTest = false 
)

Definition at line 700 of file hadEFrac_nd_data_mc_systs.C.

References allTimeWatchdog::can, canMan::cans, om::cout, CutNames, update_sam_good_runs_metadata::cuts, allTimeWatchdog::endl, ana::getAllDirectNumuSysts2017(), ana::SpectrumLoader::Go(), inFile, kBinWidthWeight, ana::kCosNumi, ana::kCVNm, ana::kHadE, ana::kHadEFrac, ana::kHadEFracAxis, ana::kIsNumuCC(), ana::kMuE, ana::kNumuCCOptimisedAxis, ana::kNumuContainND2017, ana::kNumuPID2017, ana::kNumuQuality, ana::kPPFXFluxCVWgt, ana::kRemID, ana::kStandardSpillCuts, ana::kTrkLength, ana::kXSecCVWgt2017, MakeTextFile(), OutFile, Preliminary(), ana::QuantileCutsFromTH2(), ana::SpectrumLoaderBase::SetSpillCut(), ana::Binning::Simple(), string, systs, art::to_string(), and WriteBlurb().

701 {
702 
703  ////////////////////////////////////////
704  // Get stuff for the hadEFrac Cut:
705  ////////////////////////////////////////
706  const int NHadEFracQuantiles = 4; // defines how many divisions of hadEFrac are used
707 
708  std::string fdspecfile = "/nova/app/users/karlwarb/Workspace/NuMuSystematics/FDQuantileHists/final_full_FD_histo_for_quantile_cuts.root";
709  TFile* inFile = TFile::Open( fdspecfile.c_str() );
710  gDirectory->cd("dir_FDSpec2D");
711  TH2 *FDSpec2D = (TH2*)inFile->FindObjectAny("FDSpec2D");
712  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(FDSpec2D, kNumuCCOptimisedAxis, kHadEFracAxis, NHadEFracQuantiles);
713 
714  ////////////////////////////////////////
715  // Define Axes and cuts.
716  ////////////////////////////////////////
717 
718  std::vector<Cut> TieredCuts;
719  std::vector<std::string> CutNames;
720  //CutNames.emplace_back("Qual"); TieredCuts.emplace_back(kNumuQuality);
721  CutNames.emplace_back("Qual_Cont"); TieredCuts.emplace_back(kNumuQuality && kNumuContainND2017);
722  CutNames.emplace_back("Qual_Cont_PID"); TieredCuts.emplace_back(kNumuQuality && kNumuContainND2017 && kNumuPID2017);
723  //CutNames.emplace_back("Qual_Cont_PID_True"); TieredCuts.emplace_back(kNumuQuality && kNumuContainND2017 && kNumuPID2017 && kIsNumuCC);
724 
725  const HistAxis EnergyAxis ( "Reconstructed Muon Energy (GeV)", Binning::Simple(50, 0, 5 ), kMuE );
726  const HistAxis LengthAxis ( "Length of Primary Track (m)" , Binning::Simple(50, 0, 16 ), kTrkLength );
727  const HistAxis HadEAxis ( "Hadronic Energy (GeV)" , Binning::Simple(50, 0, 3 ), kHadE );
728  const HistAxis HadEFracAxis( "Hadronic Energy Fraction" , Binning::Simple(50, 0, 1.01), kHadEFrac );
729  const HistAxis CosNuMiAxis ( "Kalman Track Cos #theta_{NuMI}" , Binning::Simple(50, 0, 1.01), kCosNumi );
730  const HistAxis ReMIDAxis ( "ReMID score" , Binning::Simple(50, 0, 1.01), kRemID );
731  const HistAxis CVNNuMuAxis ( "CVN NuMu score" , Binning::Simple(50, 0, 1.01), kCVNm );
732 
733  ////////////////////////////////////////
734  // Now make the plots....
735  ////////////////////////////////////////
736  gStyle->SetMarkerStyle(kFullCircle);
737  TGaxis::SetMaxDigits(3);
738 
739  // --- Configure the definition to use.
740  std::string fnameNDMC = "prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
741  std::string fnameNDData = "prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
742  if (!IsTest) {
743  //fnameNDMC = "prod_sumdecaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1_numu2017"; // Takes a VERY long time to run in one macro
744  //fnameNDMC = "prod_sumdecaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1_numu2017_stride10";
745  fnameNDMC = "prod_sumdecaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1_numu2017_stride22";
746  //fnameNDMC = "prod_sumdecaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1_numu2017_lim1";
747  fnameNDData= "prod_sumdecaf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns_numu2017";
748  }
749  // --- Set the Loaders, along with spill cuts.
750  SpectrumLoader loaderMC(fnameNDMC);
751  SpectrumLoader loaderData(fnameNDData);
752  loaderMC.SetSpillCut(kStandardSpillCuts);
753  loaderData.SetSpillCut(kStandardSpillCuts);
754 
755  // --- Load the systematics
756  std::vector<const ISyst*> systs = getAllDirectNumuSysts2017();
757  //std::vector<const ISyst*> systs = getSyst_AhtBY();
758  //std::vector<const ISyst*> systs = getSyst_BhtBY();
759  //std::vector<const ISyst*> systs = getSyst_CV1uBY();
760  //std::vector<const ISyst*> systs = getSyst_CV2uBY();
761  //std::vector<const ISyst*> systs = getAllXsecSysts_2017();
762  //std::vector<const ISyst*> systs = {&kMAQAGenieReducedSyst2017};
763 
764  // --- Make a vector of "Selections" which are a combination of Quantile && Tiered cuts.
765  std::vector<Selection> selections;
766  for (size_t cuts=0; cuts < TieredCuts.size(); ++cuts) {
767  for (size_t quant=0; quant < HadEFracQuantCuts.size(); ++quant) {
768  // --- Want no quantile cut selections too.
769  if (quant == 0) {
770  selections.emplace_back( TieredCuts[cuts], CutNames[cuts]+"_QuantAll",
771  "Selected events pass "+CutNames[cuts]+" all quantiles");
772  }
773  selections.emplace_back( TieredCuts[cuts] && HadEFracQuantCuts[quant], CutNames[cuts]+"_Quant"+std::to_string(quant+1),
774  "Selected events pass "+CutNames[cuts]+" quantile "+std::to_string(quant+1)+".");
775  }
776  }
777 
778  // --- Make a vector of "TangibleAxis" which have the axis and variables for which I want to make spectra.
779  std::vector<TangibleAxis> variables;
780 
781  if ( RunBinNorm ) {
782  variables.emplace_back( kNumuCCOptimisedAxis, "NuMuE" , "CC energy estimator.");
783  } else {
784  variables.emplace_back( EnergyAxis , "MuonE" , "Reconstructed energy of primary muon track.");
785  variables.emplace_back( HadEAxis , "HadE" , "Hadronic enery, i.e. numu energy estimate minus muon track energy. " );
786  variables.emplace_back( HadEFracAxis , "HadEFrac" , "Hadronic enery fraction, i.e. ration of hadronic energy to numu energy. " );
787  variables.emplace_back( ReMIDAxis , "ReMIDScore", "ReMId kNN score." );
788  variables.emplace_back( CVNNuMuAxis , "CVNNuMu" , "CVN muon identification score." );
789  }
790 
791  //variables.emplace_back( LengthAxis , "TrkLength" , "Primary track length." );
792  //variables.emplace_back( CosNuMiAxis , "CosNuMi" , "Beam direction of muon track. " );
793 
794 
795  // // // copied from sa script
796  // // variables.emplace_back(HistAxis("Slice N_{Hit}", Binning::Simple(50, 0, 500), kNHit),
797  // // "slcNHit", "Number of hits in slice. " );
798 
799  // // variables.emplace_back(HistAxis("Average Hadronic Energy Per Hit (GeV)", Binning::Simple(40, 0, 0.04), kHadEPerNHit),
800  // // "hadEPerNHit", "Average energy per hit in hadronic cluster, i.e. had_E/had_n_hit. " );
801 
802  // // variables.emplace_back(HistAxis("Track Energy Per Hit (GeV)", Binning::Simple(40, 0, 0.04), kTrkEPerNHit),
803  // // "trkEPerNHit", "Average energy per hit on primary track, i.e. trk_E/trk_n_hit. " );
804 
805  // // variables.emplace_back(HistAxis("Hadronic N_{Hit}", Binning::Simple(50, 0, 100), kHadNHit),
806  // // "hadNHit", "Number of hits in hadronic cluster. ");
807 
808 
809  // variables.emplace_back(HistAxis("Slice Maximum Y (m)", kXYBins, kSlcMaxY),
810  // "maxy", "Maximum Y position of slice. " );
811  // variables.emplace_back(HistAxis("Number of Tracks in Slice", Binning::Simple(14, 1, 15), kNKalman),
812  // "nkal", "Number of tracks in slice. " );
813  // // variables.emplace_back(HistAxis("Number of Hits in Slice", Binning::Simple(50, 0, 500), kNHit),
814  // // "nhit", "Number of hits in slice. " );
815  // variables.emplace_back(HistAxis("Muon Track cos(#theta_{Z})", Binning::Simple(50, 0,1), kDirZ),
816  // "dirZ", "Z-direction of muon track. " );
817  // variables.emplace_back(HistAxis("Track Start X Position (m)", kXYBins, kTrkStartX),
818  // "trkStartX", "Track start x position. " );
819  // variables.emplace_back(HistAxis("Track Start Y Position (m)", kXYBins, kTrkStartY),
820  // "trkStartY", "Track start y position. " );
821  // variables.emplace_back(
822  // HistAxis("Track Start Z Position (m)", kZBins, kTrkStartZ),
823  // "trkStartZ", "Track start z position. " );
824  // variables.emplace_back(
825  // HistAxis("Track End X Position (m)", kXYBins, kTrkEndX),
826  // "trkEndX", "Track stop x position. " );
827  // variables.emplace_back(
828  // HistAxis("Track End Y Position (m)", kXYBins, kTrkEndY),
829  // "trkEndY", "Track stop y position. " );
830  // variables.emplace_back(
831  // HistAxis("Track End Z Position (m)", kZBins, kTrkEndZ),
832  // "trkEndZ", "Track stop z position. " );
833  // // variables.emplace_back(
834  // // HistAxis("Slice Duration [ns]", Binning::Simple(50,0,3000), kSliceDuration),
835  // // "sliceDuration", "Slice duration. " );
836  // // variables.emplace_back(
837  // // HistAxis("Number of Hits in Primary Track", Binning::Simple(50,0,500), kTrkNhits),
838  // // "trkNhits", "Number of hits on primary track. ");
839  // // variables.emplace_back(
840  // // HistAxis("Length of Primary Track (m)", Binning::Simple(50,0,16), kTrkLength),
841  // // "trkLength", "Primary track length. " );
842 
843  // variables.emplace_back(
844  // HistAxis("Scattering Log-likelihood", Binning::Simple(50,-0.5,0.5), kReMIdScatLLH),
845  // "scatLL", "ReMId scattering log log-likelihood for primary track. " );
846  // variables.emplace_back(
847  // HistAxis("dE/dx Log-likelihood", Binning::Simple(50,-3,1), kReMIdDEDxLLH),
848  // "dedxLL", "ReMId dE/dx log log-likelihood for primary track. " );
849  // variables.emplace_back(
850  // HistAxis("Non-hadronic Plane Fraction",
851  // Binning::Simple(50,0,1), kReMIdMeasFrac),
852  // "nonHadPlaneFrac", "ReMId Non-hadronic plane fraction. " );
853 
854  // // finished copy from sa script
855 
856  // --- What is my weight going to be for the spectra?
857  Var MyWeight = kPPFXFluxCVWgt * kXSecCVWgt2017;
858  if (RunBinNorm) MyWeight = kPPFXFluxCVWgt * kXSecCVWgt2017 * kBinWidthWeight;
859 
860  std::vector<DataMCPair> pairs;
861 
862  pairs.reserve(selections.size() * variables.size());
863  for(const auto& sel:selections){
864  for(const auto& variable:variables){
865  pairs.emplace_back(sel, variable, loaderData, loaderMC, systs, MyWeight, !kIsNumuCC );
866  }
867  }
868 
869  loaderMC.Go();
870  loaderData.Go();
871 
872  std::vector<TCanvas*> cans;
873 
874  for(const auto& pair:pairs) {
875 
876  std::cout << "\nNow looking pairs, " << pair.ShortName() << " - " << pair.CName() << ", it has purity " << pair.Purity() << std::endl;
877  TString name(TString(pair.CName()) + "_allSysts_pot");
878 
879  //cans.push_back(new TCanvas(name,name,1200,1000));
880  cans.push_back(new TCanvas(name,name));
881  pair.OverlayDataMCSyst();
882  WriteBlurb(pair, "nd_syst_plots/",
883  std::string(cans.back()->GetName())+".txt",
884  "Full systematic band shown. ",
885  "Near detector data/MC comparison for numu first analysis. " );
886  /*
887  cans.push_back(LogClone(cans.back()));
888  WriteBlurb(pair, "nd_syst_plots/",
889  std::string(cans.back()->GetName())+".txt",
890  "Full systematic band shown. Semi-log scale.",
891  "Near detector data/MC comparison for numu first analysis. " );
892  */
893 
894  // Other plot used by Vlad.
895  //*
896  TString nameNorm(TString(pair.CName()) + "_allSysts_area");
897  //cans.push_back(new TCanvas(nameNorm,nameNorm,1200,1000));
898  cans.push_back(new TCanvas(nameNorm,nameNorm));
899  pair.OverlayDataMCSystNorm();
900  WriteBlurb(pair, "nd_syst_plots/",
901  std::string(cans.back()->GetName())+".txt",
902  std::string("Each systematically shifted histogram (both up and down) ")
903  +std::string("is normalized to the area of the MC distribution, ")
904  +std::string("then summed in quadrature." ),
905  "Near detector data/MC comparison for numu first analysis. " );
906 
907  //*/
908 
909  /*
910  cans.push_back(LogClone(cans.back()));
911  WriteBlurb(pair, "nd_syst_plots/",
912  std::string(cans.back()->GetName())+".txt",
913  std::string("Each systematically shifted histogram (both up and down) ")
914  +std::string("is normalized to the area of the MC distribution, ")
915  +std::string("then summed in quadrature. Semi-log scale." ),
916  "Near detector data/MC comparison for numu first analysis. ");
917  */
918  }
919 
920  // Open a file to save all of the canvases to.
921  TFile *OutFile = new TFile("nd_syst_plots/NearDet_NuMiData_Systs_NuMuAna17.root", "RECREATE");
922  OutFile->cd();
923 
924  for(const auto& can:cans) {
925  can->cd();
926  Preliminary();
927  //can -> SetLeftMargin(0.13);
928  can->SaveAs (TString("nd_syst_plots/") + can->GetName() + ".pdf");
929  can->Write ( can->GetName() );
930  MakeTextFile( can->GetName() );
931  }
932 }
const Var kHadE
Definition: NumuVars.h:23
const XML_Char * name
Definition: expat.h:151
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Cut kNumuContainND2017([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.nshwlid;++i){TVector3 start=sr->vtx.elastic.fuzzyk.png[i].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[i].shwlid.stop;if(std::min(start.X(), stop.X())< -180.0) return false;if(std::max(start.X(), stop.X()) > 180.0) return false;if(std::min(start.Y(), stop.Y())< -180.0) return false;if(std::max(start.Y(), stop.Y()) > 180.0) return false;if(std::min(start.Z(), stop.Z())< 20.0) return false;if(std::max(start.Z(), stop.Z()) > 1525.0) return false;}if(sr->trk.kalman.ntracks< 1) return false;for(unsigned int i=0;i< sr->trk.kalman.ntracks;++i){if(i==sr->trk.kalman.idxremid) continue;else if(sr->trk.kalman.tracks[i].start.Z() > 1275||sr->trk.kalman.tracks[i].stop.Z() > 1275) return false;}return(sr->trk.kalman.ntracks > sr->trk.kalman.idxremid &&sr->slc.firstplane > 1 &&sr->slc.lastplane< 212 &&sr->trk.kalman.tracks[0].start.Z()< 1100 &&(sr->trk.kalman.tracks[0].stop.Z()< 1275 ||sr->sel.contain.kalyposattrans< 55) &&sr->sel.contain.kalfwdcellnd > 5 &&sr->sel.contain.kalbakcellnd > 10);})
Definition: NumuCuts2017.h:11
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
void Preliminary()
const Var kTrkLength([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].len/100;})
Definition: NumuVars.h:65
ifstream inFile
Definition: AnaPlotMaker.h:34
const Var kBinWidthWeight([](const caf::SRProxy *sr){const double Enu=kCCE(sr); if(Enu< 0.75) return 0.1/0.75;if(Enu >=0.75 &&Enu< 1) return 0.1/0.25;if(Enu >=1 &&Enu< 2) return 0.1/0.1;if(Enu >=2 &&Enu< 3) return 0.1/0.25;if(Enu >=3 &&Enu< 4) return 0.1/0.5;if(Enu >=4 &&Enu< 5) return 0.1/1;else return 1.;})
const Var kRemID
PID
Definition: Vars.cxx:81
const Var kHadEFrac
Definition: NumuVars.h:24
const Cut kNumuPID2017([](const caf::SRProxy *sr){return(sr->sel.remid.pid > 0.5 &&sr->sel.cvn.numuid > 0.5);})
Definition: NumuCuts2017.h:27
list cans
Definition: canMan.py:12
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
std::vector< const ISyst * > getAllDirectNumuSysts2017()
Get a vector of all the numu group systs.
Definition: NumuSysts.cxx:169
TFile * OutFile
const Var kCosNumi({"hdr.det","sel.remid.bestidx","trk.kalman.dir.fX","trk.kalman.dir.fY","trk.kalman.dir.fZ"}, [](const caf::StandardRecord *sr){if(sr->trk.nkalman > 0 &&sr->sel.remid.bestidx!=999){if(sr->hdr.det==1){return sr->trk.kalman[sr->sel.remid.bestidx].dir.Dot(beamDirND);}if(sr->hdr.det==2){return sr->trk.kalman[sr->sel.remid.bestidx].dir.Dot(beamDirFD);}}return-5.;})
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
const Cut kNumuQuality
Definition: NumuCuts.h:18
const Var kXSecCVWgt2017
Definition: XsecTunes.h:36
const Var kMuE
Definition: NumuVars.h:22
void MakeTextFile(std::string OutName)
const Var kCVNm
PID
Definition: Vars.cxx:39
void WriteBlurb(const DataMCPair &pair, std::string dir, std::string name, std::string extra="", std::string beginning="")
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string
TCanvas* LogClone ( const TCanvas *  can)

Definition at line 123 of file hadEFrac_nd_data_mc_systs.C.

References plot_validation_datamc::c, make_syst_table_plots::h, MECModelEnuComparisons::i, std::log10(), cet::sqlite::max(), min(), and cet::pow().

124 {
125 
126  TCanvas* clone = (TCanvas*)can->DrawClone();
127  clone->cd();
128 
129  clone->SetCanvasSize(can->GetWw(), can->GetWh());
130 
132  float max = 0;
133 
134  for(const auto& obj:*(clone->GetListOfPrimitives()))
135  {
136  if(obj->InheritsFrom("TH1"))
137  {
138  TH1* h = (TH1*)obj;
139  for(int i = 1; i <= h->GetNbinsX(); ++i)
140  {
141  int c = h->GetBinContent(i);
142  if(c != 0 && c < min) min = c;
143  if (c > max) max = c;
144  }
145  }
146  }
147  min *= 0.8;
148  float span = log10(max) - log10(min);
149  span *= 1.5;
150  max = pow(10, span + log10(min));
151  for(const auto& obj:*(clone->GetListOfPrimitives()))
152  {
153  if(obj->InheritsFrom("TH1"))
154  {
155  ((TH1*)obj)->SetMinimum(min);
156  ((TH1*)obj)->SetMaximum(max);
157  }
158  }
159 
160 
161 
162  TString name = TString(can->GetTitle()) + "_logy";
163  clone->SetName(name);
164  clone->SetTitle(name);
165  clone->SetLogy();
166  return clone;
167 }
const XML_Char * name
Definition: expat.h:151
constexpr T pow(T x)
Definition: pow.h:75
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
T log10(T number)
Definition: d0nt_math.hpp:120
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
void MakeTextFile ( std::string  OutName)

Definition at line 676 of file hadEFrac_nd_data_mc_systs.C.

References om::cout, allTimeWatchdog::endl, confusionMatrixTree::out, and string.

Referenced by hadEFrac_nd_data_mc_systs().

676  {
677  // Determine output name, and caption.
678  std::string FNa = "nd_syst_plots/"+OutName+".txt";
679  // Replace underscores in the canvas name
680  while (OutName.find("_") != std::string::npos) OutName.replace(OutName.find("_"),1," ");
681  // Add a string about it being a cut level.
682  if (OutName.find("Qual") != std::string::npos) OutName.insert(OutName.find(" Qual"), ", Cut level:");
683  // Add a string about it being a cut level.
684  if (OutName.find("pot") != std::string::npos) OutName.replace(OutName.find(" pot"),4,". With POT normalisation.");
685  // Add a string about it being a cut level.
686  if (OutName.find("area") != std::string::npos) OutName.replace(OutName.find(" area"),5,". With Area normalisation.");
687 
688  std::string Cap = "Plot showing the number of ND NuMi events in #nu_{#mu} Ana17 for variable: " + OutName;
689  std::cout << "\nFile name: " << FNa << "\n\tCaption: " << Cap << std::endl;
690  // Write to file.
691  std::ofstream TxtOut ( FNa.c_str(), std::ofstream::out );
692  TxtOut << Cap;
693  TxtOut.close();
694  // Done.
695  return;
696 }
OStream cout
Definition: OStream.cxx:6
enum BeamMode string
void Preliminary ( )

Definition at line 72 of file hadEFrac_nd_data_mc_systs.C.

References kBlue, and prelim.

Referenced by hadEFrac_nd_data_mc_systs().

73 {
74  TLatex* prelim = new TLatex(.9, .95, "NO#nuA Preliminary");
75  prelim->SetTextColor(kBlue);
76  prelim->SetNDC();
77  prelim->SetTextSize(2/30.);
78  prelim->SetTextAlign(32);
79  prelim->Draw();
80 }
TLatex * prelim
Definition: Xsec_final.C:133
enum BeamMode kBlue
void RedrawAxes ( )

Definition at line 102 of file hadEFrac_nd_data_mc_systs.C.

References string.

Referenced by DataMCPair::AestheticsArea(), DataMCPair::AestheticsPOT(), DataMCPair::OverlayDataMCSyst(), and DataMCPair::OverlayDataMCSystNorm().

103 {
104  // --- Loop through the objects in the pad.
105  for(const auto& obj:*(gPad->GetListOfPrimitives())) {
106  // --- Want to repaint all TH1's.
107  if(obj->InheritsFrom("TH1")) {
108  // --- Check if I have the Reco Energy canvas?
109  std::string XTit = ((TH1*)obj)->GetXaxis()->GetTitle();
110  if ( XTit.find("Reconstructed Neutrino Energ") != std::string::npos ) {
111  ((TH1*)obj)->GetYaxis()->SetTitle("Events / 0.1 GeV");
112  }
113  // Repaint the axes.
114  ((TH1*)obj)->GetXaxis()->Paint();
115  //((TH1*)obj)->GetYaxis()->SetTitleOffset(1.1);
116  ((TH1*)obj)->GetYaxis()->Paint();
117  ((TH1*)obj)->GetZaxis()->Paint();
118  }
119  }
120 }
enum BeamMode string
void WriteBlurb ( const DataMCPair pair,
std::string  dir,
std::string  name,
std::string  extra = "",
std::string  beginning = "" 
)

Definition at line 667 of file hadEFrac_nd_data_mc_systs.C.

References ana::Tangible< T >::fBlurb, ana::DataMCPair::fSel, and confusionMatrixTree::out.

Referenced by hadEFrac_nd_data_mc_systs(), and ND_DataMC_Comp_Systs().

669 {
670  std::ofstream out(dir + name);
671  out << pair.fAxis.fBlurb << pair.fSel.fBlurb << extra;
672 }
const XML_Char * name
Definition: expat.h:151
std::string fBlurb
Definition: DataMCPair.h:46
Selection fSel
Definition: DataMCPair.h:182
TDirectory * dir
Definition: macro.C:5

Variable Documentation

const Var kBinWidthWeight([](const caf::SRProxy *sr){const double Enu=kCCE(sr); if(Enu< 0.75) return 0.1/0.75;if(Enu >=0.75 &&Enu< 1) return 0.1/0.25;if(Enu >=1 &&Enu< 2) return 0.1/0.1;if(Enu >=2 &&Enu< 3) return 0.1/0.25;if(Enu >=3 &&Enu< 4) return 0.1/0.5;if(Enu >=4 &&Enu< 5) return 0.1/1;else return 1.;})