21 #include "cetlib_except/exception.h" 22 #include "cetlib/search_path.h" 70 std::vector<std::vector<TComplex> >
fKernelS;
93 produces< std::vector<recob::Wire> >();
94 produces<art::Assns<raw::RawDigit, recob::Wire>>();
107 cet::search_path sp(
"FW_SEARCH_PATH");
117 LOG_DEBUG(
"CalWire") <<
"CalWire_plugin: Opening Electronics Response File: " 125 TH2D *respRe =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespRe") );
126 TH2D *respIm =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespIm") );
127 TH1D *decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"real/decayHist"));
128 unsigned int wires = decayHist->GetNbinsX();
129 unsigned int bins = respRe->GetYaxis()->GetNbins();
130 unsigned int bin = 0;
131 unsigned int wire = 0;
134 fKernelR.resize(respRe->GetXaxis()->GetNbins());
135 const TArrayD *edges = respRe->GetXaxis()->GetXbins();
136 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
138 for(bin = 0; bin < bins; ++
bin) {
140 const TComplex a(respRe->GetBinContent(i+1,bin+1),
141 respIm->GetBinContent(i+1,bin+1));
144 for(; wire < (*edges)[i+1]; ++wire) {
149 respRe =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespRe") );
150 respIm =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespIm") );
151 decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"sim/decayHist"));
152 wires = decayHist->GetNbinsX();
153 bins = respRe->GetYaxis()->GetNbins();
156 fKernelS.resize(respRe->GetXaxis()->GetNbins());
157 const TArrayD *edges1 = respRe->GetXaxis()->GetXbins();
159 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
161 for(bin = 0; bin < bins; ++
bin) {
162 const TComplex b(respRe->GetBinContent(i+1,bin+1),
163 respIm->GetBinContent(i+1,bin+1));
166 for(; wire < (*edges1)[i+1]; ++wire) {
188 std::vector<double> decayConsts;
189 std::vector<int> kernMap;
190 std::vector<std::vector<TComplex> > kernel;
207 std::unique_ptr<std::vector<recob::Wire> > wirecol(
new std::vector<recob::Wire>);
209 std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire> > WireDigitAssn
216 if (!digitVecHandle->size())
return;
217 mf::LogInfo(
"CalWire") <<
"CalWire:: digitVecHandle size is " << digitVecHandle->size();
222 unsigned int dataSize = digitVec0->
Samples();
224 int transformSize = fFFT->
FFTSize();
228 double decayConst = 0.;
229 double fitAmplitude = 0.;
230 std::vector<float> holder;
231 std::vector<short> rawadc(transformSize);
232 std::vector<TComplex> freqHolder(transformSize+1);
235 for(
unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
241 holder.resize(transformSize);
246 for(bin = 0; bin < dataSize; ++
bin)
249 if(
fExpEndBins && std::abs(decayConsts[channel]) > 0.0){
251 TH1D expTailData(
"expTailData",
"Tail data for fit",
253 TF1 expFit(
"expFit",
"[0]*exp([1]*x)");
257 decayConst = decayConsts[channel];
259 expFit.FixParameter(1,decayConst);
260 expFit.SetParameter(0,fitAmplitude);
261 expTailData.Fit(&expFit,
"QWN",
"",dataSize-
fExpEndBins,dataSize);
262 expFit.SetRange(dataSize,transformSize);
263 for(bin = 0; bin < dataSize; ++
bin)
264 holder[dataSize+bin]= expFit.Eval(bin+dataSize);
283 throw cet::exception(
"CalWire") <<
"Bad signal type = " << sigtype <<
"\n";
284 if (k >= kernel.size())
285 throw cet::exception(
"CalWire") <<
"kernel size < " << k <<
"!\n";
289 holder.resize(dataSize,1
e-5);
295 for(bin = 0; bin < holder.size(); ++
bin) holder[bin]-=average;
302 <<
"Can't associate wire #" << (wirecol->size() - 1)
303 <<
" with raw digit #" << digitVec.
key();
307 if(wirecol->size() == 0)
310 evt.
put(std::move(wirecol));
311 evt.
put(std::move(WireDigitAssn));
float GetPedestal() const
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
std::string fResponseFile
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< int > fKernMapR
Helper functions to create a wire.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::vector< double > fDecayConstsR
Definition of basic raw digits.
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
unsigned short Samples() const
Number of samples in the uncompressed ADC data.
ProductID put(std::unique_ptr< PROD > &&product)
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.
T get(std::string const &key) const
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
void reconfigure(fhicl::ParameterSet const &p)
Utility object to perform functions of association.
std::string fDigitModuleLabel
module that made digits
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
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.