10 #include "cetlib_except/exception.h" 77 if(!fGetFilterFromHisto)
79 mf::LogInfo(
"SignalShapingServiceDUNE") <<
"Getting Filter from .fcl file";
81 std::vector<double> colFiltParams =
82 pset.
get<std::vector<double> >(
"ColFilterParams");
84 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
85 fColFilterFunc->SetParameter(i, colFiltParams[i]);
90 std::vector<double> indUFiltParams = pset.
get<std::vector<double> >(
"IndUFilterParams");
92 for(
unsigned int i=0; i<indUFiltParams.size(); ++i)
93 fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
96 std::vector<double> indVFiltParams = pset.
get<std::vector<double> >(
"IndVFilterParams");
98 for(
unsigned int i=0; i<indVFiltParams.size(); ++i)
99 fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
106 mf::LogInfo(
"SignalShapingServiceDUNE") <<
" using filter from .root file ";
114 TFile * in=
new TFile(fname.c_str(),
"READ");
115 for(
int i=0;i<fNPlanes;i++){
116 TH1D *
temp=(TH1D *)in->Get(Form(histoname.c_str(),i));
117 fFilterHist[i]=
new TH1D(Form(histoname.c_str(),i),Form(histoname.c_str(),i),temp->GetNbinsX(),0,temp->GetNbinsX());
126 if(fUseFunctionFieldShape)
129 std::vector<double> colFieldParams =
130 pset.
get<std::vector<double> >(
"ColFieldParams");
132 for(
unsigned int i=0; i<colFieldParams.size(); ++i)
133 fColFieldFunc->SetParameter(i, colFieldParams[i]);
138 std::vector<double> indUFieldParams = pset.
get<std::vector<double> >(
"IndUFieldParams");
140 for(
unsigned int i=0; i<indUFieldParams.size(); ++i)
141 fIndUFieldFunc->SetParameter(i, indUFieldParams[i]);
145 std::vector<double> indVFieldParams = pset.
get<std::vector<double> >(
"IndVFieldParams");
147 for(
unsigned int i=0; i<indVFieldParams.size(); ++i)
148 fIndVFieldFunc->SetParameter(i, indVFieldParams[i]);
151 }
else if ( fUseHistogramFieldShape ) {
152 mf::LogInfo(
"SignalShapingServiceDUNE") <<
" using the field response provided from a .root file " ;
161 std::unique_ptr<TFile> fin(
new TFile(fname.c_str(),
"READ"));
166 for (
int i = 0; i < fNPlanes; i++ ) {
167 TString iHistoName = Form(
"%s_%s", histoname.c_str(), iPlane[i].c_str());
168 TH1F *
temp = (TH1F*) fin->Get( iHistoName );
172 fFieldResponseHist[i] =
new TH1F( iHistoName, iHistoName, temp->GetNbinsX(), temp->GetBinLowEdge(1), temp->GetBinLowEdge( temp->GetNbinsX() + 1) );
186 const string myname =
"SignalShapingServiceDUNE::ctor: ";
208 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
214 const string myname =
"SignalShapingServiceDUNE::ElectronicShaping: ";
236 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
248 const string myname =
"SignalShapingServiceDUNE::GetASICGain: ";
264 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
271 const string myname =
"SignalShapingServiceDUNE::GetShapingTime: ";
278 double shaping_time = 0;
288 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
293 const string myname =
"SignalShapingServiceDUNE::GetRawNoise: ";
309 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
314 if (shapingtime == 0.5){
316 }
else if (shapingtime == 1.0){
318 }
else if (shapingtime == 2.0){
326 rawNoise = tempNoise.at(temp);
328 rawNoise *= gain/4.7;
333 const string myname =
"SignalShapingServiceDUNE::GetDeconNoise: ";
349 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
353 if (shapingtime == 0.5){
355 }
else if (shapingtime == 1.0){
357 }
else if (shapingtime == 2.0){
363 double deconNoise = tempNoise.at(temp);
365 deconNoise = deconNoise /4096.*2000./4.7 *6.241*1000/
fDeconNorm;
465 double xyz1[3] = {0.};
466 double xyz2[3] = {0.};
467 double xyzl[3] = {0.};
474 double pitch = xyz2[0] - xyz1[0];
490 int signalSize = fft->
FFTSize();
491 std::vector<double> ramp(signalSize);
496 std::vector<double> bipolar(signalSize);
508 for(
int i = 0; i < signalSize; i++) {
520 for(
int i = 0; i < signalSize; ++i){
545 mf::LogInfo(
"SignalShapingServiceDUNE") <<
" using the old field shape ";
546 double integral = 0.;
547 for(
int i = 1; i < nbinc; ++i){
552 for(
int i = 0; i < nbinc; ++i){
560 for(
int i = 0; i < nbini; ++i){
565 for(
int i = 0; i < nbini; ++i){
582 MF_LOG_DEBUG(
"SignalShapingDUNE") <<
"Setting DUNE electronics response function...";
586 std::vector<double>
time(nticks,0.);
590 double To = shapingtime;
613 4.31054*exp(-2.94809*time[i]/To)*Ao - 2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
614 -2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*cos(2.38722*time[i]/To)*Ao
615 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*Ao
616 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*cos(5.18561*time[i]/To)*Ao
617 +0.762456*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
618 -0.762456*exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
619 +0.762456*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
620 -2.6202*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
621 -0.327684*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
622 +0.327684*exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
623 -0.327684*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
624 +0.464924*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
638 element *= gain / 4.7;
669 for(
int i=0; i<=
n; ++i) {
670 double freq = 500. * i / (ts *
n);
680 for(
int i=0; i<=
n; ++i) {
681 double freq = 500. * i / (ts *
n);
688 for(
int i=0; i<=
n; ++i) {
689 double freq = 500. * i / (ts *
n);
698 for(
int i=0; i<=
n; ++i) {
726 <<
"Invalid operation: cannot rebin to a more finely binned vector!" 730 std::vector<double> SamplingTime( nticks, 0. );
731 for (
int itime = 0; itime < nticks; itime++ ) {
738 for (
int iplane = 0; iplane < 3; iplane++ ) {
739 const std::vector<double>* pResp;
740 if (not elect_only) {
754 std::vector<double> SamplingResp(nticks , 0. );
757 int nticks_input = pResp->size();
758 std::vector<double> InputTime(nticks_input, 0. );
759 for (
int itime = 0; itime < nticks_input; itime++ ) {
768 int SamplingCount = 0;
769 for (
int itime = 0; itime < nticks; itime++ ) {
770 int low = -1, up = -1;
771 for (
int jtime = 0; jtime < nticks_input; jtime++ ) {
772 if ( InputTime[jtime] == SamplingTime[itime] ) {
773 SamplingResp[itime] = (*pResp)[jtime];
778 }
else if ( InputTime[jtime] > SamplingTime[itime] ) {
781 SamplingResp[itime] = (*pResp)[low] + ( SamplingTime[itime] - InputTime[low] ) * ( (*pResp)[up] - (*pResp)[low] ) / ( InputTime[up] - InputTime[low] );
787 SamplingResp[itime] = 0.;
791 SamplingResp.resize( SamplingCount, 0.);
794 if (not elect_only) {
819 unsigned int const channel)
const {
820 const string myname =
"SignalShapingServiceDUNE::FieldResponseTOffset: ";
827 double time_offset = 0;
837 <<
"can't determine view for channel " << channel <<
" with geometry " << geom->
DetectorName() <<
"\n";
852 return Convolute<double>(clockData,
channel,
func);
857 return ConvoluteElectronicResponse<float>(clockData,
channel,
func);
863 return ConvoluteElectronicResponse<double>(clockData,
channel,
func);
869 return Deconvolute<float>(clockData,
channel,
func);
875 return Deconvolute<double>(clockData,
channel,
func);
void set_normflag(bool flag)
const std::vector< double > & Response_save() const
double fColFieldRespAmp
amplitude of response to field
TF1 * fColFilterFunc
Parameterized collection filter function.
~SignalShapingServiceDUNE()
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
std::vector< TComplex > fColFilter
util::SignalShaping fIndUSignalShaping
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
std::vector< TComplex > fIndUFilter
std::vector< TComplex > fIndVFilter
Namespace for general, non-LArSoft-specific utilities.
util::SignalShaping fColElectResponseSignalShaping
double GetShapingTime(Channel channel) const override
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
util::SignalShaping fIndVSignalShaping
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
static constexpr double g
std::vector< double > fShapeTimeConst
time constants for exponential shaping
void ShiftData(std::vector< TComplex > &input, double shift)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void SetFilters(detinfo::DetectorClocksData const &clockData)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< DoubleVec > GetNoiseFactVec() const override
const std::vector< double > & Response() const
std::vector< float > FloatVector
double fCol3DCorrection
correction factor to account for 3D path of
int fNFieldBins
number of bins for field response
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
Planes which measure Z direction.
std::vector< double > fASICGainInMVPerFC
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
double GetDeconNoise(Channel channel) const override
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
std::vector< DoubleVec > fNoiseFactVec
double fIndVFieldRespAmp
amplitude of response to field
constexpr int Ticks() const noexcept
Current clock tick (that is, the number of tick Time() falls in).
art framework interface to geometry description
std::vector< double > fIndUFieldResponse
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
void SetResponseSampling(detinfo::DetectorClocksData const &clockData, bool elect_only=false)
std::vector< double > fElectResponse
void CalculateDeconvKernel() const
void reconfigure(const fhicl::ParameterSet &pset)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
double fInd3DCorrection
correction factor to account for 3D path of
util::SignalShaping fIndUElectResponseSignalShaping
std::vector< double > fCalibResponseTOffset
double fIndUFieldRespAmp
amplitude of response to field
T get(std::string const &key) const
TF1 * fIndUFilterFunc
Parameterized induction filter function.
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
SignalShapingServiceDUNE(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
const util::SignalShaping & ElectronicShaping(unsigned int channel) const
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
static int max(int a, int b)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
const util::SignalShaping & SignalShaping(Channel channel) const override
util::SignalShaping fIndVElectResponseSignalShaping
void ConvoluteElectronicResponse(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
std::vector< double > fIndVFieldResponse
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
#define DEFINE_ART_SERVICE(svc)
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, Channel const channel) const override
void Convolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
Encapsulate the construction of a single detector plane.
std::vector< double > DoubleVector
Contains all timing reference information for the detector.
TF1 * fColFieldFunc
Parameterized collection field shape function.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
bool fInit
Initialization flag.
TH1D * fFilterHist[3]
Histogram used to hold the collection filter, hardcoded for the time being.
std::string find_file(std::string const &filename) const
void SetFieldResponse(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
void SetElectResponse(double shapingtime, double gain)
double GetASICGain(Channel channel) const override
double GetDeconNorm() const override
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
util::SignalShaping fColSignalShaping
double GetRawNoise(Channel channel) const override
void AddFilterFunction(const std::vector< TComplex > &filt)
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
unsigned int GetSignalSize() const override
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
TH1F * fFieldResponseHist[3]
Histogram used to hold the field response, hardcoded for the time being.
std::vector< double > fColFieldResponse