All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
icarus_tool::ElectronicsResponseBesselApprox Class Reference
Inheritance diagram for icarus_tool::ElectronicsResponseBesselApprox:
icarus_tool::IElectronicsResponse

Public Member Functions

 ElectronicsResponseBesselApprox (const fhicl::ParameterSet &pset)
 
 ~ElectronicsResponseBesselApprox ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void setResponse (size_t numBins, double binWidth) override
 
void outputHistograms (art::TFileDirectory &) const override
 
size_t getPlane () const override
 
double getFCperADCMicroS () const override
 
double getASICShapingTime () const override
 
const icarusutil::TimeVecgetResponseVec () const override
 
const icarusutil::FrequencyVecgetResponseFFTVec () const override
 

Private Attributes

size_t fPlane
 
double fFCperADCMicroS
 
double fASICShapingTime
 
double fADCPerPCAtLowestASICGain
 
double fTimeOffset
 
double fBinWidth
 
icarusutil::TimeVec fElectronicsResponseBesselApproxVec
 
icarusutil::FrequencyVec fElectronicsResponseFFTVec
 
std::unique_ptr
< icarus_signal_processing::ICARUSFFT
< double > > 
fFFT
 Object to handle thread safe FFT. More...
 

Additional Inherited Members

- Private Member Functions inherited from icarus_tool::IElectronicsResponse
virtual ~IElectronicsResponse () noexcept=default
 

Detailed Description

Definition at line 24 of file ElectronicsResponseBesselApprox_tool.cc.

Constructor & Destructor Documentation

icarus_tool::ElectronicsResponseBesselApprox::ElectronicsResponseBesselApprox ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 64 of file ElectronicsResponseBesselApprox_tool.cc.

64  :
65  fBinWidth(0.),
66  fFFT(nullptr)
67 {
68  configure(pset);
69 }
std::unique_ptr< icarus_signal_processing::ICARUSFFT< double > > fFFT
Object to handle thread safe FFT.
void configure(const fhicl::ParameterSet &pset) override
icarus_tool::ElectronicsResponseBesselApprox::~ElectronicsResponseBesselApprox ( )
inline

Definition at line 29 of file ElectronicsResponseBesselApprox_tool.cc.

29 {}

Member Function Documentation

void icarus_tool::ElectronicsResponseBesselApprox::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Implements icarus_tool::IElectronicsResponse.

Definition at line 71 of file ElectronicsResponseBesselApprox_tool.cc.

72 {
73  // Start by recovering the parameters
74  fPlane = pset.get<size_t>("Plane");
75  fFCperADCMicroS = pset.get<double>("FCperADCMicroS");
76  fASICShapingTime = pset.get<double>("ASICShapingTime");
77  fADCPerPCAtLowestASICGain = pset.get<double>("ADCPerPCAtLowestASICGain");
78  fTimeOffset = pset.get<double>("TimeOffset");
79 
80  return;
81 }
double icarus_tool::ElectronicsResponseBesselApprox::getASICShapingTime ( ) const
inlineoverridevirtual
double icarus_tool::ElectronicsResponseBesselApprox::getFCperADCMicroS ( ) const
inlineoverridevirtual
size_t icarus_tool::ElectronicsResponseBesselApprox::getPlane ( ) const
inlineoverridevirtual
const icarusutil::FrequencyVec& icarus_tool::ElectronicsResponseBesselApprox::getResponseFFTVec ( ) const
inlineoverridevirtual
const icarusutil::TimeVec& icarus_tool::ElectronicsResponseBesselApprox::getResponseVec ( ) const
inlineoverridevirtual
void icarus_tool::ElectronicsResponseBesselApprox::outputHistograms ( art::TFileDirectory &  histDir) const
overridevirtual

Implements icarus_tool::IElectronicsResponse.

Definition at line 146 of file ElectronicsResponseBesselApprox_tool.cc.

147 {
148  // It is assumed that the input TFileDirectory has been set up to group histograms into a common
149  // folder at the calling routine's level. Here we create one more level of indirection to keep
150  // histograms made by this tool separate.
151  std::string dirName = "ElectronicsPlane_" + std::to_string(fPlane);
152 
153  art::TFileDirectory dir = histDir.mkdir(dirName.c_str());
154 
155  std::string histName = "ElectronicsResponseBesselApprox_" + std::to_string(fPlane);
156 
157  double hiEdge = fElectronicsResponseBesselApproxVec.size() * fBinWidth;
158 
159  TProfile* hist = dir.make<TProfile>(histName.c_str(), "Response;Time(us)", fElectronicsResponseBesselApproxVec.size(), 0., hiEdge);
160 
161  for(size_t idx = 0; idx < fElectronicsResponseBesselApproxVec.size(); idx++) hist->Fill((double(idx)+0.5) * fBinWidth, fElectronicsResponseBesselApproxVec.at(idx), 1.);
162 
163  // Get the FFT of the response
164  size_t halfFFTDataSize(fElectronicsResponseBesselApproxVec.size()/2);
165 
166  std::vector<double> powerVec(halfFFTDataSize);
167 
168  std::transform(fElectronicsResponseBesselApproxVec.begin(), fElectronicsResponseBesselApproxVec.begin() + halfFFTDataSize, powerVec.begin(), [](const auto& val){return std::abs(val);});
169 
170  // Now we can plot this...
171  double maxFreq = 0.5 / fBinWidth; // binWidth will be in us, maxFreq will be units of MHz
172  double freqWidth = maxFreq / powerVec.size();
173 
174  histName = "FFT_" + histName;
175 
176  TProfile* fftHist = dir.make<TProfile>(histName.c_str(), "Electronics FFT; Frequency(MHz)", powerVec.size(), 0., maxFreq);
177 
178  for(size_t idx = 0; idx < powerVec.size(); idx++)
179  {
180  double bin = (idx + 0.5) * freqWidth;
181 
182  fftHist->Fill(bin, powerVec.at(idx), 1.);
183  }
184 
185  return;
186 }
static constexpr Sample_t transform(Sample_t sample)
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
T abs(T value)
tuple dir
Definition: dropbox.py:28
std::string to_string(WindowPattern const &pattern)
void icarus_tool::ElectronicsResponseBesselApprox::setResponse ( size_t  numBins,
double  binWidth 
)
overridevirtual

Implements icarus_tool::IElectronicsResponse.

Definition at line 83 of file ElectronicsResponseBesselApprox_tool.cc.

84 {
85  // The input binWidth is in nanoseconds, we need to convert to microseconds to match the
86  // parameters for the electronics response which are given in us
87  double timeCorrect = 1.e-3;
88 
89  fBinWidth = binWidth * timeCorrect;
90 
91  fElectronicsResponseBesselApproxVec.resize(numBins, 0.);
92 
93  // Check that we have initialized our FFT object
94  if (!fFFT) fFFT = std::make_unique<icarus_signal_processing::ICARUSFFT<double>>(numBins);
95 
96  // This note from Filippo:
97  // The following sets the ICARUS electronics response function in
98  // time-space. Function comes from BNL SPICE simulation of ICARUS
99  // electronics. SPICE gives the electronics transfer function in
100  // frequency-space. The inverse laplace transform of that function
101  // (in time-space) was calculated in Mathematica and is what is being
102  // used below. Parameters Ao and To are cumulative gain/timing parameters
103  // from the full (ASIC->Intermediate amp->Receiver->ADC) electronics chain.
104  // They have been adjusted to make the SPICE simulation to match the
105  // actual electronics response. Default params are Ao=1.4, To=0.5us.
106 
107  for(size_t timeIdx = 0; timeIdx < numBins; timeIdx++)
108  {
109  double binTime = (double(timeIdx) + 0.5) * fBinWidth - fTimeOffset;
110  double funcArg = 0.;
111 
112  if (binTime >= 0.) funcArg = binTime / fASICShapingTime;
113 
114  double leftArg2 = (0.9 * funcArg) * (0.9 * funcArg);
115  double rightArg2 = (0.5 * funcArg) * (0.5 * funcArg);
116 
117  fElectronicsResponseBesselApproxVec[timeIdx] = (1. - exp(-0.5*leftArg2)) * exp(-0.5*rightArg2);
118  }
119 
120  // normalize fElectResponse[i], before the convolution
121  // Put in overall normalization in a pedantic way:
122  // first put in the pulse area per eleectron at the lowest gain setting,
123  // then normalize by the actual ASIC gain setting used.
124  // This code is executed only during initialization of service,
125  // so don't worry about code inefficiencies here.
126  // double last_integral=0;
127  // double last_max=0;
128 
129  // ICARUS Normalization are the following
130  // Field response is normalized to 1 electron. Shaping function written as (t/tau)*exp(-t/tau) is normalized to 1
131  // From test pulse measurement with FLIC@CERN we have 0.027 fC/(ADC*us)
132  // Therefore 0.027*6242 electrons/(ADC*us)
133 
134  // The below scales the response by 1./FCperADCMicroS... but this gets taken out in the normalization
135  std::transform(fElectronicsResponseBesselApproxVec.begin(),fElectronicsResponseBesselApproxVec.end(),fElectronicsResponseBesselApproxVec.begin(),std::bind(std::divides<double>(),std::placeholders::_1,fFCperADCMicroS));
136 
137  double respIntegral = std::accumulate(fElectronicsResponseBesselApproxVec.begin(),fElectronicsResponseBesselApproxVec.end(),0.);
138 
139  std::transform(fElectronicsResponseBesselApproxVec.begin(),fElectronicsResponseBesselApproxVec.end(),fElectronicsResponseBesselApproxVec.begin(),std::bind(std::divides<double>(),std::placeholders::_1,respIntegral));
140 
142 
143  return;
144 }
static constexpr Sample_t transform(Sample_t sample)
std::unique_ptr< icarus_signal_processing::ICARUSFFT< double > > fFFT
Object to handle thread safe FFT.

Member Data Documentation

double icarus_tool::ElectronicsResponseBesselApprox::fADCPerPCAtLowestASICGain
private

Definition at line 46 of file ElectronicsResponseBesselApprox_tool.cc.

double icarus_tool::ElectronicsResponseBesselApprox::fASICShapingTime
private

Definition at line 45 of file ElectronicsResponseBesselApprox_tool.cc.

double icarus_tool::ElectronicsResponseBesselApprox::fBinWidth
private

Definition at line 50 of file ElectronicsResponseBesselApprox_tool.cc.

icarusutil::TimeVec icarus_tool::ElectronicsResponseBesselApprox::fElectronicsResponseBesselApproxVec
private

Definition at line 53 of file ElectronicsResponseBesselApprox_tool.cc.

icarusutil::FrequencyVec icarus_tool::ElectronicsResponseBesselApprox::fElectronicsResponseFFTVec
private

Definition at line 56 of file ElectronicsResponseBesselApprox_tool.cc.

double icarus_tool::ElectronicsResponseBesselApprox::fFCperADCMicroS
private

Definition at line 44 of file ElectronicsResponseBesselApprox_tool.cc.

std::unique_ptr<icarus_signal_processing::ICARUSFFT<double> > icarus_tool::ElectronicsResponseBesselApprox::fFFT
private

Object to handle thread safe FFT.

Definition at line 59 of file ElectronicsResponseBesselApprox_tool.cc.

size_t icarus_tool::ElectronicsResponseBesselApprox::fPlane
private

Definition at line 43 of file ElectronicsResponseBesselApprox_tool.cc.

double icarus_tool::ElectronicsResponseBesselApprox::fTimeOffset
private

Definition at line 47 of file ElectronicsResponseBesselApprox_tool.cc.


The documentation for this class was generated from the following file: