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

Public Member Functions

 OpHitFinderStandard (const fhicl::ParameterSet &pset)
 
 ~OpHitFinderStandard ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void outputHistograms (art::TFileDirectory &) const override
 
void FindOpHits (const raw::OpDetWaveform &, OpHitVec &) const override
 

Private Attributes

double fSPEArea
 
double fHitThreshold
 
int fBaselineSample
 

Additional Inherited Members

- Private Member Functions inherited from light::IOpHitFinder
virtual ~IOpHitFinder () noexcept=default
 

Detailed Description

Definition at line 23 of file OpHitFinderStandard_tool.cc.

Constructor & Destructor Documentation

light::OpHitFinderStandard::OpHitFinderStandard ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 43 of file OpHitFinderStandard_tool.cc.

44 {
45  configure(pset);
46 }
void configure(const fhicl::ParameterSet &pset) override
light::OpHitFinderStandard::~OpHitFinderStandard ( )

Definition at line 48 of file OpHitFinderStandard_tool.cc.

49 {
50 }

Member Function Documentation

void light::OpHitFinderStandard::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Implements light::IOpHitFinder.

Definition at line 52 of file OpHitFinderStandard_tool.cc.

53 {
54  fHitThreshold = pset.get< double >("HitThreshold");
55  fSPEArea = pset.get< double >("SPEArea");
56  fBaselineSample = pset.get< int >("BaselineSample");
57 
58  return;
59 }
void light::OpHitFinderStandard::FindOpHits ( const raw::OpDetWaveform opDetWaveform,
OpHitVec opHitVec 
) const
overridevirtual

Implements light::IOpHitFinder.

Definition at line 62 of file OpHitFinderStandard_tool.cc.

64 {
65  int chNumber = opDetWaveform.ChannelNumber();
66  std::cout << "Photon channel: " << chNumber << std::endl;
67  // Load pulses into WaveformVector
68  //std::vector < short_t > WaveformVector = wvf.Waveform();
69 
70  int grsize = opDetWaveform.size();
71 
72  //std::vector<Double_t> TimeVector;
73  //std::vector<Double_t> ADCVector;
74 
75  //TimeVector.size()= grsize;
76  //ADCVector.size()= grsize;
77 
78  double TimeVector[10000];
79  double ADCVector[10000];
80 
81  unsigned short frame;
82  double Area;
83  double fasttotal;
84  double time_abs;
85  double FWHM;
86  double phelec;
87 
88  double baseline=0;
89 
90  for (int btime =0; btime< fBaselineSample; btime++)
91  {
92  baseline = baseline+ opDetWaveform[btime];
93  }
94 
95  baseline = baseline/fBaselineSample;
96 
97  std::cout << "Baseline " << baseline << std::endl;
98 
99 
100  for (int wtime=0; wtime< grsize; wtime++)
101  {
102  TimeVector[wtime] = wtime;
103  ADCVector[wtime] = -(opDetWaveform[wtime]-baseline);
104  }
105 
106  TGraph *gr = new TGraph(grsize,TimeVector,ADCVector);
107 
108  int n_graph = gr->GetN();
109  double *y_graph = gr->GetY();
110 
111  int min_time = TMath::LocMax(n_graph,y_graph);
112  double min_time_to_put = TMath::LocMax(n_graph,y_graph);
113  double min = y_graph[min_time];
114  double min_to_put = min;
115 
116  std::cout << "Min " << min << std::endl;
117 
118  if (min>fHitThreshold)
119  {
120  TF1 *funz= new TF1("funz", "pol1(0)", min_time-2.0, min_time);
121 
122  gr->Fit("funz","R");
123 
124  double start_moment = funz->GetX(baseline, 0, min_time);
125 
126  std::cout << "Start " << start_moment << std::endl;
127 
128  TF1 *gauss_start= new TF1("gauss_start", "gaus", min_time-5.0, min_time);
129  TF1 *gauss_end = new TF1("gauss_end", "gaus", min_time, min_time+10);
130 
131  gauss_start->SetParameter(1,min_time);
132  gauss_end->SetParameter(1,min_time);
133 
134  gr->Fit("gauss_start","R");
135 
136  double Constant1 = gauss_start->GetParameter(0);
137  //double Mean1 = gauss_start->GetParameter(1);
138  double Sigma1 = gauss_start->GetParameter(2);
139 
140  std::cout << "GaussParam 00 " << gauss_start->GetParameter(0) << "GaussParam 01 " << gauss_start->GetParameter(1) << "GaussParam 02 " << gauss_start->GetParameter(2) << std::endl;
141 
142  gr->Fit("gauss_end","R");
143 
144  double Constant2 = gauss_end->GetParameter(0);
145  //double Mean2 = gauss_end->GetParameter(1);
146  double Sigma2 = gauss_end->GetParameter(2);
147 
148  std::cout << "GaussParam 10 " << gauss_end->GetParameter(0) << "GaussParam 11 " << gauss_end->GetParameter(1) << "GaussParam 12 " << gauss_end->GetParameter(2) << std::endl;
149 
150  frame = 1;
151  Area = ((Constant1*Sigma1)/2 + (Constant2*Sigma2)/2)*sqrt(2*3.14159);
152  fasttotal = 3/4;
153  time_abs = sqrt(min_time_to_put);
154  FWHM = 2.35*((Sigma1+Sigma2)/2);
155  phelec = Area/fSPEArea;
156 
157  // recob::OpHit adcVec(chNumber, min_time_to_put, time_abs, frame, FWHM, Area, min_to_put, phelec, fasttotal);//including hit info
158  // pulseVecPtr->emplace_back(std::move(adcVec));
159 
160  funz->~TF1();
161  gauss_start->~TF1();
162  gauss_end->~TF1();
163  gr->~TGraph();
164  }
165  else
166  {
167  //std::cout << "No OpHit in channel " << chNumber << std::endl;
168  min_time_to_put=0;
169  min_to_put=0;
170  Area=0;
171  frame=0;
172  fasttotal=0;
173  time_abs=0;
174  FWHM=0;
175  phelec=0;
176  }
177 
178  recob::OpHit opHit(chNumber, min_time_to_put, time_abs, frame, FWHM, Area, min_to_put, phelec, fasttotal);
179 
180  opHitVec.push_back(recob::OpHit());
181  opHitVec.back() = opHit;
182 
183  return;
184 }
BEGIN_PROLOG baseline
BEGIN_PROLOG could also be cout
void light::OpHitFinderStandard::outputHistograms ( art::TFileDirectory &  histDir) const
overridevirtual

Implements light::IOpHitFinder.

Definition at line 186 of file OpHitFinderStandard_tool.cc.

187 {
188  // It is assumed that the input TFileDirectory has been set up to group histograms into a common
189  // folder at the calling routine's level. Here we create one more level of indirection to keep
190  // histograms made by this tool separate.
191 /*
192  std::string dirName = "OpHitFinderPlane_" + std::to_string(fPlane);
193 
194  art::TFileDirectory dir = histDir.mkdir(dirName.c_str());
195 
196  auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
197  double samplingRate = detprop->SamplingRate();
198  double numBins = fOpHitFinderVec.size();
199  double maxFreq = 500. / samplingRate;
200  std::string histName = "OpHitFinderPlane_" + std::to_string(fPlane);
201 
202  TH1D* hist = dir.make<TH1D>(histName.c_str(), "OpHitFinder;Frequency(MHz)", numBins, 0., maxFreq);
203 
204  for(int bin = 0; bin < numBins; bin++)
205  {
206  double freq = maxFreq * double(bin + 0.5) / double(numBins);
207 
208  hist->Fill(freq, fOpHitFinderVec.at(bin).Re());
209  }
210 */
211 
212  return;
213 }

Member Data Documentation

int light::OpHitFinderStandard::fBaselineSample
private

Definition at line 38 of file OpHitFinderStandard_tool.cc.

double light::OpHitFinderStandard::fHitThreshold
private

Definition at line 37 of file OpHitFinderStandard_tool.cc.

double light::OpHitFinderStandard::fSPEArea
private

Definition at line 36 of file OpHitFinderStandard_tool.cc.


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