CheckBrightnessModel.C
Go to the documentation of this file.
1 
2 #include "CalibAnaPlot.h"
3 #include "CalibAnaTypes.h"
4 #include <iomanip>
5 
7 
8  public:
9 
11  // vvv CalibAnaPlot implimentations
12  void SchedulePlots();
13  void ScheduleSamples();
14  void ScheduleHitVars();
15  void FillHitPlots();
16  // ^^^ CalibAnaPlot implimentations
17  void DoAna();
18 
19  private:
20  std::vector< std::string > fEpochList;
21 
22 };
23 
24 
26  : CalibAnaPlot(outpath)
27 {
28 }
29 
30 void CheckBrightnessModel(std::string outpath="fd_brightness")
31 {
32  BrightnessModelPlots bmplots(outpath);
33  bmplots.Initialize();
34  bmplots.SetTreeLoopStride(1000);
35 
36  bmplots.DoAna();
37 }
38 
39 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
41 {
42  /*
43  for(auto sample : fSamples){
44  Initialize();
45  ProcessTrees(sample.first);
46  }
47  */
48 
49  SchedulePlots();
50 
51  std::string plotdir = "fd_bbrightness_datamc";
52 
53  for(auto& plot : fPlots){
54 
55  Plot denom_plot(fOutPath+"/fd_mc_highgain.root", // plot file
56  plot.first, // plot name
57  LegendLabel("fd_mc_highgain"));
58 
59  std::vector< Plot > plotstack;
60  for(auto& samp : fSamples)
61  if(samp.first.find("mc")==std::string::npos)
62  plotstack.push_back( Plot( fOutPath+"/"+samp.first+".root",
63  plot.first,
64  LegendLabel(samp.first) ) );
65 
66  Draw(plotdir, plotstack, denom_plot, "Data / MC" );
67  }
68 
69 }
70 
71 
72 
73 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
75 {
76  // The filled branches are protected members of
77  // CalibAnaPlot, so can be used here
78 
79  std::string vstr;
80  if(view==0){ vstr="x"; }
81  if(view==1){ vstr="y"; }
82 
83  std::string end = vstr;
84 
85  float pecm = pe/path;
86  fPlots["pecm_w_"+end] ->Fill(w,pecm);
87  fPlots["pecm_cell_"+end] ->Fill(cell,pecm);
88  fPlots["pecm_plane_"+end] ->Fill(plane,pecm);
89  float pecorrcm = pecorr/path;
90  fPlots["pecorrcm_w_"+end] ->Fill(w,pecorrcm);
91  fPlots["pecorrcm_cell_"+end] ->Fill(cell,pecorrcm);
92  fPlots["pecorrcm_plane_"+end] ->Fill(plane,pecorrcm);
93 
94 
95  if(brightbin<0 || brightbin>11){
96  std::cout << "bad brightness bin: " << brightbin << std::endl;
97  return;
98  }
99 
100  std::string tempname = "pecm_w_" + vstr + "_b" + std::to_string(brightbin);
101  fPlots[tempname] ->Fill(w,pecm);
102  tempname = "pecm_cell_" + vstr + "_b" + std::to_string(brightbin);
103  fPlots[tempname] ->Fill(cell,pecm);
104  tempname = "pecm_plane_" + vstr + "_b" + std::to_string(brightbin);
105  fPlots[tempname] ->Fill(plane,pecm);
106 
107 
108  std::string tempname2 = "pecorrcm_w_" + vstr + "_b" + std::to_string(brightbin);
109  fPlots[tempname2] ->Fill(w,pecorrcm);
110  tempname2 = "pecorrcm_cell_" + vstr + "_b" + std::to_string(brightbin);
111  fPlots[tempname2] ->Fill(cell,pecorrcm);
112  tempname2 = "pecorrcm_plane_" + vstr + "_b" + std::to_string(brightbin);
113  fPlots[tempname2] ->Fill(plane,pecorrcm);
114 
115 
116 
117 
118 }
119 
120 
121 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
123 {
124  fHitVars="plane, view, w, cell, pe, pecorr, path, brightbin,";
125 }
126 
127 
128 
129 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
131 {
132  int nBins(120);
133 
134  std::vector< PlotAxis > xaxes = {
135  {"w", "W (cm)", nBins, -fDet->HalfW(), fDet->HalfW() },
136  {"cell", "Cell", (int)fDet->NCells(), 0, (float)fDet->NCells() },
137  {"plane", "Plane", (int)fDet->NPlanes(), 0, (float)fDet->NPlanes() }
138  };
139 
140 
141  std::vector< ContentAxis > yaxes = {
142  {"pecm", "PE/cm"},
143  {"pecorrcm", "PECorr/cm"}
144  // add just path, just pe
145  };
146 
147 
148  std::string vstr;
149  std::vector< std::string > views = {"x", "y"};
150  for( auto& v : views){
151  if(v=="x") vstr = "X";
152  if(v=="y") vstr = "Y";
153 
154  for(auto& xax : xaxes){
155  for(auto& yax : yaxes){
156 
157  std::string name = yax.label +"_"+ xax.label +"_"+ v;
158 
159  fPlots[name] = new TProfile( name.c_str(),
160  (vstr+" View;" + xax.title +";"+ yax.title).c_str(),
161  xax.nbins, xax.min, xax.max );
162 
163  if(yax.label=="pecm"){
164  for(unsigned int b=0; b<12; b++){
165  std::stringstream bname; bname << name << "_b" << b;
166  //std::cout << bname.str() << std::endl;
167  fPlots[bname.str()] = new TProfile( bname.str().c_str(),
168  (vstr+" View, Bin "+b+";" + xax.title +";"+ yax.title),
169  xax.nbins, xax.min, xax.max );
170  } // bright bins
171  } // which vars to expand
172 
173  if(yax.label=="pecorrcm"){
174  for(unsigned int b=0; b<12; b++){
175  std::stringstream bname; bname << name << "_b" << b;
176  //std::cout << bname.str() << std::endl;
177  fPlots[bname.str()] = new TProfile( bname.str().c_str(),
178  (vstr+" View, Bin "+b+";" + xax.title +";"+ yax.title),
179  xax.nbins, xax.min, xax.max );
180  } // bright bins
181  } // which vars to expand
182 
183 
184 
185  } // yax
186  } // xax
187  } // views
188 
189 }
190 
191 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
193 {
194  std::vector< std::string > epoch_list = {
195  "5a" };
196 
197  fEpochList = epoch_list;
198 
199  for( auto& ep : epoch_list ){
200  //fSamples["fd_data_ep"+ep]="/nova/ana/users/talion/miniprod5_calibana/fd_data_epoch5a/merged.root";
201  fSamples["fd_data_ep"+ep]="/nova/ana/users/talion/miniprod5_calibana/fd_data_epoch5a/merged_v13relcal.root";
202  }
203 
204 
205  fSamples["fd_mc_highgain"]="/nova/ana/users/talion/miniprod5_calibana/fd_mc_highgain/merged.p3.root";
206 }
207 
const XML_Char * name
Definition: expat.h:151
std::map< std::string, TH1 * > fPlots
Definition: CalibAnaPlot.h:57
int nBins
Definition: plotROC.py:16
unsigned int NCells()
Definition: Detector.h:12
std::string fOutPath
Definition: CalibAnaPlot.h:62
std::string LegendLabel(std::string key)
Definition: CalibAnaPlot.h:239
void Initialize()
Definition: CalibAnaPlot.h:138
float HalfW()
Definition: Detector.h:15
std::string fHitVars
Definition: CalibAnaPlot.h:67
====================================================================== ///
Definition: CutFlow_Data.C:28
void SetTreeLoopStride(unsigned int stride)
Definition: CalibAnaPlot.h:32
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
unsigned int NPlanes()
Definition: Detector.h:13
void Draw(std::string pdfdir, std::vector< Plot > plots, Plot denom_plot, std::string ratio_title="")
Definition: CalibAnaPlot.h:168
const hit & b
Definition: hits.cxx:21
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void CheckBrightnessModel(std::string outpath="fd_brightness")
std::vector< std::string > fEpochList
std::map< std::string, std::string > fSamples
Definition: CalibAnaPlot.h:59
BrightnessModelPlots(std::string outpath)
void plot(std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
Detector * fDet
Definition: CalibAnaPlot.h:68