24 #include "cetlib/search_path.h" 25 #include "cetlib_except/exception.h" 62 std::vector<std::vector<TComplex>>
fKernelS;
83 cet::search_path sp(
"FW_SEARCH_PATH");
84 sp.find_file(pset.get<std::string>(
"ResponseFile"),
fResponseFile);
88 produces<std::vector<recob::Wire>>();
89 produces<art::Assns<raw::RawDigit, recob::Wire>>();
96 MF_LOG_DEBUG(
"CalWire") <<
"CalWire_plugin: Opening Electronics Response File: " 103 TH2D* respRe =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespRe"));
104 TH2D* respIm =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespIm"));
105 TH1D* decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"real/decayHist"));
106 unsigned int wires = decayHist->GetNbinsX();
107 unsigned int bins = respRe->GetYaxis()->GetNbins();
108 unsigned int bin = 0;
109 unsigned int wire = 0;
112 fKernelR.resize(respRe->GetXaxis()->GetNbins());
113 const TArrayD* edges = respRe->GetXaxis()->GetXbins();
114 for (
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
116 for (bin = 0; bin < bins; ++
bin) {
118 const TComplex a(respRe->GetBinContent(i + 1, bin + 1),
119 respIm->GetBinContent(i + 1, bin + 1));
122 for (; wire < (*edges)[i + 1]; ++wire) {
127 respRe =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespRe"));
128 respIm =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespIm"));
129 decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"sim/decayHist"));
130 wires = decayHist->GetNbinsX();
131 bins = respRe->GetYaxis()->GetNbins();
134 fKernelS.resize(respRe->GetXaxis()->GetNbins());
135 const TArrayD* edges1 = respRe->GetXaxis()->GetXbins();
137 for (
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
139 for (bin = 0; bin < bins; ++
bin) {
140 const TComplex b(respRe->GetBinContent(i + 1, bin + 1),
141 respIm->GetBinContent(i + 1, bin + 1));
144 for (; wire < (*edges1)[i + 1]; ++wire) {
160 std::vector<double> decayConsts;
161 std::vector<int> kernMap;
162 std::vector<std::vector<TComplex>> kernel;
179 std::unique_ptr<std::vector<recob::Wire>> wirecol(
new std::vector<recob::Wire>);
181 std::unique_ptr<art::Assns<raw::RawDigit, recob::Wire>> WireDigitAssn(
188 if (!digitVecHandle->size())
return;
189 mf::LogInfo(
"CalWire") <<
"CalWire:: digitVecHandle size is " << digitVecHandle->size();
194 unsigned int dataSize = digitVec0->
Samples();
196 int transformSize = fFFT->
FFTSize();
200 double decayConst = 0.;
201 double fitAmplitude = 0.;
202 std::vector<float> holder;
203 std::vector<short> rawadc(transformSize);
204 std::vector<TComplex> freqHolder(transformSize + 1);
207 for (
unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter) {
213 holder.resize(transformSize);
218 for (bin = 0; bin < dataSize; ++
bin)
219 holder[bin] = (rawadc[bin] - digitVec->
GetPedestal());
225 TF1 expFit(
"expFit",
"[0]*exp([1]*x)");
229 decayConst = decayConsts[channel];
231 expFit.FixParameter(1, decayConst);
232 expFit.SetParameter(0, fitAmplitude);
233 expTailData.Fit(&expFit,
"QWN",
"", dataSize -
fExpEndBins, dataSize);
234 expFit.SetRange(dataSize, transformSize);
235 for (bin = 0; bin < dataSize; ++
bin)
236 holder[dataSize + bin] = expFit.Eval(bin + dataSize);
255 throw cet::exception(
"CalWire") <<
"Bad signal type = " << sigtype <<
"\n";
256 if (k >= kernel.size())
throw cet::exception(
"CalWire") <<
"kernel size < " << k <<
"!\n";
260 holder.resize(dataSize, 1
e-5);
263 double average = 0.0;
266 for (bin = 0; bin < holder.size(); ++
bin)
267 holder[bin] -= average;
274 <<
"Can't associate wire #" << (wirecol->size() - 1) <<
" with raw digit #" 279 if (wirecol->size() == 0)
mf::LogWarning(
"CalWire") <<
"No wires made for this event.";
281 evt.
put(std::move(wirecol));
282 evt.
put(std::move(WireDigitAssn));
float GetPedestal() const
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
std::string fResponseFile
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< int > fKernMapR
Helper functions to create a wire.
EDProducer(fhicl::ParameterSet const &pset)
ChannelID_t Channel() const
DAQ channel this raw data was read from.
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::vector< double > fDecayConstsR
Definition of basic raw digits.
Class managing the creation of a new recob::Wire object.
creation of calibrated signals on wires
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< double > fDecayConstsS
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
#define DEFINE_ART_MODULE(klass)
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
Collect all the RawData header files together.
key_type key() const noexcept
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
std::vector< std::vector< TComplex > > fKernelR
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
std::string fDigitModuleLabel
module that made digits
std::vector< std::vector< TComplex > > fKernelS
int fExpEndBins
number of end bins to consider for tail fit
Declaration of basic channel signal object.
int fPostsample
number of postsample bins
void produce(art::Event &evt)
std::vector< int > fKernMapS
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
CalWire(fhicl::ParameterSet const &pset)
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Signal from collection planes.