All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
caldata::CalWireT962 Class Reference
Inheritance diagram for caldata::CalWireT962:

Public Member Functions

 CalWireT962 (fhicl::ParameterSet const &pset)
 
void produce (art::Event &evt)
 
void beginJob ()
 

Private Attributes

std::string fResponseFile
 
int fExpEndBins
 number of end bins to consider for tail fit More...
 
int fPostsample
 number of postsample bins More...
 
std::string fDigitModuleLabel
 module that made digits More...
 
std::vector< std::vector
< TComplex > > 
fKernelR
 
std::vector< std::vector
< TComplex > > 
fKernelS
 
std::vector< double > fDecayConstsR
 
std::vector< double > fDecayConstsS
 
std::vector< int > fKernMapR
 
std::vector< int > fKernMapS
 

Detailed Description

Definition at line 43 of file CalWireT962_module.cc.

Constructor & Destructor Documentation

caldata::CalWireT962::CalWireT962 ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 84 of file CalWireT962_module.cc.

85  : EDProducer{pset}
86  {
87  fDigitModuleLabel = pset.get< std::string >("DigitModuleLabel", "daq");
88  fExpEndBins = pset.get< int > ("ExponentialEndBins");
89  fPostsample = pset.get< int > ("PostsampleBins");
90 
91  cet::search_path sp("FW_SEARCH_PATH");
92  sp.find_file(pset.get<std::string>("ResponseFile"), fResponseFile);
93 
94  produces< std::vector<recob::Wire> >();
95  produces<art::Assns<raw::RawDigit, recob::Wire>>();
96 
97  }
int fPostsample
number of postsample bins
std::string fDigitModuleLabel
module that made digits
int fExpEndBins
number of end bins to consider for tail fit

Member Function Documentation

void caldata::CalWireT962::beginJob ( )

Definition at line 100 of file CalWireT962_module.cc.

101  {
102 
103  MF_LOG_DEBUG("CalWireT962") << "CalWireT962_module: Opening Electronics Response File: "
104  << fResponseFile.c_str();
105 
106  TFile f(fResponseFile.c_str());
107  if( f.IsZombie() )
108  mf::LogWarning("CalWireT962") << "Cannot open response file "
109  << fResponseFile.c_str();
110 
111  TH2D *respRe = dynamic_cast<TH2D*>(f.Get("real/RespRe") );
112  TH2D *respIm = dynamic_cast<TH2D*>(f.Get("real/RespIm") );
113  TH1D *decayHist = dynamic_cast<TH1D*>(f.Get("real/decayHist"));
114  unsigned int wires = decayHist->GetNbinsX();
115  unsigned int bins = respRe->GetYaxis()->GetNbins();
116  unsigned int bin = 0;
117  unsigned int wire = 0;
118  fDecayConstsR.resize(wires);
119  fKernMapR.resize(wires);
120  fKernelR.resize(respRe->GetXaxis()->GetNbins());
121  const TArrayD *edges = respRe->GetXaxis()->GetXbins();
122  for(int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
123  fKernelR[i].resize(bins);
124  for(bin = 0; bin < bins; ++bin) {
125 
126  const TComplex a(respRe->GetBinContent(i+1,bin+1),
127  respIm->GetBinContent(i+1,bin+1));
128  fKernelR[i][bin]=a;
129  }
130  for(; wire < (*edges)[i+1]; ++wire) {
131  fKernMapR[wire]=i;
132  fDecayConstsR[wire]=decayHist->GetBinContent(wire+1);
133  }
134  }
135  respRe = dynamic_cast<TH2D*>(f.Get("sim/RespRe") );
136  respIm = dynamic_cast<TH2D*>(f.Get("sim/RespIm") );
137  decayHist = dynamic_cast<TH1D*>(f.Get("sim/decayHist"));
138  wires = decayHist->GetNbinsX();
139  bins = respRe->GetYaxis()->GetNbins();
140  fDecayConstsS.resize(wires);
141  fKernMapS.resize(wires);
142  fKernelS.resize(respRe->GetXaxis()->GetNbins());
143  const TArrayD *edges1 = respRe->GetXaxis()->GetXbins();
144  wire =0;
145  for(int i = 0; i < respRe->GetXaxis()->GetNbins(); ++i) {
146  fKernelS[i].resize(bins);
147  for(bin = 0; bin < bins; ++bin) {
148  const TComplex b(respRe->GetBinContent(i+1,bin+1),
149  respIm->GetBinContent(i+1,bin+1));
150  fKernelS[i][bin]=b;
151  }
152  for(; wire < (*edges1)[i+1]; ++wire) {
153  fKernMapS[wire]=i;
154  fDecayConstsS[wire]=decayHist->GetBinContent(wire+1);
155  }
156  }
157 
158  f.Close();
159  }
std::vector< std::vector< TComplex > > fKernelR
std::vector< double > fDecayConstsS
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
process_name gaushit a
std::vector< int > fKernMapS
std::vector< double > fDecayConstsR
std::vector< std::vector< TComplex > > fKernelS
std::vector< int > fKernMapR
void caldata::CalWireT962::produce ( art::Event &  evt)

Definition at line 162 of file CalWireT962_module.cc.

163  {
164 
165 
166  // get the geometry
167  art::ServiceHandle<geo::Geometry const> geom;
168 
169  std::vector<double> decayConsts;
170  std::vector<int> kernMap;
171  std::vector<std::vector<TComplex> > kernel;
172  //Put correct response functions and decay constants in place
173  if(evt.isRealData()) {
174  decayConsts=fDecayConstsR;
175  kernMap=fKernMapR;
176  kernel=fKernelR;
177  }
178  else {
179  decayConsts=fDecayConstsS;
180  kernMap=fKernMapS;
181  kernel=fKernelS;
182  }
183 
184  // get the FFT service to have access to the FFT size
185  art::ServiceHandle<util::LArFFT> fFFT;
186 
187  // make a collection of Wires
188  std::unique_ptr<std::vector<recob::Wire> > wirecol(new std::vector<recob::Wire>);
189  // ... and an association set
190  std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire> > WireDigitAssn
191  (new art::Assns<raw::RawDigit,recob::Wire>);
192 
193  // Read in the digit List object(s).
194  art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
195  evt.getByLabel(fDigitModuleLabel, digitVecHandle);
196 
197  if (!digitVecHandle->size()) return;
198  mf::LogInfo("CalWireT962") << "CalWireT962:: digitVecHandle size is " << digitVecHandle->size();
199 
200  // Use the handle to get a particular (0th) element of collection.
201  art::Ptr<raw::RawDigit> digitVec0(digitVecHandle, 0);
202 
203  unsigned int dataSize = digitVec0->Samples(); //size of raw data vectors
204 
205  int transformSize = fFFT->FFTSize();
206  raw::ChannelID_t channel = raw::InvalidChannelID; // channel number
207  unsigned int bin(0); // time bin loop variable
208 
209  lariov::ChannelStatusProvider const& channelStatus
210  = art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
211 
212  double decayConst = 0.; // exponential decay constant of electronics shaping
213  double fitAmplitude = 0.; //This is the seed value for the amplitude in the exponential tail fit
214  std::vector<float> holder; // holds signal data
215  std::vector<TComplex> freqHolder(transformSize+1); // temporary frequency data
216 
217  // loop over all wires
218  for(unsigned int rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){ // ++ move
219  holder.clear();
220 
221  art::Ptr<raw::RawDigit> digitVec(digitVecHandle, rdIter);
222  raw::RawDigit::ADCvector_t rawadc(digitVec->Samples()); // vector holding uncompressed adc values
223  raw::Uncompress(digitVec->ADCs(), rawadc, digitVec->Compression());
224  channel = digitVec->Channel();
225 
226  // skip bad channels
227  if(!channelStatus.IsBad(channel)) {
228  holder.resize(transformSize);
229 
230  for(bin = 0; bin < dataSize; ++bin)
231  holder[bin]=(rawadc[bin]-digitVec->GetPedestal());
232  // fExpEndBins only nonzero for detectors needing exponential tail fitting
233  if(fExpEndBins && std::abs(decayConsts[channel]) > 0.0){
234 
235  TH1D expTailData("expTailData","Tail data for fit",
236  fExpEndBins,dataSize-fExpEndBins,dataSize);
237  TF1 expFit("expFit","[0]*exp([1]*x)");
238 
239  for(bin = 0; bin < (unsigned int)fExpEndBins; ++bin)
240  expTailData.Fill(dataSize-fExpEndBins+bin,holder[dataSize-fExpEndBins+bin]);
241  decayConst = decayConsts[channel];
242  fitAmplitude = holder[dataSize-fExpEndBins]/exp(decayConst*(dataSize-fExpEndBins));
243  expFit.FixParameter(1,decayConst);
244  expFit.SetParameter(0,fitAmplitude);
245  expTailData.Fit(&expFit,"QWN","",dataSize-fExpEndBins,dataSize);
246  expFit.SetRange(dataSize,transformSize);
247  for(bin = 0; bin < dataSize; ++bin)
248  holder[dataSize+bin]= expFit.Eval(bin+dataSize);
249  }
250  // This is actually deconvolution, by way of convolution with the inverted
251  // kernel. This code assumes the response function has already been
252  // been transformed and inverted. This way a complex multiplication, rather
253  // than a complex division is performed saving 2 multiplications and
254  // 2 divsions
255 
256  fFFT->Convolute(holder,kernel[kernMap[channel]]);
257  } // end if channel is a good channel
258 
259  holder.resize(dataSize,1e-5);
260  //This restores the DC component to signal removed by the deconvolution.
261  if(fPostsample) {
262  double average=0.0;
263  for(bin=0; bin < (unsigned int)fPostsample; ++bin)
264  average+=holder[holder.size()-1-bin]/(double)fPostsample;
265  for(bin = 0; bin < holder.size(); ++bin) holder[bin]-=average;
266  }
267 
268  // Make a single ROI that spans the entire data size
269  wirecol->push_back(recob::WireCreator(holder,*digitVec).move());
270 
271  // add an association between the last object in wirecol
272  // (that we just inserted) and digitVec
273  if (!util::CreateAssn(*this, evt, *wirecol, digitVec, *WireDigitAssn)) {
274  throw art::Exception(art::errors::ProductRegistrationFailure)
275  << "Can't associate wire #" << (wirecol->size() - 1)
276  << " with raw digit #" << digitVec.key();
277  } // if failed to add association
278  }
279 
280  if(wirecol->size() == 0)
281  mf::LogWarning("CalWireT962") << "No wires made for this event.";
282 
283  evt.put(std::move(wirecol));
284  evt.put(std::move(WireDigitAssn));
285 
286  return;
287  }
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
int fPostsample
number of postsample bins
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
Class managing the creation of a new recob::Wire object.
Definition: WireCreator.h:53
std::vector< std::vector< TComplex > > fKernelR
std::vector< double > fDecayConstsS
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
T abs(T value)
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
std::string fDigitModuleLabel
module that made digits
std::vector< int > fKernMapS
Class providing information about the quality of channels.
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.
std::vector< double > fDecayConstsR
do i e
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
std::vector< std::vector< TComplex > > fKernelS
std::vector< int > fKernMapR
int fExpEndBins
number of end bins to consider for tail fit

Member Data Documentation

std::vector<double> caldata::CalWireT962::fDecayConstsR
private

vector holding RC decay constants

Definition at line 68 of file CalWireT962_module.cc.

std::vector<double> caldata::CalWireT962::fDecayConstsS
private

vector holding RC decay constants

Definition at line 70 of file CalWireT962_module.cc.

std::string caldata::CalWireT962::fDigitModuleLabel
private

module that made digits

Definition at line 62 of file CalWireT962_module.cc.

int caldata::CalWireT962::fExpEndBins
private

number of end bins to consider for tail fit

Definition at line 60 of file CalWireT962_module.cc.

std::vector<std::vector<TComplex> > caldata::CalWireT962::fKernelR
private

holds transformed induction response function

Definition at line 64 of file CalWireT962_module.cc.

std::vector<std::vector<TComplex> > caldata::CalWireT962::fKernelS
private

holds transformed induction response function

Definition at line 66 of file CalWireT962_module.cc.

std::vector<int> caldata::CalWireT962::fKernMapR
private

map telling which channels have which response functions

Definition at line 72 of file CalWireT962_module.cc.

std::vector<int> caldata::CalWireT962::fKernMapS
private

map telling which channels have which response functions

Definition at line 74 of file CalWireT962_module.cc.

int caldata::CalWireT962::fPostsample
private

number of postsample bins

Definition at line 61 of file CalWireT962_module.cc.

std::string caldata::CalWireT962::fResponseFile
private

response file containing transformed shape histograms and decay constants

Definition at line 56 of file CalWireT962_module.cc.


The documentation for this class was generated from the following file: