17 #include "cetlib/search_path.h" 18 #include "cetlib_except/exception.h" 31 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 32 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 63 std::vector<std::vector<TComplex>>
fKernelS;
87 cet::search_path sp(
"FW_SEARCH_PATH");
88 sp.find_file(pset.get<std::string>(
"ResponseFile"),
fResponseFile);
90 produces<std::vector<recob::Wire>>();
91 produces<art::Assns<raw::RawDigit, recob::Wire>>();
98 MF_LOG_DEBUG(
"CalWireT962") <<
"CalWireT962_module: Opening Electronics Response File: " 105 TH2D* respRe =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespRe"));
106 TH2D* respIm =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespIm"));
107 TH1D* decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"real/decayHist"));
108 unsigned int wires = decayHist->GetNbinsX();
109 unsigned int bins = respRe->GetYaxis()->GetNbins();
110 unsigned int bin = 0;
111 unsigned int wire = 0;
114 fKernelR.resize(respRe->GetXaxis()->GetNbins());
115 const TArrayD* edges = respRe->GetXaxis()->GetXbins();
116 for (
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
118 for (bin = 0; bin < bins; ++
bin) {
120 const TComplex a(respRe->GetBinContent(i + 1, bin + 1),
121 respIm->GetBinContent(i + 1, bin + 1));
124 for (; wire < (*edges)[i + 1]; ++wire) {
129 respRe =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespRe"));
130 respIm =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespIm"));
131 decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"sim/decayHist"));
132 wires = decayHist->GetNbinsX();
133 bins = respRe->GetYaxis()->GetNbins();
136 fKernelS.resize(respRe->GetXaxis()->GetNbins());
137 const TArrayD* edges1 = respRe->GetXaxis()->GetXbins();
139 for (
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
141 for (bin = 0; bin < bins; ++
bin) {
142 const TComplex b(respRe->GetBinContent(i + 1, bin + 1),
143 respIm->GetBinContent(i + 1, bin + 1));
146 for (; wire < (*edges1)[i + 1]; ++wire) {
162 std::vector<double> decayConsts;
163 std::vector<int> kernMap;
164 std::vector<std::vector<TComplex>> kernel;
181 std::unique_ptr<std::vector<recob::Wire>> wirecol(
new std::vector<recob::Wire>);
183 std::unique_ptr<art::Assns<raw::RawDigit, recob::Wire>> WireDigitAssn(
190 if (!digitVecHandle->size())
return;
191 mf::LogInfo(
"CalWireT962") <<
"CalWireT962:: digitVecHandle size is " << digitVecHandle->size();
196 unsigned int dataSize = digitVec0->
Samples();
198 int transformSize = fFFT->
FFTSize();
202 lariov::ChannelStatusProvider
const& channelStatus =
205 double decayConst = 0.;
206 double fitAmplitude = 0.;
207 std::vector<float> holder;
208 std::vector<TComplex> freqHolder(transformSize + 1);
211 for (
unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter) {
221 if (!channelStatus.IsBad(channel)) {
222 holder.resize(transformSize);
224 for (bin = 0; bin < dataSize; ++
bin)
225 holder[bin] = (rawadc[bin] - digitVec->
GetPedestal());
231 TF1 expFit(
"expFit",
"[0]*exp([1]*x)");
235 decayConst = decayConsts[channel];
238 expFit.FixParameter(1, decayConst);
239 expFit.SetParameter(0, fitAmplitude);
240 expTailData.Fit(&expFit,
"QWN",
"", dataSize -
fExpEndBins, dataSize);
241 expFit.SetRange(dataSize, transformSize);
242 for (bin = 0; bin < dataSize; ++
bin)
243 holder[dataSize + bin] = expFit.Eval(bin + dataSize);
251 fFFT->
Convolute(holder, kernel[kernMap[channel]]);
254 holder.resize(dataSize, 1
e-5);
257 double average = 0.0;
260 for (bin = 0; bin < holder.size(); ++
bin)
261 holder[bin] -= average;
271 <<
"Can't associate wire #" << (wirecol->size() - 1) <<
" with raw digit #" 276 if (wirecol->size() == 0)
mf::LogWarning(
"CalWireT962") <<
"No wires made for this event.";
278 evt.
put(std::move(wirecol));
279 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.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fPostsample
number of postsample bins
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< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition of basic raw digits.
Class managing the creation of a new recob::Wire object.
creation of calibrated signals on wires
std::vector< std::vector< TComplex > > fKernelR
std::vector< double > fDecayConstsS
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
#define DEFINE_ART_MODULE(klass)
std::string fDigitModuleLabel
module that made digits
Collect all the RawData header files together.
key_type key() const noexcept
std::vector< int > fKernMapS
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
std::string fResponseFile
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
std::vector< double > fDecayConstsR
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void produce(art::Event &evt)
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
CalWireT962(fhicl::ParameterSet const &pset)
std::vector< std::vector< TComplex > > fKernelS
art framework interface to geometry description
std::vector< int > fKernMapR
int fExpEndBins
number of end bins to consider for tail fit