ROOTANA
TCamacADCHistogram.cxx
Go to the documentation of this file.
1 #include "TCamacADCHistogram.h"
2 
3 #include "TCamacADCData.hxx"
4 #include "TDirectory.h"
5 
6 const int Nchannels = 12;
7 
8 /// Reset the histograms for this canvas
10 
11  SetSubTabName("Camac");
13 }
14 
15 
17 
18  // Otherwise make histograms
19  clear();
20 
21  for(int i = 0; i < Nchannels; i++){ // loop over channels
22 
23  char name[100];
24  char title[100];
25  sprintf(name,"CamacADC_%i_%i",0,i);
26 
27  // Delete old histograms, if we already have them
28  TH1D *old = (TH1D*)gDirectory->Get(name);
29  if (old){
30  delete old;
31  }
32 
33  // Create new histograms
34 
35  sprintf(title,"CAMAC ADC for channel=%i",i);
36 
37  TH1D *tmp = new TH1D(name,title,2100,0,2100);
38  tmp->SetYTitle("ADC value");
39  tmp->SetXTitle("Bin");
40  push_back(tmp);
41  }
42 
43 }
44 
45 
46 
47 
48 /// Update the histograms for this canvas.
50 
51  TCamacData *data = dataContainer.GetEventData<TCamacData>("ADC8");
52  if(!data) return;
53 
54  /// Get the Vector of ADC Measurements.
55  std::vector<CamacADCEvent> measurements = data->GetMeasurements();
56  for(unsigned int i = 0; i < measurements.size(); i++){ // loop over measurements
57 
58  // For each measurement, fill the ADC values for each channel.
59  for(unsigned int ch = 0; ch < 12; ch++){
60  GetHistogram(ch)->Fill(measurements[i].GetADC(ch));
61  }
62  }
63 }
64 
65 
66 
67 /// Take actions at begin run
68 void TCamacADCHistograms::BeginRun(int transition,int run,int time){
69 
71 
72 }
73 
74 /// Take actions at end run
75 void TCamacADCHistograms::EndRun(int transition,int run,int time){
76 
77 }
const int Nchannels
R__EXTERN TDirectory * gDirectory
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void UpdateHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
TCamacADCHistograms()
Reset the histograms for this canvas.
void EndRun(int transition, int run, int time)
Take actions at end run
std::vector< CamacADCEvent > & GetMeasurements()
Get the Vector of TDC Measurements.
T * GetEventData(const char *name)
Add a templated function that returns event data in the format that we want.
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.
TH1 * GetHistogram(unsigned i)
A helper method for accessing each histogram. Does bounds checking.