PAASS
Software suite to Acquire and Analyze Data from Pixie16
scope.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
4 // PixieCore libraries
5 #include "ChannelEvent.hpp"
6 #include "HelperFunctions.hpp"
7 #include "XiaData.hpp"
8 
9 // Local files
10 #include "scope.hpp"
11 
12 #ifdef USE_HRIBF
13 #include "GetArguments.hpp"
14 #include "Scanor.hpp"
15 #include "ScanorInterface.hpp"
16 #endif
17 
18 // Root files
19 #include "TSystem.h"
20 #include "TStyle.h"
21 #include "TMath.h"
22 #include "TGraph.h"
23 #include "TH2F.h"
24 #include "TAxis.h"
25 #include "TFile.h"
26 #include "TF1.h"
27 #include "TLine.h"
28 #include "TProfile.h"
29 #include "TPaveStats.h"
30 
31 // Define the name of the program.
32 #ifndef PROG_NAME
33 #define PROG_NAME "Scope"
34 #endif
35 
36 #define ADC_TIME_STEP 4 // ns
37 #define SLEEP_WAIT 1E4 // When not in shared memory mode, length of time to wait after gSystem->ProcessEvents is called (in us).
38 
56 double PaulauskasFitFunc(double *x, double *p) {
57  //Compute the time difference between x and the phase corrected for clock ticks.
58  float diff = (x[0] - p[2])/ADC_TIME_STEP;
59  //If the difference is less than zero we return the baseline.
60  if (diff < 0 ) return p[0];
61  //Return the computed function.
62  return p[0] + p[1] * exp(-diff * p[3]) * (1 - exp(-pow(diff * p[4],4)));
63 }
64 
66 // class scopeUnpacker
68 
70 scopeUnpacker::scopeUnpacker(const unsigned int &mod/*=0*/, const unsigned int &chan/*=0*/) : Unpacker(){
71  mod_ = mod;
72  chan_ = chan;
73  threshLow_ = 0;
74  threshHigh_ = -1;
75 }
76 
82  if(!addr_){ return; }
83 
84  XiaData *current_event = NULL;
85 
86  // Fill the processor event deques with events
87  while(!rawEvent.empty()){
88  if(!running)
89  break;
90 
91  //Get the first event in the FIFO.
92  current_event = rawEvent.front();
93  rawEvent.pop_front();
94 
95  // Safety catches for null event or empty ->GetTrace().
96  if(!current_event || current_event->GetTrace().empty()){
97  continue;
98  }
99 
100  // Pass this event to the correct processor
101  double maximum =
102  TraceFunctions::FindMaximum(current_event->GetTrace(),
103  current_event->GetTrace().size()).second;
104  if(current_event->GetModuleNumber() == mod_ && current_event->GetChannelNumber() == chan_){
105  //Check threhsold.
106  if (maximum < threshLow_) {
107  delete current_event;
108  continue;
109  }
110  if (threshHigh_ > threshLow_ && maximum > threshHigh_) {
111  delete current_event;
112  continue;
113  }
114 
115  //Store the waveform in the stack of waveforms to be displayed.
116  if(addr_->AddEvent(current_event)){
117  addr_->ProcessEvents();
118  }
119  }
120  }
121 }
122 
124 // class scopeScanner
126 
128 scopeScanner::scopeScanner(int mod /*= 0*/, int chan/*=0*/) : RootScanner() {
129  need_graph_update = false;
130  resetGraph_ = false;
131  acqRun_ = true;
132  singleCapture_ = false;
133  init = false;
134  running = true;
135  performFit_ = false;
136  performCfd_ = false;
137  numEvents = 20;
138  numAvgWaveforms_ = 1;
139  cfdF_ = 0.5;
140  cfdD_ = 1;
141  cfdL_ = 1;
142  fitLow_ = 10;
143  fitHigh_ = 15;
144  delay_ = 2;
145  num_displayed = 0;
146  time(&last_trace);
147 
148  graph = new TGraph();
149  cfdLine = new TLine();
150  cfdLine->SetLineColor(kRed);
151  cfdPol3 = new TF1("cfdPol3", "pol3");
152  cfdPol3->SetLineColor(kGreen+1);
153  cfdPol2 = new TF1("cfdPol2", "pol2");
154  cfdPol2->SetLineColor(kMagenta+1);
155 
156  hist = new TH2F("hist","",256,0,1,256,0,1);
157 
158  SetupFunc();
159 
160  gStyle->SetPalette(51);
161 
162  //Display the stats: Integral
163  gStyle->SetOptStat(1000000);
164 
165  //Display Fit Stats: Fit Values, Errors, and ChiSq.
166  gStyle->SetOptFit(111);
167 }
168 
171  delete graph;
172  delete cfdLine;
173  delete cfdPol3;
174  delete cfdPol2;
175  delete hist;
176  delete paulauskasFunc;
177 }
178 
180  paulauskasFunc = new TF1("paulauskas",PaulauskasFitFunc,0,1,5);
181  paulauskasFunc->SetParNames("voffset","amplitude","phase","beta","gamma");
182 
183  return paulauskasFunc;
184 }
185 
186 void scopeScanner::ResetGraph(unsigned int size) {
187  delete graph;
188 
189  graph = new TGraph(size);
190  graph->SetMarkerStyle(kFullDotSmall);
191 
192  if(size != x_vals.size()){
193  std::cout << msgHeader << "Changing trace length from " << x_vals.size()*ADC_TIME_STEP << " to " << size*ADC_TIME_STEP << " ns.\n";
194  x_vals.resize(size);
195  for(size_t index = 0; index < x_vals.size(); index++)
196  x_vals[index] = ADC_TIME_STEP * index;
197  }
198  hist->SetBins(x_vals.size(), x_vals.front(), x_vals.back() + ADC_TIME_STEP, 1, 0, 1);
199 
200  std::stringstream stream;
201  stream << "M" << ((scopeUnpacker*)core)->GetMod() << "C" << ((scopeUnpacker*)core)->GetChan();
202  graph->SetTitle(stream.str().c_str());
203  hist->SetTitle(stream.str().c_str());
204 
205  resetGraph_ = false;
206 }
207 
209  static float histAxis[2][2];
210 
211  if(chanEvents_.size() < numAvgWaveforms_)
212  return;
213 
214  if(chanEvents_.front()->size != x_vals.size()){ // The length of the trace has changed.
215  resetGraph_ = true;
216  }
217  if (resetGraph_) {
218  ResetGraph(chanEvents_.front()->size);
219  ResetZoom();
220  for (int i=0;i<2;i++) {
221  histAxis[i][0] = 1E9;
222  histAxis[i][1] = -1E9;
223  }
224  }
225 
226  //For a waveform pulse we use a graph.
227  if (numAvgWaveforms_ == 1) {
228  int index = 0;
229  for (size_t i = 0; i < chanEvents_.front()->size; ++i) {
230  graph->SetPoint(index, x_vals[i], chanEvents_.front()->event->GetTrace().at(i));
231  index++;
232  }
233 
234  UpdateZoom();
235 
236  graph->Draw("AP0");
237 
238  float lowVal = (chanEvents_.front()->max_index - fitLow_) * ADC_TIME_STEP;
239  float highVal = (chanEvents_.front()->max_index + fitHigh_) * ADC_TIME_STEP;
240 
242  /*
243  if(performCfd_){
244  ChannelEvent *evt = chanEvents_.front();
245 
246  // Find the zero-crossing of the cfd waveform.
247  float cfdCrossing = evt->AnalyzeCFD(cfdF_);
248 
249  // Draw the cfd crossing line.
250  cfdLine->DrawLine(cfdCrossing*ADC_TIME_STEP, userZoomVals[1][0], cfdCrossing*ADC_TIME_STEP, userZoomVals[1][1]);
251 
252  // Draw the 3rd order polynomial.
253  cfdPol3->SetParameter(0, evt->cfdPar[0]);
254  cfdPol3->SetParameter(1, evt->cfdPar[1]/ADC_TIME_STEP);
255  cfdPol3->SetParameter(2, evt->cfdPar[2]/std::pow(ADC_TIME_STEP, 2.0));
256  cfdPol3->SetParameter(3, evt->cfdPar[3]/std::pow(ADC_TIME_STEP, 3.0));
257  // Find the pulse maximum by fitting with a third order polynomial.
258  if(evt->event->adcTrace[evt->max_index-1] >= evt->event->adcTrace[evt->max_index+1]) // Favor the left side of the pulse.
259  cfdPol3->SetRange((evt->max_index - 2)*ADC_TIME_STEP, (evt->max_index + 1)*ADC_TIME_STEP);
260  else // Favor the right side of the pulse.
261  cfdPol3->SetRange((evt->max_index - 1)*ADC_TIME_STEP, (evt->max_index + 2)*ADC_TIME_STEP);
262  cfdPol3->Draw("SAME");
263 
264  // Draw the 2nd order polynomial.
265  cfdPol2->SetParameter(0, evt->cfdPar[4]);
266  cfdPol2->SetParameter(1, evt->cfdPar[5]/ADC_TIME_STEP);
267  cfdPol2->SetParameter(2, evt->cfdPar[6]/std::pow(ADC_TIME_STEP, 2.0));
268  cfdPol2->SetRange((evt->cfdIndex - 1)*ADC_TIME_STEP, (evt->cfdIndex + 1)*ADC_TIME_STEP);
269  cfdPol2->Draw("SAME");
270  }
271  */
272 
273  if(performFit_){
274  paulauskasFunc->SetRange(lowVal, highVal);
275  paulauskasFunc->SetParameters(chanEvents_.front()->baseline, 0.5 * chanEvents_.front()->qdc, lowVal, 0.5, 0.1);
276  paulauskasFunc->FixParameter(0, chanEvents_.front()->baseline);
277  graph->Fit(paulauskasFunc,"QMER");
278  }
279  }
280  else { //For multiple events with make a 2D histogram and plot the profile on top.
281  //Determine the maximum and minimum values of the events.
282  for (unsigned int i = 0; i < numAvgWaveforms_; i++) {
283  ChannelEvent* evt = chanEvents_.at(i);
284  float evtMin = *std::min_element(evt->event->GetTrace().begin(), evt->event->GetTrace().end());
285  float evtMax = *std::max_element(evt->event->GetTrace().begin(), evt->event->GetTrace().end());
286  evtMin -= fabs(0.1 * evtMax);
287  evtMax += fabs(0.1 * evtMax);
288  if (evtMin < histAxis[1][0]) histAxis[1][0] = evtMin;
289  if (evtMax > histAxis[1][1]) histAxis[1][1] = evtMax;
290  }
291 
292  //Reset the histogram
293  hist->Reset();
294 
295  //Rebin the histogram
296  hist->SetBins(x_vals.size(), x_vals.front(), x_vals.back() + ADC_TIME_STEP, histAxis[1][1] - histAxis[1][0], histAxis[1][0], histAxis[1][1]);
297 
298  //Fill the histogram
299  for (unsigned int i = 0; i < numAvgWaveforms_; i++) {
300  ChannelEvent* evt = chanEvents_.at(i);
301  for (size_t i=0; i < evt->size; ++i) {
302  hist->Fill(x_vals[i], evt->event->GetTrace()[i]);
303  }
304  }
305 
306  prof = hist->ProfileX("AvgPulse");
307  prof->SetLineColor(kRed);
308  prof->SetMarkerColor(kRed);
309 
310  float lowVal = prof->GetBinCenter(prof->GetMaximumBin() - fitLow_);
311  float highVal = prof->GetBinCenter(prof->GetMaximumBin() + fitHigh_);
312 
313  if(performFit_){
314  paulauskasFunc->SetRange(lowVal, highVal);
315  paulauskasFunc->SetParameters(chanEvents_.front()->baseline, 0.5 * chanEvents_.front()->qdc, lowVal, 0.5, 0.2);
316  paulauskasFunc->FixParameter(0, chanEvents_.front()->baseline);
317  prof->Fit(paulauskasFunc,"QMER");
318  }
319 
320  hist->SetStats(false);
321  hist->Draw("COLZ");
322  prof->Draw("SAMES");
323 
324  UpdateZoom();
325 
326  GetCanvas()->Update();
327  TPaveStats* stats = (TPaveStats*) prof->GetListOfFunctions()->FindObject("stats");
328  if (stats) {
329  stats->SetX1NDC(0.55);
330  stats->SetX2NDC(0.9);
331  }
332  }
333 
334  // Remove the events from the deque.
335  for (unsigned int i = 0; i < numAvgWaveforms_; i++) {
336  delete chanEvents_.front();
337  chanEvents_.pop_front();
338  }
339 
340  // Update the canvas.
341  GetCanvas()->Update();
342 
343  // Save the TGraph to a file.
344  if (saveFile_ != "") {
345  TFile f(saveFile_.c_str(), "RECREATE");
346  graph->Clone("trace")->Write();
347  f.Close();
348  saveFile_ = "";
349  }
350 
351  num_displayed++;
352 }
353 
359 bool scopeScanner::Initialize(std::string prefix_){
360  if(init){ return false; }
361 
362  // Print a small welcome message.
363  std::cout << " Displaying traces for mod = " << ((scopeUnpacker*)core)->GetMod() << ", chan = " << ((scopeUnpacker*)core)->GetChan() << ".\n";
364 
365  return (init = true);
366 }
367 
372 void scopeScanner::Notify(const std::string &code_/*=""*/){
373  if(code_ == "START_SCAN"){
374  ClearEvents();
375  acqRun_ = true;
376  }
377  else if(code_ == "STOP_SCAN"){ acqRun_ = false; }
378  else if(code_ == "SCAN_COMPLETE"){ std::cout << msgHeader << "Scan complete.\n"; }
379  else if(code_ == "LOAD_FILE"){ std::cout << msgHeader << "File loaded.\n"; }
380  else if(code_ == "REWIND_FILE"){ }
381  else{ std::cout << msgHeader << "Unknown notification code '" << code_ << "'!\n"; }
382 }
383 
389  if(!core){ core = (Unpacker*)(new scopeUnpacker()); }
390  return core;
391 }
392 
399  if(!event_){ return false; }
400 
401  //Get the first event int the FIFO.
402  ChannelEvent *channel_event = new ChannelEvent(event_);
403 
404  //Process the waveform.
406  //channel_event->ComputeBaseline();
407  //channel_event->FindQDC();
408 
409  //Push the channel event into the deque.
410  chanEvents_.push_back(channel_event);
411 
412  // Handle the individual XiaData.
413  if(chanEvents_.size() >= numAvgWaveforms_)
414  return true;
415 
416  return false;
417 }
418 
424  //Check if we have delayed the plotting enough
425  time_t cur_time;
426  time(&cur_time);
427  while(difftime(cur_time, last_trace) < delay_) {
428  //If in shm mode and the plotting time has not alloted the events are cleared and this function is aborted.
429  if (ShmMode()) {
430  ClearEvents();
431  return false;
432  }
433  else {
434  IdleTask();
435  time(&cur_time);
436  }
437  }
438 
439  //When we have the correct number of waveforms we plot them.
440  Plot();
441 
442  //If this is a single capture we stop the plotting.
443  if (singleCapture_) running = false;
444 
445  //Update the time.
446  time(&last_trace);
447 
448  return true;
449 }
450 
452  while(!chanEvents_.empty()){
453  delete chanEvents_.front();
454  chanEvents_.pop_front();
455  }
456 }
457 
464 void scopeScanner::CmdHelp(const std::string &prefix_/*=""*/){
465  std::cout << " set <module> <channel> - Set the module and channel of signal of interest (default = 0, 0).\n";
466  std::cout << " stop - Stop the acquistion.\n";
467  std::cout << " run - Run the acquistion.\n";
468  std::cout << " single - Perform a single capture.\n";
469  std::cout << " thresh <low> [high] - Set the plotting window for trace maximum.\n";
470  std::cout << " fit <low> <high> - Turn on fitting of waveform. Set <low> to \"off\" to disable.\n";
471  std::cout << " cfd [F=0.5] [D=1] [L=1] - Turn on cfd analysis of waveform. Set [F] to \"off\" to disable.\n";
472  std::cout << " avg <numWaveforms> - Set the number of waveforms to average.\n";
473  std::cout << " save <fileName> - Save the next trace to the specified file name..\n";
474  std::cout << " delay [time] - Set the delay between drawing traces (in seconds, default = 1 s).\n";
475  std::cout << " log - Toggle log/linear mode on the y-axis.\n";
476  std::cout << " clear - Clear all stored traces and start over.\n";
477 }
478 
486  AddOption(optionExt("mod", required_argument, NULL, 'M', "<module>", "Module of signal of interest (default=0)"));
487  AddOption(optionExt("chan", required_argument, NULL, 'C', "<channel>", "Channel of signal of interest (default=0)"));
488 }
489 
494 void scopeScanner::SyntaxStr(char *name_){
495  std::cout << " usage: " << std::string(name_) << " [options]\n";
496 }
497 
505  if(userOpts.at(0).active)
506  std::cout << msgHeader << "Set module to (" << ((scopeUnpacker*)core)->SetMod(atoi(userOpts.at(0).argument.c_str())) << ").\n";
507  if(userOpts.at(1).active)
508  std::cout << msgHeader << "Set channel to (" << ((scopeUnpacker*)core)->SetChan(atoi(userOpts.at(1).argument.c_str())) << ").\n";
509 }
510 
518 bool scopeScanner::ExtraCommands(const std::string &cmd_, std::vector<std::string> &args_){
519  if(cmd_ == "set"){ // Toggle debug mode
520  if(args_.size() == 2){
521  // Clear all events from the event deque.
522  ClearEvents();
523 
524  // Set the module and channel.
525  ((scopeUnpacker*)core)->SetMod(atoi(args_.at(0).c_str()));
526  ((scopeUnpacker*)core)->SetChan(atoi(args_.at(1).c_str()));
527 
528  resetGraph_ = true;
529  }
530  else{
531  std::cout << msgHeader << "Invalid number of parameters to 'set'\n";
532  std::cout << msgHeader << " -SYNTAX- set <module> <channel>\n";
533  }
534  }
535  else if(cmd_ == "single") {
537  }
538  else if (cmd_ == "thresh") {
539  if (args_.size() == 1) {
540  ((scopeUnpacker*)core)->SetThreshLow(atoi(args_.at(0).c_str()));
541  ((scopeUnpacker*)core)->SetThreshHigh(-1);
542  }
543  else if (args_.size() == 2) {
544  ((scopeUnpacker*)core)->SetThreshLow(atoi(args_.at(0).c_str()));
545  ((scopeUnpacker*)core)->SetThreshHigh(atoi(args_.at(1).c_str()));
546  }
547  else {
548  std::cout << msgHeader << "Invalid number of parameters to 'thresh'\n";
549  std::cout << msgHeader << " -SYNTAX- thresh <lowerThresh> [upperThresh]\n";
550  }
551  }
552  else if (cmd_ == "fit") {
553  if (args_.size() >= 1 && args_.at(0) == "off") { // Turn root fitting off.
554  if(performFit_){
555  std::cout << msgHeader << "Disabling root fitting.\n";
556  delete graph->GetListOfFunctions()->FindObject(paulauskasFunc->GetName());
557  GetCanvas()->Update();
558  performFit_ = false;
559  }
560  else{ std::cout << msgHeader << "Fitting is not enabled.\n"; }
561  }
562  else if (args_.size() == 2) { // Turn root fitting on.
563  fitLow_ = atoi(args_.at(0).c_str());
564  fitHigh_ = atoi(args_.at(1).c_str());
565  std::cout << msgHeader << "Setting root fitting range to [" << fitLow_ << ", " << fitHigh_ << "].\n";
566  performFit_ = true;
567  }
568  else {
569  std::cout << msgHeader << "Invalid number of parameters to 'fit'\n";
570  std::cout << msgHeader << " -SYNTAX- fit <low> <high>\n";
571  std::cout << msgHeader << " -SYNTAX- fit off\n";
572  }
573  }
574  else if (cmd_ == "cfd") {
575  cfdF_ = 0.5;
576  cfdD_ = 1;
577  cfdL_ = 1;
578  if (args_.empty()) { performCfd_ = true; }
579  else if (args_.size() == 1) {
580  if(args_.at(0) == "off"){ // Turn cfd analysis off.
581  if(performCfd_){
582  std::cout << msgHeader << "Disabling cfd analysis.\n";
583  performCfd_ = false;
584  }
585  else{ std::cout << msgHeader << "Cfd is not enabled.\n"; }
586  }
587  else{
588  cfdF_ = atof(args_.at(0).c_str());
589  performCfd_ = true;
590  }
591  }
592  else if (args_.size() == 2) {
593  cfdF_ = atof(args_.at(0).c_str());
594  cfdD_ = atoi(args_.at(1).c_str());
595  performCfd_ = true;
596  }
597  else if (args_.size() == 3) {
598  cfdF_ = atof(args_.at(0).c_str());
599  cfdD_ = atoi(args_.at(1).c_str());
600  cfdL_ = atoi(args_.at(2).c_str());
601  performCfd_ = true;
602  }
603  if(performCfd_)
604  std::cout << msgHeader << "Enabling cfd analysis with F=" << cfdF_ << ", D=" << cfdD_ << ", L=" << cfdL_ << std::endl;
605  }
606  else if (cmd_ == "avg") {
607  if (args_.size() == 1) {
608  numAvgWaveforms_ = atoi(args_.at(0).c_str());
609  }
610  else {
611  std::cout << msgHeader << "Invalid number of parameters to 'avg'\n";
612  std::cout << msgHeader << " -SYNTAX- avg <numWavefroms>\n";
613  }
614  }
615  else if(cmd_ == "save") {
616  if (args_.size() == 1) {
617  saveFile_ = args_.at(0);
618  }
619  else {
620  std::cout << msgHeader << "Invalid number of parameters to 'save'\n";
621  std::cout << msgHeader << " -SYNTAX- save <fileName>\n";
622  }
623  }
624  else if(cmd_ == "delay"){
625  if(args_.size() == 1){ delay_ = atoi(args_.at(0).c_str()); }
626  else{
627  std::cout << msgHeader << "Invalid number of parameters to 'delay'\n";
628  std::cout << msgHeader << " -SYNTAX- delay <time>\n";
629  }
630  }
631  else if(cmd_ == "log"){
632  if(GetCanvas()->GetLogy()){
633  GetCanvas()->SetLogy(0);
634  std::cout << msgHeader << "y-axis set to linear.\n";
635  }
636  else{
637  GetCanvas()->SetLogy(1);
638  std::cout << msgHeader << "y-axis set to log.\n";
639  }
640  }
641  else if(cmd_ == "clear"){
642  ClearEvents();
643  std::cout << msgHeader << "Event deque cleared.\n";
644  }
645  else{ return false; }
646 
647  return true;
648 }
649 
650 
651 #ifndef USE_HRIBF
652 int main(int argc, char *argv[]){
653  // Define a new unpacker object.
655 
656  // Set the output message prefix.
657  scanner.SetProgramName(std::string(PROG_NAME));
658 
659  // Initialize the scanner.
660  if(!scanner.Setup(argc, argv))
661  return 1;
662 
663  // Run the main loop.
664  int retval = scanner.Execute();
665 
666  scanner.Close();
667 
668  return retval;
669 }
670 #else
671 scopeScanner *scanner = NULL;
672 
673 // Do some startup stuff.
674 extern "C" void startup_()
675 {
676  scanner = new scopeScanner();
677 
678  // Handle command line arguments from SCANOR
679  scanner->Setup(GetNumberArguments(), GetArguments());
680 
681  // Get a pointer to a class derived from Unpacker.
683 }
684 
688 extern "C" void drrsub_(uint32_t &iexist) {
689  drrmake_();
690  hd1d_(8000, 2, 256, 256, 0, 255, "Run DAMM you!", strlen("Run DAMM you!"));
691  endrr_();
692 }
693 
694 // Catch the exit call from scanor and clean up c++ objects CRT
695 extern "C" void cleanup_()
696 {
697  // Do some cleanup.
698  std::cout << "\nCleaning up..\n";
699  scanner->Close();
700  delete scanner;
701 }
702 #endif
703 
int main(int argc, char *argv[])
Definition: scope.cpp:652
bool running
True if debug mode is set.
Definition: Unpacker.hpp:115
TCanvas * GetCanvas()
Definition: RootScanner.hpp:15
virtual bool AddEvent(XiaData *event_)
TF1 * SetupFunc()
Definition: scope.cpp:179
time_t last_trace
The time of the last trace.
Definition: scope.hpp:212
scopeScanner(int mod=0, int chan=0)
Default constructor.
Definition: scope.cpp:128
void ClearEvents()
Definition: scope.cpp:451
void IdleTask()
Definition: RootScanner.cpp:30
int GetNumberArguments(void)
void startup_()
Do some startup stuff.
Definition: utkscanor.cpp:23
virtual void ExtraArguments()
Definition: scope.cpp:504
bool performCfd_
Definition: scope.hpp:207
TLine * cfdLine
Definition: scope.hpp:217
void UpdateZoom(TVirtualPad *pad=gPad)
Definition: RootScanner.cpp:47
virtual void CmdHelp(const std::string &prefix_="")
Definition: scope.cpp:464
virtual void Notify(const std::string &code_="")
Definition: scope.cpp:372
StatsData stats
Instance of the class (not sure why -SVP)
Definition: StatsData.cpp:19
std::deque< XiaData * > rawEvent
The list of all events in a spill.
Definition: Unpacker.hpp:118
TF1 * paulauskasFunc
A TF1 of the Paulauskas Function (NIM A 737 (2014) 22)
Definition: scope.hpp:223
size_t numEvents
Definition: scope.hpp:191
A file containing stand-alone functions (only depend on standard C++ headers) that are used in the so...
virtual bool AddEvent(XiaData *event_)
Definition: scope.cpp:398
int delay_
Definition: scope.hpp:198
bool running
Definition: scope.hpp:205
unsigned int GetChannelNumber() const
Definition: XiaData.hpp:113
bool Close()
Shutdown cleanly.
void AddOption(optionExt opt_)
Pointer to class derived from Unpacker class.
TGraph * graph
The TGraph for plotting traces.
Definition: scope.hpp:216
bool need_graph_update
The number of seconds to wait between drawing traces.
Definition: scope.hpp:200
virtual bool ProcessEvents()
bool Setup(int argc, char *argv[])
Setup user options and initialize all required objects.
double PaulauskasFitFunc(double *x, double *p)
Definition: scope.cpp:56
UtkScanInterface * scanner
Definition: utkscanor.cpp:19
std::deque< ChannelEvent * > chanEvents_
The buffer of waveforms to be plotted.
Definition: scope.hpp:210
virtual void ArgHelp()
Definition: scope.cpp:485
virtual Unpacker * GetCore()
Definition: scope.cpp:388
unsigned int numAvgWaveforms_
Definition: scope.hpp:188
TH2F * hist
The histogram containing the waveform frequencies.
Definition: scope.hpp:220
void SetProgramName(const std::string &head_)
Set the header string used to prefix output messages.
int threshHigh_
Definition: scope.hpp:53
TF1 * cfdPol3
Definition: scope.hpp:218
void drrmake_()
DAMM initialization call.
Unpacker * core
bool acqRun_
Definition: scope.hpp:202
TF1 * cfdPol2
Definition: scope.hpp:219
XiaData * event
Ignore this event.
unsigned int mod_
The module of the signal of interest.
Definition: scope.hpp:50
std::string msgHeader
size_t size
y values for the cfd analyzed waveform.
bool ShmMode()
Return true if shared memory mode is enabled.
~scopeScanner()
Destructor.
Definition: scope.cpp:170
char ** GetArguments(void)
Returns an argv style array that can be used to pass to getopt and other similar functions.
scopeUnpacker(const unsigned int &mod=0, const unsigned int &chan=0)
Default constructor.
Definition: scope.cpp:70
virtual bool ExtraCommands(const std::string &cmd_, std::vector< std::string > &args_)
Definition: scope.cpp:518
bool singleCapture_
Definition: scope.hpp:203
void ResetGraph(unsigned int size_)
Definition: scope.cpp:186
TProfile * prof
The profile of the average histogram.
Definition: scope.hpp:221
std::vector< int > x_vals
Definition: scope.hpp:209
virtual void SyntaxStr(char *name_)
Definition: scope.cpp:494
#define ADC_TIME_STEP
Definition: scope.cpp:36
void drrsub_(uint32_t &iexist)
Defines the main interface with the SCANOR library, the program essentially starts here...
Definition: utkscanor.cpp:42
void Plot()
Plot the current event.
Definition: scope.cpp:208
static ScanorInterface * get()
int fitHigh_
Definition: scope.hpp:197
void endrr_()
DAMM declaration wrap-up call.
pair< unsigned int, double > FindMaximum(const vector< T > &data, const unsigned int &traceDelayInBins)
This function finds the maximum bin and the value of the maximum bin for the provided vector...
A pixie16 channel event.
Definition: XiaData.hpp:19
bool performFit_
Definition: scope.hpp:206
virtual bool Initialize(std::string prefix_="")
Definition: scope.cpp:359
bool resetGraph_
Set to true if the graph range needs updated.
Definition: scope.hpp:201
float cfdF_
The number of waveforms to store.
Definition: scope.hpp:193
virtual void ProcessRawEvent(ScanInterface *addr_=NULL)
Definition: scope.cpp:81
void ResetZoom(TVirtualPad *pad=gPad)
Definition: RootScanner.cpp:35
unsigned int num_displayed
The number of displayed traces.
Definition: scope.hpp:189
virtual bool ProcessEvents()
Definition: scope.cpp:423
std::string saveFile_
The name of the file to save a trace.
Definition: scope.hpp:214
int threshLow_
Definition: scope.hpp:52
std::vector< unsigned int > GetTrace() const
Definition: XiaData.hpp:155
void SetUnpacker(Unpacker *a)
#define PROG_NAME
Definition: scope.cpp:33
bool init
Definition: scope.hpp:204
int fitLow_
Definition: scope.hpp:196
void cleanup_()
Catch the exit call from scanor and clean up c++ objects CRT.
Definition: utkscanor.cpp:55
int Execute()
Run the program.
void hd1d_(const int &, const int &, const int &, const int &, const int &, const int &, const char *, int)
create a DAMM 1D histogram args are damm id, half-words per channel, param length, hist length, low x-range, high x-range, and title
std::vector< optionExt > userOpts
Base level command line options for the scan.
unsigned int chan_
The channel of the signal of interest.
Definition: scope.hpp:51
unsigned int GetModuleNumber() const
Definition: XiaData.hpp:141