10 #include "cetlib_except/exception.h" 26 mf::LogInfo(
"SignalShapingServiceDUNE10kt") <<
"Deprecated: Consider using SignalShapingServiceDUNE";
77 if(!fGetFilterFromHisto)
79 mf::LogInfo(
"SignalShapingServiceDUNE10kt") <<
"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(
"SignalShapingServiceDUNE10kt") <<
" 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(
"SignalShapingServiceDUNE35t") <<
" 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) );
206 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 229 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 244 double shaping_time = 0;
253 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 274 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 280 if (shapingtime == 0.5){
282 }
else if (shapingtime == 1.0){
284 }
else if (shapingtime == 2.0){
292 rawNoise = tempNoise.at(temp);
294 rawNoise *= gain/4.7;
314 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 319 if (shapingtime == 0.5){
321 }
else if (shapingtime == 1.0){
323 }
else if (shapingtime == 2.0){
329 double deconNoise = tempNoise.at(temp);
331 deconNoise = deconNoise /4096.*2000./4.7 *6.241*1000/
fDeconNorm;
416 double xyz1[3] = {0.};
417 double xyz2[3] = {0.};
418 double xyzl[3] = {0.};
425 double pitch = xyz2[0] - xyz1[0];
441 int signalSize = fft->
FFTSize();
442 std::vector<double> ramp(signalSize);
447 std::vector<double> bipolar(signalSize);
459 for(
int i = 0; i < signalSize; i++) {
471 for(
int i = 0; i < signalSize; ++i){
496 mf::LogInfo(
"SignalShapingServiceDUNE10kt") <<
" using the old field shape ";
497 double integral = 0.;
498 for(
int i = 1; i < nbinc; ++i){
503 for(
int i = 0; i < nbinc; ++i){
511 for(
int i = 0; i < nbini; ++i){
516 for(
int i = 0; i < nbini; ++i){
533 MF_LOG_DEBUG(
"SignalShapingDUNE10kt") <<
"Setting DUNE10kt electronics response function...";
537 std::vector<double>
time(nticks,0.);
541 double To = shapingtime;
564 4.31054*exp(-2.94809*time[i]/To)*Ao - 2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
565 -2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*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)*cos(5.18561*time[i]/To)*Ao
568 +0.762456*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
569 -0.762456*exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
570 +0.762456*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
571 -2.6202*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
572 -0.327684*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
573 +0.327684*exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
574 -0.327684*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
575 +0.464924*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
589 element *= gain / 4.7;
620 for(
int i=0; i<=
n; ++i) {
621 double freq = 500. * i / (ts *
n);
631 for(
int i=0; i<=
n; ++i) {
632 double freq = 500. * i / (ts *
n);
639 for(
int i=0; i<=
n; ++i) {
640 double freq = 500. * i / (ts *
n);
649 for(
int i=0; i<=
n; ++i) {
677 <<
"Invalid operation: cannot rebin to a more finely binned vector!" 681 std::vector<double> SamplingTime( nticks, 0. );
682 for (
int itime = 0; itime < nticks; itime++ ) {
689 for (
int iplane = 0; iplane < 3; iplane++ ) {
690 const std::vector<double>* pResp;
697 std::vector<double> SamplingResp(nticks , 0. );
700 int nticks_input = pResp->size();
701 std::vector<double> InputTime(nticks_input, 0. );
702 for (
int itime = 0; itime < nticks_input; itime++ ) {
711 int SamplingCount = 0;
712 for (
int itime = 0; itime < nticks; itime++ ) {
713 int low = -1, up = -1;
714 for (
int jtime = 0; jtime < nticks_input; jtime++ ) {
715 if ( InputTime[jtime] == SamplingTime[itime] ) {
716 SamplingResp[itime] = (*pResp)[jtime];
721 }
else if ( InputTime[jtime] > SamplingTime[itime] ) {
724 SamplingResp[itime] = (*pResp)[low] + ( SamplingTime[itime] - InputTime[low] ) * ( (*pResp)[up] - (*pResp)[low] ) / ( InputTime[up] - InputTime[low] );
730 SamplingResp[itime] = 0.;
734 SamplingResp.resize( SamplingCount, 0.);
755 unsigned int const channel)
const 763 double time_offset = 0;
772 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" void set_normflag(bool flag)
const std::vector< double > & Response_save() const
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
Namespace for general, non-LArSoft-specific utilities.
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
std::vector< double > fCalibResponseTOffset
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
TF1 * fIndUFilterFunc
Parameterized induction filter function.
void SetFilters(detinfo::DetectorClocksData const &clockData)
static constexpr double g
void ShiftData(std::vector< TComplex > &input, double shift)
void SetElectResponse(double shapingtime, double gain)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double GetShapingTime(unsigned int const channel) const
std::vector< double > fColFieldResponse
double GetASICGain(unsigned int const channel) const
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
util::SignalShaping fIndVSignalShaping
Planes which measure Z direction.
SignalShapingServiceDUNE10kt(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
std::vector< double > fIndUFieldResponse
std::vector< double > fShapeTimeConst
time constants for exponential shaping
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, unsigned int const channel) const
double fIndVFieldRespAmp
amplitude of response to field
constexpr int Ticks() const noexcept
Current clock tick (that is, the number of tick Time() falls in).
std::vector< DoubleVec > fNoiseFactVec
art framework interface to geometry description
double fIndUFieldRespAmp
amplitude of response to field
bool fInit
Initialization flag.
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
void CalculateDeconvKernel() const
TF1 * fIndVFilterFunc
Parameterized induction filter function.
void reconfigure(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
TH1D * fFilterHist[3]
Histogram used to hold the collection filter, hardcoded for the time being.
std::vector< TComplex > fIndUFilter
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
std::vector< double > fIndVFieldResponse
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
static int max(int a, int b)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void SetFieldResponse(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
util::SignalShaping fColSignalShaping
TF1 * fColFilterFunc
Parameterized collection filter function.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
TH1F * fFieldResponseHist[3]
Histogram used to hold the field response, hardcoded for the time being.
#define DEFINE_ART_SERVICE(svc)
const util::SignalShaping & SignalShaping(unsigned int channel) const
Encapsulate the construction of a single detector plane.
Contains all timing reference information for the detector.
double GetDeconNoise(unsigned int const channel) const
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
double fColFieldRespAmp
amplitude of response to field
std::vector< double > fElectResponse
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
std::string find_file(std::string const &filename) const
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
~SignalShapingServiceDUNE10kt()
void SetResponseSampling(detinfo::DetectorClocksData const &clockData)
double GetRawNoise(unsigned int const channel) const
util::SignalShaping fIndUSignalShaping
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
std::vector< double > fASICGainInMVPerFC
LArSoft geometry interface.
int fNFieldBins
number of bins for field response
TF1 * fColFieldFunc
Parameterized collection field shape function.
void AddFilterFunction(const std::vector< TComplex > &filt)
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
std::vector< TComplex > fIndVFilter
cet::coded_exception< error, detail::translate > exception
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
std::vector< TComplex > fColFilter