All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Attributes | List of all members
daq::FakeParticle Class Reference

FakeParticle class definiton. More...

Inheritance diagram for daq::FakeParticle:
daq::IFakeParticle

Public Member Functions

 FakeParticle (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~FakeParticle ()
 Destructor. More...
 
virtual void configure (const fhicl::ParameterSet &) override
 Interface for configuring the particular algorithm tool. More...
 
virtual void overlayFakeParticle (detinfo::DetectorClocksData const &clockData, ArrayFloat &waveforms) override
 Creates a fake particle and overlays on the input fragment. More...
 
- Public Member Functions inherited from daq::IFakeParticle
virtual ~IFakeParticle () noexcept=default
 Virtual Destructor. More...
 

Private Types

using FFTPointer = std::unique_ptr< icarus_signal_processing::ICARUSFFT< double >>
 

Private Attributes

std::vector< size_t > fWireEndPoints
 
size_t fStartTick
 
float fStartAngle
 
int fNumElectronsPerMM
 
size_t fPlaneToSimulate
 
float fMMPerTick
 
float fMMPerWire
 
float fTanThetaTW
 
float fTanTheta
 
float fSinTheta
 
float fCosTheta
 
std::vector< size_t > fTickEndPoints
 
icarusutil::TimeVec fFFTTimeVec
 
FFTPointer fFFT
 
const geo::GeometryfGeometry
 
const detinfo::DetectorPropertiesfDetector
 
icarusutil::SignalShapingICARUSServicefSignalShapingService
 

Additional Inherited Members

- Public Types inherited from daq::IFakeParticle
using VectorShort = std::vector< short >
 Creates a fake particle and overlays on the input fragment. More...
 
using VectorFloat = std::vector< float >
 
using ArrayShort = std::vector< VectorShort >
 
using ArrayFloat = std::vector< VectorFloat >
 

Detailed Description

FakeParticle class definiton.

Definition at line 41 of file FakeParticle_tool.cc.

Member Typedef Documentation

using daq::FakeParticle::FFTPointer = std::unique_ptr<icarus_signal_processing::ICARUSFFT<double>>
private

Definition at line 91 of file FakeParticle_tool.cc.

Constructor & Destructor Documentation

daq::FakeParticle::FakeParticle ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Parameters
pset

Definition at line 100 of file FakeParticle_tool.cc.

101 {
102  this->configure(pset);
103 
104  return;
105 }
virtual void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
daq::FakeParticle::~FakeParticle ( )

Destructor.

Definition at line 109 of file FakeParticle_tool.cc.

110 {
111 }

Member Function Documentation

void daq::FakeParticle::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Interface for configuring the particular algorithm tool.

Parameters
ParameterSetThe input set of parameters for configuration

Implements daq::IFakeParticle.

Definition at line 114 of file FakeParticle_tool.cc.

115 {
116  fWireEndPoints = pset.get<std::vector<size_t>>("WireEndPoints", std::vector<size_t>()={25,550});
117  fStartTick = pset.get<size_t >("StartTick", 1000);
118  fStartAngle = pset.get<float >("StartAngle", 45);
119  fNumElectronsPerMM = pset.get<int >("NumElectronsPerMM", 6000);
120  fPlaneToSimulate = pset.get<size_t >("PlaneToSimulate", 2);
121 
122  fGeometry = art::ServiceHandle<geo::Geometry const>{}.get();
123  fSignalShapingService = art::ServiceHandle<icarusutil::SignalShapingICARUSService>{}.get();
124 
125  // Convert ticks in us to mm by taking the drift velocity and multiplying by the tick period
126  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
127  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
128  double driftVelocity = detProp.DriftVelocity() * 10.; // should be mm/us
129  double samplingRate = sampling_rate(clockData) / 1000.; // sampling rate returned in ns
130 
131  fMMPerTick = driftVelocity * samplingRate;
132 
133  fMMPerWire = fGeometry->WirePitch() * 10.; // wire pitch returned in cm, want mm
134 
135  // Get slope (tan(theta)) and related angles
136  fTanTheta = std::tan(fStartAngle * M_PI / 180.);
137  fCosTheta = 1. / sqrt(1. + fTanTheta * fTanTheta);
139 
141 
142  // Constrain x range
143  fWireEndPoints[1] = std::min(fWireEndPoints[1],size_t(576));
144 
145  // Now compute the tick start/end points
146  fTickEndPoints.push_back(fStartTick);
147  fTickEndPoints.push_back(size_t(std::round(fTanThetaTW * float(fWireEndPoints[1] - fWireEndPoints[0]) + fStartTick)));
148 
149  // Check to see if we have run off the end of our frame (max 576,4096)
150  if (fTickEndPoints[1] > size_t(4096))
151  {
152  // Probably should worry about the 90 degree case...
153  if (std::fabs(fStartAngle) < 90)
154  {
155  fWireEndPoints[1] = std::round(float(4096 - fStartTick) / fTanTheta + fWireEndPoints[0]);
156  fTickEndPoints[1] = 4096;
157  }
158  else
160  }
161 
162  // Now set up our plans for doing the convolution
163  int numberTimeSamples = fDetector->NumberTimeSamples();
164 
165  fFFTTimeVec.resize(numberTimeSamples,0.);
166 
167  fFFT = std::make_unique<icarus_signal_processing::ICARUSFFT<double>>(numberTimeSamples);
168 
169  return;
170 }
icarusutil::TimeVec fFFTTimeVec
icarusutil::SignalShapingICARUSService * fSignalShapingService
virtual unsigned int NumberTimeSamples() const =0
std::vector< size_t > fTickEndPoints
const detinfo::DetectorProperties * fDetector
std::vector< size_t > fWireEndPoints
const geo::Geometry * fGeometry
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
auto const detProp
void daq::FakeParticle::overlayFakeParticle ( detinfo::DetectorClocksData const &  clockData,
ArrayFloat waveforms 
)
overridevirtual

Creates a fake particle and overlays on the input fragment.

Parameters
waveformsThe waveform container to place fake particle on

Implements daq::IFakeParticle.

Definition at line 172 of file FakeParticle_tool.cc.

173 {
174  // We have assumed the input waveform array will have 576 wires...
175  // Our "range" must be contained within that. By assumption we start at wire 0, so really just need
176  // to set the max range
177  size_t maxWire = std::min(waveforms.size(),fWireEndPoints[1]);
178 
179  // Create a temporary waveform to handle the input charge
180 // icarusutil::TimeVec tempWaveform(waveforms[0].size(),0.);
181 
182  // Also recover the gain
183  float asicGain = fSignalShapingService->GetASICGain(0) * sampling_rate(clockData) / 1000.; // something like 67.4
184 
185  // Get a base channel number for the plane we want
187 
188  // Recover the response function information for this channel
189  const icarus_tool::IResponse& response = fSignalShapingService->GetResponse(channel);
190 
191  // Also want the time offset for this channel
192  int timeOffset = fSignalShapingService->ResponseTOffset(channel);
193 
194  // Loop over the wire range
195  for(size_t wireIdx = fWireEndPoints[0]; wireIdx < maxWire; wireIdx++)
196  {
197  // As the track angle becomes more parallel to the electron drift direction there will be more charge
198  // deposited per mm that will impact a given wire. So we need to try to accommodate this here.
199  // Start by computing the starting tick (based on how far we have gone so far)
200  size_t startTick = size_t(fTanThetaTW * float(wireIdx - fWireEndPoints[0])) + fTickEndPoints[0];
201 
202  // If this has gone outside the maximum tick then we are done
203  if (!(startTick < fTickEndPoints[1] && startTick < fFFTTimeVec.size())) break;
204 
205  // Begin by computing the number of ticks for this given wire, converted to tick units and
206  // always at least one tick
207  size_t deltaTicks = size_t(fMMPerWire * std::fabs(fTanTheta)) + 1;
208  size_t endTick = startTick + deltaTicks;
209 
210  // Trim back if we look to step outside of the max range
211  endTick = std::min(endTick,fTickEndPoints[1]);
212  endTick = std::min(endTick,fFFTTimeVec.size());
213 
214  // Ok, now loop through the ticks and deposit charge.
215  // This will be the number of electrons per mm (input)
216  // x the total arc length of track for this step
217  float arcLenPerWire = fMMPerWire / fCosTheta;
218  float arcLenPerTick = arcLenPerWire / float(deltaTicks);
219  float numElectronsWire = fNumElectronsPerMM * arcLenPerWire;
220  float fracElecPerTick = numElectronsWire * arcLenPerTick / arcLenPerWire;
221 
222  // Make sure the waveform is zeroed
223  std::fill(fFFTTimeVec.begin(),fFFTTimeVec.end(),0.);
224 
225  // Now loop through the ticks and deposit charge
226  for(size_t tickIdx = startTick; tickIdx < endTick; tickIdx++)
227  fFFTTimeVec[tickIdx] = fracElecPerTick / asicGain;
228 
229  // Convolute with the response functions
230 // fSignalShapingService->Convolute(channel, fFFTTimeVec);
231  fFFT->convolute(fFFTTimeVec, response.getConvKernel(), timeOffset);
232 
233  // And now add this to the waveform in question
234  VectorFloat& waveform = waveforms[wireIdx];
235 
236  std::transform(waveform.begin(),waveform.end(),fFFTTimeVec.begin(),waveform.begin(),std::plus<float>());
237  }
238 
239  return;
240 }
icarusutil::TimeVec fFFTTimeVec
icarusutil::SignalShapingICARUSService * fSignalShapingService
double GetASICGain(unsigned int const channel) const
static constexpr Sample_t transform(Sample_t sample)
std::vector< size_t > fTickEndPoints
virtual const icarusutil::FrequencyVec & getConvKernel() const =0
std::vector< float > VectorFloat
Definition: IFakeParticle.h:51
std::vector< size_t > fWireEndPoints
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
const geo::Geometry * fGeometry
const icarus_tool::IResponse & GetResponse(size_t channel) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
int ResponseTOffset(unsigned int const channel) const

Member Data Documentation

float daq::FakeParticle::fCosTheta
private

Definition at line 86 of file FakeParticle_tool.cc.

const detinfo::DetectorProperties* daq::FakeParticle::fDetector
private

Definition at line 96 of file FakeParticle_tool.cc.

FFTPointer daq::FakeParticle::fFFT
private

Definition at line 93 of file FakeParticle_tool.cc.

icarusutil::TimeVec daq::FakeParticle::fFFTTimeVec
private

Definition at line 89 of file FakeParticle_tool.cc.

const geo::Geometry* daq::FakeParticle::fGeometry
private

Definition at line 95 of file FakeParticle_tool.cc.

float daq::FakeParticle::fMMPerTick
private

Definition at line 81 of file FakeParticle_tool.cc.

float daq::FakeParticle::fMMPerWire
private

Definition at line 82 of file FakeParticle_tool.cc.

int daq::FakeParticle::fNumElectronsPerMM
private

Definition at line 77 of file FakeParticle_tool.cc.

size_t daq::FakeParticle::fPlaneToSimulate
private

Definition at line 78 of file FakeParticle_tool.cc.

icarusutil::SignalShapingICARUSService* daq::FakeParticle::fSignalShapingService
private

Definition at line 97 of file FakeParticle_tool.cc.

float daq::FakeParticle::fSinTheta
private

Definition at line 85 of file FakeParticle_tool.cc.

float daq::FakeParticle::fStartAngle
private

Definition at line 76 of file FakeParticle_tool.cc.

size_t daq::FakeParticle::fStartTick
private

Definition at line 75 of file FakeParticle_tool.cc.

float daq::FakeParticle::fTanTheta
private

Definition at line 84 of file FakeParticle_tool.cc.

float daq::FakeParticle::fTanThetaTW
private

Definition at line 83 of file FakeParticle_tool.cc.

std::vector<size_t> daq::FakeParticle::fTickEndPoints
private

Definition at line 87 of file FakeParticle_tool.cc.

std::vector<size_t> daq::FakeParticle::fWireEndPoints
private

Definition at line 74 of file FakeParticle_tool.cc.


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