ROOTANA
TTRB3Histogram.cxx
Go to the documentation of this file.
1 #include "TTRB3Histogram.hxx"
2 
3 #include "TTRB3Data.hxx"
4 #include "TDirectory.h"
5 
6 const int NchannelPerFpga = 64; /// what is right value?
7 const int Nfpga = 4;
8 
9 /// Reset the histograms for this canvas
11 
12  SetSubTabName("TRB3 Histograms");
13  SetGroupName("FPGA");
16 }
17 
18 
20 
21 
22  // Otherwise make histograms
23  clear();
24 
25  std::cout << "Create Histos" << std::endl;
26  for(int j = 0; j < Nfpga; j++){ // loop over FPGA
27  for(int i = 0; i < NchannelPerFpga; i++){ // loop over channels
28 
29  char name[100];
30  char title[100];
31  sprintf(name,"TRB3_%i_%i",j,i);
32 
33  // Delete old histograms, if we already have them
34  TH1D *old = (TH1D*)gDirectory->Get(name);
35  if (old){
36  delete old;
37  }
38 
39 
40  // Create new histograms
41 
42  sprintf(title,"TRB3 histogram for fpga=%i channel=%i",j, i);
43 
44  TH1D *tmp = new TH1D(name,title,500000,0,10000000);
45  tmp->SetXTitle("Hit time (ps)");
46  tmp->SetYTitle("Number of Entries");
47  push_back(tmp);
48  }
49  }
50 
51 }
52 
53 
54 
55 
56 /// Update the histograms for this canvas.
58 
59  TTRB3Data *data = dataContainer.GetEventData<TTRB3Data>("TRB0");
60  if(!data) data = dataContainer.GetEventData<TTRB3Data>("TRBA");
61  if(data){
62  //data->Print();
63 
64  double reftime = 0;
65  for(int i = 0; i < data->GetNumberMeasurements(); i++){
66  std::vector<TrbTdcMeas> meas = data->GetMeasurements();
67  double time = meas[i].GetFinalTime();
68  uint32_t id = meas[i].GetBoardId();
69  uint32_t ch = meas[i].GetChannel();
70  int hch = NchannelPerFpga*id + ch;
71  // std::cout << hch << " " << id << " " << ch << std::endl;
72  GetHistogram(hch)->Fill(time);
73 
74  }
75 
76  }
77 
78 }
79 
80 
81 
82 /// Take actions at begin run
83 void TTRB3Histograms::BeginRun(int transition,int run,int time){
84 
86 
87 }
88 
89 
90 /// Reset the histograms for this canvas
92 
93  SetSubTabName("TRB3 Fine Histograms");
94  SetGroupName("FPGA");
97 }
98 
99 
101 
102 
103  // Otherwise make histograms
104  clear();
105 
106  for(int j = 0; j < Nfpga; j++){ // loop over FPGA
107  for(int i = 0; i < NchannelPerFpga; i++){ // loop over channels
108 
109  char name[100];
110  char title[100];
111  sprintf(name,"TRB3_Fine_%i_%i",j,i);
112 
113  // Delete old histograms, if we already have them
114  TH1D *old = (TH1D*)gDirectory->Get(name);
115  if (old){
116  delete old;
117  }
118 
119 
120  // Create new histograms
121 
122  sprintf(title,"TRB3 Fine Times for fpga=%i channel=%i",j, i);
123 
124  TH1D *tmp = new TH1D(name,title,512,-0.5,511.5);
125  tmp->SetXTitle("Fine Time (DC)");
126  tmp->SetYTitle("Number of Entries");
127  push_back(tmp);
128  }
129  }
130 
131 }
132 
133 
134 
135 
136 /// Update the histograms for this canvas.
138 
139  TTRB3Data *data = dataContainer.GetEventData<TTRB3Data>("TRB0");
140  if(!data) data = dataContainer.GetEventData<TTRB3Data>("TRBA");
141  if(data){
142  double reftime = 0;
143  for(int i = 0; i < data->GetNumberMeasurements(); i++){
144  std::vector<TrbTdcMeas> meas = data->GetMeasurements();
145  uint32_t id = meas[i].GetBoardId();
146  uint32_t ch = meas[i].GetChannel();
147  int hch = NchannelPerFpga*id + ch;
148  GetHistogram(hch)->Fill(meas[i].GetFineTime());
149  }
150  }
151 }
152 
153 
154 
155 /// Take actions at begin run
156 void TTRB3FineHistograms::BeginRun(int transition,int run,int time){
158 }
159 
160 
161 
162 
163 /// Reset the histograms for this canvas
165 
166  SetSubTabName("TRB3 Diff Histograms");
167  SetGroupName("FPGA");
169  fReferenceFpga = 0;
170  fReferenceCh = 1;
171 
173 }
174 
175 
177 
178 
179  // Otherwise make histograms
180  clear();
181 
182  std::cout << "Create Histos" << std::endl;
183  for(int j = 0; j < Nfpga; j++){ // loop over FPGA
184  for(int i = 0; i < NchannelPerFpga; i++){ // loop over channels
185 
186  char name[100];
187  char title[100];
188  sprintf(name,"TRB3_diff_%i_%i",j,i);
189 
190  // Delete old histograms, if we already have them
191  TH1D *old = (TH1D*)gDirectory->Get(name);
192  if (old){
193  delete old;
194  }
195 
196 
197  // Create new histograms
198 
199  sprintf(title,"TRB3 difference histogram for fpga=%i channel=%i",j, i);
200 
201  TH1D *tmp = new TH1D(name,title,20000,-109400,109400);
202  tmp->SetXTitle("Hit time (ps)");
203  tmp->SetYTitle("Number of Entries");
204  push_back(tmp);
205  }
206  }
207 
208 }
209 
210 
211 
212 
213 /// Update the histograms for this canvas.
215 
216  TTRB3Data *data = dataContainer.GetEventData<TTRB3Data>("TRB0");
217  if(!data) data = dataContainer.GetEventData<TTRB3Data>("TRBA");
218  if(data){
219  //data->Print();
220 
221  // Loop over first time to find the reference time
222  double reftime = 0;
223  bool foundRef = false;
224 
225  for(int i = 0; i < data->GetNumberMeasurements(); i++){
226  std::vector<TrbTdcMeas> meas = data->GetMeasurements();
227  double time = meas[i].GetFinalTime();
228  uint32_t id = meas[i].GetBoardId();
229  uint32_t ch = meas[i].GetChannel();
230  if(fReferenceFpga == id && fReferenceCh == ch){
231  reftime = time;
232  foundRef = true;
233  // std::cout << "Epoch time : " << ((double)meas[i].GetEpochTime())/1000000.0 << std::endl;
234  }
235  }
236 
237  if(foundRef){
238 
239  for(int i = 0; i < data->GetNumberMeasurements(); i++){
240  std::vector<TrbTdcMeas> meas = data->GetMeasurements();
241  double time = meas[i].GetFinalTime();
242  uint32_t id = meas[i].GetBoardId();
243  uint32_t ch = meas[i].GetChannel();
244  int hch = NchannelPerFpga*id + ch;
245  GetHistogram(hch)->Fill(time-reftime);
246 
247  // if(i==3)
248  //std::cout << "Finetime: " << meas[i].GetFineTime() << std::endl;
249 
250  }
251  }
252 
253  }
254 
255 }
256 
257 
258 
259 /// Take actions at begin run
260 void TTRB3DiffHistograms::BeginRun(int transition,int run,int time){
261 
263 
264 }
265 
R__EXTERN TDirectory * gDirectory
const int NchannelPerFpga
const int Nfpga
what is right value?
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)
void SetNumberChannelsInGroup(int numberChannelsInGroups)
virtual void SetSubTabName(std::string name)
Set the name of the sub-tab for these plots, if running DaqDisplay.
void SetGroupName(std::string name)
Set name for the 'group'.
TH1 * GetHistogram(unsigned i)
A helper method for accessing each histogram. Does bounds checking.
std::vector< TrbTdcMeas > & GetMeasurements()
Get the Vector of TDC Measurements.
Definition: TTRB3Data.hxx:24
const int GetNumberMeasurements()
Definition: TTRB3Data.hxx:21
TTRB3DiffHistograms()
Reset the histograms for this canvas.
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void UpdateHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
void CreateHistograms()
Function to create histograms; users will want to implement this function.
TTRB3FineHistograms()
Reset the histograms for this canvas.
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.
TTRB3Histograms()
Reset the histograms for this canvas.
void UpdateHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void BeginRun(int transition, int run, int time)
Take actions at begin run.