TriggerPlots.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include "TH1F.h"
3 #include "TH2F.h"
4 #include "NovaTimingUtilities/TimingUtilities.h"
11 using namespace om;
12 
13 static const double kSEC_PER_TDC = (1.0/64.0E6);
14 static const double TICKS_PER_USEC = (64);
15 // using unsigned long long rather than uint64_t to ensure consisent behavior on OSX and LINUX
16 static const unsigned long long TICKS_PER_SEC = (64E6);
17 // Trigger delays for FarDet. Docdb 10555
18 static const double TIME_OF_FLIGHT = 2700.56;
19 static const double MI_SHIFT = 1561.26;
20 double TRIG_DELAY;
21 
24 {
26 
27  if(Settings::Instance().fDet == kNDOS) {
28  fDtBNBTrig = h.GetTH1F("DtBNBTrig");
29  fDtNuMITrig = h.GetTH1F("DtNuMITrig");
30  fDtCalibTrig = h.GetTH1F("DtCalibTrig");
31  fDtAccelTrig = h.GetTH1F("DtAccelTrig");
32  fDtAccelClkCoincidence = h.GetTH1F("DtAccelClkCoincidence");
33  fTriggerVsHour = h.GetTH2F("TriggerVsHour");
34  fTriggerVsHourGeneral = h.GetTH2F("TriggerVsHourGeneral");
35  fTriggerUsecResidualVsHour = h.GetTH2F("TriggerUsecResidualVsHour");
36  TRIG_DELAY = 0;
37  }
38  if(Settings::Instance().fDet == kNEARDET) {
39  fDtBNBTrig = h.GetTH1F("DtBNBTrig");
40  fDtNuMITrig = h.GetTH1F("DtNuMITrig");
41  fDtCalibTrig = h.GetTH1F("DtCalibTrig");
42  fDtAccelTrig = h.GetTH1F("DtAccelTrig");
43  fDtAccelClkCoincidence = h.GetTH1F("DtAccelClkCoincidence");
44  fTriggerVsHour = h.GetTH2F("TriggerVsHour");
45  fTriggerVsHourGeneral = h.GetTH2F("TriggerVsHourGeneral");
46  fTriggerUsecResidualVsHour = h.GetTH2F("TriggerUsecResidualVsHour");
47  TRIG_DELAY = 0;
48  }
49  if(Settings::Instance().fDet == kFARDET) {
50  fDtNuMITrig = h.GetTH1F("DtNuMITrig");
51  fDtCalibTrig = h.GetTH1F("DtCalibTrig");
52  fDtAccelTrig = h.GetTH1F("DtAccelTrig");
53  fDtAccelClkCoincidence = h.GetTH1F("DtAccelClkCoincidence");
54  fTriggerVsHour = h.GetTH2F("TriggerVsHour");
55  fTriggerVsHourGeneral = h.GetTH2F("TriggerVsHourGeneral");
56  fTriggerUsecResidualVsHour = h.GetTH2F("TriggerUsecResidualVsHour");
58  }
59  if(Settings::Instance().fDet == kTESTBEAM) {
60  fDtBNBTrig = h.GetTH1F("DtBNBTrig");
61  fDtCalibTrig = h.GetTH1F("DtCalibTrig");
62  fDtAccelTrig = h.GetTH1F("DtAccelTrig");
63  fDtAccelClkCoincidence = h.GetTH1F("DtAccelClkCoincidence");
64  fTriggerVsHour = h.GetTH2F("TriggerVsHour");
65  fTriggerVsHourGeneral = h.GetTH2F("TriggerVsHourGeneral");
66  fTriggerUsecResidualVsHour = h.GetTH2F("TriggerUsecResidualVsHour");
67  TRIG_DELAY = 0;
68  }
69 
70  fDeltaMasterTrigger = h.GetTH1F("DeltaMasterTrigger");
71  fEventsTimeContinuous = h.GetTH1F("EventsTimeContinuous");
72  fEvtMinusPrevEvt = h.GetTH1F("EvtMinusPrevEvt");
73  fIncompleteEvents = h.GetTH1F("IncompleteEvents");
74  fDeltaTSNEWSTrigger = h.GetTH1F("DeltaTSNEWSTrigger");
75 
76  fT0prevNuMI = 0;
77  fT0prevBNB = 0;
78  fT0prevCalib = 0;
79  fT0prevAccel = 0;
80 
81  fRunPrev = 0;
82  fEventPrev = 0;
84 
85  fTrigEvt = new RawEventList();
86 }
87 
88 //......................................................................
89 
91 
92 //......................................................................
93 
95 {
96  // NOTE: Since the fT0prev* variables are initialized to zero, the very
97  // first dt will be huge. BUT, this will only happen the very first time
98  // and that dt will go into the overflow bin of the histogram so I felt
99  // it wasn't worth it to add an extra "if(fT0prev* != 0)" statement that
100  // would only be necessary the very first time a trigger appears.
101  if(r.fTrigger == 0) {
102  double dt = (r.fT0 - fT0prevNuMI)*kSEC_PER_TDC;
103  fDtNuMITrig->Fill(dt);
104  fT0prevNuMI = r.fT0;
105  }
106  if(r.fTrigger == 1 && Settings::Instance().fDet != kFARDET) {
107  double dt = (r.fT0 - fT0prevBNB)*kSEC_PER_TDC;
108  fDtBNBTrig->Fill(dt);
109  fT0prevBNB = r.fT0;
110  }
111  if(r.fTrigger == 2) {
112  double dt = (r.fT0 - fT0prevCalib)*kSEC_PER_TDC;
113  fDtCalibTrig->Fill(dt);
114  fT0prevCalib = r.fT0;
115  }
116  if(r.fTrigger == 5) {
117  double dt = (r.fT0 - fT0prevAccel)*kSEC_PER_TDC;
118  fDtAccelTrig->Fill(dt);
119  fT0prevAccel = r.fT0;
120 
121  double residual_usec = (r.fT0%TICKS_PER_SEC);
122  if ( residual_usec > TICKS_PER_SEC/2 ) residual_usec -= TICKS_PER_SEC;
123  residual_usec *= (1.0/TICKS_PER_USEC);
124  residual_usec -= TRIG_DELAY;
125  double RESID_OVERFLOW = fDtAccelClkCoincidence->GetXaxis()->GetXmax();
126  if ( residual_usec > RESID_OVERFLOW ) residual_usec = RESID_OVERFLOW-1;
127  if ( residual_usec < -RESID_OVERFLOW ) residual_usec = -RESID_OVERFLOW+1;
128  fDtAccelClkCoincidence->Fill(residual_usec);
129 
130  fTriggerUsecResidualVsHour->Fill(r.fHour, residual_usec);
131  }
132 
133  // NOTE: Bad trigger numbers will just go into the under/over-flow bins.
134  fTriggerVsHour->Fill(r.fHour, r.fTrigger);
136  if(r.fHour >= 23.0) {
137  fTriggerVsHour->Fill(r.fHour - 24.0, r.fTrigger);
138  fTriggerVsHourGeneral->Fill(r.fHour - 24.0, r.fTrigger);
139  }
140 
141  if (r.fRun==fRunPrev) {
143  }
144 
145  double deltaMT = -1;
146 
147  if (r.fTrigger == 25){
148  if (fMasterTriggerPrev != 0) {
149  deltaMT = r.fMasterTrigger - fMasterTriggerPrev;
150  fDeltaMasterTrigger->Fill(deltaMT);
151  } else {
152  fDeltaMasterTrigger->Fill(0);
153  }
154 
156 
157  if (deltaMT == 0) {
159  }
160  else {
161  fTrigEvt = new RawEventList();
163  }
164 
166 
168  }
169 
171  fIncompleteEvents->GetXaxis()->SetBinLabel(1, "Complete");
172  fIncompleteEvents->GetXaxis()->SetBinLabel(2, "Incomplete");
173  fIncompleteEvents->SetMinimum(0.1);
174 
175  fEventsTimeContinuous->GetXaxis()->SetBinLabel(1, "False");
176  fEventsTimeContinuous->GetXaxis()->SetBinLabel(2, "True");
177 
178  fRunPrev = r.fRun;
179  fEventPrev = r.fEvent;
180 }
181 
182 ////////////////////////////////////////////////////////////////////////
static const double MI_SHIFT
unsigned long int fT0
Trigger time in nova time units (64 Mhz ticks)
unsigned int fMasterTrigger
Master trigger number.
unsigned int fMasterTriggerPrev
Definition: TriggerPlots.h:38
TH1F * fEventsTimeContinuous
Definition: TriggerPlots.h:23
TH1F * fDeltaTSNEWSTrigger
Definition: TriggerPlots.h:29
long int TimeDiffBetweenEvents(const RawEventSummary &evtFirst, const RawEventSummary &evtSecond)
TH1F * fIncompleteEvents
Definition: TriggerPlots.h:24
TH1F * GetTH1F(const char *nm)
Definition: HistoSet.cxx:68
static const double kSEC_PER_TDC
double TRIG_DELAY
unsigned long int fEventPrev
Definition: TriggerPlots.h:37
unsigned long int fT0prevBNB
Definition: TriggerPlots.h:32
unsigned long int fT0prevAccel
Definition: TriggerPlots.h:34
virtual void GetRawEventSummary(const RawEventSummary &r)
Interface to the event summary.
TH2F * fTriggerUsecResidualVsHour
Definition: TriggerPlots.h:27
unsigned int fEvent
Event nunber.
unsigned long int fT0prevNuMI
Definition: TriggerPlots.h:31
bool IsEventContinuousInTime(const RawEventSummary &evtFirst, const RawEventSummary &evtSecond)
TH2F * fTriggerVsHour
Definition: TriggerPlots.h:25
Definition: Cand.cxx:23
Detector_t fDet
Definition: Settings.h:18
TH2F * GetTH2F(const char *nm)
Definition: HistoSet.cxx:89
float fHour
A fractional hour of the day.
TH1F * fEvtMinusPrevEvt
Definition: TriggerPlots.h:28
unsigned int fRun
Run number.
A simple object that conatins all the global settings.
static const double TIME_OF_FLIGHT
RawEventList * fTrigEvt
Definition: TriggerPlots.h:40
static const double TICKS_PER_USEC
TH2F * fTriggerVsHourGeneral
Definition: TriggerPlots.h:26
unsigned int fTrigger
Trigger type.
unsigned long int fRunPrev
Definition: TriggerPlots.h:36
TRandom3 r(0)
static const unsigned long long TICKS_PER_SEC
unsigned long int fT0prevCalib
Definition: TriggerPlots.h:33
TH1F * fDtAccelClkCoincidence
Definition: TriggerPlots.h:21
static HistoSet & Instance()
Definition: HistoSet.cxx:24
Hold the collection of histograms created by the producer.
static Settings & Instance()
Definition: Settings.cxx:12
TH1F * fDeltaMasterTrigger
Definition: TriggerPlots.h:22
bool fEventIncomplete
Is the event incomplete?
Online Monitoring package header.
void AddEventToRawEventList(const RawEventSummary &evtsum)
All the interesting event-level data.