ROOTANA
TV1730DppWaveform.cxx
Go to the documentation of this file.
1 #include "TV1730DppWaveform.h"
2 
3 #include "TV1730DppData.hxx"
4 #include "TDirectory.h"
5 
6 
7 /// Reset the histogram for this canvas
9 
10  SetSubTabName("V1730 DPP");
12  SetNumSamples(64);
13  SetNanosecsPerSample(2); //ADC clock runs at 500Mhz on the v1730 = units of 2 nsecs
14 
16 }
17 
18 
20 
21  // check if we already have histograms.
22  char tname[100];
23  sprintf(tname,"V1730Dpp_%i_%i",0,0);
24 
25  TH1D *tmp = (TH1D*)gDirectory->Get(tname);
26  if (tmp) return;
27 
28  // Otherwise make histogram
29  clear();
30 
31  for(int i = 0; i < 16; i++){ // loop over 16 channels
32 
33  char name[100];
34  char title[100];
35  sprintf(name,"V1730Dpp_%i",i);
36 
37  sprintf(title,"V1730 Waveform for channel=%i",i);
38 
39  TH1D *tmp = new TH1D(name, title, this->numSamples, 0, this->numSamples);
40  tmp->GetXaxis()->SetLimits(0, this->numSamples*this->nanosecsPerSample);
41  tmp->SetXTitle("ns");
42  tmp->SetYTitle("ADC value");
43 
44  push_back(tmp);
45  }
46 
47 
48 }
49 
50 
51 
52 
54 
55  int eventid = dataContainer.GetMidasData().GetEventId();
56  int timestamp = dataContainer.GetMidasData().GetTimeStamp();
57 
58  TV1730DppData *v1730 = dataContainer.GetEventData<TV1730DppData>("V730");
59 
60 
61  if(v1730 ){
62 
63 
64  std::vector<ChannelMeasurement> measurements = v1730->GetMeasurements();
65 
66  for(int i = 0; i < measurements.size(); i++){
67 
68  int chan = measurements[i].GetChannel();
69 
70  // Reset the histogram...
71  for(int ib = 0; ib < this->numSamples; ib++)
72  GetHistogram(chan)->SetBinContent(ib+1,0);
73 
74  // Hack!
75  float offset = 0;
76  if(chan == 1)
77  offset = 35;
78  //std::cout << "Nsamples " << measurements[i].GetNSamples() << std::endl;
79  for(int ib = 0; ib < measurements[i].GetNSamples(); ib++){
80 
81 
82  GetHistogram(chan)->SetBinContent(ib+1, measurements[i].GetSample(ib)-offset);
83  //std::cout << "Setting " << chan << " " << ib << " " << measurements[i].GetSample(ib) << std::endl;
84 
85  }
86 
87  }
88 
89  }
90 
91 }
92 
93 
95 
96  // Loop over all the data, reset histos
97  for(int iBoard=0; iBoard<32; iBoard++){// Loop over V1730Dpp boards
98  for(int i = 0; i < 8; i++){ // loop over channels
99  int index = iBoard*8 + i;
100 
101  // Reset the histogram...
102  for(int ib = 0; ib < 2500; ib++)
103  GetHistogram(index)->SetBinContent(ib,0);
104  GetHistogram(index)->Reset();
105  }
106  }
107 }
108 
109 /// Take actions at begin run
110 void TV1730DppWaveform::BeginRun(int transition,int run,int time){
111 
113 
114 }
115 
116 /// Take actions at end run
117 void TV1730DppWaveform::EndRun(int transition,int run,int time){
118 
119 }
R__EXTERN TDirectory * gDirectory
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)
Class to store DPP data from CAEN V1730.
std::vector< ChannelMeasurement > & GetMeasurements()
Get the Vector of TDC Measurements.
void SetNanosecsPerSample(int nsecsPerSample)
void UpdateHistograms(TDataContainer &dataContainer)
TV1730DppWaveform()
Reset the histogram for this canvas.
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void EndRun(int transition, int run, int time)
Take actions at end run
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void SetNumSamples(int numSamples)