Public Member Functions | Private Attributes | List of all members
calgaushf::CalGausHFDUNE10kt Class Reference
Inheritance diagram for calgaushf::CalGausHFDUNE10kt:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 CalGausHFDUNE10kt (fhicl::ParameterSet const &pset)
 
virtual ~CalGausHFDUNE10kt ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

int fDeconvKernSize
 
int fPostsample
 number of postsample bins More...
 
std::string fDigitModuleLabel
 constants More...
 
std::string fSpillName
 
std::string fCalDataModuleLabel
 
double fMinSigInd
 Induction signal height threshold. More...
 
double fMinSigCol
 Collection signal height threshold. More...
 
double fIndWidth
 Initial width for induction fit. More...
 
double fColWidth
 Initial width for collection fit. More...
 
double fIndMinWidth
 Minimum induction hit width. More...
 
double fColMinWidth
 Minimum collection hit width. More...
 
int fMaxMultiHit
 maximum hits for multi fit More...
 
int fAreaMethod
 Type of area calculation. More...
 
std::vector< double > fAreaNorms
 factors for converting area to same units as peak height More...
 
double fChi2NDF
 
double StartIime
 maximum Chisquared / NDF allowed for a hit to be saved More...
 
double StartTimeError
 
double EndTime
 
double EndTimeError
 
double RMS
 
int NumOfHits
 
double MeanPosition
 
double MeanPosError
 
double Amp
 
double AmpError
 
double Charge
 
double ChargeError
 
double FitGoodnes
 
int FitNDF
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 81 of file CalGausHFDUNE10kt_module.cc.

Constructor & Destructor Documentation

calgaushf::CalGausHFDUNE10kt::CalGausHFDUNE10kt ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 140 of file CalGausHFDUNE10kt_module.cc.

140  : EDProducer{pset}
141  {
142  fSpillName="";
143  this->reconfigure(pset);
144 
145  // let HitCollectionCreator declare that we are going to produce
146  // hits and associations with wires and raw digits
148  (producesCollector(), fSpillName, false /* doWireAssns */, true /* doRawDigitAssns */);
149 
150  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.cxx:248
ProducesCollector & producesCollector() noexcept
void reconfigure(fhicl::ParameterSet const &p)
calgaushf::CalGausHFDUNE10kt::~CalGausHFDUNE10kt ( )
virtual

Definition at line 153 of file CalGausHFDUNE10kt_module.cc.

154  {
155  }

Member Function Documentation

void calgaushf::CalGausHFDUNE10kt::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 189 of file CalGausHFDUNE10kt_module.cc.

190  {
191  }
void calgaushf::CalGausHFDUNE10kt::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 194 of file CalGausHFDUNE10kt_module.cc.

195  {
196  }
void calgaushf::CalGausHFDUNE10kt::produce ( art::Event evt)
virtual
Todo:
need to have a disambiguation algorithm somewhere in here

Implements art::EDProducer.

Definition at line 199 of file CalGausHFDUNE10kt_module.cc.

200  {
201  // get the geometry
203 
204  // Get signal shaping service.
206 
207 
208  //Gaussian hit finder initializations etc.
209  TH1::AddDirectory(kFALSE);
210 
211 
212  // ---------------------------
213  // --- Seed Fit Functions --- (This function used to "seed" the mean peak position)
214  // ---------------------------
215  TF1 *hit = new TF1("hit","gaus",0,3200); // FIXME use DetectorProperties
216 
217  // ###############################################
218  // ### Making a ptr vector to put on the event ###
219  // ###############################################
220  // this contains the hit collection
221  // and its associations to raw digits (not to wires)
223  evt, fSpillName, false /* doWireAssns */, true /* doRawDigitAssns */
224  );
225 
226 
227  // ##########################################
228  // ### Reading in the Wire List object(s) ###
229  // ##########################################
230  //auto wireVecHandle = evt.getHandle< std::vector<recob::Wire> >(fCalDataModuleLabel);
231  //art::ServiceHandle<geo::Geometry> geom;
232 
233  // #########################################################
234  // ### List of useful variables used throughout the code ###
235  // #########################################################
236  double threshold = 0.; // minimum signal size for id'ing a hit
237  double fitWidth = 0.; //hit fit width initial value
238  double minWidth = 0.; //minimum hit width
239  //channel = 0; // channel number
240  geo::SigType_t sigType; // Signal Type (Collection or Induction)
241  geo::View_t view; // view
242  std::vector<int> startTimes; // stores time of 1st local minimum
243  std::vector<int> maxTimes; // stores time of local maximum
244  std::vector<int> endTimes; // stores time of 2nd local minimum
245  int time = 0; // current time bin
246  int minTimeHolder = 0; // current start time
247 
248  std::string eqn = "gaus(0)"; // string for equation for gaus fit
249  //std::string seed = "gaus(0)"; // string for equation seed gaus fit
250 
251 
252  bool maxFound = false; // Flag for whether a peak > threshold has been found
253  std::stringstream numConv;
254 
255 
256  // Read in the digit List object(s).
258 
260  if (fSpillName.size()>0) digitVecHandle = evt.getHandle< std::vector<raw::RawDigit> >(itag1);
261  else digitVecHandle = evt.getHandle< std::vector<raw::RawDigit> >(fDigitModuleLabel);
262 
263  if (!digitVecHandle->size()) return;
264  mf::LogInfo("CalGausHFDUNE10kt") << "CalGausHFDUNE10kt:: digitVecHandle size is " << digitVecHandle->size();
265 
266  // Use the handle to get a particular (0th) element of collection.
267  art::Ptr<raw::RawDigit> digitVec0(digitVecHandle, 0);
268 
269  if (digitVec0->Compression() != raw::kZeroSuppression) {
271  << "CalGausHFDUNE only supports zero-suppressed raw digit input!";
272  } // if
273 
274 
275  raw::ChannelID_t channel = raw::InvalidChannelID; // channel number
276  unsigned int bin(0); // time bin loop variable
277 
278  filter::ChannelFilter *chanFilt = new filter::ChannelFilter();
279 
280  std::vector<float> holder; // holds signal data
281  std::vector<float> rawadc_conv; // holds signal data before time domain deconvolution
282  std::vector<short> rawadc; // vector holding uncompressed adc values
283 
284  // loop over all wires
285  for(size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){ // ++ move
286  holder.clear();
287 
288  // get the reference to the current raw::RawDigit
289  art::Ptr<raw::RawDigit> digitVec(digitVecHandle, rdIter);
290  channel = digitVec->Channel();
291 
292  // skip bad channels
293  if(!chanFilt->BadChannel(channel)) {
294 
295 
296  const int numberofblocks = digitVec->ADC(1);
297 
298  int zerosuppressedindex = numberofblocks*2 + 2;
299 
300  //loop over all nonzero blocks
301  for(int i=0; i<numberofblocks; i++){
302 
303  const int lengthofblock = digitVec->ADC(2+numberofblocks+i);
304  rawadc.resize(lengthofblock);
305  holder.resize(lengthofblock);
306  rawadc_conv.resize(lengthofblock);
307 
308  for (int j=0;j<lengthofblock;j++)
309  {
310  rawadc[j] = digitVec->ADC(zerosuppressedindex);
311  zerosuppressedindex++;
312  }
313 
314 
315 
316  // loop over all adc values and subtract the pedestal
317  for(bin = 0; bin < rawadc.size(); ++bin)
318  rawadc_conv[bin]=(rawadc[bin]-digitVec->GetPedestal());
319 
320 
321  sigType = geom->SignalType(channel);
322  view = geom->View(channel);
323 
324  if(sigType == geo::kCollection){
325 
326  //Leave collection plane signals as is
327  for(bin = 0; bin < rawadc_conv.size(); ++bin)
328  holder[bin] = rawadc_conv[bin];
329  }
330  else if(sigType == geo::kInduction){
331 
332  //Integrate over signal in induction planes
333  for(bin = 0; bin < rawadc_conv.size(); ++bin)
334  holder[bin] = (bin>0) ? rawadc_conv[bin] + holder[bin-1] : rawadc_conv[bin];
335  }
336 
337 
338 
339  //Beginning of Gaussian hit finder loop over signal blocks
340 
341 
342  //##############################
343  //### Looping over the wires ###
344  //##############################
345 
346  //for(size_t wireIter = 0; wireIter < wirecol->size(); wireIter++){
347 
348  //art::Ptr<recob::Wire> wire(wirecol, wireIter);
349 
350  //std::vector<recob::Wire>::iterator wire;
351  //for(wire=wirecol->begin(); wire != wirecol->end(); wire++){
352  // --- Setting Channel Number and Wire Number as well as signal type ---
353  //channel = wire->RawDigit()->Channel();
354 
355 
356  // -----------------------------------------------------------
357  // -- Clearing variables at the start of looping over wires --
358  // -----------------------------------------------------------
359  startTimes.clear();
360  maxTimes.clear();
361  endTimes.clear();
362  //std::vector<float> signal(wire->Signal());
363  std::vector<float> signal(holder);
364  std::vector<float>::iterator timeIter; // iterator for time bins
365  time = 0;
366  minTimeHolder = 0;
367  maxFound = false;
368  // -- Setting the appropriate signal widths and thresholds --
369  // -- for either the collection or induction plane --
370  if(sigType == geo::kInduction){
371  threshold = fMinSigInd;
372  fitWidth = fIndWidth;
373  minWidth = fIndMinWidth;
374  }//<-- End if Induction Plane
375  else if(sigType == geo::kCollection){
376  threshold = fMinSigCol;
377  fitWidth = fColWidth;
378  minWidth = fColMinWidth;
379  }//<-- End if Collection Plane
380 
381 
382  // ##################################
383  // ### Looping over Signal Vector ###
384  // ##################################
385  for(timeIter = signal.begin();timeIter+2<signal.end();timeIter++){
386  // ##########################################################
387  // ### LOOK FOR A MINIMUM ###
388  // ### Testing if the point timeIter+1 is at a minimum by ###
389  // ### checking if timeIter and timeIter+1 and if it is ###
390  // ### then we add this to the endTimes ###
391  // ##########################################################
392  if(*timeIter > *(timeIter+1) && *(timeIter+1) < *(timeIter+2)){
393  //--- Note: We only keep the a minimum if we've already ---
394  //--- found a point above threshold ---
395  if(maxFound){
396  endTimes.push_back(time+1);
397  maxFound = false;
398  //keep these in case new hit starts right away
399  minTimeHolder = time+2;
400  }
401  else minTimeHolder = time+1;
402 
403  }//<---End Checking if this is a minimum
404 
405 
406  // ########################################################
407  // ### Testing if the point timeIter+1 is a maximum and ###
408  // ### if it and is above threshold then we add it to ###
409  // ### the startTime ###
410  // ########################################################
411  //if not a minimum, test if we are at a local maximum
412  //if so, and the max value is above threshold, add it and proceed.
413  else if(*timeIter < *(timeIter+1) && *(timeIter+1) > *(timeIter+2) && *(timeIter+1) > threshold){
414  maxFound = true;
415  maxTimes.push_back(time+1);
416  startTimes.push_back(minTimeHolder);
417  }
418 
419  time++;
420 
421  }//end loop over signal vec
422 
423  // ###########################################################
424  // ### If there was no minimum found before the end, but a ###
425  // ### maximum was found then add an end point to the end ###
426  // ###########################################################
427  while( maxTimes.size() > endTimes.size() ){
428  endTimes.push_back(signal.size()-1);
429 
430  }//<---End maxTimes.size > endTimes.size
431 
432  // ####################################################
433  // ### If no startTime hit was found skip this wire ###
434  // ####################################################
435  if( startTimes.size() == 0 ){
436  continue;
437  }
438 
439  /////////////////////////////////////////////////////////////////////////////
440  /////////////////////////////////////////////////////////////////////////////
441 
442  // ##########################################################
443  // ### PERFORM THE FITTING, ADDING HITS TO THE HIT VECTOR ###
444  // ##########################################################
445 
446  //All code below does the fitting, adding of hits
447  //to the hit vector and when all wires are complete
448  //saving them
449 
450  double totSig(0); //stores the total hit signal
451  double startT(0); //stores the start time
452  double endT(0); //stores the end time
453  int numHits(0); //number of consecutive hits being fitted
454  int size(0); //size of data vector for fit
455  int hitIndex(0); //index of current hit in sequence
456  double amplitude(0); //fit parameters
457  double minPeakHeight(0); //lowest peak height in multi-hit fit
458 
459 
460  StartIime = 0; // stores the start time of the hit
461  StartTimeError = 0; // stores the error assoc. with the start time of the hit
462  EndTime = 0; // stores the end time of the hit
463  EndTimeError = 0; // stores the error assoc. with the end time of the hit
464  RMS = 0; // stores the RMS from the gaussian fit
465  MeanPosition = 0; // stores the peak time position of the hit
466  MeanPosError = 0; // stores the error assoc. with thte peak time of the hit
467  Charge = 0; // stores the total charge assoc. with the hit
468  ChargeError = 0; // stores the error on the charge
469  Amp = 0; // stores the amplitude of the hit
470  AmpError = 0; // stores the error assoc. with the amplitude
471  NumOfHits = 0; // stores the multiplicity of the hit
472  FitGoodnes = 0; // stores the Chi2/NDF of the hit
473  FitNDF = -1; // stores the NDF of the hit
474 
475 
476 
477  //stores gaussian paramters first index is the hit number
478  //the second refers to height, position, and width respectively
479  std::vector<double> hitSig;
480 
481  // ########################################
482  // ### Looping over the hitIndex Vector ###
483  // ########################################
484  while( hitIndex < (signed)startTimes.size() ) {
485  // --- Zeroing Start Times and End Times ---
486  startT = 0;
487  endT = 0;
488  // Note: numHits is hardcoded to one here (Need to fix!)
489  numHits=1;
490 
491  minPeakHeight = signal[maxTimes[hitIndex]];
492 
493  // consider adding pulse to group of consecutive hits if:
494  // 1 less than max consecutive hits
495  // 2 we are not at the last point in the signal vector
496  // 3 the height of the dip between the two is greater than threshold/2
497  // 4 and there is no gap between them
498  while(numHits < fMaxMultiHit && numHits+hitIndex < (signed)endTimes.size() &&
499  signal[endTimes[hitIndex+numHits-1]] >threshold/2.0 &&
500  startTimes[hitIndex+numHits] - endTimes[hitIndex+numHits-1] < 2){
501  if(signal[maxTimes[hitIndex+numHits]] < minPeakHeight){
502  minPeakHeight=signal[maxTimes[hitIndex+numHits]];
503 
504  }//<---Only move the mean peakHeight in this hit
505 
506  numHits++;//<---Interate the multihit function
507 
508  }//<---End multihit while loop
509 
510 
511 
512  // ###########################################################
513  // ### Finding the first point from the beginning (startT) ###
514  // ### which is greater then 1/2 the smallest peak ###
515  // ###########################################################
516  startT=startTimes[hitIndex];
517  while(signal[(int)startT] < minPeakHeight/2.0) {startT++;}
518 
519  // #########################################################
520  // ### Finding the first point from the end (endT) which ###
521  // ### is greater then 1/2 the smallest peak ###
522  // #########################################################
523  endT=endTimes[hitIndex+numHits-1];
524  while(signal[(int)endT] <minPeakHeight/2.0) {endT--;}
525 
526 
527  // ###############################################################
528  // ### Putting the current considered hit into a 1-D Histogram ###
529  // ###############################################################
530  //--- Size of hit = endT - startT ---
531  size = (int)(endT-startT);
532 
533  // ###########################################################################
534  // ### Bug Fix: For ADC counts occuring at the end of the ticks range ###
535  // ### the hitfinder incorrectly assigns the size of the hit as a negative ###
536  // ### number...so we fix this to be 0 so that this hit is skipped ###
537  // ###########################################################################
538  if(size < 0){size = 0;}
539 
540 
541  // --- TH1D HitSignal ---
542  TH1D hitSignal("hitSignal","",size,startT,endT);
543 
544  for(int i = (int)startT; i < (int)endT; i++){
545  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546  // ~~~ Filling the pulse signals into TH1D histograms ~~~
547  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548  hitSignal.Fill(i,signal[i]);
549 
550  //std::cout<<"i = "<<i<<" , signal[i] = "<<signal[i]<<std::endl;
551  }//<---End for looping over startT and endT
552 
553 
554  // ##################################################################################################
555  // ### Trying to utilize the old approach of builing my TF1 and then implementing this new method ###
556  // ##################################################################################################
557 
558  // ########################################################
559  // ### Building TFormula for seedHit and basic Gaussian ###
560  // ########################################################
561  eqn = "gaus(0)";
562  for(int i = 3; i < numHits*3; i+=3){
563  eqn.append("+gaus(");
564  numConv.str("");
565  numConv << i;
566  eqn.append(numConv.str());
567  eqn.append(")");
568  }
569 
570 
571 
572  // --- TF1 function for GausHit ---
573  TF1 Gaus("Gaus",eqn.c_str(),0,size);
574 
575  // ##############################################################################
576  // ### For multi-pulse hits we loop over all the hits and fit N Gaus function ###
577  // ##############################################################################
578  if(numHits > 1) {
579  // --- Loop over numHits ---
580  for(int i = 0; i < numHits; ++i){
581 
582  // ###################################################################
583  // ### Set the parameters of the Gaus hit based on the seedHit fit ###
584  // ###################################################################
585  //amplitude = 0.5*(threshold+signal[maxTimes[hitIndex+i]]);
586 
587  amplitude = signal[maxTimes[hitIndex+i]];
588  Gaus.SetParameter(3*i,amplitude);
589  Gaus.SetParameter(1+3*i, maxTimes[hitIndex+i]);
590  Gaus.SetParameter(2+3*i, fitWidth);
591  Gaus.SetParLimits(3*i, 0.0, 3.0*amplitude);
592  Gaus.SetParLimits(1+3*i, startT , endT);
593  Gaus.SetParLimits(2+3*i, 0.0, 10.0*fitWidth);
594  }//end loop over hits
595  }//end if numHits > 1
596 
597  // ######################################################################
598  // ### For single pulse hits we perform a fit using a single Gaussian ###
599  // ######################################################################
600  else{
601 
602  Gaus.SetParameters(signal[maxTimes[hitIndex]],maxTimes[hitIndex],fitWidth);
603  Gaus.SetParLimits(0,0.0,1.5*signal[maxTimes[hitIndex]]);
604  Gaus.SetParLimits(1, startT , endT);
605  Gaus.SetParLimits(2,0.0,10.0*fitWidth);
606  }
607 
608  // ####################################################
609  // ### PERFORMING THE TOTAL GAUSSIAN FIT OF THE HIT ###
610  // ####################################################
611  hitSignal.Sumw2();
612 
613  hitSignal.Fit(&Gaus,"QNRW","", startT, endT);
614  //hitSignal.Fit(&Gaus,"QR0LLi","", startT, endT);
615 
616 
617  for(int hitNumber = 0; hitNumber < numHits; ++hitNumber){
618  totSig = 0;
619 
620 
621  // ###########################################################
622  // ### Record this hit if the amplitude is > threshold/2.0 ###
623  // ### and the width is > minWidth ###
624  // ###########################################################
625  if(Gaus.GetParameter(3*hitNumber) > threshold/2.0 &&
626  Gaus.GetParameter(3*hitNumber+2) > minWidth){
627  StartIime = Gaus.GetParameter(3*hitNumber+1) - Gaus.GetParameter(3*hitNumber+2); // position - width
628 
629  EndTime = Gaus.GetParameter(3*hitNumber+1) + Gaus.GetParameter(3*hitNumber+2); // position + width
630 
631  MeanPosition = Gaus.GetParameter(3*hitNumber+1);
632  StartIime = Gaus.GetParameter(3*hitNumber+2); // width
633 
634  //StartTimeError = TMath::Sqrt( (Gaus.GetParError(3*hitNumber+1)*Gaus.GetParError(3*hitNumber+1)) +
635  // (Gaus.GetParError(3*hitNumber+2)*Gaus.GetParError(3*hitNumber+2)));
636 
637  //EndTimeError = TMath::Sqrt( (Gaus.GetParError(3*hitNumber+1)*Gaus.GetParError(3*hitNumber+1)) +
638  // (Gaus.GetParError(3*hitNumber+2)*Gaus.GetParError(3*hitNumber+2)));
639 
640 
641  //MeanPosError = Gaus.GetParError(3*hitNumber+1);
642 
643 
644 
645 
646  hitSig.resize(size);
647  for(int sigPos = 0; sigPos<size; sigPos++){ //<---Loop over the size (endT - startT)
648 
649  hitSig[sigPos] = Gaus.GetParameter(3*hitNumber)*TMath::Gaus(sigPos+startT,Gaus.GetParameter(3*hitNumber+1), Gaus.GetParameter(3*hitNumber+2));
650  totSig+=hitSig[(int)sigPos];
651 
652  }//<---End Signal postion loop
653 
654  // --- Getting the total charge using the area method ---
655  if(fAreaMethod) {
656  totSig = std::sqrt(2*TMath::Pi())*Gaus.GetParameter(3*hitNumber)*Gaus.GetParameter(3*hitNumber+2)/fAreaNorms[(size_t)sigType];
657 
658  }//<---End Area Method
659  Charge = totSig;
660  // ---------------------------------------------------------------------------------
661  // --- chargeErr=TMath::Sqrt(TMath::Pi())*(amplitudeErr*width+widthErr*amplitude); ---
662  // -----------------------------------------------------------------------------------
663  ChargeError = TMath::Sqrt(TMath::Pi())*(Gaus.GetParError(3*hitNumber+0)*Gaus.GetParameter(3*hitNumber+2)+
664  Gaus.GetParError(3*hitNumber+2)*Gaus.GetParameter(3*hitNumber+0)); //estimate from area of Gaussian
665  Amp = Gaus.GetParameter(3*hitNumber);
666  AmpError = Gaus.GetParError(3*hitNumber);
667  NumOfHits = numHits;
668 
669  // #######################################################
670  // ### Using seeded values to get a better estimate of ###
671  // ### the errors associated with the fit ###
672  // #######################################################
673  // -----------------------------------------
674  // --- Determing the goodness of the fit ---
675  // -----------------------------------------
676  hit->SetParameters(Amp,MeanPosition, Gaus.GetParameter(3*hitNumber+2));
677  hit->FixParameter(0,Amp);
678  //hit->SetParLimits(0,Amp/2, Amp*2);
679  //hit->FixParameter(1,MeanPosition);
680  hit->SetParLimits(1,MeanPosition - 3, MeanPosition + 3);
681  //hit->FixParameter(2,Gaus.GetParameter(3*hitNumber+2));//<---Should I be setting the fitWidth initally
682  // #############################
683  // ### Perform Hit on Signal ###
684  // #############################
685 
686 
687  float TempStartTime = MeanPosition - 4;
688  float TempEndTime = MeanPosition + 4;
689 
690  hitSignal.Fit(hit,"QNRLLi","", TempStartTime, TempEndTime);
691 
692 
693  FitGoodnes = hit->GetChisquare() / hit->GetNDF();
694  FitNDF = hit->GetNDF();
695 
696  StartTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
697  (hit->GetParError(2)*hit->GetParError(2)));
698 
699  EndTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
700  (hit->GetParError(2)*hit->GetParError(2)));
701 
702 
703  MeanPosError = hit->GetParError(1);
704 
705  // ####################################################################################
706  // ### Skipping hits with a chi2/NDF larger than the value defined in the .fcl file ###
707  // ####################################################################################
708  if(FitGoodnes > fChi2NDF){continue;}
709 
710  // get the WireID for this hit
711  std::vector<geo::WireID> wids = geom->ChannelToWire(channel);
712  ///\todo need to have a disambiguation algorithm somewhere in here
713  // for now, just take the first option returned from ChannelToWire
714  geo::WireID wid = wids[0];
715 
716  recob::Hit hit(
717  channel, // channel
718  (raw::TDCtick_t) startT, // start_tick
719  (raw::TDCtick_t) endT, // end_tick
720  MeanPosition, // peak_time
721  MeanPosError, // sigma_peak_time
722  RMS, // rms,
723  Amp, // peak_amplitude,
724  AmpError, // sigma_peak_amplitude
725  std::accumulate // summedADC
726  (signal.begin() + TempStartTime, signal.begin() + TempEndTime, 0.),
727  Charge, // hit_integral
728  ChargeError, // hit_sigma_integral
729  NumOfHits, // multiplicity
730  hitNumber, // local_index
731  FitGoodnes, // goodness_of_fit
732  FitNDF, // dof
733  view, // view
734  sigType, // signal_type
735  wid // wireID
736  );
737  hcol.emplace_back(std::move(hit), digitVec);
738 
739  }//<---End looking at hits over threshold
740 
741  }//<---End Looping over numHits
742 
743 
744  hitIndex+=numHits;
745  }//<---End while hitIndex < startTimes.size()
746 
747 
748 
749  //}//<---End looping over wireIter
750 
751 
752  //std::cout << "Test1" << std::endl;
753 
754 
755  } // end loop over nonzero blocks
756 
757 
758  } // end if not a bad channel
759 
760 
761  } // end loop over wires
762 
763  // move the hit collection and the associations into the event
764  hcol.put_into(evt);
765 
766  delete chanFilt;
767 
768 
769  return;
770  }
intermediate_table::iterator iterator
double fIndWidth
Initial width for induction fit.
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool BadChannel(uint32_t channel) const
double fColMinWidth
Minimum collection hit width.
double fColWidth
Initial width for collection fit.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
uint8_t channel
Definition: CRTFragment.hh:201
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
double fIndMinWidth
Minimum induction hit width.
Zero Suppression algorithm.
Definition: RawTypes.h:11
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
A class handling a collection of hits and its associations.
Definition: HitCreator.h:508
Signal from induction planes.
Definition: geo_types.h:145
enum geo::_plane_sigtype SigType_t
def move(depos, offset)
Definition: depos.py:107
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
double fMinSigCol
Collection signal height threshold.
Detector simulation of raw signals on wires.
int fMaxMultiHit
maximum hits for multi fit
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
double fMinSigInd
Induction signal height threshold.
QTextStream & bin(QTextStream &s)
double StartIime
maximum Chisquared / NDF allowed for a hit to be saved
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
int fAreaMethod
Type of area calculation.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
std::vector< double > fAreaNorms
factors for converting area to same units as peak height
Signal from collection planes.
Definition: geo_types.h:146
void calgaushf::CalGausHFDUNE10kt::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 158 of file CalGausHFDUNE10kt_module.cc.

159  {
160  fDigitModuleLabel = p.get< std::string >("DigitModuleLabel", "daq");
161  fPostsample = p.get< int > ("PostsampleBins");
162  fDeconvKernSize = p.get< int > ("DeconvKernSize");
163 
164  fSpillName="";
165 
166  size_t pos = fDigitModuleLabel.find(":");
167  if( pos!=std::string::npos ) {
168  fSpillName = fDigitModuleLabel.substr( pos+1 );
169  fDigitModuleLabel = fDigitModuleLabel.substr( 0, pos );
170  }
171 
172  // Implementation of optional member function here.
173  //fCalDataModuleLabel = p.get< std::string >("CalDataModuleLabel");
174  fMinSigInd = p.get< double >("MinSigInd");
175  fMinSigCol = p.get< double >("MinSigCol");
176  fIndWidth = p.get< double >("IndWidth");
177  fColWidth = p.get< double >("ColWidth");
178  fIndMinWidth = p.get< double >("IndMinWidth");
179  fColMinWidth = p.get< double >("ColMinWidth");
180  fMaxMultiHit = p.get< int >("MaxMultiHit");
181  fAreaMethod = p.get< int >("AreaMethod");
182  fAreaNorms = p.get< std::vector< double > >("AreaNorms");
183  fChi2NDF = p.get< double >("Chi2NDF");
184 
185 
186  }
double fIndWidth
Initial width for induction fit.
std::string string
Definition: nybbler.cc:12
double fColMinWidth
Minimum collection hit width.
double fColWidth
Initial width for collection fit.
double fIndMinWidth
Minimum induction hit width.
int fPostsample
number of postsample bins
p
Definition: test.py:223
double fMinSigCol
Collection signal height threshold.
int fMaxMultiHit
maximum hits for multi fit
double fMinSigInd
Induction signal height threshold.
int fAreaMethod
Type of area calculation.
std::vector< double > fAreaNorms
factors for converting area to same units as peak height

Member Data Documentation

double calgaushf::CalGausHFDUNE10kt::Amp
private

Definition at line 126 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::AmpError
private

Definition at line 127 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::Charge
private

Definition at line 128 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::ChargeError
private

Definition at line 129 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::EndTime
private

Definition at line 120 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::EndTimeError
private

Definition at line 121 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::fAreaMethod
private

Type of area calculation.

Definition at line 112 of file CalGausHFDUNE10kt_module.cc.

std::vector<double> calgaushf::CalGausHFDUNE10kt::fAreaNorms
private

factors for converting area to same units as peak height

Definition at line 113 of file CalGausHFDUNE10kt_module.cc.

std::string calgaushf::CalGausHFDUNE10kt::fCalDataModuleLabel
private

Definition at line 104 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fChi2NDF
private

Definition at line 114 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fColMinWidth
private

Minimum collection hit width.

Definition at line 110 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fColWidth
private

Initial width for collection fit.

Definition at line 108 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::fDeconvKernSize
private

Definition at line 96 of file CalGausHFDUNE10kt_module.cc.

std::string calgaushf::CalGausHFDUNE10kt::fDigitModuleLabel
private

constants

module that made digits

Definition at line 99 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fIndMinWidth
private

Minimum induction hit width.

Definition at line 109 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fIndWidth
private

Initial width for induction fit.

Definition at line 107 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::FitGoodnes
private

Definition at line 130 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::FitNDF
private

Definition at line 131 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::fMaxMultiHit
private

maximum hits for multi fit

Definition at line 111 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fMinSigCol
private

Collection signal height threshold.

Definition at line 106 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::fMinSigInd
private

Induction signal height threshold.

Definition at line 105 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::fPostsample
private

number of postsample bins

Definition at line 98 of file CalGausHFDUNE10kt_module.cc.

std::string calgaushf::CalGausHFDUNE10kt::fSpillName
private

nominal spill is an empty string it is set by the DigitModuleLabel ex.: "daq:preSpill" for prespill data

Definition at line 101 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::MeanPosError
private

Definition at line 125 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::MeanPosition
private

Definition at line 124 of file CalGausHFDUNE10kt_module.cc.

int calgaushf::CalGausHFDUNE10kt::NumOfHits
private

Definition at line 123 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::RMS
private

Definition at line 122 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::StartIime
private

maximum Chisquared / NDF allowed for a hit to be saved

Definition at line 118 of file CalGausHFDUNE10kt_module.cc.

double calgaushf::CalGausHFDUNE10kt::StartTimeError
private

Definition at line 119 of file CalGausHFDUNE10kt_module.cc.


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