AlgoSSPLeadingEdge.cc
Go to the documentation of this file.
1 //=========================================================
2 // AlgoSSPLeadingEdge.cc
3 // This class provides the digital output for the
4 // Leading Edge Discrimintator, used in SSP module.
5 //
6 // Vitor Luzio, UFABC, 2017
7 // Based on AlgoSiPM.cxx
8 //=========================================================
9 
10 
11 
13 
14 namespace pmtana {
15 
16  //---------------------------------------------------------------------------
18  : PMTPulseRecoBase(name)
19  {
20 
21  _adc_thres = pset.get< float >("ADCThreshold" );
22 // _min_width = pset.get< float >("MinWidth" );
23 // _2nd_thres = pset.get< float >("SecondThreshold");
24  _pedestal = pset.get< float >("Pedestal" );
25  _dwindow = pset.get< int >("DWindow" );
26  _rdwindow = pset.get< size_t >("ReadoutWd" );
27  _pretrg = pset.get< size_t >("PreTrg" );
28 
29  // std::cout << "VITOR DEBUG" << std::endl;
30  // std::cout << "ADCThreshold = " << _adc_thres << std::endl;
31  // std::cout << "DWindow = " << _dwindow << std::endl;
32  // std::cout << "Readout Window = " << _rdwindow << std::endl;
33  // std::cout << "Pre Trigger = " << _pretrg << std::endl;
34  // std::cout << "VITOR DEBUG" << std::endl;
35 
36 
37 
38 
39 // _nsigma = 5;
40 
41  Reset();
42 
43  }
44 
45  //---------------------------------------------------------------------------
47  {}
48 
49  //---------------------------------------------------------------------------
51  {
52 
54 
55  }
56 
57  //---------------------------------------------------------------------------
59  const pmtana::PedestalMean_t& ped_mean,
60  const pmtana::PedestalSigma_t& ped_rms )
61  {
62 
63  bool fire = false;
64  int counter = 0;
65  double pedestal = _pedestal;
66  double threshold = _adc_thres;
67  double threshold2 = _adc_thres;
68  threshold += pedestal;
69  // double pre_threshold = _2nd_thres;
70  // pre_threshold += pedestal;
71 
72  int d_window = _dwindow;
73  int timer = 0; //time to delay the wf and compare amplitudes
74  int readout_window = _rdwindow; //from 0 to 2046 in SSP
75  int readout_pretrigger = _pretrg; //(from 0 to 2047 in SSP)
76  double threshold_cmp;
77  int tamanho, cnt2;
78 
79  Reset();
80  tamanho = wf.size();
81 
82 
83  for (short const &value : wf) {
84 
85  cnt2 = value;
86  if(cnt2 != value){std::cout << "teste VITOR" << std::endl; }
87 
88  if (counter < (tamanho - d_window )) {
89 
90  threshold_cmp = wf[counter+d_window]-wf[counter];
91 
92 
93  if (threshold_cmp >= threshold2){
94 
95  if(timer==0){trg_wvf.emplace_back(counter+d_window);}
96 
97  if(!fire && timer==0){
98  fire = true;
99  if(readout_pretrigger < (counter + d_window)){
100  _pulse.t_start = counter + d_window - readout_pretrigger;
101  }else{
102  _pulse.t_start = 1;
103  }
104  timer++;
105  }else if(timer>0 && timer < d_window){
106  timer++;
107  }else if(timer == d_window){
108  timer=0;
109  }
110 
111  }else {
112  if(timer>0 && timer < d_window){timer++;}
113  else if(timer==d_window || timer==0 ){timer=0;}
114 
115  }
116  if (fire==true && counter == (_pulse.t_start + readout_window)){ //we need to configure the _min_widht to be 700 bins
117  fire = false;
118  _pulse.t_end = counter - 1;
119  _pulse_v.push_back(_pulse);
121 
122  }
123  }
124 
125  counter++;
126 
127  }
128 
129  if (fire) { //It's not mine, but is a good strategy to handle the pulses at the end of waveform
130 
131  // Take care of a pulse that did not finish within the readout window
132 
133  fire = false;
134  _pulse.t_end = tamanho;
135  _pulse_v.push_back(_pulse);
137 
138  }
139 
140  return true;
141 
142  }
143 
144 }
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
static QCString name
Definition: declinfo.cpp:673
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
std::string string
Definition: nybbler.cc:12
void Reset()
A method to be called event-wise to reset parameters.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::vector< short > Waveform_t
std::vector< double > PedestalMean_t
AlgoSSPLeadingEdge(const fhicl::ParameterSet &pset, const std::string name="AlgoSSPLeadingEdge")
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
QTextStream & endl(QTextStream &s)