11 #include "cetlib_except/exception.h" 57 std::vector<double>
params = pset.
get<std::vector<double>>(
"ShapeFuncParams");
58 for(
unsigned i=0;i<params.size();++i ){
60 fColShapeFunc->SetParameter(i, params[i]);
68 std::vector<double> params1 = params;
69 if( pset.
has_key(
"ShapeFunc1m" ) )
72 params1 = pset.
get<std::vector<double>>(
"ShapeFuncParams1m");
75 for(
unsigned i=0;i<params1.size();++i ){
77 fColShapeFunc1m->SetParameter(i, params1[i]);
81 mf::LogInfo(
"SignalShapingServiceDUNEDPhase") <<
" Area normalization : "<<
fAreaNorm <<
" ADC x us\n" 82 <<
" Shape function : "<<fShapeFunc <<
"\n" 83 <<
" Decon normalization : "<<fDeconNorm <<
"\n" 84 <<
" Response sampling period : "<< fRespSamplingPeriod<<
" us \n" 85 <<
" Noise : "<<fAmpENC<<
" electrons\n" 89 mf::LogInfo(
"SignalShapingServiceDUNEDPhase") <<
" Parameters for 1m view :\n" 90 <<
" Area normalization : "<<
fAreaNorm1m <<
" ADC x us\n" 96 mf::LogInfo(
"SignalShapingServiceDUNE") <<
"Getting Field response from .fcl file";
99 std::vector<double> colFieldParams =
100 pset.
get<std::vector<double> >(
"ColFieldFunctionParams");
101 fColFieldFunc =
new TF1(
"colFieldFunction", colField.c_str());
102 for(
unsigned int i=0; i<colFieldParams.size(); ++i)
103 fColFieldFunc->SetParameter(i, colFieldParams[i]);
105 mf::LogInfo(
"SignalShapingServiceDUNE") <<
"Getting Filter from .fcl file";
107 std::vector<double> colFiltParams =
108 pset.
get<std::vector<double> >(
"ColFilterParams");
110 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
111 fColFilterFunc->SetParameter(i, colFiltParams[i]);
128 auto const* geom = lar::providerFrom<geo::Geometry>();
129 std::vector<geo::WireID> Wires = geom->ChannelToWire(channel);
131 double wirestartpoint[3];
132 double wireendpoint[3];
133 geom->WireEndPoints(Wires[0],wirestartpoint,wireendpoint);
134 double wirelength = sqrt(
pow(wirestartpoint[0]-wireendpoint[0],2) +
pow(wirestartpoint[1]-wireendpoint[1],2) +
pow(wirestartpoint[2]-wireendpoint[2],2));
136 if((
int)wirelength == 300)
138 else if((
int)wirelength == 100)
142 <<
"unexpected signal type " << geom->SignalType(channel)
143 <<
" for channel #" << channel <<
"\n";
189 std::vector<double> fresp;
215 std::vector<geo::WireID> Wires = geom->
ChannelToWire(channel);
216 double wirestartpoint[3];
217 double wireendpoint[3];
219 double wirelength = sqrt(
pow(wirestartpoint[0]-wireendpoint[0],2) +
pow(wirestartpoint[1]-wireendpoint[1],2) +
pow(wirestartpoint[2]-wireendpoint[2],2));
221 if((
int)wirelength == 300)
223 else if((
int)wirelength == 100)
226 throw cet::exception(
"SignalShapingServiceDUNEDPhase")<<
"can't determine" 240 std::vector<geo::WireID> Wires = geom->
ChannelToWire(channel);
241 double wirestartpoint[3];
242 double wireendpoint[3];
244 double wirelength = sqrt(
pow(wirestartpoint[0]-wireendpoint[0],2) +
pow(wirestartpoint[1]-wireendpoint[1],2) +
pow(wirestartpoint[2]-wireendpoint[2],2));
246 if((
int)wirelength == 300)
248 else if((
int)wirelength == 100)
251 throw cet::exception(
"SignalShapingServiceDUNEDPhase")<<
"can't determine" 287 MF_LOG_DEBUG(
"SignalShapingDUNEDPhase") <<
"Setting DUNEDPhase field response function...";
290 std::vector<double>
time(nticks,0.);
291 fresp.resize(nticks, 0.);
294 for(
size_t i = 0; i < fresp.size(); ++i)
303 for(
size_t i = 0; i < fresp.size(); ++i)
317 MF_LOG_DEBUG(
"SignalShapingDUNEDPhase") <<
"Setting DUNEDPhase electronics response function...";
320 std::vector<double> resp(nticks, 0.);
326 for(
auto i=0;i<nticks; ++i )
329 double v = fshape->Eval( t );
330 if( t == 0 || v != v || v < 0 ) v = 0;
332 if( v > max ) max = v;
338 double norm = areanorm / (sum * dt);
341 for(
auto& element : resp)
343 element *= norm * 1.60217657e-4;
346 MF_LOG_DEBUG(
"SignalShapingDUNEDPhase") <<
"Area norm "<<areanorm<<
" -> norm "<<norm <<
"\n" 347 <<
"Pulse height "<<pheight;
372 <<
"Invalid operation: cannot rebin to a more finely binned vector!" 385 int nticks_input = pResp->size();
388 std::vector<double> InputTime(nticks_input, 0. );
389 std::vector<double> InputResp(nticks_input, 0. );
390 for (
int itime = 0; itime < nticks_input; itime++ )
392 InputResp[itime] = (*pResp)[itime];
397 TSpline3 ispl(
"ispl", &InputTime[0], &InputResp[0], nticks_input);
405 std::vector<double> SamplingResp( nticks , 0. );
407 double maxtime = InputTime.back();
409 for (
int itime = 0; itime < nticks; itime++ )
411 double t = itime * dt;
413 if(t > maxtime)
break;
414 SamplingResp[itime] = ispl.Eval(t);
431 int nhalf = nsize / 2;
438 double df = 1.0/(ts*1.0E-3 * nsize);
440 for(
int i=0; i<=nhalf; ++i)
443 double freq = i * df;
487 return std::vector<DoubleVec>();
494 unsigned int const channel)
const {
bool fInit
Initialization flag.
void set_normflag(bool flag)
const std::vector< double > & Response_save() const
Namespace for general, non-LArSoft-specific utilities.
double GetDeconNorm() const override
double fADCpermV
Digitizer scale.
void SetFilters(detinfo::DetectorClocksData const &clockData)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const std::vector< double > & Response() const
std::vector< float > FloatVector
util::SignalShaping fColSignalShaping1m
double fAmpENC
noise in num of electrons used where???
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
double GetASICGain(Channel channel) const override
double fAmpENCADC
noise rescaled to ADC
TF1 * fColFilterFunc
for 3x1x1 1m strips
double fRespSamplingPeriod
Sampling period for response in ns.
double GetAreaNorm(unsigned int const channel) const
double GetDeconNoise(Channel channel) const override
void SetResponseSampling(detinfo::DetectorClocksData const &clockData, util::SignalShaping &sig)
art framework interface to geometry description
double fPulseHeight1m
pulse amtplitide in mV per fC
util::SignalShaping fColSignalShaping
void CalculateDeconvKernel() const
bool fAddFieldFunction
Enable the filed function.
T get(std::string const &key) const
double GetShapingTime(Channel channel) const override
double fAreaNorm
in units (ADC x us) / fC
std::vector< DoubleVec > GetNoiseFactVec() const override
void Convolute(unsigned int channel, std::vector< T > &func) const
const util::SignalShaping & SignalShaping(unsigned int channel) const override
void reconfigure(const fhicl::ParameterSet &pset)
double fPulseHeight
pulse height in mV per fC
bool has_key(std::string const &key) const
static int max(int a, int b)
Service to provide DUNE dual-phase signal shaping for simulation (convolution) and reconstruction (de...
auto norm(Vector const &v)
Return norm of the specified vector.
TF1 * fColFieldFunc
Parameterized collection field function.
double GetRawNoise(Channel channel) const override
unsigned int GetSignalSize() const override
#define DEFINE_ART_SERVICE(svc)
double FieldResponse(double tval_us)
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, unsigned int const channel) const override
Encapsulate the construction of a single detector plane.
std::vector< double > DoubleVector
Contains all timing reference information for the detector.
void SetFieldResponse(std::vector< double > &fresp)
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
double SetElectResponse(const TF1 *fshape, util::SignalShaping &sig, double areanorm)
double fColFieldRespAmp
amplitude of response to field
std::vector< TComplex > fColFilter
SignalShapingServiceDUNEDPhase(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
double fAreaNorm1m
in units (ADC x us) / fC for 1m strips
void AddFilterFunction(const std::vector< TComplex > &filt)
~SignalShapingServiceDUNEDPhase()
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
void Deconvolute(unsigned int channel, std::vector< T > &func) const