Belle II Software development
TTDDQMModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <rawdata/modules/TTDDQM/TTDDQMModule.h>
10#include <TDirectory.h>
11
12using namespace std;
13using namespace Belle2;
14
15//-----------------------------------------------------------------
16// Register the Module
17//-----------------------------------------------------------------
18REG_MODULE(TTDDQM);
19
20//-----------------------------------------------------------------
21// Implementation
22//-----------------------------------------------------------------
23
24TTDDQMModule::TTDDQMModule() : HistoModule(), m_EventLevelTriggerTimeInfo()
25{
26 //Set module properties
27 setDescription("Monitor TTD Trigger and Injection");
28 // his DQM module can be run offline or online
29 // if included in online DQM, binning should be reviewed (size!) and
30 // adapted to the binning of the corresponding sub detector (or GDL) histograms
31 // it may replace some of the histograms currently filled by sub-detectors
33 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
34 std::string("TTD"));
35
36}
37
39{
40 TDirectory* oldDir = gDirectory;
41 if (m_histogramDirectoryName != "") {
42 oldDir->mkdir(m_histogramDirectoryName.c_str());// do not rely on return value, might be ZERO
43 oldDir->cd(m_histogramDirectoryName.c_str());//changing to the right directory
44 }
45
46 hTrigAfterInjLER = new TH2I("hTTDTrigAfterInjLER",
47 "Triggers for LER veto tuning;Time since last injection in #mus;Time within beam cycle in #mus", 500, 0, 30000, 100, 0,
48 5120 / 508.);
49 hTrigAfterInjHER = new TH2I("hTTDTrigAfterInjHER",
50 "Triggers for HER veto tuning;Time since last injection in #mus;Time within beam cycle in #mus", 500, 0, 30000, 100, 0,
51 5120 / 508.);
52
53 hTriggersDeltaT = new TH1I("hTTDTriggersDeltaT",
54 "#delta Trigger Time since previous trigger;#delta t in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0, 50000);
55 hTriggersPerBunch = new TH1I("hTTDTriggerBunch", "Triggers per Bunch;Bunch(rel);Triggers per 4 Bunches", 1280, 0, 1280 * 4);
56
57 hBunchInjLER = new TH1I("hTTDBunchInjLER", "Last Injected Bunch LER;Bunch(rel);Counts per 4 Bunches", 1280, 0, 1280 * 4);
58 hBunchInjHER = new TH1I("hTTDBunchInjHER", "Last Injected Bunch HER;Bunch(rel);Counts per 4 Bunches", 1280, 0, 1280 * 4);
59
60 hTrigBunchInjLER = new TH2I("hTTDTrigBunchInjLER",
61 "Correlation between triggered bunch and injected bunch in LER;Injected Bunch(rel);Triggered Bunch(rel)", 256, 0, 1280 * 4, 256, 0,
62 1280 * 4);
63 hTrigBunchInjHER = new TH2I("hTTDTrigBunchInjHER",
64 "Correlation between triggered bunch and injected bunch in HER;Injected Bunch(rel);Triggered Bunch(rel)", 256, 0, 1280 * 4, 256, 0,
65 1280 * 4);
66
67 hTrigBunchInjLERproj = new TH1I("hTTDTrigBunchInjLERproj",
68 "Offset between triggered bunch and injected bunch in LER;Injected Bunch(rel)-Triggered Bunch(rel);Counts per 4 Bunches", 1280, 0,
69 1280 * 4);
70 hTrigBunchInjHERproj = new TH1I("hTTDTrigBunchInjHERproj",
71 "Offset between triggered bunch and injected bunch in HER;Injected Bunch(rel)-Triggered Bunch(rel);Counts per 4 Bunches", 1280, 0,
72 1280 * 4);
73 // cd back to root directory
74 oldDir->cd();
75}
76
78{
79 REG_HISTOGRAM
80 m_EventLevelTriggerTimeInfo.isRequired();
81}
82
84{
85 // all ptr are set in defineHisto, thus no need for nullptr check
86 hTrigAfterInjLER->Reset();
87 hTrigAfterInjHER->Reset();
88 hTriggersDeltaT->Reset();
89 hTriggersPerBunch->Reset();
90 hBunchInjHER->Reset();
91 hBunchInjLER->Reset();
92 hTrigBunchInjLER->Reset();
93 hTrigBunchInjHER->Reset();
94 hTrigBunchInjLERproj->Reset();
95 hTrigBunchInjHERproj->Reset();
96}
97
99{
100
101 if (m_EventLevelTriggerTimeInfo.isValid() and m_EventLevelTriggerTimeInfo->isValid()) {
102 // TODO conversion of clock ticks to time not yet done in EventLevelTriggerTimeInfo
103 // all values are given in clock ticks of RF clock/4, thus one tick correspond to 4 bunches
104 // ~ 508 MHz RF -> 127 = 508/4 (clock ticks)
105 // 5120 possible bunch positions from RF and ring circumference -> 1280 = 5120/4 (in ticks)
106 // use an int and not the real fraction number to avoid binning effects for getting inexact time
107 // any bunch number is currently relative and not matching the SKB number (offset differs for LER, HER)
108 // time after injection is time after prekick signal, real injection happens ~90us afterwards (offset differs for LER, HER)
109 hTriggersDeltaT->Fill(m_EventLevelTriggerTimeInfo->getTimeSincePrevTrigger() / 127.);
110 int triggered_bunch_in_ticks = m_EventLevelTriggerTimeInfo->getBunchNumber();
111 hTriggersPerBunch->Fill(triggered_bunch_in_ticks * 4);
112
113
114 if (m_EventLevelTriggerTimeInfo->hasInjection()) {
115 auto time_since_inj_in_ticks = m_EventLevelTriggerTimeInfo->getTimeSinceLastInjection();// in clock ticks
116 // 127MHz clock ticks to us, inexact rounding, use integer to avoid binning effects
117 float time_since_inj_in_us = time_since_inj_in_ticks / 127.;
118 // swapped? 1280-1-injected_bunch_in_ticks?
119 int injected_bunch_in_ticks = ((time_since_inj_in_ticks - triggered_bunch_in_ticks + 1280) % 1280);
120
121 if (m_EventLevelTriggerTimeInfo->isHER()) {
122 hTrigAfterInjHER->Fill(time_since_inj_in_us, time_since_inj_in_us - int(time_since_inj_in_us / (5120 / 508.)) * (5120 / 508.));
123 hBunchInjHER->Fill(injected_bunch_in_ticks * 4);
124 hTrigBunchInjHER->Fill(injected_bunch_in_ticks * 4, triggered_bunch_in_ticks * 4);
125 hTrigBunchInjHERproj->Fill(((injected_bunch_in_ticks - triggered_bunch_in_ticks + 1280) % 1280) * 4);
126 } else {
127 hTrigAfterInjLER->Fill(time_since_inj_in_us, time_since_inj_in_us - int(time_since_inj_in_us / (5120 / 508.)) * (5120 / 508.));
128 hBunchInjLER->Fill(injected_bunch_in_ticks * 4);
129 hTrigBunchInjLER->Fill(injected_bunch_in_ticks * 4, triggered_bunch_in_ticks * 4);
130 hTrigBunchInjLERproj->Fill(((injected_bunch_in_ticks - triggered_bunch_in_ticks + 1280) % 1280) * 4);
131 }
132 }
133 }
134}
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void initialize() override final
initialize function
Definition: TTDDQMModule.cc:77
TH1I * hTriggersDeltaT
Histogram for Delta T to previous Trigger.
Definition: TTDDQMModule.h:50
TH2I * hTrigAfterInjHER
Histogram Veto tuning triggers after HER injection.
Definition: TTDDQMModule.h:45
TTDDQMModule()
Constructor defining the parameters.
Definition: TTDDQMModule.cc:24
TH2I * hTrigBunchInjLER
Histogram correlation triggered and injected bunch LER.
Definition: TTDDQMModule.h:47
TH1I * hBunchInjHER
Histogram injected LER bunch (triggers)
Definition: TTDDQMModule.h:54
void defineHisto() override final
defineHisto function
Definition: TTDDQMModule.cc:38
TH1I * hTrigBunchInjHERproj
Histogram offset triggered and injected bunch HER.
Definition: TTDDQMModule.h:57
TH1I * hBunchInjLER
Histogram injected HER bunch (triggers)
Definition: TTDDQMModule.h:53
void event() override final
event function
Definition: TTDDQMModule.cc:98
TH1I * hTrigBunchInjLERproj
Histogram offset triggered and injected bunch LER.
Definition: TTDDQMModule.h:56
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
Definition: TTDDQMModule.h:38
TH2I * hTrigBunchInjHER
Histogram correlation triggered and injected bunch HER.
Definition: TTDDQMModule.h:48
TH2I * hTrigAfterInjLER
Histogram Veto tuning triggers after LER injection.
Definition: TTDDQMModule.h:44
void beginRun() override final
beginRun function
Definition: TTDDQMModule.cc:83
StoreObjPtr< EventLevelTriggerTimeInfo > m_EventLevelTriggerTimeInfo
Input object for TTD mdst object.
Definition: TTDDQMModule.h:41
TH1I * hTriggersPerBunch
Histogram for Triggers per Bunch
Definition: TTDDQMModule.h:51
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.