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

Public Member Functions

 SimWire (fhicl::ParameterSet const &pset)
 

Private Member Functions

void produce (art::Event &evt) override
 
void beginJob () override
 
void ConvoluteResponseFunctions ()
 convolute electronics and field response More...
 
void SetFieldResponse ()
 response of wires to field More...
 
void SetElectResponse ()
 response of electronics More...
 
void GenNoise (std::vector< float > &array, CLHEP::HepRandomEngine &engine)
 

Private Attributes

std::string fDriftEModuleLabel
 module making the ionization electrons More...
 
raw::Compress_t fCompression
 compression type to use More...
 
int fNTicks
 number of ticks of the clock More...
 
double fSampleRate
 sampling rate in ns More...
 
unsigned int fNSamplesReadout
 number of ADC readout samples in 1 readout frame More...
 
double fCol3DCorrection
 
double fInd3DCorrection
 
unsigned int fNElectResp
 number of entries from response to use More...
 
double fInputFieldRespSamplingPeriod
 Sampling period in the input field response. More...
 
double fShapeTimeConst
 time constants for exponential shaping More...
 
double fADCPerPCAtLowestASICGain
 ADCs/pC at lowest gain setting of 4.7 mV/fC. More...
 
double fASICGainInMVPerFC
 actual gain setting used in mV/fC More...
 
int fNoiseNchToSim
 number of noise channels to generate More...
 
std::string fNoiseModelChoice
 choice for noise model More...
 
std::string fNoiseFluctChoice
 choice for noise freq component mag fluctuations More...
 
std::vector< int > fFieldRespTOffset
 field response time offset in ticks More...
 
std::vector< int > fCalibRespTOffset
 calib response time offset in ticks More...
 
std::vector< float > fColFieldParams
 collection plane field function parameterization More...
 
std::vector< float > fIndFieldParams
 induction plane field function parameterization More...
 
std::vector< double > fColFieldResponse
 response function for the field @ collection plane More...
 
std::vector< double > fIndFieldResponse
 response function for the field @ induction plane More...
 
std::vector< TComplex > fColShape
 response function for the field @ collection plane More...
 
std::vector< TComplex > fIndShape
 response function for the field @ induction plane More...
 
std::vector< double > fElectResponse
 response function for the electronics More...
 
std::vector< std::vector< float > > fNoise
 noise on each channel for each time More...
 
std::vector< double > fNoiseModelPar
 noise model params More...
 
std::vector< double > fNoiseFluctPar
 Poisson noise fluctuations params. More...
 
TH1D * fIndFieldResp
 response function for the field @ induction plane More...
 
TH1D * fColFieldResp
 response function for the field @ collection plane More...
 
TH1D * fElectResp
 response function for the electronics More...
 
TH1D * fColTimeShape
 convoluted shape for field x electronics @ col plane More...
 
TH1D * fIndTimeShape
 convoluted shape for field x electronics @ ind plane More...
 
TH1D * fNoiseDist
 distribution of noise counts More...
 
TF1 * fNoiseFluct
 Poisson dist for fluctuations in magnitude of noise freq components. More...
 
CLHEP::HepRandomEngine & fEngine
 Random-number engine owned by art. More...
 

Detailed Description

Definition at line 69 of file SimWire_module.cc.

Constructor & Destructor Documentation

detsim::SimWire::SimWire ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 132 of file SimWire_module.cc.

133  : EDProducer{pset}
134  , fDriftEModuleLabel{pset.get<std::string>("DriftEModuleLabel")}
135  , fCompression{pset.get<std::string>("CompressionType") == "Huffman" ? raw::kHuffman :
136  raw::kNone}
137  , fCol3DCorrection{pset.get<double>("Col3DCorrection")}
138  , fInd3DCorrection{pset.get<double>("Ind3DCorrection")}
139  , fInputFieldRespSamplingPeriod{pset.get<double>("InputFieldRespSamplingPeriod")}
140  , fShapeTimeConst{pset.get<double>("ShapeTimeConst")}
141  , fADCPerPCAtLowestASICGain{pset.get<double>("ADCPerPCAtLowestASICGain")}
142  , fASICGainInMVPerFC{pset.get<double>("ASICGainInMVPerFC")}
143  , fNoiseNchToSim{pset.get<int>("NoiseNchToSim")}
144  , fNoiseModelChoice{pset.get<std::string>("NoiseModelChoice")}
145  , fNoiseFluctChoice{pset.get<std::string>("NoiseFluctChoice")}
146  , fFieldRespTOffset{pset.get<std::vector<int>>("FieldRespTOffset")}
147  , fCalibRespTOffset{pset.get<std::vector<int>>("CalibRespTOffset")}
148  , fColFieldParams{pset.get<std::vector<float>>("ColFieldParams")}
149  , fIndFieldParams{pset.get<std::vector<float>>("IndFieldParams")}
150  , fNoiseModelPar{pset.get<std::vector<double>>("NoiseModelPar")}
151  , fNoiseFluctPar{pset.get<std::vector<double>>("NoiseFluctPar")}
152  // create a default random engine; obtain the random seed from NuRandomService,
153  // unless overridden in configuration with key "Seed"
154  , fEngine(art::ServiceHandle<rndm::NuRandomService> {}->createEngine(*this, pset, "Seed"))
Huffman Encoding.
Definition: RawTypes.h:10
std::string fNoiseModelChoice
choice for noise model
std::vector< float > fIndFieldParams
induction plane field function parameterization
std::string fDriftEModuleLabel
module making the ionization electrons
int fNoiseNchToSim
number of noise channels to generate
double fADCPerPCAtLowestASICGain
ADCs/pC at lowest gain setting of 4.7 mV/fC.
std::string fNoiseFluctChoice
choice for noise freq component mag fluctuations
raw::Compress_t fCompression
compression type to use
double fShapeTimeConst
time constants for exponential shaping
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
no compression
Definition: RawTypes.h:9
std::vector< float > fColFieldParams
collection plane field function parameterization
std::vector< int > fCalibRespTOffset
calib response time offset in ticks
std::vector< double > fNoiseFluctPar
Poisson noise fluctuations params.
std::vector< int > fFieldRespTOffset
field response time offset in ticks
double fASICGainInMVPerFC
actual gain setting used in mV/fC
CLHEP::HepRandomEngine & fEngine
Random-number engine owned by art.
std::vector< double > fNoiseModelPar
noise model params

Member Function Documentation

void detsim::SimWire::beginJob ( )
overrideprivate

Definition at line 172 of file SimWire_module.cc.

173  {
174  // ... get access to the TFile service
175  art::ServiceHandle<art::TFileService const> tfs;
176 
177  fNoiseDist = tfs->make<TH1D>("Noise", ";Noise (ADC);", 1000, -10., 10.);
178 
179  art::ServiceHandle<util::LArFFT const> fFFT;
180  fNTicks = fFFT->FFTSize();
181 
182  // ... Poisson dist function for fluctuating magnitude of noise frequency component
183  if ( fNoiseFluctChoice == "SimplePoisson" ) {
184  // .. simple modified Poisson with (x-1)! in denominator
185  double params[1];
186  fNoiseFluct = new TF1("_poisson", "[0]**(x) * exp(-[0]) / ROOT::Math::tgamma(x)", 0, 5.);
187  params[0] = fNoiseFluctPar[0]; // Poisson mean
188  fNoiseFluct->SetParameters(params);
189  } else if ( fNoiseFluctChoice == "WeightedPoisson" ) {
190  // .. weighted Poisson in ArgoNeuT DDN model
191  double params[3];
192  fNoiseFluct = new TF1("_poisson", "[0]*pow([1]/[2], x/[2])*exp(-[1]/[2])/ROOT::Math::tgamma(x/[2]+1.)", 0, 5.);
193  params[0] = fNoiseFluctPar[0];
194  params[1] = fNoiseFluctPar[1];
195  params[2] = fNoiseFluctPar[2];
196  fNoiseFluct->SetParameters(params);
197  } else {
198  throw cet::exception("SimWire::beginJob") << fNoiseFluctChoice
199  << " is an unknown noise fluctuation choice" << std::endl;
200  }
201 
202  // ... generate the noise in advance depending on value of fNoiseNchToSim:
203  // positive - generate N=fNoiseNchToSim channels & randomly pick from pool when adding to signal
204  // zero - no noise
205  // negative - generate unique noise for each channel for each event
206  if (fNoiseNchToSim>0) {
207  if (fNoiseNchToSim>10000) {
208  throw cet::exception("SimWire::beginJob") << fNoiseNchToSim
209  << " noise channels requested exceeds 10000" << std::endl;
210  }
211  fNoise.resize(fNoiseNchToSim);
212  for (unsigned int p = 0; p < fNoise.size(); ++p) {
214  for (int i = 0; i < fNTicks; ++i) {
215  fNoiseDist->Fill(fNoise[p][i]);
216  }
217  }
218  }
219 
220 
221  // ... set field response and electronics response, then convolute them
225  }
TF1 * fNoiseFluct
Poisson dist for fluctuations in magnitude of noise freq components.
int fNoiseNchToSim
number of noise channels to generate
void SetElectResponse()
response of electronics
pdgs p
Definition: selectors.fcl:22
TH1D * fNoiseDist
distribution of noise counts
std::string fNoiseFluctChoice
choice for noise freq component mag fluctuations
std::vector< std::vector< float > > fNoise
noise on each channel for each time
void GenNoise(std::vector< float > &array, CLHEP::HepRandomEngine &engine)
std::vector< double > fNoiseFluctPar
Poisson noise fluctuations params.
void ConvoluteResponseFunctions()
convolute electronics and field response
void SetFieldResponse()
response of wires to field
int fNTicks
number of ticks of the clock
art::ServiceHandle< art::TFileService > tfs
CLHEP::HepRandomEngine & fEngine
Random-number engine owned by art.
void detsim::SimWire::ConvoluteResponseFunctions ( )
private

convolute electronics and field response

Definition at line 338 of file SimWire_module.cc.

339  {
340  double tick, ticks, peak;
341 
342  std::vector<double> col(fNTicks, 0.);
343  std::vector<double> ind(fNTicks, 0.);
344  std::vector<TComplex> kern(fNTicks/2 + 1);
345  std::vector<double> delta(fNTicks, 0.);
346 
347  art::ServiceHandle<util::LArFFT> fFFT;
348 
349  // ... do collection plane
350  fColShape.resize(fNTicks/2+1);
351  fFFT->DoFFT(fElectResponse, fColShape);
352 
353  fFFT->DoFFT(fColFieldResponse, kern);
354  for(unsigned int i=0; i<kern.size(); ++i)
355  fColShape[i] *= kern[i];
356 
357  fFFT->DoInvFFT(fColShape, col);
358 
359  delta[0] = 1.0;
360  peak = fFFT->PeakCorrelation(delta, col);
361  tick = 0.;
362  ticks = tick - peak;
363  fFFT->ShiftData(fColShape, ticks);
364  fFFT->DoInvFFT(fColShape, col);
365 
366  // ... do induction plane
367  fIndShape.resize(fNTicks/2+1);
368  fFFT->DoFFT(fElectResponse, fIndShape);
369 
370  kern.clear();
371  kern.resize(fNTicks/2 + 1);
372  fFFT->DoFFT(fIndFieldResponse, kern);
373  for(unsigned int i=0; i<kern.size(); ++i)
374  fIndShape[i] *= kern[i];
375 
376  fFFT->DoInvFFT(fIndShape, ind);
377 
378  delta.resize(0);
379  delta.resize(fNTicks,0);
380  delta[0] = 1.0;
381  peak = fFFT->PeakCorrelation(delta, ind);
382  tick = 0.;
383  ticks = tick - peak;
384  fFFT->ShiftData(fIndShape, ticks);
385  fFFT->DoInvFFT(fIndShape, ind);
386 
387  // ... write the time-domain shapes out to a file
388  art::ServiceHandle<art::TFileService const> tfs;
389  fColTimeShape = tfs->make<TH1D>(
390  "ConvolutedCollection",";ticks; Electronics#timesCollection",fNTicks,0,fNTicks);
391  fIndTimeShape = tfs->make<TH1D>(
392  "ConvolutedInduction",";ticks; Electronics#timesInduction",fNTicks,0,fNTicks);
393 
394  // ... check that you did the right thing
395  for(unsigned int i = 0; i < ind.size(); ++i){
396  fColTimeShape->Fill(i, col[i]);
397  fIndTimeShape->Fill(i, ind[i]);
398  }
399 
400  fColTimeShape->Write();
401  fIndTimeShape->Write();
402 
403  }
std::vector< TComplex > fColShape
response function for the field @ collection plane
std::vector< double > fElectResponse
response function for the electronics
TH1D * fColTimeShape
convoluted shape for field x electronics @ col plane
tick ticks
Alias for common language habits.
Definition: electronics.h:78
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
std::vector< double > fColFieldResponse
response function for the field @ collection plane
std::vector< TComplex > fIndShape
response function for the field @ induction plane
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
int fNTicks
number of ticks of the clock
TH1D * fIndTimeShape
convoluted shape for field x electronics @ ind plane
art::ServiceHandle< art::TFileService > tfs
void detsim::SimWire::GenNoise ( std::vector< float > &  array,
CLHEP::HepRandomEngine &  engine 
)
private

Definition at line 407 of file SimWire_module.cc.

408  {
409  CLHEP::RandFlat flat(engine);
410 
411  noise.clear();
412  noise.resize(fNTicks, 0.);
413  std::vector<TComplex> noiseFrequency(fNTicks/2+1, 0.); // noise in frequency space
414 
415  double pval = 0.;
416  double phase = 0.;
417  double rnd[2] = {0.};
418 
419  // .. width of frequencyBin in kHz
420  double binWidth = 1.0/(fNTicks*fSampleRate*1.0e-6);
421 
422  for (int i=0; i< fNTicks/2+1; ++i) {
423 
424  double x=(i+0.5)*binWidth;
425 
426  if ( fNoiseModelChoice == "Legacy" ) {
427  // ... Legacy exponential model kept here for reference:
428  // par[0]=NoiseFact, par[1]=NoiseWidth, par[2]=LowCutoff, par[3-7]=0
429  // example parameter values for fcl: NoiseModelPar:[ 1.32e-1,120,7.5,0,0,0,0,0 ]
430  pval = fNoiseModelPar[0] * exp(-(double)i * binWidth / fNoiseModelPar[1]);
431  double lofilter = 1.0 / (1.0 + exp(-(i - fNoiseModelPar[2] / binWidth) / 0.5));
432  flat.fireArray(1, rnd, 0, 1);
433  pval *= lofilter * (0.9 + 0.2 * rnd[0]);
434  } else if ( fNoiseModelChoice == "ModUBooNE" ) {
435  // ... Modified uBooNE model with additive exp to account for low freq region:
436  // example parameter values for fcl: NoiseModelPar:[
437  // 4450.,-530.,280.,110.,
438  // -0.85,18.,0.064,74. ]
439  pval = fNoiseModelPar[0]*exp(-0.5*pow((x-fNoiseModelPar[1])/fNoiseModelPar[2],2))
440  *exp(-0.5*pow(x/fNoiseModelPar[3],fNoiseModelPar[4]))
442  double randomizer = fNoiseFluct->GetRandom();
443  pval = pval * randomizer/fNTicks;
444  } else if ( fNoiseModelChoice == "ArgoNeuT" ) {
445  // ... ArgoNeuT data driven model:
446  // In fcl set parameters to: NoiseModelPar:[
447  // 5000,-5.52058e2,2.81587e2,-5.66561e1,
448  // 4.10817e1,1.76284e1,1e-1,5.97838e1 ]
449  pval = fNoiseModelPar[0]*exp(-0.5*pow((x-fNoiseModelPar[1])/fNoiseModelPar[2],2))
450  *((fNoiseModelPar[3]/(x+fNoiseModelPar[4]))+1)
452  double randomizer = fNoiseFluct->GetRandom();
453  pval = pval * randomizer/fNTicks;
454  } else {
455  throw cet::exception("SimWire::GenNoise") << fNoiseModelChoice
456  << " is an unknown choice for the noise model" << std::endl;
457  }
458 
459  flat.fireArray(1,rnd,0,1);
460  phase = rnd[0]*2.*TMath::Pi();
461 
462  TComplex tc(pval*cos(phase),pval*sin(phase));
463  noiseFrequency[i] += tc;
464  }
465 
466  // .. inverse FFT MCSignal
467  art::ServiceHandle<util::LArFFT> fFFT;
468  fFFT->DoInvFFT(noiseFrequency, noise);
469 
470  noiseFrequency.clear();
471 
472  // .. multiply each noise value by fNTicks as the InvFFT
473  // divides each bin by fNTicks assuming that a forward FFT
474  // has already been done.
475  for (unsigned int i = 0; i < noise.size(); ++i)
476  noise[i] *= 1. * fNTicks;
477  }
std::string fNoiseModelChoice
choice for noise model
TF1 * fNoiseFluct
Poisson dist for fluctuations in magnitude of noise freq components.
process_name opflash particleana ie x
double fSampleRate
sampling rate in ns
int fNTicks
number of ticks of the clock
std::vector< double > fNoiseModelPar
noise model params
void detsim::SimWire::produce ( art::Event &  evt)
overrideprivate

Definition at line 229 of file SimWire_module.cc.

230  {
231 
232  art::ServiceHandle<geo::Geometry const> geo;
233 
234  // ... generate unique noise for each channel in each event
235  if (fNoiseNchToSim<0) {
236  fNoise.clear();
237  fNoise.resize(geo->Nchannels());
238  for(unsigned int p = 0; p < geo->Nchannels(); ++p){
240  }
241  }
242 
243  // ... make a vector of const sim::SimChannel* that has same number
244  // of entries as the number of channels in the detector
245  // and set the entries for the channels that have signal on them
246  // using the chanHandle
247  std::vector<const sim::SimChannel*> chanHandle;
248  evt.getView(fDriftEModuleLabel,chanHandle);
249 
250  std::vector<const sim::SimChannel*> channels(geo->Nchannels());
251  for(size_t c = 0; c < chanHandle.size(); ++c){
252  channels[chanHandle[c]->Channel()] = chanHandle[c];
253  }
254 
255  // ... make an unique_ptr of sim::SimDigits that allows ownership of the produced
256  // digits to be transferred to the art::Event after the put statement below
257  auto digcol = std::make_unique<std::vector<raw::RawDigit>>();
258 
259  art::ServiceHandle<util::LArFFT> fFFT;
260 
261  // ... Add all channels
262  CLHEP::RandFlat flat(fEngine);
263 
264  std::map<int,double>::iterator mapIter;
265  for(unsigned int chan = 0; chan < geo->Nchannels(); chan++) {
266 
267  std::vector<short> adcvec(fNTicks, 0);
268  std::vector<double> fChargeWork(fNTicks, 0.);
269 
270  if( channels[chan] ){
271 
272  // .. get the sim::SimChannel for this channel
273  const sim::SimChannel* sc = channels[chan];
274 
275  // .. loop over the tdcs and grab the number of electrons for each
276  for(int t = 0; t < fNTicks; ++t)
277  fChargeWork[t] = sc->Charge(t);
278 
279  int time_offset = 0;
280 
281  // .. Convolve charge with appropriate response function
282  if(geo->SignalType(chan) == geo::kInduction){
283  fFFT->Convolute(fChargeWork,fIndShape);
284  time_offset = fFieldRespTOffset[1]+fCalibRespTOffset[1];
285  } else {
286  fFFT->Convolute(fChargeWork,fColShape);
287  time_offset = fFieldRespTOffset[0]+fCalibRespTOffset[0];
288  }
289 
290  // .. Apply field response offset
291  std::vector<int> temp;
292  if (time_offset <=0){
293  temp.assign(fChargeWork.begin(),fChargeWork.begin()-time_offset);
294  fChargeWork.erase(fChargeWork.begin(),fChargeWork.begin()-time_offset);
295  fChargeWork.insert(fChargeWork.end(),temp.begin(),temp.end());
296  }else{
297  temp.assign(fChargeWork.end()-time_offset,fChargeWork.end());
298  fChargeWork.erase(fChargeWork.end()-time_offset,fChargeWork.end());
299  fChargeWork.insert(fChargeWork.begin(),temp.begin(),temp.end());
300  }
301 
302  }
303 
304  // ... Add noise to signal depending on value of fNoiseNchToSim
305  if(fNoiseNchToSim!=0){
306  int noisechan = chan;
307  if(fNoiseNchToSim>0){
308  noisechan = TMath::Nint(flat.fire()*(1.*(fNoise.size()-1)+0.1));
309  }
310  for(int i = 0; i < fNTicks; ++i){
311  adcvec[i] = (short)TMath::Nint(fNoise[noisechan][i] + fChargeWork[i]);
312  }
313  } else {
314  for(int i = 0; i < fNTicks; ++i){
315  adcvec[i] = (short)TMath::Nint(fChargeWork[i]);
316  }
317  }
318 
319  adcvec.resize(fNSamplesReadout);
320 
321  // ... compress the adc vector using the desired compression scheme,
322  // if raw::kNone is selected nothing happens to adcvec
323  // This shrinks adcvec, if fCompression is not kNone.
324  raw::Compress(adcvec, fCompression);
325 
326  // ... add this digit to the collection
327  digcol->emplace_back(chan, fNTicks, move(adcvec), fCompression);
328 
329  }//end loop over channels
330 
331  evt.put(std::move(digcol));
332 
333  return;
334  }
unsigned int fNSamplesReadout
number of ADC readout samples in 1 readout frame
std::vector< TComplex > fColShape
response function for the field @ collection plane
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:145
std::string fDriftEModuleLabel
module making the ionization electrons
int fNoiseNchToSim
number of noise channels to generate
pdgs p
Definition: selectors.fcl:22
raw::Compress_t fCompression
compression type to use
std::vector< std::vector< float > > fNoise
noise on each channel for each time
std::vector< int > fCalibRespTOffset
calib response time offset in ticks
void GenNoise(std::vector< float > &array, CLHEP::HepRandomEngine &engine)
Signal from induction planes.
Definition: geo_types.h:145
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
Definition: SimChannel.cxx:138
std::vector< TComplex > fIndShape
response function for the field @ induction plane
int fNTicks
number of ticks of the clock
std::vector< int > fFieldRespTOffset
field response time offset in ticks
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
Definition: raw.cxx:19
TCEvent evt
Definition: DataStructs.cxx:8
CLHEP::HepRandomEngine & fEngine
Random-number engine owned by art.
void detsim::SimWire::SetElectResponse ( )
private

response of electronics

Definition at line 534 of file SimWire_module.cc.

535  {
536  fElectResponse.resize(fNTicks, 0.);
537  std::vector<double> time(fNTicks,0.);
538 
539  // ... Gain and shaping time variables from fcl file:
540  double Ao = 1.0;
541  double To = fShapeTimeConst; //peaking time
542 
543  // ... this is actually sampling time, in ns
544  mf::LogInfo("SimWire::SetElectResponse") << "Check sampling intervals: "
545  << fInputFieldRespSamplingPeriod << " ns"
546  << "Check number of samples: " << fNTicks;
547 
548  // ... The following sets the microboone electronics response function in
549  // time-space. Function comes from BNL SPICE simulation of DUNE35t
550  // electronics. SPICE gives the electronics transfer function in
551  // frequency-space. The inverse laplace transform of that function
552  // (in time-space) was calculated in Mathematica and is what is being
553  // used below. Parameters Ao and To are cumulative gain/timing parameters
554  // from the full (ASIC->Intermediate amp->Receiver->ADC) electronics chain.
555  // They have been adjusted to make the SPICE simulation to match the
556  // actual electronics response. Default params are Ao=1.4, To=0.5us.
557  double max = 0;
558 
559  for (size_t i = 0; i < fElectResponse.size(); ++i) {
560 
561  // ... convert time to microseconds, to match fElectResponse[i] definition
562  time[i] = (1.*i)*fInputFieldRespSamplingPeriod *1e-3;
563  fElectResponse[i] =
564  4.31054*exp(-2.94809*time[i]/To)*Ao - 2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
565  -2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*cos(2.38722*time[i]/To)*Ao
566  +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*Ao
567  +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*cos(5.18561*time[i]/To)*Ao
568  +0.762456*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
569  -0.762456*exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
570  +0.762456*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
571  -2.6202*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
572  -0.327684*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
573  +0.327684*exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
574  -0.327684*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
575  +0.464924*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
576 
577  if (fElectResponse[i] > max) max = fElectResponse[i];
578 
579  }// end loop over time buckets
580 
581  // ... "normalize" fElectResponse[i], before the convolution
582 
583  for (auto& element : fElectResponse) {
584  element /= max;
585  element *= fADCPerPCAtLowestASICGain * 1.60217657e-7;
586  element *= fASICGainInMVPerFC / 4.7; // relative to lowest gain setting of 4.7 mV/fC
587  }
588 
589  fNElectResp = fElectResponse.size();
590 
591  // ... write the response out to a file
592 
593  art::ServiceHandle<art::TFileService const> tfs;
594  fElectResp = tfs->make<TH1D>(
595  "ElectronicsResponse",";t (ns);Electronics Response",fNElectResp,0,fNElectResp);
596  for (unsigned int i = 0; i < fNElectResp; ++i) {
597  fElectResp->Fill(i, fElectResponse[i]);
598  }
599 
600  fElectResp->Write();
601  }
std::vector< double > fElectResponse
response function for the electronics
double fADCPerPCAtLowestASICGain
ADCs/pC at lowest gain setting of 4.7 mV/fC.
unsigned int fNElectResp
number of entries from response to use
double fShapeTimeConst
time constants for exponential shaping
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
int fNTicks
number of ticks of the clock
double fASICGainInMVPerFC
actual gain setting used in mV/fC
do i e
TH1D * fElectResp
response function for the electronics
art::ServiceHandle< art::TFileService > tfs
void detsim::SimWire::SetFieldResponse ( )
private

response of wires to field

Definition at line 481 of file SimWire_module.cc.

482  {
483 
484  // ... Files to write the response functions to
485  art::ServiceHandle<art::TFileService const> tfs;
486  fIndFieldResp = tfs->make<TH1D>("InductionFieldResponse",";t (ns);Induction Response",fNTicks,0,fNTicks);
487  fColFieldResp = tfs->make<TH1D>("CollectionFieldResponse",";t (ns);Collection Response",fNTicks,0,fNTicks);
488 
489  fColFieldResponse.resize(fNTicks, 0.);
490  fIndFieldResponse.resize(fNTicks, 0.);
491 
492  // ... First set response for collection plane
493  int nbinc = fColFieldParams[0];
494 
495  double integral = 0.;
496  for (int i = 1; i < nbinc; ++i) {
497  fColFieldResponse[i] = i * i;
498  integral += fColFieldResponse[i];
499  }
500 
501  for (int i = 0; i < nbinc; ++i) {
502  fColFieldResponse[i] *= fColFieldParams[1]/integral;
503  fColFieldResp->Fill(i, fColFieldResponse[i]);
504  }
505 
506  // ... Now set response for induction plane
507  int nbini = fIndFieldParams[0];
508  unsigned short lastbini = 2 * nbini;
509 
510  integral = 0;
511  for (unsigned short i = 0; i < lastbini; ++i) {
512  double ang = i * TMath::Pi() / nbini;
513  fIndFieldResponse[i] = sin(ang);
514  if (fIndFieldResponse[i] > 0) {
515  integral += fIndFieldResponse[i];
516  } else {
517  fIndFieldResponse[i] *= fIndFieldParams[2]; // scale the negative lobe by 10% (from ArgoNeuT)
518  }
519  }
520  ++lastbini;
521 
522  for (unsigned short i = 0; i < lastbini; ++i) {
523  fIndFieldResponse[i] *= fIndFieldParams[1]/integral;
524  fIndFieldResp->Fill(i, fIndFieldResponse[i]);
525  }
526 
527  // ... Save the field responses
528  fColFieldResp->Write();
529  fIndFieldResp->Write();
530  }
std::vector< float > fIndFieldParams
induction plane field function parameterization
std::vector< float > fColFieldParams
collection plane field function parameterization
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
std::vector< double > fColFieldResponse
response function for the field @ collection plane
TH1D * fIndFieldResp
response function for the field @ induction plane
int fNTicks
number of ticks of the clock
art::ServiceHandle< art::TFileService > tfs
TH1D * fColFieldResp
response function for the field @ collection plane

Member Data Documentation

double detsim::SimWire::fADCPerPCAtLowestASICGain
private

ADCs/pC at lowest gain setting of 4.7 mV/fC.

Definition at line 97 of file SimWire_module.cc.

double detsim::SimWire::fASICGainInMVPerFC
private

actual gain setting used in mV/fC

Definition at line 98 of file SimWire_module.cc.

std::vector<int> detsim::SimWire::fCalibRespTOffset
private

calib response time offset in ticks

Definition at line 104 of file SimWire_module.cc.

double detsim::SimWire::fCol3DCorrection
private

correction factor to account for 3D path of electrons thru wires

Definition at line 90 of file SimWire_module.cc.

std::vector<float> detsim::SimWire::fColFieldParams
private

collection plane field function parameterization

Definition at line 105 of file SimWire_module.cc.

TH1D* detsim::SimWire::fColFieldResp
private

response function for the field @ collection plane

Definition at line 117 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fColFieldResponse
private

response function for the field @ collection plane

Definition at line 107 of file SimWire_module.cc.

std::vector<TComplex> detsim::SimWire::fColShape
private

response function for the field @ collection plane

Definition at line 109 of file SimWire_module.cc.

TH1D* detsim::SimWire::fColTimeShape
private

convoluted shape for field x electronics @ col plane

Definition at line 119 of file SimWire_module.cc.

raw::Compress_t detsim::SimWire::fCompression
private

compression type to use

Definition at line 85 of file SimWire_module.cc.

std::string detsim::SimWire::fDriftEModuleLabel
private

module making the ionization electrons

Definition at line 84 of file SimWire_module.cc.

TH1D* detsim::SimWire::fElectResp
private

response function for the electronics

Definition at line 118 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fElectResponse
private

response function for the electronics

Definition at line 111 of file SimWire_module.cc.

CLHEP::HepRandomEngine& detsim::SimWire::fEngine
private

Random-number engine owned by art.

Definition at line 124 of file SimWire_module.cc.

std::vector<int> detsim::SimWire::fFieldRespTOffset
private

field response time offset in ticks

Definition at line 103 of file SimWire_module.cc.

double detsim::SimWire::fInd3DCorrection
private

correction factor to account for 3D path of electrons thru wires

Definition at line 92 of file SimWire_module.cc.

std::vector<float> detsim::SimWire::fIndFieldParams
private

induction plane field function parameterization

Definition at line 106 of file SimWire_module.cc.

TH1D* detsim::SimWire::fIndFieldResp
private

response function for the field @ induction plane

Definition at line 116 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fIndFieldResponse
private

response function for the field @ induction plane

Definition at line 108 of file SimWire_module.cc.

std::vector<TComplex> detsim::SimWire::fIndShape
private

response function for the field @ induction plane

Definition at line 110 of file SimWire_module.cc.

TH1D* detsim::SimWire::fIndTimeShape
private

convoluted shape for field x electronics @ ind plane

Definition at line 120 of file SimWire_module.cc.

double detsim::SimWire::fInputFieldRespSamplingPeriod
private

Sampling period in the input field response.

Definition at line 95 of file SimWire_module.cc.

unsigned int detsim::SimWire::fNElectResp
private

number of entries from response to use

Definition at line 94 of file SimWire_module.cc.

std::vector<std::vector<float> > detsim::SimWire::fNoise
private

noise on each channel for each time

Definition at line 112 of file SimWire_module.cc.

TH1D* detsim::SimWire::fNoiseDist
private

distribution of noise counts

Definition at line 121 of file SimWire_module.cc.

TF1* detsim::SimWire::fNoiseFluct
private

Poisson dist for fluctuations in magnitude of noise freq components.

Definition at line 122 of file SimWire_module.cc.

std::string detsim::SimWire::fNoiseFluctChoice
private

choice for noise freq component mag fluctuations

Definition at line 101 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fNoiseFluctPar
private

Poisson noise fluctuations params.

Definition at line 114 of file SimWire_module.cc.

std::string detsim::SimWire::fNoiseModelChoice
private

choice for noise model

Definition at line 100 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fNoiseModelPar
private

noise model params

Definition at line 113 of file SimWire_module.cc.

int detsim::SimWire::fNoiseNchToSim
private

number of noise channels to generate

Definition at line 99 of file SimWire_module.cc.

unsigned int detsim::SimWire::fNSamplesReadout
private

number of ADC readout samples in 1 readout frame

Definition at line 89 of file SimWire_module.cc.

int detsim::SimWire::fNTicks
private

number of ticks of the clock

Definition at line 87 of file SimWire_module.cc.

double detsim::SimWire::fSampleRate
private

sampling rate in ns

Definition at line 88 of file SimWire_module.cc.

double detsim::SimWire::fShapeTimeConst
private

time constants for exponential shaping

Definition at line 96 of file SimWire_module.cc.


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