ROOTANA
TDT724Waveform.cxx
Go to the documentation of this file.
1 #include "TDT724Waveform.h"
2 
3 #include "TDT724RawData.hxx"
4 #include "TDirectory.h"
5 
6 
7 /// Reset the histograms for this canvas
9 
10  SetSubTabName("DT724 Waveforms");
12  SetNanosecsPerSample(10); //ADC clock runs at 100Mhz on the 724 = units of 10 nsecs
13 
15 
16 }
17 
18 
20 
21  // check if we already have histogramss.
22  char tname[100];
23  sprintf(tname,"DT724_%i",0);
24 
25  TH1D *tmp = (TH1D*)gDirectory->Get(tname);
26  if (tmp) return;
27 
28  int fWFLength = 2000; // Need a better way of detecting this...
29  int numSamples = fWFLength / nanosecsPerSample;
30 
31  // Otherwise make histograms
32  clear();
33 
34  for(int i = 0; i < 2; i++){ // loop over 2 channels
35 
36  char name[100];
37  char title[100];
38  sprintf(name,"DT724_%i",i);
39 
40  sprintf(title,"DT724 Waveform for channel=%i",i);
41 
42  TH1D *tmp = new TH1D(name, title, numSamples, 0, fWFLength);
43  tmp->SetXTitle("ns");
44  tmp->SetYTitle("ADC value");
45 
46  push_back(tmp);
47  }
48  std::cout << "TDT724Waveform done init...... " << std::endl;
49 
50 }
51 
52 
54 
55  int eventid = dataContainer.GetMidasData().GetEventId();
56  int timestamp = dataContainer.GetMidasData().GetTimeStamp();
57 
58  TDT724RawData *dt724 = dataContainer.GetEventData<TDT724RawData>("D724");
59 
60  if(dt724){
61 
62 
63  std::vector<RawChannelMeasurement> measurements = dt724->GetMeasurements();
64 
65  for(int i = 0; i < measurements.size(); i++){
66 
67  int chan = measurements[i].GetChannel();
68 
69 
70  // Reset the histogram...
71  for(int ib = 0; ib < GetHistogram(chan)->GetNbinsX(); ib++)
72  GetHistogram(chan)->SetBinContent(ib+1,0);
73 
74  //std::cout << "Nsamples " << measurements[i].GetNSamples() << std::endl;
75  for(int ib = 0; ib < measurements[i].GetNSamples(); ib++){
76  GetHistogram(chan)->SetBinContent(ib+1, measurements[i].GetSample(ib));
77  }
78 
79  }
80  }
81 
82 }
83 
84 
85 
87 
88 
89  for(int i = 0; i < 8; i++){ // loop over channels
90  int index = i;
91 
92  // Reset the histogram...
93  for(int ib = 0; ib < GetHistogram(index)->GetNbinsX(); ib++) {
94  GetHistogram(index)->SetBinContent(ib, 0);
95  }
96 
97  GetHistogram(index)->Reset();
98 
99  }
100 }
R__EXTERN TDirectory * gDirectory
Class to store raw data from CAEN 100MHz DT724 (for raw readout, no-DPP).
std::vector< RawChannelMeasurement > & GetMeasurements()
Get the Vector of TDC Measurements.
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void SetNanosecsPerSample(int nsecsPerSample)
void UpdateHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
TDT724Waveform()
Reset the histograms for this canvas.
T * GetEventData(const char *name)
Add a templated function that returns event data in the format that we want.
TMidasEvent & GetMidasData() const
Get the MIDAS data for this event, in TMidasEvent format.
virtual TObject * Get(const char *namecycle)
virtual void SetSubTabName(std::string name)
Set the name of the sub-tab for these plots, if running DaqDisplay.
virtual void SetUpdateOnlyWhenPlotted(bool whenupdate)
TH1 * GetHistogram(unsigned i)
A helper method for accessing each histogram. Does bounds checking.
uint16_t GetEventId() const
return the event id
Definition: TMidasEvent.cxx:93
uint32_t GetTimeStamp() const
return the time stamp (unix time in seconds)