Classes | Functions
test_response.cxx File Reference
#include "WireCellUtil/Waveform.h"
#include "WireCellUtil/Units.h"
#include "WireCellUtil/Binning.h"
#include "WireCellUtil/Response.h"
#include "TCanvas.h"
#include "TH1F.h"
#include <algorithm>

Go to the source code of this file.

Classes

struct  Plotter
 

Functions

std::pair< TH1F *, TH1F * > plot_response (Plotter &plt, double gain_unit=units::mV/units::fC)
 
void plot_ratio (Plotter &plt, TH1F *one, TH1F *two, const std::string &title)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 104 of file test_response.cxx.

105 {
106  {
107  Plotter plt(Form("%s.pdf", argv[0]));
108  auto units = plot_response(plt);
109  auto anons = plot_response(plt, 1.0);
110  plot_ratio(plt, units.first, anons.first, "Ratio for 1us, 7.8mV/fC");
111  plot_ratio(plt, units.second, anons.second, "Ratio for 2us, 14.0V/fC");
112  }
113 }
void plot_ratio(Plotter &plt, TH1F *one, TH1F *two, const std::string &title)
std::pair< TH1F *, TH1F * > plot_response(Plotter &plt, double gain_unit=units::mV/units::fC)
void plot_ratio ( Plotter plt,
TH1F *  one,
TH1F *  two,
const std::string title 
)

Definition at line 82 of file test_response.cxx.

83 {
84  TH1F* rat = (TH1F*)two->Clone("rat");
85  rat->Divide(one);
86 
87  plt.canvas.Clear();
88  auto pad = &plt.canvas;
89  pad->SetGridx();
90  pad->SetGridy();
91 
92  const double eps = 0.01;
93  TH1F* frame = pad->DrawFrame(0,1-eps,10,1+eps,title.c_str());
94  frame->SetXTitle("Time (microsecond)");
95  frame->SetYTitle("gain ratio");
96  pad->SetGridx();
97  pad->SetGridy();
98  rat->SetLineColor(1);
99  rat->Draw("hist,same");
100 
101  plt();
102 }
TCanvas canvas
std::pair< TH1F *, TH1F * > plot_response ( Plotter plt,
double  gain_unit = units::mV/units::fC 
)

Definition at line 32 of file test_response.cxx.

33 {
34  const double gain1 = 7.8*gain_unit;
35  const double gain2 = 14.0*gain_unit;
36  const double shaping1 = 1.0*units::us;
37  const double shaping2 = 2.0*units::us;
38  const double tmax = 10.0*units::us;
39  const double tick = 0.05*units::us;
40 
41  const Binning bins(tmax/tick, 0, tmax);
42 
43  Response::ColdElec ce1(gain1, shaping1);
44  Response::ColdElec ce2(gain2, shaping2);
45 
46  // exercise the generator
47  Waveform::realseq_t res1 = ce1.generate(bins);
48  Waveform::realseq_t res2 = ce2.generate(bins);
49 
50  TH1F* resp1 = new TH1F("resp1","Cold Electronics Response at 1us shaping",
51  bins.nbins(), bins.min()/units::us, bins.max()/units::us);
52  TH1F* resp2 = new TH1F("resp2","Cold Electronics Response at 2us shaping",
53  bins.nbins(), bins.min()/units::us, bins.max()/units::us);
54  resp1->SetLineColor(2);
55  resp2->SetLineColor(4);
56  for (size_t ind=0; ind<res1.size(); ++ind) {
57  const double t_us = bins.center(ind) / units::us;
58  resp1->Fill(t_us, res1[ind] / gain_unit);
59  resp2->Fill(t_us, res2[ind] / gain_unit);
60  }
61 
62  plt.canvas.Clear();
63  auto pad = &plt.canvas;
64  pad->SetGridx();
65  pad->SetGridy();
66  TH1F* frame = pad->DrawFrame(0,0,10,15,"Cold Electronics Response Functions (1us,7.8mV/fC and 2us,14.0mV/fC)");
67  frame->SetXTitle("Time (microsecond)");
68  if (gain_unit == units::mV/units::fC) {
69  frame->SetYTitle("Gain (mV/fC)");
70  }
71  else {
72  frame->SetYTitle("Gain");
73  }
74  resp1->Draw("hist,same");
75  resp2->Draw("hist,same");
76 
77  plt();
78 
79  return std::make_pair(resp1, resp2);
80 }
Sequence< real_t > realseq_t
Definition: Waveform.h:31
A functional object caching gain and shape.
Definition: Response.h:165
const double tick
float fC
Definition: units.py:113
static const double us
Definition: Units.h:101
TCanvas canvas