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

Public Member Functions

 SimWireSBND (fhicl::ParameterSet const &pset)
 
virtual ~SimWireSBND ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 

Private Attributes

std::string fDriftEModuleLabel
 module making the ionization electrons More...
 
raw::Compress_t fCompression
 compression type to use More...
 
size_t fNTicks
 number of ticks of the clock More...
 
unsigned int fNTimeSamples
 number of ADC readout samples in all readout frames (per event) More...
 
float fCollectionPed
 ADC value of baseline for collection plane. More...
 
float fInductionPed
 ADC value of baseline for induction plane. More...
 
float fCollectionSat
 ADC value of pre-amp saturation for collection plane. More...
 
float fInductionSat
 ADC value of pre-amp saturation for induction plane. More...
 
float fBaselineRMS
 ADC value of baseline RMS within each channel. More...
 
TH1D * fNoiseDist
 distribution of noise counts More...
 
bool fGenNoise
 if True -> Gen Noise. if False -> Skip noise generation entierly More...
 
art::ServiceHandle
< ChannelNoiseService
noiseserv
 
std::string fTrigModName
 Trigger data product producer name. More...
 
CLHEP::HepRandomEngine & fPedestalEngine
 

Static Private Attributes

static constexpr float adcsaturation {4095}
 

Detailed Description

Definition at line 69 of file SimWireSBND_module.cc.

Constructor & Destructor Documentation

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

Definition at line 112 of file SimWireSBND_module.cc.

113  : EDProducer{pset}
114  // create a default random engine; obtain the random seed from NuRandomService,
115  // unless overridden in configuration with key "Seed" and "SeedPedestal"
116  // , fNoiseEngine(art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*this, "HepJamesRandom", "noise", pset, "Seed"))
117  , fPedestalEngine(art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*this, "HepJamesRandom", "pedestal", pset, "SeedPedestal"))
CLHEP::HepRandomEngine & fPedestalEngine
detsim::SimWireSBND::~SimWireSBND ( )
virtual

Definition at line 129 of file SimWireSBND_module.cc.

130 {
131 }

Member Function Documentation

void detsim::SimWireSBND::beginJob ( )

Definition at line 185 of file SimWireSBND_module.cc.

186 {
187 
188  // get access to the TFile service
189  art::ServiceHandle<art::TFileService> tfs;
190 
191  fNoiseDist = tfs->make<TH1D>("Noise", ";Noise (ADC);", 1000, -10., 10.);
192 
193  art::ServiceHandle<util::LArFFT> fFFT;
194  fNTicks = fFFT->FFTSize();
195 
196  if ( fNTicks % 2 != 0 )
197  MF_LOG_DEBUG("SimWireSBND") << "Warning: FFTSize not a power of 2. "
198  << "May cause issues in (de)convolution.\n";
199 
200  if ( fNTimeSamples > fNTicks )
201  mf::LogError("SimWireSBND") << "Cannot have number of readout samples "
202  << "greater than FFTSize!";
203 
204  return;
205 
206 }
size_t fNTicks
number of ticks of the clock
unsigned int fNTimeSamples
number of ADC readout samples in all readout frames (per event)
TH1D * fNoiseDist
distribution of noise counts
art::ServiceHandle< art::TFileService > tfs
void detsim::SimWireSBND::endJob ( )

Definition at line 209 of file SimWireSBND_module.cc.

210 {}
void detsim::SimWireSBND::produce ( art::Event &  evt)

Definition at line 212 of file SimWireSBND_module.cc.

213 {
214  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
215 
216  //Generate gaussian and coherent noise if doing uBooNE noise model. For other models it does nothing.
217  noiseserv->generateNoise(clockData);
218 
219  // get the geometry to be able to figure out signal types and chan -> plane mappings
220  art::ServiceHandle<geo::Geometry> geo;
221  //unsigned int signalSize = fNTicks;
222  //
223  //Get the channels status
224  lariov::ChannelStatusProvider const& channelStatus(art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider());
225 
226  std::vector<const sim::SimChannel*> chanHandle;
227  evt.getView(fDriftEModuleLabel, chanHandle);
228 
229  //Get fIndShape and fColShape from SignalShapingService, on the fly
230  art::ServiceHandle<util::SignalShapingServiceSBND> sss;
231 
232  // make a vector of const sim::SimChannel* that has same number
233  // of entries as the number of channels in the detector
234  // and set the entries for the channels that have signal on them
235  // using the chanHandle
236  std::vector<const sim::SimChannel*> channels(geo->Nchannels(), nullptr);
237  for (size_t c = 0; c < chanHandle.size(); ++c) {
238  channels.at(chanHandle.at(c)->Channel()) = chanHandle.at(c);
239  }
240 
241  const auto NChannels = geo->Nchannels();
242 
243  // vectors for working
244  std::vector<short> adcvec(fNTimeSamples, 0);
245  std::vector<double> chargeWork(fNTicks, 0.);
246 
247 
248 
249  // make a unique_ptr of sim::SimDigits that allows ownership of the produced
250  // digits to be transferred to the art::Event after the put statement below
251  std::unique_ptr< std::vector<raw::RawDigit>> digcol(new std::vector<raw::RawDigit>);
252  digcol->reserve(NChannels);
253 
254  unsigned int chan = 0;
255  art::ServiceHandle<util::LArFFT> fFFT;
256 
257  //LOOP OVER ALL CHANNELS
258  std::map<int, double>::iterator mapIter;
259  for (chan = 0; chan < geo->Nchannels(); chan++) {
260 
261  if (channelStatus.IsBad(chan)) continue;
262 
263  // get the sim::SimChannel for this channel
264  const sim::SimChannel* sc = channels.at(chan);
265  std::fill(chargeWork.begin(), chargeWork.end(), 0.);
266  if ( sc ) {
267 
268  // loop over the tdcs and grab the number of electrons for each
269  for (int t = 0; t < (int)(chargeWork.size()); ++t) {
270 
271  int tdc = clockData.TPCTick2TDC(t);
272 
273  // continue if tdc < 0
274  if ( tdc < 0 ) continue;
275 
276  chargeWork.at(t) = sc->Charge(tdc);
277 
278  }
279 
280  // Convolve charge with appropriate response function
281  sss->Convolute(clockData, chan, chargeWork);
282 
283  }
284  std::vector<float> noisetmp(fNTicks, 0.);
285 
286  // Add noise to channel.
287  if( fGenNoise ) noiseserv->addNoise(clockData, chan,noisetmp);
288 
289  //Pedestal determination
290  float ped_mean = fCollectionPed;
291  float preamp_sat=fCollectionSat;
292  geo::SigType_t sigtype = geo->SignalType(chan);
293  if (sigtype == geo::kInduction) {
294  ped_mean = fInductionPed;
295  preamp_sat = fInductionSat;
296  }
297  //slight variation on ped on order of RMS of baseline variation
298  // (skip this if BaselineRMS = 0 in fhicl)
299  if( fBaselineRMS ) {
300  CLHEP::RandGaussQ rGaussPed(fPedestalEngine, 0.0, fBaselineRMS);
301  ped_mean += rGaussPed.fire();
302  }
303 
304  for (unsigned int i = 0; i < fNTimeSamples; ++i) {
305 
306  float chargecontrib = chargeWork.at(i);
307  if (chargecontrib>preamp_sat) chargecontrib=preamp_sat;
308 
309  float adcval = noisetmp.at(i) + chargecontrib + ped_mean;
310 
311  //Add Noise to NoiseDist Histogram
312  if (i % 100 == 0)
313  fNoiseDist->Fill(noisetmp.at(i));
314 
315  //allow for ADC saturation
316  if ( adcval > adcsaturation )
317  adcval = adcsaturation;
318  //don't allow for "negative" saturation
319  if ( adcval < 0 )
320  adcval = 0;
321 
322  adcvec.at(i) = (unsigned short)(adcval+0.5);
323 
324  }// end loop over signal size
325 
326  // resize the adcvec to be the correct number of time samples,
327  // just drop the extra samples
328  //adcvec.resize(fNTimeSamples);
329 
330  // compress the adc vector using the desired compression scheme,
331  // if raw::kNone is selected nothing happens to adcvec
332  // This shrinks adcvec, if fCompression is not kNone.
333  raw::Compress(adcvec, fCompression);
334 
335  // add this digit to the collection
336  raw::RawDigit rd(chan, fNTimeSamples, adcvec, fCompression);
337  rd.SetPedestal(ped_mean);
338  digcol->push_back(rd);
339 
340  }// end loop over channels
341 
342  evt.put(std::move(digcol));
343 
344 }//produce()
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
float fInductionSat
ADC value of pre-amp saturation for induction plane.
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:145
std::string fDriftEModuleLabel
module making the ionization electrons
float fCollectionSat
ADC value of pre-amp saturation for collection plane.
bool fGenNoise
if True -&gt; Gen Noise. if False -&gt; Skip noise generation entierly
float fInductionPed
ADC value of baseline for induction plane.
art::ServiceHandle< ChannelNoiseService > noiseserv
static constexpr float adcsaturation
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
enum geo::_plane_sigtype SigType_t
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
Class providing information about the quality of channels.
size_t fNTicks
number of ticks of the clock
unsigned int fNTimeSamples
number of ADC readout samples in all readout frames (per event)
float fBaselineRMS
ADC value of baseline RMS within each channel.
CLHEP::HepRandomEngine & fPedestalEngine
TH1D * fNoiseDist
distribution of noise counts
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
raw::Compress_t fCompression
compression type to use
float fCollectionPed
ADC value of baseline for collection plane.
void detsim::SimWireSBND::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 134 of file SimWireSBND_module.cc.

135 {
136  fDriftEModuleLabel = p.get< std::string >("DriftEModuleLabel");
137  fGenNoise = p.get< bool >("GenNoise");
138  fCollectionPed = p.get< float >("CollectionPed",690.);
139  fInductionPed = p.get< float >("InductionPed",2100.);
140  fCollectionSat = p.get< float >("CollectionSat",2922.);
141  fInductionSat = p.get< float >("InductionSat",1247.);
142  fBaselineRMS = p.get< float >("BaselineRMS");
143  fTrigModName = p.get< std::string >("TrigModName");
144 
145  //Map the Shaping times to the entry position for the noise ADC
146  //level in fNoiseFactInd and fNoiseFactColl
147  //fShapingTimeOrder = { {0.5, 0 }, {1.0, 1}, {2.0, 2}, {3.0, 3} };
148 
149  //if (fGetNoiseFromHisto)
150  //{
151  // fNoiseHistoName = p.get< std::string >("NoiseHistoName");
152 
153  // cet::search_path sp("FW_SEARCH_PATH");
154  // sp.find_file(p.get<std::string>("NoiseFileFname"), fNoiseFileFname);
155 
156  // TFile in(fNoiseFileFname.c_str(), "READ");
157  // if (!in.IsOpen()) {
158  // throw art::Exception(art::errors::FileOpenError)
159  // << "Could not find Root file '" << fNoiseHistoName
160  // << "' for noise histogram\n";
161  // }
162  // fNoiseHist = (TH1D*) in.Get(fNoiseHistoName.c_str());
163 
164  // if (!fNoiseHist) {
165  // throw art::Exception(art::errors::NotFound)
166  // << "Could not find noise histogram '" << fNoiseHistoName
167  // << "' in Root file '" << in.GetPath() << "'\n";
168  // }
169  // // release the histogram from its file; now we own it
170  // fNoiseHist->SetDirectory(nullptr);
171  // in.Close();
172  //}
173 
174  //detector properties information
175  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
176  fNTimeSamples = detProp.NumberTimeSamples();
177 
178  noiseserv->InitialiseProducerDeps(this, p);
179 
180 
181  return;
182 }
float fInductionSat
ADC value of pre-amp saturation for induction plane.
std::string fDriftEModuleLabel
module making the ionization electrons
float fCollectionSat
ADC value of pre-amp saturation for collection plane.
pdgs p
Definition: selectors.fcl:22
bool fGenNoise
if True -&gt; Gen Noise. if False -&gt; Skip noise generation entierly
float fInductionPed
ADC value of baseline for induction plane.
art::ServiceHandle< ChannelNoiseService > noiseserv
unsigned int fNTimeSamples
number of ADC readout samples in all readout frames (per event)
float fBaselineRMS
ADC value of baseline RMS within each channel.
std::string fTrigModName
Trigger data product producer name.
auto const detProp
float fCollectionPed
ADC value of baseline for collection plane.

Member Data Documentation

constexpr float detsim::SimWireSBND::adcsaturation {4095}
staticprivate

Definition at line 102 of file SimWireSBND_module.cc.

float detsim::SimWireSBND::fBaselineRMS
private

ADC value of baseline RMS within each channel.

Definition at line 93 of file SimWireSBND_module.cc.

float detsim::SimWireSBND::fCollectionPed
private

ADC value of baseline for collection plane.

Definition at line 89 of file SimWireSBND_module.cc.

float detsim::SimWireSBND::fCollectionSat
private

ADC value of pre-amp saturation for collection plane.

Definition at line 91 of file SimWireSBND_module.cc.

raw::Compress_t detsim::SimWireSBND::fCompression
private

compression type to use

Definition at line 85 of file SimWireSBND_module.cc.

std::string detsim::SimWireSBND::fDriftEModuleLabel
private

module making the ionization electrons

Definition at line 84 of file SimWireSBND_module.cc.

bool detsim::SimWireSBND::fGenNoise
private

if True -> Gen Noise. if False -> Skip noise generation entierly

Definition at line 95 of file SimWireSBND_module.cc.

float detsim::SimWireSBND::fInductionPed
private

ADC value of baseline for induction plane.

Definition at line 90 of file SimWireSBND_module.cc.

float detsim::SimWireSBND::fInductionSat
private

ADC value of pre-amp saturation for induction plane.

Definition at line 92 of file SimWireSBND_module.cc.

TH1D* detsim::SimWireSBND::fNoiseDist
private

distribution of noise counts

Definition at line 94 of file SimWireSBND_module.cc.

size_t detsim::SimWireSBND::fNTicks
private

number of ticks of the clock

Definition at line 87 of file SimWireSBND_module.cc.

unsigned int detsim::SimWireSBND::fNTimeSamples
private

number of ADC readout samples in all readout frames (per event)

Definition at line 88 of file SimWireSBND_module.cc.

CLHEP::HepRandomEngine& detsim::SimWireSBND::fPedestalEngine
private

Definition at line 105 of file SimWireSBND_module.cc.

std::string detsim::SimWireSBND::fTrigModName
private

Trigger data product producer name.

Definition at line 99 of file SimWireSBND_module.cc.

art::ServiceHandle<ChannelNoiseService> detsim::SimWireSBND::noiseserv
private

Definition at line 97 of file SimWireSBND_module.cc.


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