Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_DAQTree.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_DAQTree.cc
4 // Created: Tue Oct 22 14:55:40 EDT 2013
5 // Creator: dalton (on Linux gluon45.jlab.org 2.6.32-358.18.1.el6.x86_64 x86_64)
6 //
7 
8 #include <iostream>
9 #include <algorithm>
11 #include <JANA/JFactory.h>
12 using namespace jana;
13 
14 #include <stdint.h>
15 #include <DAQ/Df125WindowRawData.h>
16 #include <DAQ/Df125PulseRawData.h>
17 #include <DAQ/Df125PulseIntegral.h>
18 #include <DAQ/Df125PulseTime.h>
19 #include <DAQ/Df125PulsePedestal.h>
20 #include <DAQ/Df125TriggerTime.h>
21 #include <DAQ/DF1TDCHit.h>
22 #include <DAQ/DF1TDCTriggerTime.h>
23 #include <DAQ/Df250WindowRawData.h>
24 #include <DAQ/Df250PulseRawData.h>
25 #include <DAQ/Df250PulseIntegral.h>
26 #include <DAQ/Df250PulseTime.h>
27 #include <DAQ/Df250PulsePedestal.h>
28 #include <DAQ/Df250TriggerTime.h>
29 
30 /// Define a comparison operator for sorting objets of all the DAQ types.
32  // sort by crate, then by slot, then by channel, then by trigger number
33  if (a->rocid != b->rocid) return a->rocid < b->rocid;
34  if (a->slot != b->slot ) return a->slot < b->slot;
35  if (a->channel != b->channel) return a->channel < b->channel;
36  return a->itrigger < b->itrigger;
37 }
39  // sort by crate, then by slot, then by channel, then by trigger number
40  if (a->rocid != b->rocid) return a->rocid < b->rocid;
41  if (a->slot != b->slot ) return a->slot < b->slot;
42  if (a->channel != b->channel) return a->channel < b->channel;
43  return a->itrigger < b->itrigger;
44 }
46  // sort by crate, then by slot, then by channel, then by trigger number
47  if (a->rocid != b->rocid) return a->rocid < b->rocid;
48  if (a->slot != b->slot ) return a->slot < b->slot;
49  if (a->channel != b->channel) return a->channel < b->channel;
50  return a->itrigger < b->itrigger;
51 }
53  // sort by crate, then by slot, then by channel, then by trigger number
54  if (a->rocid != b->rocid) return a->rocid < b->rocid;
55  if (a->slot != b->slot ) return a->slot < b->slot;
56  if (a->channel != b->channel) return a->channel < b->channel;
57  return a->itrigger < b->itrigger;
58 }
60  // sort by crate, then by slot, then by channel, then by trigger number
61  if (a->rocid != b->rocid) return a->rocid < b->rocid;
62  if (a->slot != b->slot ) return a->slot < b->slot;
63  if (a->channel != b->channel) return a->channel < b->channel;
64  return a->itrigger < b->itrigger;
65 }
67  // sort by crate, then by slot, then by channel, then by trigger number
68  if (a->rocid != b->rocid) return a->rocid < b->rocid;
69  if (a->slot != b->slot ) return a->slot < b->slot;
70  return a->itrigger < b->itrigger;
71 }
72 bool DF1TDCHit_cmp(const DF1TDCHit *a,const DF1TDCHit *b){
73  // sort by crate, then by slot, then by channel, then by trigger number
74  if (a->rocid != b->rocid) return a->rocid < b->rocid;
75  if (a->slot != b->slot ) return a->slot < b->slot;
76  if (a->channel != b->channel) return a->channel < b->channel;
77  return a->itrigger < b->itrigger;
78 }
80  // sort by crate, then by slot, then by channel, then by trigger number
81  if (a->rocid != b->rocid) return a->rocid < b->rocid;
82  if (a->slot != b->slot ) return a->slot < b->slot;
83  return a->itrigger < b->itrigger;
84 }
86  // sort by crate, then by slot, then by channel, then by trigger number
87  if (a->rocid != b->rocid) return a->rocid < b->rocid;
88  if (a->slot != b->slot ) return a->slot < b->slot;
89  if (a->channel != b->channel) return a->channel < b->channel;
90  return a->itrigger < b->itrigger;
91 }
93  // sort by crate, then by slot, then by channel, then by trigger number
94  if (a->rocid != b->rocid) return a->rocid < b->rocid;
95  if (a->slot != b->slot ) return a->slot < b->slot;
96  if (a->channel != b->channel) return a->channel < b->channel;
97  return a->itrigger < b->itrigger;
98 }
100  // sort by crate, then by slot, then by channel, then by trigger number
101  if (a->rocid != b->rocid) return a->rocid < b->rocid;
102  if (a->slot != b->slot ) return a->slot < b->slot;
103  if (a->channel != b->channel) return a->channel < b->channel;
104  return a->itrigger < b->itrigger;
105 }
107  // sort by crate, then by slot, then by channel, then by trigger number
108  if (a->rocid != b->rocid) return a->rocid < b->rocid;
109  if (a->slot != b->slot ) return a->slot < b->slot;
110  if (a->channel != b->channel) return a->channel < b->channel;
111  return a->itrigger < b->itrigger;
112 }
114  // sort by crate, then by slot, then by channel, then by trigger number
115  if (a->rocid != b->rocid) return a->rocid < b->rocid;
116  if (a->slot != b->slot ) return a->slot < b->slot;
117  if (a->channel != b->channel) return a->channel < b->channel;
118  return a->itrigger < b->itrigger;
119 }
121  // sort by crate, then by slot, then by channel, then by trigger number
122  if (a->rocid != b->rocid) return a->rocid < b->rocid;
123  if (a->slot != b->slot ) return a->slot < b->slot;
124  return a->itrigger < b->itrigger;
125 }
126 
127 
128 // Routine used to create our JEventProcessor
129 #include <JANA/JApplication.h>
130 extern "C"{
131  void InitPlugin(JApplication *app){
132  InitJANAPlugin(app);
133  app->AddProcessor(new JEventProcessor_DAQTree());
134  }
135 } // "C"
136 
137 
138 //------------------
139 // JEventProcessor_DAQTree (Constructor)
140 //------------------
142 {
143 
144 }
145 
146 //------------------
147 // ~JEventProcessor_DAQTree (Destructor)
148 //------------------
150 {
151 
152 }
153 
154 //------------------
155 // init
156 //------------------
158 {
159  // This is called once at program startup. If you are creating
160  // and filling historgrams in this plugin, you should lock the
161  // ROOT mutex like this:
162  //
163  // japp->RootWriteLock();
164  // ... fill historgrams or trees ...
165  // japp->RootUnLock();
166  //
167 
168  printf("JEventProcessor_DAQTree::init()\n");
169 
170  /// Initialize the flags
171  f125WRDtree_exists = 0;
172  f125PRDtree_exists = 0;
173  f125PItree_exists = 0;
174  f125PTtree_exists = 0;
175  f125PPtree_exists = 0;
176  f125TTtree_exists = 0;
177  F1TDCHtree_exists = 0;
178  F1TDCTTtree_exists = 0;
179  f250WRDtree_exists = 0;
180  f250PRDtree_exists = 0;
181  f250PItree_exists = 0;
182  f250PTtree_exists = 0;
183  f250PPtree_exists = 0;
184  f250TTtree_exists = 0;
185 
186  return NOERROR;
187 }
188 
189 //------------------
190 // brun
191 //------------------
192 jerror_t JEventProcessor_DAQTree::brun(JEventLoop *eventLoop, int32_t runnumber)
193 {
194  // This is called whenever the run number changes
195  return NOERROR;
196 }
197 
198 //------------------
199 // evnt
200 //------------------
201 jerror_t JEventProcessor_DAQTree::evnt(JEventLoop *loop, uint64_t eventnumber)
202 {
203  // This is called for every event. Use of common resources like writing
204  // to a file or filling a histogram should be mutex protected. Using
205  // loop->Get(...) to get reconstructed objects (and thereby activating the
206  // reconstruction algorithm) should be done outside of any mutex lock
207  // since multiple threads may call this method at the same time.
208  // Here's an example:
209  //
210 
211  vector<const Df125WindowRawData*> f125WindowRawData_vec;
212  loop->Get(f125WindowRawData_vec);
213  sort(f125WindowRawData_vec.begin(), f125WindowRawData_vec.end(), Df125WindowRawData_cmp);
214 
215  vector<const Df125PulseRawData*> f125PulseRawData_vec;
216  loop->Get(f125PulseRawData_vec);
217  sort(f125PulseRawData_vec.begin(), f125PulseRawData_vec.end(), Df125PulseRawData_cmp);
218 
219  vector<const Df125PulseIntegral*> f125PulseIntegral_vec;
220  loop->Get(f125PulseIntegral_vec);
221  sort(f125PulseIntegral_vec.begin(), f125PulseIntegral_vec.end(), Df125PulseIntegral_cmp);
222 
223  vector<const Df125PulseTime*> f125PulseTime_vec;
224  loop->Get(f125PulseTime_vec);
225  sort(f125PulseTime_vec.begin(), f125PulseTime_vec.end(), Df125PulseTime_cmp);
226 
227  vector<const Df125PulsePedestal*> f125PulsePedestal_vec;
228  loop->Get(f125PulsePedestal_vec);
229  sort(f125PulsePedestal_vec.begin(), f125PulsePedestal_vec.end(), Df125PulsePedestal_cmp);
230 
231  vector<const Df125TriggerTime*> f125TriggerTime_vec;
232  loop->Get(f125TriggerTime_vec);
233  sort(f125TriggerTime_vec.begin(), f125TriggerTime_vec.end(), Df125TriggerTime_cmp);
234 
235  vector<const DF1TDCHit*> F1TDCHit_vec;
236  loop->Get(F1TDCHit_vec);
237  sort(F1TDCHit_vec.begin(), F1TDCHit_vec.end(), DF1TDCHit_cmp);
238 
239  vector<const DF1TDCTriggerTime*> F1TDCTriggerTime_vec;
240  loop->Get(F1TDCTriggerTime_vec);
241  sort(F1TDCTriggerTime_vec.begin(), F1TDCTriggerTime_vec.end(), DF1TDCTriggerTime_cmp);
242 
243  vector<const Df250WindowRawData*> f250WindowRawData_vec;
244  loop->Get(f250WindowRawData_vec);
245  sort(f250WindowRawData_vec.begin(), f250WindowRawData_vec.end(), Df250WindowRawData_cmp);
246 
247  vector<const Df250PulseRawData*> f250PulseRawData_vec;
248  loop->Get(f250PulseRawData_vec);
249  sort(f250PulseRawData_vec.begin(), f250PulseRawData_vec.end(), Df250PulseRawData_cmp);
250 
251  vector<const Df250PulseIntegral*> f250PulseIntegral_vec;
252  loop->Get(f250PulseIntegral_vec);
253  sort(f250PulseIntegral_vec.begin(), f250PulseIntegral_vec.end(), Df250PulseIntegral_cmp);
254 
255  vector<const Df250PulseTime*> f250PulseTime_vec;
256  loop->Get(f250PulseTime_vec);
257  sort(f250PulseTime_vec.begin(), f250PulseTime_vec.end(), Df250PulseTime_cmp);
258 
259  vector<const Df250PulsePedestal*> f250PulsePedestal_vec;
260  loop->Get(f250PulsePedestal_vec);
261  sort(f250PulsePedestal_vec.begin(), f250PulsePedestal_vec.end(), Df250PulsePedestal_cmp);
262 
263  vector<const Df250TriggerTime*> f250TriggerTime_vec;
264  loop->Get(f250TriggerTime_vec);
265  sort(f250TriggerTime_vec.begin(), f250TriggerTime_vec.end(), Df250TriggerTime_cmp);
266 
267  // Trees are filled with data
268  // Although we are only filling objects local to this plugin, TTree::Fill() periodically writes to file: Global ROOT lock
269  japp->RootWriteLock(); //ACQUIRE ROOT LOCK
270 
271  /// Df125WindowRawData
272  const uint32_t numDf125WRDpedsamps = 10;
273  const Int_t Df125WRDminpeakheight = 100;
274  /// Get a vector of Df125WindowRawData objects for this event (1 object for each crate/slot/channel above threshold)
275  unsigned int num_f125WRD = f125WindowRawData_vec.size();
276  /// Create tree if doesn't exist and objects found.
277  if (!f125WRDtree_exists && num_f125WRD>0) {
278  printf("DAQTree >>eventnum %llu, found %4i Df125WindowRawData objects\n",(long long unsigned int)eventnumber,num_f125WRD);
279  printf("DAQTree >>Creating tree Df125WindowRawData_tree\n");
280  Df125WindowRawData_tree = new TTree("Df125WindowRawData",
281  "tree of flash 125 raw window data (waveform samples) for each channel and event");
282  Df125WindowRawData_tree->Branch("channelnum",&channelnum,"channelnum/i");
283  Df125WindowRawData_tree->Branch("eventnum",&eventnum,"eventnum/i");
284  Df125WindowRawData_tree->Branch("rocid",&rocid,"rocid/i");
285  Df125WindowRawData_tree->Branch("slot",&slot,"slot/i");
286  Df125WindowRawData_tree->Branch("channel",&channel,"channel/i");
287  Df125WindowRawData_tree->Branch("itrigger",&itrigger,"itrigger/i");
288  Df125WindowRawData_tree->Branch("waveform",&waveform);
289  Df125WindowRawData_tree->Branch("nsamples",&nsamples,"nsamples/i");
290  Df125WindowRawData_tree->Branch("w_integral",&w_integral,"w_integral/i");
291  Df125WindowRawData_tree->Branch("w_min",&w_min,"w_min/i");
292  Df125WindowRawData_tree->Branch("w_max",&w_max,"w_max/i");
293  Df125WindowRawData_tree->Branch("w_samp1",&w_samp1,"w_samp1/i");
294  Df125WindowRawData_tree->Branch("w_ped",&w_ped,"w_ped/i");
295  Df125WindowRawData_tree->Branch("w_time",&w_time,"w_time/f");
296  Df125WindowRawData_tree->Branch("invalid_samples",&invalid_samples,"invalid_samples/b");
297  Df125WindowRawData_tree->Branch("overflow",&overflow,"overflow/b");
298  f125WRDtree_exists = 1;
299  }
300  eventnum = eventnumber;
301  // Loop over all objects in this event
302  for(unsigned int c_chan=0; c_chan<num_f125WRD; c_chan++){
303  waveform.clear();
304  channelnum = c_chan;
305  const Df125WindowRawData *f125WindowRawData = f125WindowRawData_vec[c_chan];
306  rocid = f125WindowRawData->rocid;
307  slot = f125WindowRawData->slot;
308  channel = f125WindowRawData->channel;
309  itrigger = f125WindowRawData->itrigger;
310  invalid_samples = f125WindowRawData->invalid_samples;
311  overflow = f125WindowRawData->overflow;
312 
313  // Get a vector of the samples for this channel
314  const vector<uint16_t> &samplesvector = f125WindowRawData->samples;
315  nsamples=samplesvector.size();
316  /// loop over the samples to calculate integral, min, max
317  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
318  if (samplesvector[c_samp]<4096) {
319  waveform.push_back(samplesvector[c_samp]); // push the sample into the waveform vector
320  } else {
321  waveform.push_back(4096); // push the sample into the waveform vector
322  }
323  if (c_samp==0) { // use first sample for initialization
324  w_integral = samplesvector[0];
325  w_min = samplesvector[0];
326  w_max = samplesvector[0];
327  w_samp1 = samplesvector[0];
328  w_ped = samplesvector[0];
329  } else {
330  if (c_samp<numDf125WRDpedsamps) {
331  w_ped += samplesvector[c_samp];
332  }
333  w_integral += samplesvector[c_samp];
334  if (w_min > samplesvector[c_samp]) w_min = samplesvector[c_samp];
335  if (w_max < samplesvector[c_samp]) w_max = samplesvector[c_samp];
336  }
337  }
338  /// find the time to cross half peak height
339  Int_t lastbelowsamp=0, peakheight = w_max-w_min;
340  Float_t threshold = w_min + peakheight/2.0;
341  Float_t firstaboveheight=0, lastbelowheight=0;
342  w_time=0;
343  if (peakheight > Df125WRDminpeakheight) {
344  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
345  if (samplesvector[c_samp]>threshold) {
346  firstaboveheight = samplesvector[c_samp];
347  lastbelowsamp = c_samp-1;
348  lastbelowheight = samplesvector[c_samp-1];
349  break;
350  }
351  }
352  w_time = lastbelowsamp + (threshold-lastbelowheight)/(firstaboveheight-lastbelowheight);
353  }
354  Df125WindowRawData_tree->Fill();
355  }
356 
357 
358  /// Df125PulseRawData
359  const uint32_t numDf125PRDpedsamps= 4;
360  const Int_t Df125PRDminpeakheight = 11;
361  /// Get a vector of Df125PulseRawData objects for this event (1 object for each crate/slot/channel above threshold)
362  unsigned int num_f125PRD = f125PulseRawData_vec.size();
363  /// Create tree if doesn't exist and objects found.
364  if (!f125PRDtree_exists && num_f125PRD>0) {
365  printf("DAQTree >>eventnum %llu, found %4i Df125PulseRawData objects\n",(long long unsigned int)eventnumber,num_f125PRD);
366  printf("DAQTree >>Creating tree Df125PulseRawData_tree\n");
367  Df125PulseRawData_tree = new TTree("Df125PulseRawData",
368  "tree of flash 125 pulse raw data for each channel and event");
369  Df125PulseRawData_tree->Branch("channelnum",&channelnum,"channelnum/i");
370  Df125PulseRawData_tree->Branch("eventnum",&eventnum,"eventnum/i");
371  Df125PulseRawData_tree->Branch("rocid",&rocid,"rocid/i");
372  Df125PulseRawData_tree->Branch("slot",&slot,"slot/i");
373  Df125PulseRawData_tree->Branch("channel",&channel,"channel/i");
374  Df125PulseRawData_tree->Branch("itrigger",&itrigger,"itrigger/i");
375  Df125PulseRawData_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
376  Df125PulseRawData_tree->Branch("first_sample_number",&first_sample_number,"first_sample_number/i");
377  Df125PulseRawData_tree->Branch("waveform",&waveform);
378  Df125PulseRawData_tree->Branch("nsamples",&nsamples,"nsamples/i");
379  Df125PulseRawData_tree->Branch("w_integral",&w_integral,"w_integral/i");
380  Df125PulseRawData_tree->Branch("w_min",&w_min,"w_min/i");
381  Df125PulseRawData_tree->Branch("w_max",&w_max,"w_max/i");
382  Df125PulseRawData_tree->Branch("w_samp1",&w_samp1,"w_samp1/i");
383  Df125PulseRawData_tree->Branch("w_ped",&w_ped,"w_ped/i");
384  Df125PulseRawData_tree->Branch("w_time",&w_time,"w_time/f");
385  Df125PulseRawData_tree->Branch("invalid_samples",&invalid_samples,"invalid_samples/b");
386  Df125PulseRawData_tree->Branch("overflow",&overflow,"overflow/b");
387  f125PRDtree_exists = 1;
388  }
389  eventnum = eventnumber;
390  // Loop over all objects in this event
391  for(unsigned int c_chan=0; c_chan<num_f125PRD; c_chan++){
392  waveform.clear();
393  channelnum = c_chan;
394  const Df125PulseRawData *f125PulseRawData = f125PulseRawData_vec[c_chan];
395  rocid = f125PulseRawData->rocid;
396  slot = f125PulseRawData->slot;
397  channel = f125PulseRawData->channel;
398  itrigger = f125PulseRawData->itrigger;
399  pulse_number = f125PulseRawData->pulse_number;
400  first_sample_number = f125PulseRawData->first_sample_number;
401  invalid_samples = f125PulseRawData->invalid_samples;
402  overflow = f125PulseRawData->overflow;
403  // Get a vector of the samples for this channel
404  const vector<uint16_t> &samplesvector = f125PulseRawData->samples;
405  nsamples=samplesvector.size();
406  /// loop over the samples to calculate integral, min, max
407  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
408  /// Deal with overflow by setting sample to max val
409  if (samplesvector[c_samp]<4096) {
410  waveform.push_back(samplesvector[c_samp]); // push the sample into the waveform vector
411  } else {
412  waveform.push_back(4096); // push the sample into the waveform vector
413  }
414  if (c_samp==0) { // use first sample for initialization
415  w_integral = samplesvector[0];
416  w_min = samplesvector[0];
417  w_max = samplesvector[0];
418  w_samp1 = samplesvector[0];
419  w_ped = samplesvector[0];
420  } else {
421  if (c_samp<numDf125PRDpedsamps) {
422  w_ped += samplesvector[c_samp];
423  }
424  w_integral += samplesvector[c_samp];
425  if (w_min > samplesvector[c_samp]) w_min = samplesvector[c_samp];
426  if (w_max < samplesvector[c_samp]) w_max = samplesvector[c_samp];
427  }
428  }
429  /// find the time to cross half peak height
430  Int_t lastbelowsamp=0, peakheight = w_max-w_min;
431  Float_t threshold = w_min + peakheight/2.0;
432  Float_t firstaboveheight=0, lastbelowheight=0;
433  w_time=0;
434  if (peakheight > Df125PRDminpeakheight) {
435  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
436  if (samplesvector[c_samp]>threshold) {
437  firstaboveheight = samplesvector[c_samp];
438  lastbelowsamp = c_samp-1;
439  lastbelowheight = samplesvector[c_samp-1];
440  break;
441  }
442  }
443  w_time = lastbelowsamp + (threshold-lastbelowheight)/(firstaboveheight-lastbelowheight);
444  }
445  Df125PulseRawData_tree->Fill();
446  }
447 
448  /// Df125PulseIntegral
449  /// Get a vector of Df125PulseIntegral objects for this event (1 object for each crate/slot/channel above threshold)
450  unsigned int num_f125PI = f125PulseIntegral_vec.size();
451  /// Create tree if doesn't exist and objects found.
452  if (!f125PItree_exists && num_f125PI>0) {
453  printf("DAQTree >>eventnum %llu, found %4i Df125PulseIntegral objects\n",(long long unsigned int)eventnumber,num_f125PI);
454  printf("DAQTree >>Creating tree Df125PulseIntegral_tree\n");
455  Df125PulseIntegral_tree = new TTree("Df125PulseIntegral",
456  "tree of flash 125 pulse integral for each channel and event");
457  Df125PulseIntegral_tree->Branch("channelnum",&channelnum,"channelnum/i");
458  Df125PulseIntegral_tree->Branch("eventnum",&eventnum,"eventnum/i");
459  Df125PulseIntegral_tree->Branch("rocid",&rocid,"rocid/i");
460  Df125PulseIntegral_tree->Branch("slot",&slot,"slot/i");
461  Df125PulseIntegral_tree->Branch("channel",&channel,"channel/i");
462  Df125PulseIntegral_tree->Branch("itrigger",&itrigger,"itrigger/i");
463  Df125PulseIntegral_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
464  Df125PulseIntegral_tree->Branch("quality_factor",&quality_factor,"quality_factor/i");
465  Df125PulseIntegral_tree->Branch("integral",&integral,"integral/i");
466  Df125PulseIntegral_tree->Branch("pedestal",&pedestal,"pedestal/i");
467  f125PItree_exists = 1;
468  }
469  eventnum = eventnumber;
470  /// Loop over all Df125PulseIntegral objects in this event
471  for(unsigned int c_chan=0; c_chan<num_f125PI; c_chan++){
472  channelnum = c_chan;
473  const Df125PulseIntegral *f125PulseIntegral = f125PulseIntegral_vec[c_chan];
474  rocid = f125PulseIntegral->rocid;
475  slot = f125PulseIntegral->slot;
476  channel = f125PulseIntegral->channel;
477  itrigger = f125PulseIntegral->itrigger;
478  pulse_number = f125PulseIntegral->pulse_number;
479  quality_factor= f125PulseIntegral->quality_factor;
480  integral = f125PulseIntegral->integral;
481  pedestal = f125PulseIntegral->pedestal;
482  Df125PulseIntegral_tree->Fill();
483  }
484 
485 
486  /// Df125PulseTime
487  /// Get a vector of Df125PulseTime objects for this event (1 object for each crate/slot/channel above threshold)
488  unsigned int num_f125PT = f125PulseTime_vec.size();
489  /// Create tree if doesn't exist and objects found.
490  if (!f125PTtree_exists && num_f125PT>0) {
491  printf("DAQTree >>eventnum %llu, found %4i Df125PulseTime objects\n",(long long unsigned int)eventnumber,num_f125PT);
492  printf("DAQTree >>Creating tree f125PulseTime_tree\n");
493  Df125PulseTime_tree = new TTree("Df125PulseTime",
494  "tree of flash 125 pulse times for each channel and event");
495  Df125PulseTime_tree->Branch("channelnum",&channelnum,"channelnum/i");
496  Df125PulseTime_tree->Branch("eventnum",&eventnum,"eventnum/i");
497  Df125PulseTime_tree->Branch("rocid",&rocid,"rocid/i");
498  Df125PulseTime_tree->Branch("slot",&slot,"slot/i");
499  Df125PulseTime_tree->Branch("channel",&channel,"channel/i");
500  Df125PulseTime_tree->Branch("itrigger",&itrigger,"itrigger/i");
501  Df125PulseTime_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
502  Df125PulseTime_tree->Branch("quality_factor",&quality_factor,"quality_factor/i");
503  Df125PulseTime_tree->Branch("time",&time,"time/i");
504  f125PTtree_exists = 1;
505  }
506  eventnum = eventnumber;
507  /// Loop over all Df125PulseTime objects in this event
508  for(unsigned int c_chan=0; c_chan<num_f125PT; c_chan++){
509  channelnum = c_chan;
510  const Df125PulseTime *f125PulseTime = f125PulseTime_vec[c_chan];
511  rocid = f125PulseTime->rocid;
512  slot = f125PulseTime->slot;
513  channel = f125PulseTime->channel;
514  itrigger = f125PulseTime->itrigger;
515  pulse_number = f125PulseTime->pulse_number;
516  quality_factor= f125PulseTime->quality_factor;
517  time = f125PulseTime->time;
518  Df125PulseTime_tree->Fill();
519  }
520 
521  /// Df125PulsePedestal
522  /// Get a vector of Df125PulsePedestal objects for this event (1 object for each crate/slot/channel above threshold)
523  unsigned int num_f125PP = f125PulsePedestal_vec.size();
524  /// Create tree if doesn't exist and objects found.
525  if (!f125PPtree_exists && num_f125PP>0) {
526  printf("DAQTree >>eventnum %llu, found %4i Df125PulsePedestal objects\n",(long long unsigned int)eventnumber,num_f125PP);
527  printf("DAQTree >>Creating tree f125PulsePedestal_tree\n");
528  Df125PulsePedestal_tree = new TTree("Df125PulsePedestal",
529  "tree of flash 125 pulse times for each channel and event");
530  Df125PulsePedestal_tree->Branch("channelnum",&channelnum,"channelnum/i");
531  Df125PulsePedestal_tree->Branch("eventnum",&eventnum,"eventnum/i");
532  Df125PulsePedestal_tree->Branch("rocid",&rocid,"rocid/i");
533  Df125PulsePedestal_tree->Branch("slot",&slot,"slot/i");
534  Df125PulsePedestal_tree->Branch("channel",&channel,"channel/i");
535  Df125PulsePedestal_tree->Branch("itrigger",&itrigger,"itrigger/i");
536  Df125PulsePedestal_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
537  Df125PulsePedestal_tree->Branch("pedestal",&pedestal,"pedestal/i");
538  Df125PulsePedestal_tree->Branch("pulse_peak",&pulse_peak,"pulse_peak/i");
539  f125PPtree_exists = 1;
540  }
541  eventnum = eventnumber;
542  /// Loop over all Df125PulsePedestal objects in this event
543  for(unsigned int c_chan=0; c_chan<num_f125PP; c_chan++){
544  channelnum = c_chan;
545  const Df125PulsePedestal *f125PulsePedestal = f125PulsePedestal_vec[c_chan];
546  rocid = f125PulsePedestal->rocid;
547  slot = f125PulsePedestal->slot;
548  channel = f125PulsePedestal->channel;
549  itrigger = f125PulsePedestal->itrigger;
550  pulse_number = f125PulsePedestal->pulse_number;
551  pedestal= f125PulsePedestal->pedestal;
552  pulse_peak = f125PulsePedestal->pulse_peak;
553  Df125PulsePedestal_tree->Fill();
554  }
555 
556 
557  /// Df125TriggerTime
558  /// Get a vector of Df125TriggerTime objects for this event (1 object for each crate/slot)
559  unsigned int num_f125TT = f125TriggerTime_vec.size();
560  /// Create tree if doesn't exist and objects found.
561  if (!f125TTtree_exists && num_f125TT>0) {
562  printf("DAQTree >>eventnum %llu, found %4i Df125TriggerTime objects\n",(long long unsigned int)eventnumber,num_f125TT);
563  printf("DAQTree >>Creating tree Df125TriggerTime_tree\n");
564  Df125TriggerTime_tree = new TTree("Df125TriggerTime",
565  "tree of flash 125 trigger times for each slot and event");
566  Df125TriggerTime_tree->Branch("eventnum",&eventnum,"eventnum/i");
567  Df125TriggerTime_tree->Branch("rocid",&rocid,"rocid/i");
568  Df125TriggerTime_tree->Branch("slot",&slot,"slot/i");
569  Df125TriggerTime_tree->Branch("itrigger",&itrigger,"itrigger/i");
570  Df125TriggerTime_tree->Branch("time",&time,"time/l");
571  f125TTtree_exists = 1;
572  }
573  eventnum = eventnumber;
574  /// Loop over all Df125TriggerTime objects in this event
575  for(unsigned int c_chan=0; c_chan<num_f125TT; c_chan++){
576  channelnum = c_chan;
577  const Df125TriggerTime *f125TriggerTime = f125TriggerTime_vec[c_chan];
578  rocid = f125TriggerTime->rocid;
579  slot = f125TriggerTime->slot;
580  itrigger = f125TriggerTime->itrigger;
581  time = f125TriggerTime->time;
582  Df125TriggerTime_tree->Fill();
583  }
584 
585 
586  /// DF1TDCHit
587  /// Get a vector of DF1TDCHit objects for this event (1 object for each crate/slot/channel above threshold)
588  unsigned int num_F1TDCH = F1TDCHit_vec.size();
589  /// Create tree if doesn't exist and objects found.
590  if (!F1TDCHtree_exists && num_F1TDCH>0) {
591  printf("DAQTree >>eventnum %llu, found %4i DF1TDCHit objects\n",(long long unsigned int)eventnumber,num_F1TDCH);
592  printf("DAQTree >>Creating tree F1TDCHit_tree\n");
593  DF1TDCHit_tree = new TTree("DF1TDCHit", "tree of F1 TDC hit times for each channel and event");
594  DF1TDCHit_tree->Branch("channelnum",&channelnum,"channelnum/i");
595  DF1TDCHit_tree->Branch("eventnum",&eventnum,"eventnum/i");
596  DF1TDCHit_tree->Branch("rocid",&rocid,"rocid/i");
597  DF1TDCHit_tree->Branch("slot",&slot,"slot/i");
598  DF1TDCHit_tree->Branch("channel",&channel,"channel/i");
599  DF1TDCHit_tree->Branch("itrigger",&itrigger,"itrigger/i");
600  DF1TDCHit_tree->Branch("trig_time",&trig_time,"trig_time/i");
601  DF1TDCHit_tree->Branch("time",&time,"time/i");
602  DF1TDCHit_tree->Branch("data_word",&data_word,"data_word/i");
603  F1TDCHtree_exists = 1;
604  }
605  eventnum = eventnumber;
606  /// Loop over all DF1TDCHit objects in this event
607  for(unsigned int c_chan=0; c_chan<num_F1TDCH; c_chan++){
608  channelnum = c_chan;
609  const DF1TDCHit *F1TDCHit = F1TDCHit_vec[c_chan];
610  rocid = F1TDCHit->rocid;
611  slot = F1TDCHit->slot;
612  channel = F1TDCHit->channel;
613  itrigger = F1TDCHit->itrigger;
614  trig_time= F1TDCHit->trig_time;
615  time = F1TDCHit->time;
616  data_word = F1TDCHit->data_word;
617  DF1TDCHit_tree->Fill();
618  }
619 
620 
621  /// DF1TDCTriggerTime
622  /// Get a vector of DF1TDCTriggerTime objects for this event (1 object for each crate/slot)
623  unsigned int num_F1TDCTT = F1TDCTriggerTime_vec.size();
624  /// Create tree if doesn't exist and objects found.
625  if (!F1TDCTTtree_exists && num_F1TDCTT>0) {
626  printf("DAQTree >>eventnum %llu, found %4i DF1TDCTriggerTime objects\n",(long long unsigned int)eventnumber,num_F1TDCTT);
627  printf("DAQTree >>Creating tree DF1TDCTriggerTime_tree\n");
628  DF1TDCTriggerTime_tree = new TTree("DF1TDCTriggerTime", "tree of F1 TDC trigger times for each slot and event");
629  DF1TDCTriggerTime_tree->Branch("eventnum",&eventnum,"eventnum/i");
630  DF1TDCTriggerTime_tree->Branch("rocid",&rocid,"rocid/i");
631  DF1TDCTriggerTime_tree->Branch("slot",&slot,"slot/i");
632  DF1TDCTriggerTime_tree->Branch("itrigger",&itrigger,"itrigger/i");
633  DF1TDCTriggerTime_tree->Branch("time",&time,"time/l");
634  F1TDCTTtree_exists = 1;
635  }
636  eventnum = eventnumber;
637  /// Loop over all DF1TDCTriggerTime objects in this event
638  for(unsigned int c_chan=0; c_chan<num_F1TDCTT; c_chan++){
639  channelnum = c_chan;
640  const DF1TDCTriggerTime *F1TDCTriggerTime = F1TDCTriggerTime_vec[c_chan];
641  rocid = F1TDCTriggerTime->rocid;
642  slot = F1TDCTriggerTime->slot;
643  itrigger = F1TDCTriggerTime->itrigger;
644  time = F1TDCTriggerTime->time;
645  DF1TDCTriggerTime_tree->Fill();
646  }
647 
648  /// Df250WindowRawData
649  const uint32_t numDf250WRDpedsamps= 10;
650  const Int_t Df250WRDminpeakheight = 11;
651  /// Get a vector of Df250WindowRawData objects for this event (1 object for each crate/slot/channel above threshold)
652  unsigned int num_f250WRD = f250WindowRawData_vec.size();
653  /// Create tree if doesn't exist and objects found.
654  if (!f250WRDtree_exists && num_f250WRD>0) {
655  printf("DAQTree >>eventnum %llu, found %4i Df250WindowRawData objects\n",(long long unsigned int)eventnumber,num_f250WRD);
656  printf("DAQTree >>Creating tree Df250WindowRawData_tree\n");
657  Df250WindowRawData_tree = new TTree("Df250WindowRawData",
658  "tree of flash 250 raw window data (waveform samples) for each channel and event");
659  Df250WindowRawData_tree->Branch("channelnum",&channelnum,"channelnum/i");
660  Df250WindowRawData_tree->Branch("eventnum",&eventnum,"eventnum/i");
661  Df250WindowRawData_tree->Branch("rocid",&rocid,"rocid/i");
662  Df250WindowRawData_tree->Branch("slot",&slot,"slot/i");
663  Df250WindowRawData_tree->Branch("channel",&channel,"channel/i");
664  Df250WindowRawData_tree->Branch("itrigger",&itrigger,"itrigger/i");
665  Df250WindowRawData_tree->Branch("waveform",&waveform);
666  Df250WindowRawData_tree->Branch("nsamples",&nsamples,"nsamples/i");
667  Df250WindowRawData_tree->Branch("w_integral",&w_integral,"w_integral/i");
668  Df250WindowRawData_tree->Branch("w_min",&w_min,"w_min/i");
669  Df250WindowRawData_tree->Branch("w_max",&w_max,"w_max/i");
670  Df250WindowRawData_tree->Branch("w_samp1",&w_samp1,"w_samp1/i");
671  Df250WindowRawData_tree->Branch("w_ped",&w_ped,"w_ped/i");
672  Df250WindowRawData_tree->Branch("w_time",&w_time,"w_time/f");
673  Df250WindowRawData_tree->Branch("invalid_samples",&invalid_samples,"invalid_samples/b");
674  Df250WindowRawData_tree->Branch("overflow",&overflow,"overflow/b");
675  f250WRDtree_exists = 1;
676  }
677  eventnum = eventnumber;
678  // Loop over all objects in this event
679  for(unsigned int c_chan=0; c_chan<num_f250WRD; c_chan++){
680  waveform.clear();
681  channelnum = c_chan;
682  const Df250WindowRawData *f250WindowRawData = f250WindowRawData_vec[c_chan];
683  rocid = f250WindowRawData->rocid;
684  slot = f250WindowRawData->slot;
685  channel = f250WindowRawData->channel;
686  itrigger = f250WindowRawData->itrigger;
687  invalid_samples = f250WindowRawData->invalid_samples;
688  overflow = f250WindowRawData->overflow;
689  // Get a vector of the samples for this channel
690  const vector<uint16_t> &samplesvector = f250WindowRawData->samples;
691  nsamples=samplesvector.size();
692  /// loop over the samples to calculate integral, min, max
693  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
694  if (samplesvector[c_samp]<4096) {
695  waveform.push_back(samplesvector[c_samp]); // push the sample into the waveform vector
696  } else {
697  waveform.push_back(4096); // push the sample into the waveform vector
698  }
699  if (c_samp==0) { // use first sample for initialization
700  w_integral = samplesvector[0];
701  w_min = samplesvector[0];
702  w_max = samplesvector[0];
703  w_samp1 = samplesvector[0];
704  w_ped = samplesvector[0];
705  } else {
706  if (c_samp<numDf250WRDpedsamps) {
707  w_ped += samplesvector[c_samp];
708  }
709  w_integral += samplesvector[c_samp];
710  if (w_min > samplesvector[c_samp]) w_min = samplesvector[c_samp];
711  if (w_max < samplesvector[c_samp]) w_max = samplesvector[c_samp];
712  }
713  }
714  /// find the time to cross half peak height
715  Int_t lastbelowsamp=0, peakheight = w_max-w_min;
716  Float_t threshold = w_min + peakheight/2.0;
717  Float_t firstaboveheight=0, lastbelowheight=0;
718  w_time=0;
719  if (peakheight > Df250WRDminpeakheight) {
720  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
721  if (samplesvector[c_samp]>threshold) {
722  firstaboveheight = samplesvector[c_samp];
723  lastbelowsamp = c_samp-1;
724  lastbelowheight = samplesvector[c_samp-1];
725  break;
726  }
727  }
728  w_time = lastbelowsamp + (threshold-lastbelowheight)/(firstaboveheight-lastbelowheight);
729  }
730  Df250WindowRawData_tree->Fill();
731  }
732 
733 
734  /// Df250PulseRawData
735  const uint32_t numDf250PRDpedsamps= 4;
736  const Int_t Df250PRDminpeakheight = 11;
737  /// Get a vector of Df250PulseRawData objects for this event (1 object for each crate/slot/channel above threshold)
738  unsigned int num_f250PRD = f250PulseRawData_vec.size();
739  /// Create tree if doesn't exist and objects found.
740  if (!f250PRDtree_exists && num_f250PRD>0) {
741  printf("DAQTree >>eventnum %llu, found %4i Df250PulseRawData objects\n",(long long unsigned int)eventnumber,num_f250PRD);
742  printf("DAQTree >>Creating tree Df250PulseRawData_tree\n");
743  Df250PulseRawData_tree = new TTree("Df250PulseRawData",
744  "tree of flash 250 pulse raw data for each channel and event");
745  Df250PulseRawData_tree->Branch("channelnum",&channelnum,"channelnum/i");
746  Df250PulseRawData_tree->Branch("eventnum",&eventnum,"eventnum/i");
747  Df250PulseRawData_tree->Branch("rocid",&rocid,"rocid/i");
748  Df250PulseRawData_tree->Branch("slot",&slot,"slot/i");
749  Df250PulseRawData_tree->Branch("channel",&channel,"channel/i");
750  Df250PulseRawData_tree->Branch("itrigger",&itrigger,"itrigger/i");
751  Df250PulseRawData_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
752  Df250PulseRawData_tree->Branch("first_sample_number",&first_sample_number,"first_sample_number/i");
753  Df250PulseRawData_tree->Branch("waveform",&waveform);
754  Df250PulseRawData_tree->Branch("nsamples",&nsamples,"nsamples/i");
755  Df250PulseRawData_tree->Branch("w_integral",&w_integral,"w_integral/i");
756  Df250PulseRawData_tree->Branch("w_min",&w_min,"w_min/i");
757  Df250PulseRawData_tree->Branch("w_max",&w_max,"w_max/i");
758  Df250PulseRawData_tree->Branch("w_samp1",&w_samp1,"w_samp1/i");
759  Df250PulseRawData_tree->Branch("w_ped",&w_ped,"w_ped/i");
760  Df250PulseRawData_tree->Branch("w_time",&w_time,"w_time/f");
761  Df250PulseRawData_tree->Branch("invalid_samples",&invalid_samples,"invalid_samples/b");
762  Df250PulseRawData_tree->Branch("overflow",&overflow,"overflow/b");
763  f250PRDtree_exists = 1;
764  }
765  eventnum = eventnumber;
766  // Loop over all objects in this event
767  for(unsigned int c_chan=0; c_chan<num_f250PRD; c_chan++){
768  waveform.clear();
769  channelnum = c_chan;
770  const Df250PulseRawData *f250PulseRawData = f250PulseRawData_vec[c_chan];
771  rocid = f250PulseRawData->rocid;
772  slot = f250PulseRawData->slot;
773  channel = f250PulseRawData->channel;
774  itrigger = f250PulseRawData->itrigger;
775  pulse_number = f250PulseRawData->pulse_number;
776  first_sample_number = f250PulseRawData->first_sample_number;
777  invalid_samples = f250PulseRawData->invalid_samples;
778  overflow = f250PulseRawData->overflow;
779  // Get a vector of the samples for this channel
780  const vector<uint16_t> &samplesvector = f250PulseRawData->samples;
781  nsamples=samplesvector.size();
782  /// loop over the samples to calculate integral, min, max
783  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
784  /// Deal with overflow by setting sample to max val
785  if (samplesvector[c_samp]<4096) {
786  waveform.push_back(samplesvector[c_samp]); // push the sample into the waveform vector
787  } else {
788  waveform.push_back(4096); // push the sample into the waveform vector
789  }
790  if (c_samp==0) { // use first sample for initialization
791  w_integral = samplesvector[0];
792  w_min = samplesvector[0];
793  w_max = samplesvector[0];
794  w_samp1 = samplesvector[0];
795  w_ped = samplesvector[0];
796  } else {
797  if (c_samp<numDf250PRDpedsamps) {
798  w_ped += samplesvector[c_samp];
799  }
800  w_integral += samplesvector[c_samp];
801  if (w_min > samplesvector[c_samp]) w_min = samplesvector[c_samp];
802  if (w_max < samplesvector[c_samp]) w_max = samplesvector[c_samp];
803  }
804  }
805  /// find the time to cross half peak height
806  Int_t lastbelowsamp=0, peakheight = w_max-w_min;
807  Float_t threshold = w_min + peakheight/2.0;
808  Float_t firstaboveheight=0, lastbelowheight=0;
809  w_time=0;
810  if (peakheight > Df250PRDminpeakheight) {
811  for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
812  if (samplesvector[c_samp]>threshold) {
813  firstaboveheight = samplesvector[c_samp];
814  lastbelowsamp = c_samp-1;
815  lastbelowheight = samplesvector[c_samp-1];
816  break;
817  }
818  }
819  w_time = lastbelowsamp + (threshold-lastbelowheight)/(firstaboveheight-lastbelowheight);
820  }
821  Df250PulseRawData_tree->Fill();
822  }
823 
824  /// Df250PulseIntegral
825  /// Get a vector of Df250PulseIntegral objects for this event (1 object for each crate/slot/channel above threshold)
826  unsigned int num_f250PI = f250PulseIntegral_vec.size();
827  /// Create tree if doesn't exist and objects found.
828  if (!f250PItree_exists && num_f250PI>0) {
829  printf("DAQTree >>eventnum %llu, found %4i Df250PulseIntegral objects\n",(long long unsigned int)eventnumber,num_f250PI);
830  printf("DAQTree >>Creating tree Df250PulseIntegral_tree\n");
831  Df250PulseIntegral_tree = new TTree("Df250PulseIntegral",
832  "tree of flash 250 pulse integral for each channel and event");
833  Df250PulseIntegral_tree->Branch("channelnum",&channelnum,"channelnum/i");
834  Df250PulseIntegral_tree->Branch("eventnum",&eventnum,"eventnum/i");
835  Df250PulseIntegral_tree->Branch("rocid",&rocid,"rocid/i");
836  Df250PulseIntegral_tree->Branch("slot",&slot,"slot/i");
837  Df250PulseIntegral_tree->Branch("channel",&channel,"channel/i");
838  Df250PulseIntegral_tree->Branch("itrigger",&itrigger,"itrigger/i");
839  Df250PulseIntegral_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
840  Df250PulseIntegral_tree->Branch("quality_factor",&quality_factor,"quality_factor/i");
841  Df250PulseIntegral_tree->Branch("integral",&integral,"integral/i");
842  Df250PulseIntegral_tree->Branch("pedestal",&pedestal,"pedestal/i");
843  Df250PulseIntegral_tree->Branch("nsamples_integral",&nsamples_integral,"nsamples_integral/i");
844  Df250PulseIntegral_tree->Branch("nsamples_pedestal",&nsamples_pedestal,"nsamples_pedestal/i");
845  f250PItree_exists = 1;
846  }
847  eventnum = eventnumber;
848  /// Loop over all Df250PulseIntegral objects in this event
849  for(unsigned int c_chan=0; c_chan<num_f250PI; c_chan++){
850  channelnum = c_chan;
851  const Df250PulseIntegral *f250PulseIntegral = f250PulseIntegral_vec[c_chan];
852  rocid = f250PulseIntegral->rocid;
853  slot = f250PulseIntegral->slot;
854  channel = f250PulseIntegral->channel;
855  itrigger = f250PulseIntegral->itrigger;
856  pulse_number = f250PulseIntegral->pulse_number;
857  quality_factor= f250PulseIntegral->quality_factor;
858  integral = f250PulseIntegral->integral;
859  pedestal = f250PulseIntegral->pedestal;
860  nsamples_integral = f250PulseIntegral->nsamples_integral;
861  nsamples_pedestal = f250PulseIntegral->nsamples_pedestal;
862  Df250PulseIntegral_tree->Fill();
863  }
864 
865 
866  /// Df250PulseTime
867  /// Get a vector of Df250PulseTime objects for this event (1 object for each crate/slot/channel above threshold)
868  unsigned int num_f250PT = f250PulseTime_vec.size();
869  /// Create tree if doesn't exist and objects found.
870  if (!f250PTtree_exists && num_f250PT>0) {
871  printf("DAQTree >>eventnum %llu, found %4i Df250PulseTime objects\n",(long long unsigned int)eventnumber,num_f250PT);
872  printf("DAQTree >>Creating tree f250PulseTime_tree\n");
873  Df250PulseTime_tree = new TTree("Df250PulseTime",
874  "tree of flash 250 pulse times for each channel and event");
875  Df250PulseTime_tree->Branch("channelnum",&channelnum,"channelnum/i");
876  Df250PulseTime_tree->Branch("eventnum",&eventnum,"eventnum/i");
877  Df250PulseTime_tree->Branch("rocid",&rocid,"rocid/i");
878  Df250PulseTime_tree->Branch("slot",&slot,"slot/i");
879  Df250PulseTime_tree->Branch("channel",&channel,"channel/i");
880  Df250PulseTime_tree->Branch("itrigger",&itrigger,"itrigger/i");
881  Df250PulseTime_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
882  Df250PulseTime_tree->Branch("quality_factor",&quality_factor,"quality_factor/i");
883  Df250PulseTime_tree->Branch("time",&time,"time/i");
884  f250PTtree_exists = 1;
885  }
886  eventnum = eventnumber;
887  /// Loop over all Df250PulseTime objects in this event
888  for(unsigned int c_chan=0; c_chan<num_f250PT; c_chan++){
889  channelnum = c_chan;
890  const Df250PulseTime *f250PulseTime = f250PulseTime_vec[c_chan];
891  rocid = f250PulseTime->rocid;
892  slot = f250PulseTime->slot;
893  channel = f250PulseTime->channel;
894  itrigger = f250PulseTime->itrigger;
895  pulse_number = f250PulseTime->pulse_number;
896  quality_factor= f250PulseTime->quality_factor;
897  time = f250PulseTime->time;
898  Df250PulseTime_tree->Fill();
899  }
900 
901  /// Df250PulsePedestal
902  /// Get a vector of Df250PulsePedestal objects for this event (1 object for each crate/slot/channel above threshold)
903  unsigned int num_f250PP = f250PulsePedestal_vec.size();
904  /// Create tree if doesn't exist and objects found.
905  if (!f250PPtree_exists && num_f250PP>0) {
906  printf("DAQTree >>eventnum %llu, found %4i Df250PulsePedestal objects\n",(long long unsigned int)eventnumber,num_f250PP);
907  printf("DAQTree >>Creating tree f250PulsePedestal_tree\n");
908  Df250PulsePedestal_tree = new TTree("Df250PulsePedestal",
909  "tree of flash 250 pulse times for each channel and event");
910  Df250PulsePedestal_tree->Branch("channelnum",&channelnum,"channelnum/i");
911  Df250PulsePedestal_tree->Branch("eventnum",&eventnum,"eventnum/i");
912  Df250PulsePedestal_tree->Branch("rocid",&rocid,"rocid/i");
913  Df250PulsePedestal_tree->Branch("slot",&slot,"slot/i");
914  Df250PulsePedestal_tree->Branch("channel",&channel,"channel/i");
915  Df250PulsePedestal_tree->Branch("itrigger",&itrigger,"itrigger/i");
916  Df250PulsePedestal_tree->Branch("pulse_number",&pulse_number,"pulse_number/i");
917  Df250PulsePedestal_tree->Branch("pedestal",&pedestal,"pedestal/i");
918  Df250PulsePedestal_tree->Branch("pulse_peak",&pulse_peak,"pulse_peak/i");
919  f250PPtree_exists = 1;
920  }
921  eventnum = eventnumber;
922  /// Loop over all Df250PulsePedestal objects in this event
923  for(unsigned int c_chan=0; c_chan<num_f250PP; c_chan++){
924  channelnum = c_chan;
925  const Df250PulsePedestal *f250PulsePedestal = f250PulsePedestal_vec[c_chan];
926  rocid = f250PulsePedestal->rocid;
927  slot = f250PulsePedestal->slot;
928  channel = f250PulsePedestal->channel;
929  itrigger = f250PulsePedestal->itrigger;
930  pulse_number = f250PulsePedestal->pulse_number;
931  pedestal= f250PulsePedestal->pedestal;
932  pulse_peak = f250PulsePedestal->pulse_peak;
933  Df250PulsePedestal_tree->Fill();
934  }
935 
936 
937  /// Df250TriggerTime
938  /// Get a vector of Df250TriggerTime objects for this event (1 object for each crate/slot)
939  unsigned int num_f250TT = f250TriggerTime_vec.size();
940  /// Create tree if doesn't exist and objects found.
941  if (!f250TTtree_exists && num_f250TT>0) {
942  printf("DAQTree >>eventnum %llu, found %4i Df250TriggerTime objects\n",(long long unsigned int)eventnumber,num_f250TT);
943  printf("DAQTree >>Creating tree Df250TriggerTime_tree\n");
944  Df250TriggerTime_tree = new TTree("Df250TriggerTime",
945  "tree of flash 250 trigger times for each slot and event");
946  Df250TriggerTime_tree->Branch("eventnum",&eventnum,"eventnum/i");
947  Df250TriggerTime_tree->Branch("rocid",&rocid,"rocid/i");
948  Df250TriggerTime_tree->Branch("slot",&slot,"slot/i");
949  Df250TriggerTime_tree->Branch("itrigger",&itrigger,"itrigger/i");
950  Df250TriggerTime_tree->Branch("time",&time,"time/l");
951  f250TTtree_exists = 1;
952  }
953  eventnum = eventnumber;
954  /// Loop over all Df250TriggerTime objects in this event
955  for(unsigned int c_chan=0; c_chan<num_f250TT; c_chan++){
956  channelnum = c_chan;
957  const Df250TriggerTime *f250TriggerTime = f250TriggerTime_vec[c_chan];
958  rocid = f250TriggerTime->rocid;
959  slot = f250TriggerTime->slot;
960  itrigger = f250TriggerTime->itrigger;
961  time = f250TriggerTime->time;
962  Df250TriggerTime_tree->Fill();
963  }
964 
965  japp->RootUnLock(); //RELEASE ROOT LOCK
966 
967  return NOERROR;
968 }
969 
970 //------------------
971 // erun
972 //------------------
974 {
975  // This is called whenever the run number changes, before it is
976  // changed to give you a chance to clean up before processing
977  // events from the next run number.
978  return NOERROR;
979 }
980 
981 //------------------
982 // fini
983 //------------------
985 {
986  // Called before program exit after event processing is finished.
987  return NOERROR;
988 }
989 
990 
991 
992 /* emacs
993  * Local Variables:
994  * mode:C++
995  * mode:font-lock
996  * c-file-style: "stroustrup"
997  * tab-width: 4
998  * End:
999  */
bool Df250PulsePedestal_cmp(const Df250PulsePedestal *a, const Df250PulsePedestal *b)
uint32_t pedestal
from Pulse Integral Data word (future)
uint32_t pulse_number
from Pulse Raw Data Data 1st word
uint32_t pulse_number
from Pulse Pedestal Data word
uint32_t quality_factor
from Pulse Integral Data word
uint32_t pulse_peak
from Pulse Pedestal Data word
uint32_t quality_factor
from Pulse Integral Data word
uint32_t pulse_number
from Pulse Time Data word
uint32_t nsamples_integral
number of samples used in integral
bool overflow
true if any sample&#39;s &quot;overflow&quot; bit set
bool Df250PulseTime_cmp(const Df250PulseTime *a, const Df250PulseTime *b)
vector< uint16_t > samples
uint32_t pulse_peak
from Pulse Pedestal Data word
jerror_t init(void)
for F1TDCH
JApplication * japp
uint32_t first_sample_number
from Pulse Raw Data Data 1st word
bool Df250PulseIntegral_cmp(const Df250PulseIntegral *a, const Df250PulseIntegral *b)
bool DF1TDCTriggerTime_cmp(const DF1TDCTriggerTime *a, const DF1TDCTriggerTime *b)
vector< uint16_t > samples
from Pulse Raw Data Data words 2-N (each word contains 2 samples)
uint32_t pulse_number
from Pulse Time Data word
bool overflow
true if any sample&#39;s &quot;overflow&quot; bit set
uint32_t time
Definition: DF1TDCHit.h:30
InitPlugin_t InitPlugin
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
bool Df125TriggerTime_cmp(const Df125TriggerTime *a, const Df125TriggerTime *b)
bool Df125PulseIntegral_cmp(const Df125PulseIntegral *a, const Df125PulseIntegral *b)
uint32_t time
from Pulse Time Data word
vector< uint16_t > samples
uint32_t pulse_number
from Pulse Pedestal Data word
uint32_t quality_factor
from Pulse Time Data word
uint32_t pulse_number
from Pulse Integral Data word
uint32_t data_word
Definition: DF1TDCHit.h:34
bool Df250PulseRawData_cmp(const Df250PulseRawData *a, const Df250PulseRawData *b)
uint32_t pedestal
from Pulse Pedestal Data word
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
bool Df250WindowRawData_cmp(const Df250WindowRawData *a, const Df250WindowRawData *b)
uint32_t time
from Pulse Time Data word
uint32_t quality_factor
from Pulse Time Data word
jerror_t fini(void)
Called after last event of last event source has been processed.
uint32_t pulse_number
from Pulse Raw Data Data 1st word
uint32_t integral
from Pulse Integral Data word
uint32_t pedestal
from Pulse Integral Data word (future)
bool invalid_samples
true if any sample&#39;s &quot;not valid&quot; bit set
bool Df125PulseRawData_cmp(const Df125PulseRawData *a, const Df125PulseRawData *b)
uint32_t integral
from Pulse Integral Data word
uint32_t channel
Definition: DDAQAddress.h:34
bool Df125WindowRawData_cmp(const Df125WindowRawData *a, const Df125WindowRawData *b)
Define a comparison operator for sorting objets of all the DAQ types.
bool invalid_samples
true if any sample&#39;s &quot;not valid&quot; bit set
static TH1I * pedestal[nChan]
uint32_t rocid
Definition: DDAQAddress.h:32
bool Df250TriggerTime_cmp(const Df250TriggerTime *a, const Df250TriggerTime *b)
uint32_t pulse_number
from Pulse Integral Data word
uint32_t pedestal
from Pulse Pedestal Data word
bool Df125PulseTime_cmp(const Df125PulseTime *a, const Df125PulseTime *b)
uint32_t trig_time
Definition: DF1TDCHit.h:29
uint32_t nsamples_pedestal
number of samples used in pedestal
uint32_t itrigger
Definition: DDAQAddress.h:35
printf("string=%s", string)
vector< uint16_t > samples
from Pulse Raw Data Data words 2-N (each word contains 2 samples)
bool Df125PulsePedestal_cmp(const Df125PulsePedestal *a, const Df125PulsePedestal *b)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
bool DF1TDCHit_cmp(const DF1TDCHit *a, const DF1TDCHit *b)
uint32_t slot
Definition: DDAQAddress.h:33
uint32_t first_sample_number
from Pulse Raw Data Data 1st word