16 #include "cetlib_except/exception.h" 17 #include "cetlib/search_path.h" 29 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 30 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 72 std::vector<std::vector<TComplex> >
fKernelS;
95 produces< std::vector<recob::Wire> >();
96 produces<art::Assns<raw::RawDigit, recob::Wire>>();
112 cet::search_path sp(
"FW_SEARCH_PATH");
121 LOG_DEBUG(
"CalWireT962") <<
"CalWireT962_module: Opening Electronics Response File: " 129 TH2D *respRe =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespRe") );
130 TH2D *respIm =
dynamic_cast<TH2D*
>(
f.Get(
"real/RespIm") );
131 TH1D *decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"real/decayHist"));
132 unsigned int wires = decayHist->GetNbinsX();
133 unsigned int bins = respRe->GetYaxis()->GetNbins();
134 unsigned int bin = 0;
135 unsigned int wire = 0;
138 fKernelR.resize(respRe->GetXaxis()->GetNbins());
139 const TArrayD *edges = respRe->GetXaxis()->GetXbins();
140 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
142 for(bin = 0; bin < bins; ++
bin) {
144 const TComplex a(respRe->GetBinContent(i+1,bin+1),
145 respIm->GetBinContent(i+1,bin+1));
148 for(; wire < (*edges)[i+1]; ++wire) {
153 respRe =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespRe") );
154 respIm =
dynamic_cast<TH2D*
>(
f.Get(
"sim/RespIm") );
155 decayHist =
dynamic_cast<TH1D*
>(
f.Get(
"sim/decayHist"));
156 wires = decayHist->GetNbinsX();
157 bins = respRe->GetYaxis()->GetNbins();
160 fKernelS.resize(respRe->GetXaxis()->GetNbins());
161 const TArrayD *edges1 = respRe->GetXaxis()->GetXbins();
163 for(
int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
165 for(bin = 0; bin < bins; ++
bin) {
166 const TComplex b(respRe->GetBinContent(i+1,bin+1),
167 respIm->GetBinContent(i+1,bin+1));
170 for(; wire < (*edges1)[i+1]; ++wire) {
192 std::vector<double> decayConsts;
193 std::vector<int> kernMap;
194 std::vector<std::vector<TComplex> > kernel;
211 std::unique_ptr<std::vector<recob::Wire> > wirecol(
new std::vector<recob::Wire>);
213 std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire> > WireDigitAssn
220 if (!digitVecHandle->size())
return;
221 mf::LogInfo(
"CalWireT962") <<
"CalWireT962:: digitVecHandle size is " << digitVecHandle->size();
226 unsigned int dataSize = digitVec0->
Samples();
228 int transformSize = fFFT->
FFTSize();
232 lariov::ChannelStatusProvider
const& channelStatus
235 double decayConst = 0.;
236 double fitAmplitude = 0.;
237 std::vector<float> holder;
238 std::vector<TComplex> freqHolder(transformSize+1);
241 for(
unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
250 if(!channelStatus.IsBad(channel)) {
251 holder.resize(transformSize);
253 for(bin = 0; bin < dataSize; ++
bin)
256 if(
fExpEndBins && std::abs(decayConsts[channel]) > 0.0){
258 TH1D expTailData(
"expTailData",
"Tail data for fit",
260 TF1 expFit(
"expFit",
"[0]*exp([1]*x)");
264 decayConst = decayConsts[channel];
266 expFit.FixParameter(1,decayConst);
267 expFit.SetParameter(0,fitAmplitude);
268 expTailData.Fit(&expFit,
"QWN",
"",dataSize-
fExpEndBins,dataSize);
269 expFit.SetRange(dataSize,transformSize);
270 for(bin = 0; bin < dataSize; ++
bin)
271 holder[dataSize+bin]= expFit.Eval(bin+dataSize);
279 fFFT->
Convolute(holder,kernel[kernMap[channel]]);
282 holder.resize(dataSize,1
e-5);
288 for(bin = 0; bin < holder.size(); ++
bin) holder[bin]-=average;
298 <<
"Can't associate wire #" << (wirecol->size() - 1)
299 <<
" with raw digit #" << digitVec.
key();
303 if(wirecol->size() == 0)
306 evt.
put(std::move(wirecol));
307 evt.
put(std::move(WireDigitAssn));
320 #endif // CALWIRET962_H
float GetPedestal() const
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fPostsample
number of postsample bins
Helper functions to create a wire.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
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
unsigned short Samples() const
Number of samples in the uncompressed ADC data.
ProductID put(std::unique_ptr< PROD > &&product)
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.
T get(std::string const &key) const
std::vector< int > fKernMapS
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::string fResponseFile
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< double > fDecayConstsR
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void produce(art::Event &evt)
void reconfigure(fhicl::ParameterSet const &p)
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