10 #include "cetlib_except/exception.h" 27 mf::LogInfo(
"SignalShapingServiceDUNE10kt") <<
"Deprecated: Consider using SignalShapingServiceDUNE";
80 if(!fGetFilterFromHisto)
82 mf::LogInfo(
"SignalShapingServiceDUNE35t") <<
"Getting Filter from .fcl file" ;
84 std::vector<double> colFiltParams =
85 pset.
get<std::vector<double> >(
"ColFilterParams");
87 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
88 fColFilterFunc->SetParameter(i, colFiltParams[i]);
93 std::vector<double> indUFiltParams = pset.
get<std::vector<double> >(
"IndUFilterParams");
95 for(
unsigned int i=0; i<indUFiltParams.size(); ++i)
96 fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
99 std::vector<double> indVFiltParams = pset.
get<std::vector<double> >(
"IndVFilterParams");
101 for(
unsigned int i=0; i<indVFiltParams.size(); ++i)
102 fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
108 mf::LogInfo(
"SignalShapingServiceDUNE35t") <<
" using filter from .root file " ;
116 TFile * in=
new TFile(fname.c_str(),
"READ");
117 for(
int i=0;i<fNPlanes;i++){
118 TH1D *
temp=(TH1D *)in->Get(Form(histoname.c_str(),i));
119 fFilterHist[i]=
new TH1D(Form(histoname.c_str(),i),Form(histoname.c_str(),i),temp->GetNbinsX(),0,temp->GetNbinsX());
128 if(fUseFunctionFieldShape)
131 std::vector<double> colFieldParams =
132 pset.
get<std::vector<double> >(
"ColFieldParams");
134 for(
unsigned int i=0; i<colFieldParams.size(); ++i)
135 fColFieldFunc->SetParameter(i, colFieldParams[i]);
140 std::vector<double> indUFieldParams = pset.
get<std::vector<double> >(
"IndUFieldParams");
142 for(
unsigned int i=0; i<indUFieldParams.size(); ++i)
143 fIndUFieldFunc->SetParameter(i, indUFieldParams[i]);
147 std::vector<double> indVFieldParams = pset.
get<std::vector<double> >(
"IndVFieldParams");
149 for(
unsigned int i=0; i<indVFieldParams.size(); ++i)
150 fIndVFieldFunc->SetParameter(i, indVFieldParams[i]);
153 }
else if ( fUseHistogramFieldShape ) {
154 mf::LogInfo(
"SignalShapingServiceDUNE35t") <<
" using the field response provided from a .root file " ;
163 std::unique_ptr<TFile> fin(
new TFile(fname.c_str(),
"READ"));
168 for (
int i = 0; i < fNPlanes; i++ ) {
169 TString iHistoName = Form(
"%s_%s", histoname.c_str(), iPlane[i].c_str());
170 TH1F *
temp = (TH1F*) fin->Get( iHistoName );
174 fFieldResponseHist[i] =
new TH1F( iHistoName, iHistoName, temp->GetNbinsX(), temp->GetBinLowEdge(1), temp->GetBinLowEdge( temp->GetNbinsX() + 1) );
208 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 232 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 247 double shaping_time = 0;
256 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 277 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 283 if (shapingtime == 0.5){
285 }
else if (shapingtime == 1.0){
287 }
else if (shapingtime == 2.0){
295 rawNoise = tempNoise.at(temp);
297 rawNoise *= gain/4.7;
317 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 322 if (shapingtime == 0.5){
324 }
else if (shapingtime == 1.0){
326 }
else if (shapingtime == 2.0){
332 double deconNoise = tempNoise.at(temp);
334 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){
497 mf::LogInfo(
"SignalShapingServiceDUNE35t") <<
" using the old field shape " ;
498 double integral = 0.;
499 for(
int i = 1; i < nbinc; ++i){
504 for(
int i = 0; i < nbinc; ++i){
511 for(
int i = 0; i < nbini; ++i){
516 for(
int i = 0; i < nbini; ++i){
535 MF_LOG_DEBUG(
"SignalShapingDUNE35t") <<
"Setting DUNE35t electronics response function...";
539 std::vector<double>
time(nticks,0.);
543 double To = shapingtime;
566 4.31054*exp(-2.94809*time[i]/To)*Ao - 2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
567 -2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*cos(2.38722*time[i]/To)*Ao
568 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*Ao
569 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*cos(5.18561*time[i]/To)*Ao
570 +0.762456*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
571 -0.762456*exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
572 +0.762456*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
573 -2.6202*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
574 -0.327684*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
575 +0.327684*exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
576 -0.327684*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
577 +0.464924*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
591 element *= gain / 4.7;
620 for(
int i=0; i<=
n; ++i) {
621 double freq = 500. * i / (ts *
n);
632 for(
int i=0; i<=
n; ++i) {
633 double freq = 500. * i / (ts *
n);
640 for(
int i=0; i<=
n; ++i) {
641 double freq = 500. * i / (ts *
n);
650 for(
int i=0; i<=
n; ++i) {
679 <<
"Invalid operation: cannot rebin to a more finely binned vector!" 683 std::vector<double> SamplingTime( nticks, 0. );
684 for (
int itime = 0; itime < nticks; itime++ ) {
691 for (
int iplane = 0; iplane < 3; iplane++ ) {
692 const std::vector<double>* pResp;
699 std::vector<double> SamplingResp(nticks , 0. );
702 int nticks_input = pResp->size();
703 std::vector<double> InputTime(nticks_input, 0. );
704 for (
int itime = 0; itime < nticks_input; itime++ ) {
713 int SamplingCount = 0;
714 for (
int itime = 0; itime < nticks; itime++ ) {
715 int low = -1, up = -1;
716 for (
int jtime = 0; jtime < nticks_input; jtime++ ) {
717 if ( InputTime[jtime] == SamplingTime[itime] ) {
718 SamplingResp[itime] = (*pResp)[jtime];
723 }
else if ( InputTime[jtime] > SamplingTime[itime] ) {
726 SamplingResp[itime] = (*pResp)[low] + ( SamplingTime[itime] - InputTime[low] ) * ( (*pResp)[up] - (*pResp)[low] ) / ( InputTime[up] - InputTime[low] );
732 SamplingResp[itime] = 0.;
736 SamplingResp.resize( SamplingCount, 0.);
749 std::ofstream
outfile(
"resutest.txt");
750 for (
size_t i = 0; i<SamplingResp.size(); ++i){
751 outfile<<i<<
" "<<SamplingResp[i]<<
std::endl;
756 std::ofstream
outfile(
"resvtest.txt");
757 for (
size_t i = 0; i<SamplingResp.size(); ++i){
758 outfile<<i<<
" "<<SamplingResp[i]<<
std::endl;
763 std::ofstream
outfile(
"resztest.txt");
764 for (
size_t i = 0; i<SamplingResp.size(); ++i){
765 outfile<<i<<
" "<<SamplingResp[i]<<
std::endl;
779 unsigned int const channel)
const 787 double time_offset = 0;
796 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" TF1 * fIndUFilterFunc
Parameterized induction filter function.
void set_normflag(bool flag)
const std::vector< double > & Response_save() const
std::vector< double > fCalibResponseTOffset
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, unsigned int const channel) const
Namespace for general, non-LArSoft-specific utilities.
TF1 * fColFieldFunc
Parameterized collection field shape function.
double GetShapingTime(unsigned int const channel) const
void SetFieldResponse(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
void reconfigure(const fhicl::ParameterSet &pset)
std::vector< double > fShapeTimeConst
time constants for exponential shaping
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
static constexpr double g
void ShiftData(std::vector< TComplex > &input, double shift)
std::vector< double > fIndUFieldResponse
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
TH1F * fFieldResponseHist[3]
Histogram used to hold the field response, hardcoded for the time being.
void SetElectResponse(double shapingtime, double gain)
TF1 * fColFilterFunc
Parameterized collection filter function.
double GetRawNoise(unsigned int const channel) const
void SetFilters(detinfo::DetectorClocksData const &clockData)
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
Planes which measure Z direction.
bool fDebugFieldShape
Save field response shape to a text file.
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
double fColFieldRespAmp
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
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
util::SignalShaping fColSignalShaping
void CalculateDeconvKernel() const
std::vector< TComplex > fColFilter
std::vector< double > fColFieldResponse
T get(std::string const &key) const
std::vector< DoubleVec > fNoiseFactVec
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
double fIndVFieldRespAmp
amplitude of response to field
bool fInit
Initialization flag.
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
double GetASICGain(unsigned int const channel) const
double GetDeconNoise(unsigned int const channel) const
void SetResponseSampling(detinfo::DetectorClocksData const &clockData)
std::vector< double > fASICGainInMVPerFC
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
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.
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
const util::SignalShaping & SignalShaping(unsigned int channel) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
#define DEFINE_ART_SERVICE(svc)
TF1 * fIndVFilterFunc
Parameterized induction filter function.
Encapsulate the construction of a single detector plane.
Contains all timing reference information for the detector.
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
std::string find_file(std::string const &filename) const
std::vector< double > fIndVFieldResponse
std::vector< TComplex > fIndVFilter
std::vector< double > fElectResponse
~SignalShapingServiceDUNE35t()
double fIndUFieldRespAmp
amplitude of response to field
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
LArSoft geometry interface.
SignalShapingServiceDUNE35t(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
void AddFilterFunction(const std::vector< TComplex > &filt)
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
cet::coded_exception< error, detail::translate > exception
int fNFieldBins
number of bins for field response
util::SignalShaping fIndVSignalShaping
util::SignalShaping fIndUSignalShaping
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
std::vector< TComplex > fIndUFilter
TH1D * fFilterHist[3]
Histogram used to hold the collection filter, hardcoded for the time being.