7 #include "art/Framework/Services/Registry/ServiceHandle.h"
8 #include "art/Framework/Services/Registry/ServiceDefinitionMacros.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
10 #include "cetlib_except/exception.h"
22 art::ActivityRegistry& )
45 fColSignalShaping.Reset();
46 fIndUSignalShaping.Reset();
47 fIndVSignalShaping.Reset();
51 fDeconNorm = pset.get<
double>(
"DeconNorm");
52 fADCPerPCAtLowestASICGain = pset.get<
double>(
"ADCPerPCAtLowestASICGain");
53 fASICGainInMVPerFC = pset.get<std::vector<double> >(
"ASICGainInMVPerFC");
55 fNFieldBins = pset.get<
int>(
"FieldBins");
56 fCol3DCorrection = pset.get<
double>(
"Col3DCorrection");
57 fInd3DCorrection = pset.get<
double>(
"Ind3DCorrection");
58 fColFieldRespAmp = pset.get<
double>(
"ColFieldRespAmp");
59 fIndUFieldRespAmp = pset.get<
double>(
"IndUFieldRespAmp");
60 fIndVFieldRespAmp = pset.get<
double>(
"IndVFieldRespAmp");
61 fShapeTimeConst = pset.get<std::vector<double> >(
"ShapeTimeConst");
62 fNoiseFactVec = pset.get<std::vector<DoubleVec> >(
"NoiseFactVec");
64 fInputFieldRespSamplingPeriod = pset.get<
double>(
"InputFieldRespSamplingPeriod");
65 fFieldResponseTOffset = pset.get<std::vector<double> >(
"FieldResponseTOffset");
67 fUseFunctionFieldShape= pset.get<
bool>(
"UseFunctionFieldShape");
68 fUseSimpleFieldShape = pset.get<
bool>(
"UseSimpleFieldShape");
69 fUseHistogramFieldShape = pset.get<
bool>(
"UseHistogramFieldShape");
71 if(fUseSimpleFieldShape) {
74 fGetFilterFromHisto= pset.get<
bool>(
"GetFilterFromHisto");
77 if(!fGetFilterFromHisto) {
79 mf::LogInfo(
"SignalShapingServiceSBND") <<
"Getting Filter from .fcl file" ;
80 std::string colFilt = pset.get<std::string>(
"ColFilter");
81 std::vector<double> colFiltParams = pset.get<std::vector<double> >(
"ColFilterParams");
82 fColFilterFunc =
new TF1(
"colFilter", colFilt.c_str());
83 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
84 fColFilterFunc->SetParameter(i, colFiltParams[i]);
88 std::string indUFilt = pset.get<std::string>(
"IndUFilter");
89 std::vector<double> indUFiltParams = pset.get<std::vector<double> >(
"IndUFilterParams");
90 fIndUFilterFunc =
new TF1(
"indUFilter", indUFilt.c_str());
91 for(
unsigned int i=0; i<indUFiltParams.size(); ++i)
92 fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
94 std::string indVFilt = pset.get<std::string>(
"IndVFilter");
95 std::vector<double> indVFiltParams = pset.get<std::vector<double> >(
"IndVFilterParams");
96 fIndVFilterFunc =
new TF1(
"indVFilter", indVFilt.c_str());
97 for(
unsigned int i=0; i<indVFiltParams.size(); ++i)
98 fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
100 constexpr
unsigned int NPlanes = 3;
102 std::string histoname = pset.get<std::string>(
"FilterHistoName");
103 mf::LogInfo(
"SignalShapingServiceSBND") <<
" using filter from .root file " ;
107 cet::search_path sp(
"FW_SEARCH_PATH");
108 auto requestedFilterFunctionPath = pset.get<std::string>(
"FilterFunctionFname");
109 if (!sp.find_file(requestedFilterFunctionPath, fname)) {
110 throw art::Exception(art::errors::Configuration)
111 <<
"Filter function file '" << requestedFilterFunctionPath
112 <<
"' not found in FW_SEARCH_PATH";
115 TFile
in(fname.c_str(),
"READ");
117 throw cet::exception(
"SignalShapingServiceSBND")
118 <<
"Can't open filter function file '" << fname <<
"'!\n";
120 mf::LogInfo(
"SignalShapingServiceSBND")
121 <<
"Reading filter histograms from '" << fname <<
"'";
122 for(
unsigned int i = 0; i < NPlanes; ++i) {
123 auto pHist =
dynamic_cast<TH1*
>(
in.Get(Form(histoname.c_str(),i)));
126 throw cet::exception(
"SignalShapingServiceSBND")
127 <<
"Can't find filter histogram '" << histoname <<
"' for plane #" << i
128 <<
" in '" << fname <<
"'!\n";
130 pHist->SetDirectory(
nullptr);
131 fFilterHist[i] = pHist;
137 if(fUseFunctionFieldShape) {
139 std::string colField = pset.get<std::string>(
"ColFieldShape");
140 std::vector<double> colFieldParams = pset.get<std::vector<double> >(
"ColFieldParams");
141 fColFieldFunc =
new TF1(
"colField", colField.c_str());
142 for(
unsigned int i=0; i<colFieldParams.size(); ++i)
143 fColFieldFunc->SetParameter(i, colFieldParams[i]);
147 std::string indUField = pset.get<std::string>(
"IndUFieldShape");
148 std::vector<double> indUFieldParams = pset.get<std::vector<double> >(
"IndUFieldParams");
149 fIndUFieldFunc =
new TF1(
"indUField", indUField.c_str());
150 for(
unsigned int i=0; i<indUFieldParams.size(); ++i)
151 fIndUFieldFunc->SetParameter(i, indUFieldParams[i]);
154 std::string indVField = pset.get<std::string>(
"IndVFieldShape");
155 std::vector<double> indVFieldParams = pset.get<std::vector<double> >(
"IndVFieldParams");
156 fIndVFieldFunc =
new TF1(
"indVField", indVField.c_str());
157 for(
unsigned int i=0; i<indVFieldParams.size(); ++i)
158 fIndVFieldFunc->SetParameter(i, indVFieldParams[i]);
161 }
else if (fUseHistogramFieldShape){
162 constexpr
unsigned int NPlanes = 3;
166 cet::search_path sp(
"FW_SEARCH_PATH");
167 auto requestedFieldResponsePath = pset.get<std::string>(
"FieldResponseFname");
168 if (!sp.find_file(requestedFieldResponsePath, fname)) {
169 throw art::Exception(art::errors::Configuration)
170 <<
"Field response file '" << requestedFieldResponsePath
171 <<
"' not found in FW_SEARCH_PATH";
173 std::string histoname = pset.get<std::string>(
"FieldResponseHistoName");
175 mf::LogInfo(
"SignalShapingServiceSBND")
176 <<
"Using the field response provided from '" << fname
177 <<
"' (histograms '" << histoname <<
"_*')";
179 TFile fin(fname.c_str(),
"READ");
180 if ( !fin.IsOpen() ) {
181 throw cet::exception(
"SignalShapingServiceSBND")
182 <<
"Could not find the field response file '" << fname <<
"'!\n";
185 const std::string iPlane[3] = {
"U",
"V",
"Y"};
187 for(
unsigned int i = 0; i < NPlanes; ++i) {
188 std::string PlaneHistoName = histoname +
"_" + iPlane[i];
189 MF_LOG_DEBUG(
"SignalShapingServiceSBND")
190 <<
"Field Response " << i <<
": " << PlaneHistoName;
192 auto pHist =
dynamic_cast<TH1*
>(fin.Get(PlaneHistoName.c_str()));
194 throw cet::exception(
"SignalShapingServiceSBND")
195 <<
"Could not find the field response histogram '" << PlaneHistoName
196 <<
"' in file '" << fname <<
"'\n";
198 if (pHist->GetNbinsX() > fNFieldBins) {
199 throw art::Exception( art::errors::Configuration ) <<
"FieldBins (" << fNFieldBins
200 <<
") should always be larger than or equal to the number of the bins in the input histogram ("
201 << pHist->GetNbinsX() <<
" in '" << PlaneHistoName <<
"')!\n";
203 pHist->SetDirectory(
nullptr);
205 fFieldResponseHist[i] = pHist;
206 MF_LOG_DEBUG(
"SignalShapingServiceSBND")
207 <<
"RESPONSE HISTOGRAM " << iPlane[i] <<
": " << pHist->GetEntries() <<
" entries in "
208 << pHist->GetNbinsX() <<
" bins (" << pHist->GetBinLowEdge(1)
209 <<
" to " << pHist->GetBinLowEdge(pHist->GetNbinsX() + 1);
236 return fIndUSignalShaping;
238 return fIndVSignalShaping;
240 return fColSignalShaping;
242 throw cet::exception(
"SignalShapingServiceSBND")<<
"1 can't determine"
246 return fColSignalShaping;
257 gain = fASICGainInMVPerFC.at(0);
259 gain = fASICGainInMVPerFC.at(1);
261 gain = fASICGainInMVPerFC.at(2);
263 throw cet::exception(
"SignalShapingServiceSBND")<<
"2 can't determine"
303 throw cet::exception(
"SignalShapingServiceSBND")<<
"4 can't determine"
306 double shapingtime = fShapeTimeConst.at(plane);
307 double gain = fASICGainInMVPerFC.at(plane);
309 if (shapingtime == 0.5){
311 }
else if (shapingtime == 1.0){
313 }
else if (shapingtime == 2.0){
320 auto tempNoise = fNoiseFactVec.at(plane);
321 rawNoise = tempNoise.at(temp);
323 rawNoise *= gain/4.7;
343 throw cet::exception(
"SignalShapingServiceSBND")<<
"5 can't determine"
346 double shapingtime = fShapeTimeConst.at(plane);
348 if (shapingtime == 0.5){
350 }
else if (shapingtime == 1.0){
352 }
else if (shapingtime == 2.0){
359 auto tempNoise = fNoiseFactVec.at(plane);
360 deconNoise = tempNoise.at(temp);
363 deconNoise = deconNoise /4096.*(fADCPerPCAtLowestASICGain/4.7/4.7) *6.241*1000/fDeconNorm;
384 SetElectResponse(fShapeTimeConst.at(2),fASICGainInMVPerFC.at(2));
388 fColSignalShaping.AddResponseFunction(fColFieldResponse);
389 fColSignalShaping.AddResponseFunction(fElectResponse);
390 fColSignalShaping.save_response();
391 fColSignalShaping.set_normflag(
false);
394 SetElectResponse(fShapeTimeConst.at(0),fASICGainInMVPerFC.at(0));
396 fIndUSignalShaping.AddResponseFunction(fIndUFieldResponse);
397 fIndUSignalShaping.AddResponseFunction(fElectResponse);
398 fIndUSignalShaping.save_response();
399 fIndUSignalShaping.set_normflag(
false);
402 SetElectResponse(fShapeTimeConst.at(1),fASICGainInMVPerFC.at(1));
404 fIndVSignalShaping.AddResponseFunction(fIndVFieldResponse);
405 fIndVSignalShaping.AddResponseFunction(fElectResponse);
406 fIndVSignalShaping.save_response();
407 fIndVSignalShaping.set_normflag(
false);
410 SetResponseSampling();
418 fColSignalShaping.AddFilterFunction(fColFilter);
419 fColSignalShaping.CalculateDeconvKernel();
421 fIndUSignalShaping.AddFilterFunction(fIndUFilter);
422 fIndUSignalShaping.CalculateDeconvKernel();
424 fIndVSignalShaping.AddFilterFunction(fIndVFilter);
425 fIndVSignalShaping.CalculateDeconvKernel();
436 art::ServiceHandle<geo::Geometry> geo;
437 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
438 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
442 double xyz1[3] = {0.};
443 double xyz2[3] = {0.};
444 double xyzl[3] = {0.};
446 geo->Plane(0).LocalToWorld(xyzl, xyz1);
447 geo->Plane(1).LocalToWorld(xyzl, xyz2);
451 double pitch = xyz2[0] - xyz1[0];
453 fColFieldResponse.resize(fNFieldBins, 0.);
454 fIndUFieldResponse.resize(fNFieldBins, 0.);
455 fIndVFieldResponse.resize(fNFieldBins, 0.);
460 double driftvelocity=
detProp.DriftVelocity()/1000.;
461 double integral = 0.;
463 if(fUseFunctionFieldShape) {
465 art::ServiceHandle<util::LArFFT> fft;
466 int signalSize = fft->FFTSize();
467 std::vector<double> ramp(signalSize);
472 std::vector<double> bipolar(signalSize);
474 fColFieldResponse.resize(signalSize, 0.);
475 fIndUFieldResponse.resize(signalSize, 0.);
476 fIndVFieldResponse.resize(signalSize, 0.);
479 fIndUFieldFunc->SetParameter(4,fIndUFieldFunc->GetParameter(4)*signalSize);
480 fIndVFieldFunc->SetParameter(4,fIndVFieldFunc->GetParameter(4)*signalSize);
482 for(
int i = 0; i < signalSize; i++) {
483 ramp[i]=fColFieldFunc->Eval(i);
484 fColFieldResponse[i]=ramp[i];
485 integral += fColFieldResponse[i];
487 bipolar[i]=fIndUFieldFunc->Eval(i);
488 fIndUFieldResponse[i]=bipolar[i];
489 bipolar[i]=fIndVFieldFunc->Eval(i);
490 fIndVFieldResponse[i]=bipolar[i];
494 for(
int i = 0; i < signalSize; ++i){
495 fColFieldResponse[i] *= fColFieldRespAmp/integral;
499 fft->ShiftData(fIndUFieldResponse,signalSize/2.0);
500 fft->ShiftData(fIndVFieldResponse,signalSize/2.0);
502 }
else if (fUseHistogramFieldShape){
506 for(
int ibin=1; ibin<=fFieldResponseHist[2]->GetNbinsX(); ibin++)
507 integral += fFieldResponseHist[2]->GetBinContent(ibin);
510 for(
int ibin=1; ibin<=fFieldResponseHist[0]->GetNbinsX(); ibin++)
511 fIndUFieldResponse[ibin-1] = fIndUFieldRespAmp*fFieldResponseHist[0]->GetBinContent(ibin)/integral;
514 for(
int ibin=1; ibin<=fFieldResponseHist[1]->GetNbinsX(); ibin++)
515 fIndVFieldResponse[ibin-1] = fIndVFieldRespAmp*fFieldResponseHist[1]->GetBinContent(ibin)/integral;
518 for(
int ibin=1; ibin<=fFieldResponseHist[2]->GetNbinsX(); ibin++)
519 fColFieldResponse[ibin-1] = fColFieldRespAmp*fFieldResponseHist[2]->GetBinContent(ibin)/integral;
521 }
else if (fUseSimpleFieldShape) {
523 mf::LogInfo(
"SignalShapingServiceSBND") <<
" using try-2 hard-coded field shapes " ;
525 const int nbincPlane = 16;
526 double cPlaneResponse[nbincPlane] = {
527 0, 0, 0, 0.02620087336, 0.02620087336,
528 0.04366812227, 0.1310043668, 0.1659388646, 0.1397379913, 0.3711790393,
529 0.06550218341, 0.0480349345, -0.01310043668, -0.004366812227, 0,
533 for(
int i = 1; i < nbincPlane; ++i){
534 fColFieldResponse[i] = cPlaneResponse[i];
535 integral += fColFieldResponse[i];
538 for(
int i = 0; i < nbincPlane; ++i){
540 fColFieldResponse[i] /= integral;
544 const int nbinuPlane = 228;
549 double uPlaneResponse[nbinuPlane] = {
550 0, 0.0001881008778, 0.0003762017556, 0.0005643026334, 0.0007524035112,
551 0.000940504389, 0.001128605267, 0.001316706145, 0.001504807022, 0.0016929079,
552 0.001881008778, 0.002069109656, 0.002257210534, 0.002445311411, 0.002633412289,
553 0.002821513167, 0.003009614045, 0.003197714923, 0.0033858158, 0.003573916678,
554 0.003762017556, 0.003950118434, 0.004138219312, 0.004326320189, 0.004514421067,
555 0.004702521945, 0.004890622823, 0.005078723701, 0.005266824579, 0.005454925456,
556 0.005643026334, 0.005831127212, 0.00601922809, 0.006207328968, 0.006395429845,
557 0.006583530723, 0.006771631601, 0.006959732479, 0.007147833357, 0.007335934234,
558 0.007524035112, 0.00771213599, 0.007900236868, 0.008088337746, 0.008276438623,
559 0.008464539501, 0.008652640379, 0.008840741257, 0.009028842135, 0.009216943012,
560 0.00940504389, 0.009593144768, 0.009781245646, 0.009969346524, 0.0101574474,
561 0.01053554828, 0.01053364916, 0.01072175003, 0.01090985091, 0.01109795179,
562 0.01128605267, 0.01147415355, 0.01166225442, 0.0118503553, 0.01203845618,
563 0.01222655706, 0.01241465794, 0.01260275881, 0.01279085969, 0.01297896057,
564 0.01316706145, 0.01335516232, 0.0135432632, 0.01373136408, 0.01391946496,
565 0.01410756584, 0.01429566671, 0.01448376759, 0.01467186847, 0.01485996935,
566 0.01504807022, 0.0152361711, 0.01542427198, 0.01561237286, 0.01580047374,
567 0.01598857461, 0.01617667549, 0.01636477637, 0.01655287725, 0.01674097812,
568 0.016929079, 0.01711717988, 0.01730528076, 0.01749338164, 0.01768148251,
569 0.01786958339, 0.01805768427, 0.01824578515, 0.01843388602, 0.0186219869,
570 0.01881008778, 0.01899818866, 0.01918628954, 0.01937439041, 0.01956249129,
571 0.01975059217, 0.01993869305, 0.02012679393, 0.0203148948, 0.02050299568,
572 0.02069109656, 0.02087919744, 0.02106729831, 0.02125539919, 0.02144350007,
573 0.02163160095, 0.02181970183, 0.0220078027, 0.02219590358, 0.02238400446,
574 0.02257210534, 0.02302354744, 0.02347498955, 0.02392643166, 0.02437787376,
575 0.02482931587, 0.02528075798, 0.02573220008, 0.02618364219, 0.0266350843,
576 0.0270865264, 0.02753796851, 0.02798941062, 0.02844085272, 0.02889229483,
577 0.02934373694, 0.02979517904, 0.03024662115, 0.03069806326, 0.03114950536,
578 0.03160094747, 0.0321652501, 0.03272955274, 0.03329385537, 0.033858158,
579 0.03442246064, 0.03498676327, 0.0355510659, 0.03611536854, 0.03667967117,
580 0.03724397381, 0.03780827644, 0.03837257907, 0.03893688171, 0.03950118434,
581 0.04006548697, 0.04062978961, 0.04119409224, 0.04175839487, 0.04232269751,
582 0.04288700014, 0.0435641633, 0.04424132646, 0.04491848962, 0.04559565278,
583 0.04627281594, 0.0469499791, 0.04762714226, 0.04830430542, 0.04898146858,
584 0.04965863174, 0.0503357949, 0.05101295806, 0.05169012122, 0.05236728438,
585 0.05304444754, 0.0537216107, 0.05439877386, 0.05507593702, 0.05575310018,
586 0.05643026334, 0.0572579072, 0.05808555107, 0.05891319493, 0.05974083879,
587 0.06056848265, 0.06139612652, 0.06222377038, 0.06305141424, 0.0638790581,
588 0.06470670196, 0.06553434583, 0.06636198969, 0.06718963355, 0.06801727741,
589 0.06884492128, 0.06967256514, 0.070500209, 0.07132785286, 0.07215549673,
590 0.07298314059, 0.07305838094, 0.07313362129, 0.07320886164, 0.07328410199,
591 0.07335934234, 0.07524035112, 0.07524035112, 0.07524035112, 0.07524035112,
592 0.07524035112, 0.07524035112, 0.07524035112, 0.07565835307, 0.06688031211,
593 -1.508982036, -1.401197605, -1.293413174, -0.5748502994, -0.3233532934,
594 -0.2694610778, -0.2694610778, -0.1796407186, -0.1437125749, -0.03592814371,
598 for(
int i = 0; i < nbinuPlane; ++i){
600 fIndUFieldResponse[i] = uPlaneResponse[i]/integral;
603 const int nbinvPlane = 20;
604 double vPlaneResponse[nbinvPlane] = {
605 0, 0, 0.01090909091, 0.01090909091, 0.01090909091,
606 0.02181818182, 0.03272727273, 0.7636363636, 2.018181818, 2.04,
607 1.090909091, -1.03861518, -1.757656458, -1.757656458, -1.118508655,
608 -0.2396804261, -0.07989347537, -0.007989347537, 0, 0
611 for (
int i = 0; i < nbinvPlane; ++i) {
613 fIndVFieldResponse[i] = vPlaneResponse[i]/integral;
619 mf::LogInfo(
"SignalShapingServiceSBND") <<
" using the old field shape " ;
620 int nbinc = TMath::Nint(fCol3DCorrection*(
std::abs(pitch))/(driftvelocity*
sampling_rate(clockData)));
622 double integral = 0.;
623 for(
int i = 1; i < nbinc; ++i){
624 fColFieldResponse[i] = fColFieldResponse[i-1] + 1.0;
625 integral += fColFieldResponse[i];
628 for(
int i = 0; i < nbinc; ++i){
629 fColFieldResponse[i] *= fColFieldRespAmp/integral;
634 int nbini = TMath::Nint(fInd3DCorrection*(
std::abs(pitch))/(driftvelocity*
sampling_rate(clockData)));
635 for(
int i = 0; i < nbini; ++i){
636 fIndUFieldResponse[i] = fIndUFieldRespAmp/(1.*nbini);
637 fIndUFieldResponse[nbini+i] = -fIndUFieldRespAmp/(1.*nbini);
640 for(
int i = 0; i < nbini; ++i){
641 fIndVFieldResponse[i] = fIndVFieldRespAmp/(1.*nbini);
642 fIndVFieldResponse[nbini+i] = -fIndVFieldRespAmp/(1.*nbini);
657 art::ServiceHandle<geo::Geometry> geo;
658 art::ServiceHandle<util::LArFFT> fft;
660 MF_LOG_DEBUG(
"SignalShapingSBND") <<
"Setting SBND electronics response function...";
662 int nticks = fft->FFTSize();
663 fElectResponse.resize(nticks, 0.);
664 std::vector<double> time(nticks,0.);
668 double To = shapingtime;
686 for(
size_t i = 0; i < fElectResponse.size(); ++i){
689 time[i] = (1.*i)*fInputFieldRespSamplingPeriod*1
e-3;
691 4.31054*
exp(-2.94809*time[i]/To)*Ao - 2.6202*
exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*Ao
692 -2.6202*
exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*cos(2.38722*time[i]/To)*Ao
693 +0.464924*
exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*Ao
694 +0.464924*
exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*cos(5.18561*time[i]/To)*Ao
695 +0.762456*
exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*Ao
696 -0.762456*
exp(-2.82833*time[i]/To)*cos(2.38722*time[i]/To)*sin(1.19361*time[i]/To)*Ao
697 +0.762456*
exp(-2.82833*time[i]/To)*cos(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
698 -2.6202*
exp(-2.82833*time[i]/To)*sin(1.19361*time[i]/To)*sin(2.38722*time[i]/To)*Ao
699 -0.327684*
exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*Ao +
700 +0.327684*
exp(-2.40318*time[i]/To)*cos(5.18561*time[i]/To)*sin(2.5928*time[i]/To)*Ao
701 -0.327684*
exp(-2.40318*time[i]/To)*cos(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao
702 +0.464924*
exp(-2.40318*time[i]/To)*sin(2.5928*time[i]/To)*sin(5.18561*time[i]/To)*Ao;
704 if(fElectResponse[i] > max) max = fElectResponse[i];
707 MF_LOG_DEBUG(
"SignalShapingSBND") <<
" Done.";
715 for(
auto&
element : fElectResponse){
717 element *= fADCPerPCAtLowestASICGain*1.60217657e-7;
732 art::ServiceHandle<util::LArFFT> fft;
733 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
736 int n = fft->FFTSize() / 2;
740 fColFilter.resize(n+1);
741 fIndUFilter.resize(n+1);
742 fIndVFilter.resize(n+1);
744 if(!fGetFilterFromHisto)
746 fColFilterFunc->SetRange(0,
double(n));
748 for(
int i=0; i<=
n; ++i) {
749 double freq = 500. * i / (ts *
n);
750 double f = fColFilterFunc->Eval(freq);
751 fColFilter[i] = TComplex(f, 0.);
757 fIndUFilterFunc->SetRange(0,
double(n));
759 for(
int i=0; i<=
n; ++i) {
760 double freq = 500. * i / (ts *
n);
761 double f = fIndUFilterFunc->Eval(freq);
762 fIndUFilter[i] = TComplex(f, 0.);
765 fIndVFilterFunc->SetRange(0,
double(n));
767 for(
int i=0; i<=
n; ++i) {
768 double freq = 500. * i / (ts *
n);
769 double f = fIndVFilterFunc->Eval(freq);
770 fIndVFilter[i] = TComplex(f, 0.);
777 for(
int i=0; i<=
n; ++i) {
778 double f = fFilterHist[2]->GetBinContent(i);
779 fColFilter[i] = TComplex(f, 0.);
780 double g = fFilterHist[1]->GetBinContent(i);
781 fIndVFilter[i] = TComplex(g, 0.);
782 double h = fFilterHist[0]->GetBinContent(i);
783 fIndUFilter[i] = TComplex(h, 0.);
788 fIndUSignalShaping.AddFilterFunction(fIndUFilter);
789 fIndVSignalShaping.AddFilterFunction(fIndVFilter);
790 fColSignalShaping.AddFilterFunction(fColFilter);
800 art::ServiceHandle<geo::Geometry> geo;
801 art::ServiceHandle<util::LArFFT> fft;
802 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
805 if( fInputFieldRespSamplingPeriod >
sampling_rate(clockData) )
806 throw cet::exception(
"SignalShapingServiceSBND") <<
"\033[93m"
807 <<
"Invalid operation: cannot rebin to a more finely binned vector!"
808 <<
"\033[00m" << std::endl;
810 int nticks = fft->FFTSize();
811 std::vector<double> SamplingTime(nticks,0.);
812 for(
int itime = 0; itime < nticks; itime++) {
817 for(
int iplane = 0; iplane <= 2; iplane++) {
818 const std::vector<double>* pResp;
820 case 0: pResp = &(fIndUSignalShaping.Response_save());
break;
821 case 1: pResp = &(fIndVSignalShaping.Response_save());
break;
822 default: pResp = &(fColSignalShaping.Response_save());
break;
825 std::vector<double> SamplingResp(nticks, 0.);
827 int nticks_input = pResp->size();
828 std::vector<double> InputTime(nticks_input, 0.);
829 for(
int itime = 0; itime < nticks_input; itime++) {
830 InputTime[itime] = (1.*itime) * fInputFieldRespSamplingPeriod;
837 int SamplingCount = 0;
838 for(
int itime = 0; itime < nticks; itime++) {
839 int low = -1, up = -1;
840 for(
int jtime = 0; jtime < nticks; jtime++) {
841 if(InputTime[jtime] == SamplingTime[itime]) {
842 SamplingResp[itime] = (*pResp)[jtime];
845 }
else if(InputTime[jtime] > SamplingTime[itime]) {
848 SamplingResp[itime] = (*pResp)[
low] + (SamplingTime[itime] - InputTime[
low]) * ( (*pResp)[up] - (*pResp)[
low]) / (InputTime[up] - InputTime[low] );
852 SamplingResp[itime] = 0;
858 SamplingResp.resize(SamplingCount, 0.);
861 case 0: fIndUSignalShaping.AddResponseFunction(SamplingResp,
true);
break;
862 case 1: fIndVSignalShaping.AddResponseFunction(SamplingResp,
true);;
break;
863 default: fColSignalShaping.AddResponseFunction(SamplingResp,
true);;
break;
872 unsigned int const channel)
const
877 double time_offset = 0;
879 time_offset = fFieldResponseTOffset.at(0);
881 time_offset = fFieldResponseTOffset.at(1);
883 time_offset = fFieldResponseTOffset.at(2);
885 throw cet::exception(
"SignalShapingServiceSBND")<<
"6 can't determine"
889 auto tpc_clock = clockData.
TPCClock();
890 return tpc_clock.
Ticks(time_offset/1.e3);
894 art::ServiceHandle<geo::Geometry> geom;
901 std::vector<geo::WireID> wires = geom->ChannelToWire(chan);
~SignalShapingServiceSBND()
double GetDeconNoise(unsigned int const channel) const
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
ElecClock const & TPCClock() const noexcept
Borrow a const TPC clock with time set to Trigger time [us].
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure Z direction.
double GetRawNoise(unsigned int const channel) const
void SetElectResponse(double shapingtime, double gain)
constexpr int Ticks() const noexcept
Current clock tick (that is, the number of tick Time() falls in).
standard_dbscan3dalg useful for diagnostics hits not in a line will not be clustered on on only for track like only for track like on on the smaller the less shower like tracks low
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
const util::SignalShaping & SignalShaping(unsigned int channel) const
double GetASICGain(unsigned int const channel) const
void SetResponseSampling()
SignalShapingServiceSBND(const fhicl::ParameterSet &pset, art::ActivityRegistry ®)
Encapsulate the construction of a single detector plane.
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
Contains all timing reference information for the detector.
int FieldResponseTOffset(detinfo::DetectorClocksData const &clockData, unsigned int const channel) const
geo::View_t GetView(unsigned int chan) const
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
void reconfigure(const fhicl::ParameterSet &pset)