cePulserToAdc.h
Go to the documentation of this file.
1 // cePulserToAdc.cxx
2 //
3 // David Adams
4 // January 2019
5 //
6 // ADC response to CE pulser.ProtoDUNE CE ADC pulser charge. See the circuit diagram
7 // http://internal.dunescience.org/people/dladams/docs/pulserCircuit.pdf
8 
9 #ifndef cePulserToAdc_H
10 #define cePulserToAdc_H
11 
12 #include "cePulser.h"
13 
14 //**********************************************************************
15 
16 // Function that returns the ADC height or area for a pulser gain setting.
17 // ia - gain setting (minus inverts charge)
18 // adcScale - d(ADC count)/dQin
19 // rLines - FPGA IO resistances (high to low) [kOhm]
20 // r6 - Fixed resistance to Vrail.
21 // cinj - Injection capacitance (fF)
22 // Returns charge in fC.
23 // Use cinj = 1 to get voltage in mV.
24 inline
25 double cePulserToAdc(int ia, double adcScale, double pedestal, double negScale,
26  const double rfLines[6], double r6, double qvscale) {
27  double dadc = adcScale*cePulser(ia, rfLines, r6, qvscale);
28  if ( ia < 0.0 ) dadc *= negScale;
29  return dadc + pedestal;
30 }
31 
32 double cePulserToAdc(double* x, double* pars) {
33  int ia = x[0];
34  double adcScale = pars[0];
35  double pedestal = pars[1];
36  double negScale = pars[2];
37  const double* rfLines = pars + 3;
38  double r6 = pars[9];
39  double qvscale = pars[10];
40  return cePulserToAdc(ia, adcScale, pedestal, negScale, rfLines, r6, qvscale);
41 }
42 
43 //**********************************************************************
44 
45 // Generate a TF1 for the ADC response.
46 inline
47 TF1* cePulserToAdcTF1(std::string fname="adcpulser", double tol =0.01,
48  double adcScale = 3.0*14.0) {
49  using Index = unsigned int;
50  const Index npar = 11;
51  TF1* pf = new TF1(fname.c_str(), cePulserToAdc, -64, 64, npar);
52  initCePulserTF1(pf, 3, tol);
53  pf->SetParName(0, "AdcScale");
54  pf->SetParName(1, "Pedestal");
55  pf->SetParName(2, "NegScale");
56  pf->SetParameter(0, adcScale);
57  pf->SetParameter(1, 0.0);
58  pf->SetParameter(2, 1.0);
59  pf->FixParameter(10, 1.8*183.0);
60  return pf;
61 }
62 
63 //**********************************************************************
64 
65 #endif
int initCePulserTF1(TF1 *pf, unsigned int ipoff, double tol=0.01)
Definition: cePulser.h:135
TF1 * cePulserToAdcTF1(std::string fname="adcpulser", double tol=0.01, double adcScale=3.0 *14.0)
Definition: cePulserToAdc.h:47
std::string string
Definition: nybbler.cc:12
auto const tol
Definition: SurfXYZTest.cc:16
unsigned int Index
double cePulser(int ia, const double rfLines[6], double r6, double qvscale)
Definition: cePulser.h:61
double cePulserToAdc(int ia, double adcScale, double pedestal, double negScale, const double rfLines[6], double r6, double qvscale)
Definition: cePulserToAdc.h:25
list x
Definition: train.py:276