MakeMEUPerCell.C
Go to the documentation of this file.
1 
2 #include "CalibAnaPlot.h"
3 #include "CalibAnaTypes.h"
4 #include "TexBuilder.h"
5 #include <iomanip>
6 #include <numeric>
7 #include "TROOT.h"
8 
9 class MEUPerCell : public CalibAnaPlot{
10 
11  public:
12 
14  // vvv CalibAnaPlot implimentations
15  void SchedulePlots();
16  void ScheduleSamples();
17  void ScheduleHitVars();
18  void FillHitPlots();
19  // ^^^ CalibAnaPlot implimentations
20  void DoAna();
21  void DriftTex(std::string plotdir);
22 
23  private:
24  std::vector< std::string > fEpochList;
26 };
27 
28 
30 : CalibAnaPlot(outpath, group)
31 {
32 }
33 
35 {
36  MEUPerCell meupercell(outpath, "nd_mp5");
37  meupercell.Initialize();
38 
39  meupercell.DoAna();
40 
41 
42  std::cout << "I HAVE FINISHED, KILL ME NOW!" << std::endl;
43 
44 }
45 
46 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
48 {
49  //WRITE YOUR ANALYSIS CODE HERE!
50 
51  for(auto sample : fSamples){
52  ProcessTrees(sample.first);
53  }
54 
55  std::vector<std::string> allsamples;
56  for( auto& samp : fSamples ) allsamples.push_back(samp.first);
57 
58  fTex = new TexBuilder( fOutPath+"/MEUPerCell.tex",
59  "Drift by FEB",
60  "Tyler Alion, Alexander Booth, Yibing Zhang",
61  "Miniproduction 5 Data vs. MC. Tricell hits from Stopping Cosmics populate all plots, with Absolute Calibration cuts applied. Showing PE/cm and PECorr/cm broken down by cell group and view then further by FEB, then further by individual cell.");
62  std::string plotdir = "nd_all_samples";
63  //FINAL ARGUMENT, BOOL FOR RATIO PLOTS.
64  Draw(plotdir, allsamples, false);
65  DriftTex(plotdir);
66 
67  delete fTex;
68 
69 }
70 
71 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
73 {
74  fTex->SectionNoNum("By View and Cell Group");
75  fTex->AddFigureRow({plotdir+"/legend"}, {""}, {""});
76  fTex->AddFigureRow({plotdir+"/pecm_time_x_0-31", plotdir+"/pecorrcm_time_y_0-31" }, {"", ""}, {"", ""});
77  fTex->AddFigureRow({plotdir+"/pecm_time_x_32-63", plotdir+"/pecorrcm_time_y_32-63"}, {"", ""}, {"", ""});
78  fTex->AddFigureRow({plotdir+"/pecm_time_x_64-95", plotdir+"/pecorrcm_time_y_64-95"}, {"", ""}, {"", ""});
79  fTex->NewPage();
80 
81  for(int p = 0; p < fDet->NPlanes(); p++)
82  {
83  fTex->SectionNoNum(Form("Plane %i", p));
84  std::string pstr = (p % 2 == 0 ? "y_" : "x_") + std::to_string(p);
85  fTex->AddFigureRow({plotdir+"/legend"}, {""}, {""});
86  fTex->AddFigureRow({plotdir+"/pecm_time_"+pstr+"_0-31", plotdir+"/pecorrcm_time_"+pstr+"_0-31" }, {"", ""}, {"", ""});
87  fTex->AddFigureRow({plotdir+"/pecm_time_"+pstr+"_32-63", plotdir+"/pecorrcm_time_"+pstr+"_32-63"}, {"", ""}, {"", ""});
88  fTex->AddFigureRow({plotdir+"/pecm_time_"+pstr+"_64-95", plotdir+"/pecorrcm_time_"+pstr+"_64-95"}, {"", ""}, {"", ""});
89  fTex->NewPage();
90  fTex->SubSectionNoNum(Form("Plane %i By Cell", p));
91  for(int c = 0; c < fDet->NCells(); c++)
92  {
93  if(c % 3 == 0 && c!=0)
94  {
95  fTex->NewPage();
96  }
97  fTex->AddFigureRow({plotdir+"/pecm_time_" +std::to_string(p)+"_"+std::to_string(c),
98  plotdir+"/pecorrcm_time_"+std::to_string(p)+"_"+std::to_string(c) }, {"", ""}, {"", ""});
99  }
100  if(p!=fDet->NPlanes()-1) fTex->NewPage();
101  }
102 }
103 
104 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
106 {
107  // The filled branches are protected members of
108  // CalibAnaPlot, so can be used here
109 
110  bool abscal_hit = ( w > -100 && w < 100 &&
111  path > 0. &&
112  pecorr > 0. && pecorr/path < 100. &&
113  pe > 0. &&
114  cmFromEnd > 100 && cmFromEnd < 200 );
115  if( !abscal_hit ) return;
116  if( plane > 191) return;
117 
118  std::string vstr, pstr;
119  if(view==0){ vstr="x"; }
120  if(view==1){ vstr="y"; }
121  pstr = std::to_string(plane);
122 
123  std::string end = vstr + "_" + pstr + "_";
124  std::string endGroup = vstr + "_";
125  std::string endCell = vstr + "_" + pstr + "_" + std::to_string(cell);
126 
127  float pecm = pe/path;
128  float pecorrcm = pecorr/path;
129  if(cell <= 31){
130  end += "0-31";
131  endGroup += "0-31";
132  }
133  else if(cell > 31 && cell <= 63){
134  end += "32-63";
135  endGroup += "32-63";
136  }
137  else{
138  end += "64-95";
139  endGroup += "64-95";
140  }
141  fPlots["pecm_time_"+end] ->Fill(evt_time,pecm);
142  fPlots["pecorrcm_time_"+end]->Fill(evt_time,pecorrcm);
143 
144  fPlots["pecm_time_"+endGroup] ->Fill(evt_time,pecm);
145  fPlots["pecorrcm_time_"+endGroup]->Fill(evt_time,pecorrcm);
146 
147  fPlots["pecm_time_"+endCell] ->Fill(evt_time,pecm);
148  fPlots["pecorrcm_time_"+endCell]->Fill(evt_time,pecorrcm);
149 }
150 
151 
152 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
154 {
155  fHitVars="w, view, plane, cell, pe, pecorr, path, evt_time, cmFromEnd,";
156 }
157 
158 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
160 {
161  int nPlanes = fDet->NPlanes();
162  int nCells = fDet->NCells();
163 
164  std::vector< PlotAxis > xaxes = {
165  {"time", "Unix Time (s)", 100, 14e8, 16e8}
166  };
167 
168  std::vector< ContentAxis > yaxes = {
169  {"pecm", "PE/cm"},
170  {"pecorrcm", "PECorr/cm"},
171  };
172 
173  std::vector< std::string > cells = {"0-31", "32-63", "64-95"};
174  std::vector<int> planes(nPlanes);
175  std::iota(planes.begin(), planes.end(), 0);
176  std::vector<int> allcells(nCells);
177  std::iota(allcells.begin(), allcells.end(), 0);
178  for(auto& p : planes){
179  std::string vstr = (p % 2 == 0 ? "Y" : "X");
180  std::string v = (p % 2 == 0 ? "y" : "x");
181  for(auto& xax : xaxes){
182  for(auto& yax : yaxes){
183  for(auto& c : cells){
184 
185  std::string name = yax.label +"_"+ xax.label +"_"+ v + "_" + std::to_string(p) + "_" + c;
186 
187  fPlots[name] = new TProfile( name.c_str(),
188  (vstr+" View, Plane "+std::to_string(p)+", Cells "+c+";" + xax.title +";"+ yax.title).c_str(),
189  xax.nbins, xax.min, xax.max );
190 
191 
192  if(p < 2){
193  name = yax.label +"_"+ xax.label +"_"+ v + "_" + c;
194  fPlots[name] = new TProfile( name.c_str(),
195  (vstr+" View, Cells "+c+";" + xax.title +";"+ yax.title).c_str(),
196  xax.nbins, xax.min, xax.max );
197  }
198  }
199  for(auto& c : allcells){
200  std::string name = yax.label +"_"+ xax.label +"_"+ v + "_" + std::to_string(p) + "_" + std::to_string(c);
201 
202  fPlots[name] = new TProfile( name.c_str(),
203  (vstr+" View, Plane "+std::to_string(p)+", Cell "+std::to_string(c)+";" + xax.title +";"+ yax.title).c_str(),
204  60, xax.min, xax.max );
205  }
206  }
207  }
208  }
209 }
210 
211 //^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
213 {
214  std::vector< std::string > epoch_list = {
215  "2a", "2b","2c","2d","2e",
216  "3b","3c","3d","3e",
217  "4a", "4b.1", "4b.2", "4c", // split 4b up manually
218  "5a","5b",
219  "6a","6b",
220  "7a","7b","7c","7d",
221  "8b" };
222 
223  fEpochList = epoch_list;
224 
225  for( auto& ep : epoch_list ){
226  if(ep=="4b.1" || ep=="4b.2")
227  fSamples["nd_data_ep"+ep]="/nova/ana/users/talion/miniprod5/pcliststop_miniprod5.b/nd_data_epoch4b/calibana/merged.root";
228  else
229  fSamples["nd_data_ep"+ep]="/nova/ana/users/talion/miniprod5/pcliststop_miniprod5.b/nd_data_epoch"+ep+"/calibana/merged.root";
230  }
231 
232  fSamples["nd_mc"]="/nova/ana/users/abooth/miniprod5.b/nd_mc/merged.root";
233 }
234 
const XML_Char * name
Definition: expat.h:151
std::map< std::string, TH1 * > fPlots
Definition: CalibAnaPlot.h:57
unsigned int NCells()
Definition: Detector.h:12
void NewPage()
Definition: TexBuilder.h:165
void MakeMEUPerCell(std::string outpath)
std::string fOutPath
Definition: CalibAnaPlot.h:62
const char * p
Definition: xmltok.h:285
void SchedulePlots()
uint32_t evt_time
Definition: CalibAnaPlot.h:80
void Initialize()
Definition: CalibAnaPlot.h:138
std::string fHitVars
Definition: CalibAnaPlot.h:67
void ScheduleSamples()
void FillHitPlots()
std::vector< std::string > fEpochList
TexBuilder * fTex
void DoAna()
void ProcessTrees(std::string sample)
Definition: CalibAnaPlot.h:329
void SubSectionNoNum(std::string subsecname)
Definition: TexBuilder.h:161
void SectionNoNum(std::string secname)
Definition: TexBuilder.h:153
OStream cout
Definition: OStream.cxx:6
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
MEUPerCell(std::string outpath, std::string group)
void ScheduleHitVars()
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void DriftTex(std::string plotdir)
std::map< std::string, std::string > fSamples
Definition: CalibAnaPlot.h:59
void AddFigureRow(std::vector< std::string > figure, std::vector< std::string > caption, std::vector< std::string > label)
Definition: TexBuilder.h:98
Detector * fDet
Definition: CalibAnaPlot.h:68
enum BeamMode string