ROOTANA
TComplicatedExampleCanvas.cxx
Go to the documentation of this file.
2 
3 //#include "TGHorizontalFrame.h"
4 #include "TGNumberEntry.h"
5 #include <TGLabel.h>
6 
7 #include "TV792Data.hxx"
8 
10 
11  for(int i = 0; i < 32; i++){
12  char name[100];
13  char title[100];
14  sprintf(name,"adcValue%i",i+10);
15  sprintf(title,"ADC values for channel %i",i);
16  adcValue[i] = new TH1F(name,title,2000,0,4000);
17  }
18 }
19 
20 void TComplicatedExampleCanvas::SetUpCompositeFrame(TGCompositeFrame *compFrame, TRootanaDisplay *display){
21 
22 
23  // Now create my embedded canvas, along with the various buttons for this canvas.
24 
25  TGHorizontalFrame *labelframe = new TGHorizontalFrame(compFrame,200,40);
26 
27  fBankCounterButton = new TGNumberEntry(labelframe, 0, 9,999, TGNumberFormat::kNESInteger,
28  TGNumberFormat::kNEANonNegative,
29  TGNumberFormat::kNELLimitMinMax,
30  0, 31);
31 
32  fBankCounterButton->Connect("ValueSet(Long_t)", "TRootanaDisplay", display, "UpdatePlotsAction()");
33  fBankCounterButton->GetNumberEntry()->Connect("ReturnPressed()", "TRootanaDisplay", display, "UpdatePlotsAction()");
34  labelframe->AddFrame(fBankCounterButton, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
35  TGLabel *labelMinicrate = new TGLabel(labelframe, "ADC Channel (0-31)");
36  labelframe->AddFrame(labelMinicrate, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
37 
38  compFrame->AddFrame(labelframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
39 
40 
41 }
42 
43 
44 
45 /// Reset the histograms for this canvas
47 
48  for(int i = 0; i < 32; i++)
49  adcValue[i]->Reset();
50 }
51 
52 /// Update the histograms for this canvas.
54 
55  // Get the V792 data
56  TV792Data *v792 = dataContainer.GetEventData<TV792Data>("ADC0");
57  if(v792 ){
58 
59  // Loop over ADC measurements
60  std::vector<VADCMeasurement>& measurements = v792->GetMeasurements();
61  for(unsigned int i = 0; i < measurements.size(); i++){
62  VADCMeasurement adcmeas = measurements[i];
63 
64  // For each measurement, update histogram
65  int chan = adcmeas.GetChannel();
66  if(chan >= 0 && chan < 32){
67  adcValue[chan]->Fill(adcmeas.GetMeasurement());
68  }
69  }
70  }
71 }
72 
73 /// Plot the histograms for this canvas
74 void TComplicatedExampleCanvas::PlotCanvas(TDataContainer& dataContainer, TRootEmbeddedCanvas *embedCanvas){
75 
76  TCanvas* c1 = embedCanvas->GetCanvas();
77  c1->Clear();
78  int whichbank = fBankCounterButton->GetNumberEntry()->GetIntNumber();
79  if(whichbank >=0 && whichbank <32)
80  adcValue[whichbank]->Draw();
81  c1->Modified();
82  c1->Update();
83 
84 }
void PlotCanvas(TDataContainer &dataContainer, TRootEmbeddedCanvas *embedCanvas)
Plot the histograms for this canvas.
void UpdateCanvasHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
void ResetCanvasHistograms()
Reset the histograms for this canvas.
void SetUpCompositeFrame(TGCompositeFrame *compFrame, TRootanaDisplay *display)
T * GetEventData(const char *name)
Add a templated function that returns event data in the format that we want.
Class for storing data from CAEN V792 module.
Definition: TV792Data.hxx:53
std::vector< VADCMeasurement > & GetMeasurements()
Get the Vector of TDC Measurements.
Definition: TV792Data.hxx:77
uint32_t GetMeasurement() const
Get the ADC measurement.
Definition: TV792Data.hxx:17
uint32_t GetChannel() const
Get the channel number.
Definition: TV792Data.hxx:26