10 #include "cetlib_except/exception.h" 75 if(!fGetFilterFromHisto)
77 mf::LogInfo(
"SignalShapingServiceDUNE34kt") <<
"Getting Filter from .fcl file";
79 std::vector<double> colFiltParams =
80 pset.
get<std::vector<double> >(
"ColFilterParams");
82 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
83 fColFilterFunc->SetParameter(i, colFiltParams[i]);
88 std::vector<double> indUFiltParams = pset.
get<std::vector<double> >(
"IndUFilterParams");
90 for(
unsigned int i=0; i<indUFiltParams.size(); ++i)
91 fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
94 std::vector<double> indVFiltParams = pset.
get<std::vector<double> >(
"IndVFilterParams");
96 for(
unsigned int i=0; i<indVFiltParams.size(); ++i)
97 fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
103 mf::LogInfo(
"SignalShapingServiceDUNE34kt") <<
" using filter from .root file ";
111 TFile * in=
new TFile(fname.c_str(),
"READ");
112 for(
int i=0;i<fNPlanes;i++){
113 TH1D *
temp=(TH1D *)in->Get(Form(histoname.c_str(),i));
114 fFilterHist[i]=
new TH1D(Form(histoname.c_str(),i),Form(histoname.c_str(),i),temp->GetNbinsX(),0,temp->GetNbinsX());
123 if(fUseFunctionFieldShape)
126 std::vector<double> colFieldParams =
127 pset.
get<std::vector<double> >(
"ColFieldParams");
129 for(
unsigned int i=0; i<colFieldParams.size(); ++i)
130 fColFieldFunc->SetParameter(i, colFieldParams[i]);
135 std::vector<double> indUFieldParams = pset.
get<std::vector<double> >(
"IndUFieldParams");
137 for(
unsigned int i=0; i<indUFieldParams.size(); ++i)
138 fIndUFieldFunc->SetParameter(i, indUFieldParams[i]);
142 std::vector<double> indVFieldParams = pset.
get<std::vector<double> >(
"IndVFieldParams");
144 for(
unsigned int i=0; i<indVFieldParams.size(); ++i)
145 fIndVFieldFunc->SetParameter(i, indVFieldParams[i]);
148 }
else if ( fUseHistogramFieldShape ) {
149 mf::LogInfo(
"SignalShapingServiceDUNE35t") <<
" using the field response provided from a .root file " ;
158 std::unique_ptr<TFile> fin(
new TFile(fname.c_str(),
"READ"));
163 for (
int i = 0; i < fNPlanes; i++ ) {
164 TString iHistoName = Form(
"%s_%s", histoname.c_str(), iPlane[i].c_str());
165 TH1F *
temp = (TH1F*) fin->Get( iHistoName );
169 fFieldResponseHist[i] =
new TH1F( iHistoName, iHistoName, temp->GetNbinsX(), temp->GetBinLowEdge(1), temp->GetBinLowEdge( temp->GetNbinsX() + 1) );
203 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 226 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 241 double shaping_time = 0;
250 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 271 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 277 if (shapingtime == 0.5){
279 }
else if (shapingtime == 1.0){
281 }
else if (shapingtime == 2.0){
289 rawNoise = tempNoise.at(temp);
291 rawNoise *= gain/4.7;
311 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" 316 if (shapingtime == 0.5){
318 }
else if (shapingtime == 1.0){
320 }
else if (shapingtime == 2.0){
326 double deconNoise = tempNoise.at(temp);
328 deconNoise = deconNoise /4096.*2000./4.7 *6.241*1000/
fDeconNorm;
410 double xyz1[3] = {0.};
411 double xyz2[3] = {0.};
412 double xyzl[3] = {0.};
419 double pitch = xyz2[0] - xyz1[0];
435 int signalSize = fft->
FFTSize();
436 std::vector<double> ramp(signalSize);
441 std::vector<double> bipolar(signalSize);
454 for(
int i = 0; i < signalSize; i++) {
466 for(
int i = 0; i < signalSize; ++i){
491 mf::LogInfo(
"SignalShapingServiceDUNE34kt") <<
" using the old field shape ";
492 double integral = 0.;
493 for(
int i = 1; i < nbinc; ++i){
498 for(
int i = 0; i < nbinc; ++i){
505 for(
int i = 0; i < nbini; ++i){
510 for(
int i = 0; i < nbini; ++i){
529 MF_LOG_DEBUG(
"SignalShapingDUNE34kt") <<
"Setting DUNE34kt electronics response function...";
533 std::vector<double>
time(nticks,0.);
537 double To = shapingtime;
560 4.31054*exp(-2.94809*time[i]/To)*Ao - 2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
561 -2.6202*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*cos(2.38722*time[i]/To)*Ao
562 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*Ao
563 +0.464924*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*cos(5.18561*time[i]/To)*Ao
564 +0.762456*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
565 -0.762456*exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
566 +0.762456*exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
567 -2.6202*exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
568 -0.327684*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
569 +0.327684*exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
570 -0.327684*exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
571 +0.464924*exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
585 element *= gain / 4.7;
614 for(
int i=0; i<=
n; ++i) {
615 double freq = 500. * i / (ts *
n);
626 for(
int i=0; i<=
n; ++i) {
627 double freq = 500. * i / (ts *
n);
634 for(
int i=0; i<=
n; ++i) {
635 double freq = 500. * i / (ts *
n);
644 for(
int i=0; i<=
n; ++i) {
673 <<
"Invalid operation: cannot rebin to a more finely binned vector!" 677 std::vector<double> SamplingTime( nticks, 0. );
678 for (
int itime = 0; itime < nticks; itime++ ) {
685 for (
int iplane = 0; iplane < 2; iplane++ ) {
686 const std::vector<double>* pResp;
693 std::vector<double> SamplingResp(nticks , 0. );
696 int nticks_input = pResp->size();
697 std::vector<double> InputTime(nticks_input, 0. );
698 for (
int itime = 0; itime < nticks_input; itime++ ) {
707 int SamplingCount = 0;
708 for (
int itime = 0; itime < nticks; itime++ ) {
709 int low = -1, up = -1;
710 for (
int jtime = 0; jtime < nticks_input; jtime++ ) {
711 if ( InputTime[jtime] == SamplingTime[itime] ) {
712 SamplingResp[itime] = (*pResp)[jtime];
717 }
else if ( InputTime[jtime] > SamplingTime[itime] ) {
720 SamplingResp[itime] = (*pResp)[low] + ( SamplingTime[itime] - InputTime[low] ) * ( (*pResp)[up] - (*pResp)[low] ) / ( InputTime[up] - InputTime[low] );
726 SamplingResp[itime] = 0.;
730 SamplingResp.resize( SamplingCount, 0.);
751 unsigned int const channel)
const 759 double time_offset = 0;
768 throw cet::exception(
"SignalShapingServiceDUNE35t")<<
"can't determine" void set_normflag(bool flag)
const std::vector< double > & Response_save() const
double fIndVFieldRespAmp
amplitude of response to field
TF1 * fIndUFilterFunc
Parameterized induction filter function.
std::vector< TComplex > fIndVFilter
std::vector< double > fShapeTimeConst
time constants for exponential shaping
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
const util::SignalShaping & SignalShaping(unsigned int channel) const
Namespace for general, non-LArSoft-specific utilities.
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
static constexpr double g
double GetShapingTime(unsigned int const channel) const
void SetResponseSampling(detinfo::DetectorClocksData const &clockData)
bool fInit
Initialization flag.
void ShiftData(std::vector< TComplex > &input, double shift)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
util::SignalShaping fColSignalShaping
~SignalShapingServiceDUNE34kt()
std::vector< TComplex > fColFilter
util::SignalShaping fIndVSignalShaping
void AddResponseFunction(const std::vector< double > &resp, bool ResetResponse=false)
Planes which measure Z direction.
void SetFieldResponse(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
std::vector< double > fIndUFieldResponse
std::vector< double > fCalibResponseTOffset
double GetASICGain(unsigned int const channel) const
constexpr int Ticks() const noexcept
Current clock tick (that is, the number of tick Time() falls in).
art framework interface to geometry description
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
TF1 * fColFilterFunc
Parameterized collection filter function.
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
TF1 * fColFieldFunc
Parameterized collection field shape function.
double fColFieldRespAmp
amplitude of response to field
void CalculateDeconvKernel() const
double GetRawNoise(unsigned int const channel) const
std::vector< DoubleVec > fNoiseFactVec
void SetFilters(detinfo::DetectorClocksData const &clockData)
std::vector< double > fElectResponse
T get(std::string const &key) const
TH1D * fFilterHist[3]
Histogram used to hold the collection filter, hardcoded for the time being.
SignalShapingServiceDUNE34kt(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
static int max(int a, int b)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
void reconfigure(const fhicl::ParameterSet &pset)
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
double fIndUFieldRespAmp
amplitude of response to field
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, unsigned int const channel) const
std::vector< double > fIndVFieldResponse
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< double > fASICGainInMVPerFC
#define DEFINE_ART_SERVICE(svc)
Encapsulate the construction of a single detector plane.
Contains all timing reference information for the detector.
int fNFieldBins
number of bins for field response
std::string find_file(std::string const &filename) const
util::SignalShaping fIndUSignalShaping
TH1F * fFieldResponseHist[3]
Histogram used to hold the field response, hardcoded for the time being.
void SetElectResponse(double shapingtime, double gain)
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
double GetDeconNoise(unsigned int const channel) const
void AddFilterFunction(const std::vector< TComplex > &filt)
std::vector< double > fColFieldResponse
std::vector< TComplex > fIndUFilter
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.