19 #include "cetlib_except/exception.h" 89 fExpEndBins = pset.get<
int > (
"ExponentialEndBins");
92 produces< std::vector<recob::Wire> >();
93 produces<art::Assns<raw::RawDigit, recob::Wire>>();
101 MF_LOG_DEBUG(
"CalWire") <<
"CalWire_plugin: Opening Electronics Response File: " 109 TH2D *respRe =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespRe") );
110 TH2D *respIm =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespIm") );
111 TH1D *decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"real/decayHist"));
112 unsigned int wires = decayHist->GetNbinsX();
113 unsigned int bins = respRe->GetYaxis()->GetNbins();
114 unsigned int bin = 0;
115 unsigned int wire = 0;
118 fKernelR.resize(respRe->GetXaxis()->GetNbins());
119 const TArrayD *edges = respRe->GetXaxis()->GetXbins();
120 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
122 for(bin = 0; bin < bins; ++
bin) {
124 const TComplex
a(respRe->GetBinContent(i+1,bin+1),
125 respIm->GetBinContent(i+1,bin+1));
128 for(; wire < (*edges)[i+1]; ++wire) {
133 respRe =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespRe") );
134 respIm =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespIm") );
135 decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"sim/decayHist"));
136 wires = decayHist->GetNbinsX();
137 bins = respRe->GetYaxis()->GetNbins();
140 fKernelS.resize(respRe->GetXaxis()->GetNbins());
141 const TArrayD *edges1 = respRe->GetXaxis()->GetXbins();
143 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
145 for(bin = 0; bin < bins; ++
bin) {
146 const TComplex
b(respRe->GetBinContent(i+1,bin+1),
147 respIm->GetBinContent(i+1,bin+1));
150 for(; wire < (*edges1)[i+1]; ++wire) {
167 std::vector<double> decayConsts;
168 std::vector<int> kernMap;
169 std::vector<std::vector<TComplex> > kernel;
186 std::unique_ptr<std::vector<recob::Wire> > wirecol(
new std::vector<recob::Wire>);
188 std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire> > WireDigitAssn
195 if (!digitVecHandle->size())
return;
196 mf::LogInfo(
"CalWire") <<
"CalWire:: digitVecHandle size is " << digitVecHandle->size();
201 unsigned int dataSize = digitVec0->
Samples();
203 int transformSize = fFFT->
FFTSize();
207 double decayConst = 0.;
208 double fitAmplitude = 0.;
209 std::vector<float> holder;
210 std::vector<short> rawadc(transformSize);
211 std::vector<TComplex> freqHolder(transformSize+1);
214 for(
unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
220 holder.resize(transformSize);
225 for(bin = 0; bin < dataSize; ++
bin)
230 TH1D expTailData(
"expTailData",
"Tail data for fit",
232 TF1 expFit(
"expFit",
"[0]*exp([1]*x)");
236 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);
262 throw cet::exception(
"CalWire") <<
"Bad signal type = " << sigtype <<
"\n";
263 if (k >= kernel.size())
264 throw cet::exception(
"CalWire") <<
"kernel size < " << k <<
"!\n";
268 holder.resize(dataSize,1
e-5);
274 for(bin = 0; bin < holder.size(); ++
bin) holder[bin]-=average;
281 <<
"Can't associate wire #" << (wirecol->size() - 1)
282 <<
" with raw digit #" << digitVec.
key();
286 if(wirecol->size() == 0)
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.
std::vector< double > fDecayConstsR
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Class managing the creation of a new recob::Wire object.
creation of calibrated signals on wires
art framework interface to geometry description
std::vector< double > fDecayConstsS
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
#define DEFINE_ART_MODULE(klass)
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
key_type key() const noexcept
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::vector< std::vector< TComplex > > fKernelR
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string fDigitModuleLabel
module that made digits
std::vector< std::vector< TComplex > > fKernelS
int fExpEndBins
number of end bins to consider for tail fit
QTextStream & bin(QTextStream &s)
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)
cet::coded_exception< error, detail::translate > exception
Signal from collection planes.