46 #include "art_root_io/TFileService.h" 47 #include "cetlib_except/exception.h" 54 #include "CLHEP/Random/RandFlat.h" 82 void GenNoise(std::vector<float>&
array, CLHEP::HepRandomEngine& engine);
164 MF_LOG_WARNING(
"SimWire") <<
"SimWire is an example module that works for the " 165 <<
"MicroBooNE detector. Each experiment should implement " 166 <<
"its own version of this module to simulate electronics " 169 produces<std::vector<raw::RawDigit>>();
178 fNoiseDist = tfs->make<TH1D>(
"Noise",
";Noise (ADC);", 1000, -10., 10.);
186 fNoiseFluct =
new TF1(
"_poisson",
"[0]**(x) * exp(-[0]) / ROOT::Math::tgamma(x)", 0, 5.);
192 "_poisson",
"[0]*pow([1]/[2], x/[2])*exp(-[1]/[2])/ROOT::Math::tgamma(x/[2]+1.)", 0, 5.);
207 <<
fNoiseNchToSim <<
" noise channels requested exceeds 10000" << std::endl;
210 for (
unsigned int p = 0; p <
fNoise.size(); ++p) {
212 for (
int i = 0; i <
fNTicks; ++i) {
228 auto const nchannels = wireReadoutGeom.Nchannels();
234 for (
unsigned int p = 0; p < nchannels; ++p) {
243 std::vector<const sim::SimChannel*> chanHandle;
246 std::vector<const sim::SimChannel*> channels(nchannels);
247 for (
size_t c = 0; c < chanHandle.size(); ++c) {
248 channels[chanHandle[c]->Channel()] = chanHandle[c];
253 auto digcol = std::make_unique<std::vector<raw::RawDigit>>();
261 for (
unsigned int chan = 0; chan < nchannels; chan++) {
263 std::vector<short> adcvec(
fNTicks, 0);
264 std::vector<double> fChargeWork(
fNTicks, 0.);
266 if (channels[chan]) {
272 for (
int t = 0; t <
fNTicks; ++t)
273 fChargeWork[t] = sc->
Charge(t);
288 std::vector<int> temp;
289 if (time_offset <= 0) {
290 temp.assign(fChargeWork.begin(), fChargeWork.begin() - time_offset);
291 fChargeWork.erase(fChargeWork.begin(), fChargeWork.begin() - time_offset);
292 fChargeWork.insert(fChargeWork.end(), temp.begin(), temp.end());
295 temp.assign(fChargeWork.end() - time_offset, fChargeWork.end());
296 fChargeWork.erase(fChargeWork.end() - time_offset, fChargeWork.end());
297 fChargeWork.insert(fChargeWork.begin(), temp.begin(), temp.end());
303 int noisechan = chan;
305 noisechan = TMath::Nint(flat.fire() * (1. * (
fNoise.size() - 1) + 0.1));
307 for (
int i = 0; i <
fNTicks; ++i) {
308 adcvec[i] = (short)TMath::Nint(
fNoise[noisechan][i] + fChargeWork[i]);
312 for (
int i = 0; i <
fNTicks; ++i) {
313 adcvec[i] = (short)TMath::Nint(fChargeWork[i]);
329 evt.
put(std::move(digcol));
340 std::vector<double> ind(
fNTicks, 0.);
341 std::vector<TComplex> kern(
fNTicks / 2 + 1);
342 std::vector<double> delta(
fNTicks, 0.);
351 for (
unsigned int i = 0; i < kern.size(); ++i)
370 for (
unsigned int i = 0; i < kern.size(); ++i)
387 "ConvolutedCollection",
";ticks; Electronics#timesCollection",
fNTicks, 0,
fNTicks);
389 "ConvolutedInduction",
";ticks; Electronics#timesInduction",
fNTicks, 0,
fNTicks);
392 for (
unsigned int i = 0; i < ind.size(); ++i) {
394 fIndTimeShape->Fill(i, ind[i]);
398 fIndTimeShape->Write();
404 CLHEP::RandFlat flat(engine);
408 std::vector<TComplex> noiseFrequency(
fNTicks / 2 + 1, 0.);
412 double rnd[2] = {0.};
417 for (
int i = 0; i <
fNTicks / 2 + 1; ++i) {
419 double x = (i + 0.5) * binWidth;
426 double lofilter = 1.0 / (1.0 + exp(-(i -
fNoiseModelPar[2] / binWidth) / 0.5));
427 flat.fireArray(1, rnd, 0, 1);
428 pval *= lofilter * (0.9 + 0.2 * rnd[0]);
439 pval = pval * randomizer /
fNTicks;
450 pval = pval * randomizer /
fNTicks;
454 <<
fNoiseModelChoice <<
" is an unknown choice for the noise model" << std::endl;
457 flat.fireArray(1, rnd, 0, 1);
458 phase = rnd[0] * 2. * TMath::Pi();
460 TComplex tc(pval * cos(phase), pval * sin(phase));
461 noiseFrequency[i] += tc;
466 fFFT->
DoInvFFT(noiseFrequency, noise);
468 noiseFrequency.clear();
473 for (
unsigned int i = 0; i < noise.size(); ++i)
484 tfs->make<TH1D>(
"InductionFieldResponse",
";t (ns);Induction Response",
fNTicks, 0,
fNTicks);
486 "CollectionFieldResponse",
";t (ns);Collection Response",
fNTicks, 0,
fNTicks);
494 double integral = 0.;
495 for (
int i = 1; i < nbinc; ++i) {
500 for (
int i = 0; i < nbinc; ++i) {
507 unsigned short lastbini = 2 * nbini;
510 for (
unsigned short i = 0; i < lastbini; ++i) {
511 double ang = i * TMath::Pi() / nbini;
521 for (
unsigned short i = 0; i < lastbini; ++i) {
527 fColFieldResp->Write();
535 std::vector<double> time(
fNTicks, 0.);
544 <<
"Check number of samples: " <<
fNTicks;
562 4.31054 * exp(-2.94809 * time[i] / To) * Ao -
563 2.6202 * exp(-2.82833 * time[i] / To) * cos(1.19361 * time[i] / To) * Ao -
564 2.6202 * exp(-2.82833 * time[i] / To) * cos(1.19361 * time[i] / To) *
565 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) *
568 cos(5.18561 * time[i] / To) * Ao +
569 0.762456 * exp(-2.82833 * time[i] / To) * sin(1.19361 * time[i] / To) * Ao -
570 0.762456 * exp(-2.82833 * time[i] / To) * cos(2.38722 * time[i] / To) *
571 sin(1.19361 * time[i] / To) * Ao +
572 0.762456 * exp(-2.82833 * time[i] / To) * cos(1.19361 * time[i] / To) *
573 sin(2.38722 * time[i] / To) * Ao -
574 2.6202 * exp(-2.82833 * time[i] / To) * sin(1.19361 * time[i] / To) *
575 sin(2.38722 * time[i] / To) * Ao -
576 0.327684 * exp(-2.40318 * time[i] / To) * sin(2.5928 * time[i] / To) * Ao +
577 +0.327684 * exp(-2.40318 * time[i] / To) * cos(5.18561 * time[i] / To) *
578 sin(2.5928 * time[i] / To) * Ao -
579 0.327684 * exp(-2.40318 * time[i] / To) * cos(2.5928 * time[i] / To) *
580 sin(5.18561 * time[i] / To) * Ao +
581 0.464924 * exp(-2.40318 * time[i] / To) * sin(2.5928 * time[i] / To) *
582 sin(5.18561 * time[i] / To) * Ao;
base_engine_t & createEngine(seed_t seed)
unsigned int fNSamplesReadout
number of ADC readout samples in 1 readout frame
std::string fNoiseModelChoice
choice for noise model
std::vector< TComplex > fColShape
response function for the field @ collection plane
enum raw::_compress Compress_t
std::vector< float > fIndFieldParams
induction plane field function parameterization
Energy deposited on a readout channel by simulated tracks.
std::vector< double > fElectResponse
response function for the electronics
TF1 * fNoiseFluct
Poisson dist for fluctuations in magnitude of noise freq components.
TH1D * fColTimeShape
convoluted shape for field x electronics @ col plane
std::string fDriftEModuleLabel
module making the ionization electrons
int fNoiseNchToSim
number of noise channels to generate
void SetElectResponse()
response of electronics
void ShiftData(std::vector< TComplex > &input, double shift)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double fADCPerPCAtLowestASICGain
ADCs/pC at lowest gain setting of 4.7 mV/fC.
EDProducer(fhicl::ParameterSet const &pset)
unsigned int fNElectResp
number of entries from response to use
TH1D * fNoiseDist
distribution of noise counts
Detector simulation of raw signals on wires.
std::string fNoiseFluctChoice
choice for noise freq component mag fluctuations
Definition of basic raw digits.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
raw::Compress_t fCompression
compression type to use
double fShapeTimeConst
time constants for exponential shaping
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
std::vector< std::vector< float > > fNoise
noise on each channel for each time
T PeakCorrelation(std::vector< T > &shape1, std::vector< T > &shape2)
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
tick ticks
Alias for common language habits.
std::vector< float > fColFieldParams
collection plane field function parameterization
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< int > fCalibRespTOffset
calib response time offset in ticks
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
void GenNoise(std::vector< float > &array, CLHEP::HepRandomEngine &engine)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
#define DEFINE_ART_MODULE(klass)
Signal from induction planes.
std::vector< double > fColFieldResponse
response function for the field @ collection plane
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
std::vector< TComplex > fIndShape
response function for the field @ induction plane
std::vector< double > fNoiseFluctPar
Poisson noise fluctuations params.
void produce(art::Event &evt) override
Collect all the RawData header files together.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
void ConvoluteResponseFunctions()
convolute electronics and field response
double fSampleRate
sampling rate in ns
void SetFieldResponse()
response of wires to field
SimWire(fhicl::ParameterSet const &pset)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
TH1D * fIndFieldResp
response function for the field @ induction plane
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
int fNTicks
number of ticks of the clock
TH1D * fIndTimeShape
convoluted shape for field x electronics @ ind plane
std::vector< int > fFieldRespTOffset
field response time offset in ticks
Encapsulate the construction of a single detector plane .
double fASICGainInMVPerFC
actual gain setting used in mV/fC
object containing MC truth information necessary for making RawDigits and doing back tracking ...
TH1D * fElectResp
response function for the electronics
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
#define MF_LOG_WARNING(category)
CLHEP::HepRandomEngine & fEngine
Random-number engine owned by art.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
TH1D * fColFieldResp
response function for the field @ collection plane
std::vector< double > fNoiseModelPar
noise model params
cet::coded_exception< error, detail::translate > exception