9 #include <svd/modules/svdDQM/SVDDQMDoseModule.h>
11 #include <rawdata/dataobjects/RawFTSW.h>
12 #include <svd/dataobjects/SVDShaperDigit.h>
13 #include <mdst/dataobjects/TRGSummary.h>
14 #include <vxd/dataobjects/VxdID.h>
17 #include <vxd/geometry/GeoCache.h>
18 #include <svd/geometry/SensorInfo.h>
19 #include <TDirectory.h>
32 setDescription(
"The SVD dose-monitoring DQM module. Fills histograms of the SVD's instantaneous occupancy and "
33 "of SVD occupancy vs time since last injection and time in beam revolution cycle.");
34 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"eventTypeFilter", m_eventFilter,
36 "Types of events to include in the plots (1 = less than noInjectionTimeout after HER injection, "
37 "2 = less than noInjectionTimeout after LER injection, 4 = more than noInjectionTimeout after any "
38 "injection; bitwise or combinations are possible; see SVDDQMDoseModule::EEventType).", 7U);
39 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
40 "Name of the directory where histograms will be placed in the ROOT file.",
41 std::string(
"SVDDose"));
42 addParam(
"offlineZSShaperDigits", m_SVDShaperDigitsName,
43 "Name of the SVDShaperDigits to use for computing occupancy (default is SVDShaperDigitsZS5).",
44 std::string(
"SVDShaperDigitsZS5"));
45 addParam(
"noInjectionTimeout", m_noInjectionTime,
46 "Time (microseconds) since last injection after which an event is considered \"No Injection\". "
47 "Also the limit for the x axis of the 2D histograms.",
49 m_trgTypes.push_back(TRGSummary::TTYP_POIS);
50 addParam(
"trgTypes", m_trgTypes,
51 "Trigger types for event selection. Empty to select everything. "
52 "Default is only Poisson w/o inj. veto.",
56 void SVDDQMDoseModule::defineHisto()
58 TDirectory* oldDir = gDirectory;
59 if (m_histogramDirectoryName !=
"") {
60 oldDir->mkdir(m_histogramDirectoryName.c_str());
61 oldDir->cd(m_histogramDirectoryName.c_str());
65 m_noInjectionTime = round(m_noInjectionTime / c_revolutionTime) * c_revolutionTime;
67 h_nEvtsVsTime =
new TH2F(
69 "SVD Events;Time since last injection [#mus];Time in beam cycle [#mus];Events / bin",
70 500, 0, m_noInjectionTime, 100, 0, c_revolutionTime);
72 m_groupOccupanciesU.reserve(c_sensorGroups.size());
73 TString name =
"SVDInstOccu_";
74 TString title =
"SVD Instantaneous Occupancy ";
75 TString axisTitle =
";Occupancy [%];Count / bin";
77 m_groupOccupanciesU.push_back(
78 new TH1F(name + group.nameSuffix +
"U",
79 title + group.titleSuffix +
" U-side" + axisTitle,
80 group.nBins, group.xMin, group.xMax));
83 m_groupNHitsU.reserve(c_sensorGroups.size());
84 name =
"SVDHitsVsTime_";
86 axisTitle =
";Time since last injection [#mus];Time in beam cycle[#mus];Hits / bin";
88 m_groupNHitsU.push_back(
89 new TH2F(name + group.nameSuffix +
"U",
90 title + group.titleSuffix +
" U-side" + axisTitle,
91 500, 0, m_noInjectionTime, 100, 0, c_revolutionTime));
95 int nb1 = TMath::Nint(m_noInjectionTime * 2.0 / c_revolutionTime);
96 h_nEvtsVsTime1 =
new TH1F(
97 "SVDEvtsVsTime1",
"SVD Events;Time since last injection [#mus];Events / bin",
98 nb1, 0, m_noInjectionTime);
100 m_groupNHits1U.reserve(c_sensorGroups.size());
101 name =
"SVDHitsVsTime1_";
103 axisTitle =
";Time since last injection [#mus];Hits / bin";
105 m_groupNHits1U.push_back(
106 new TH1F(name + group.nameSuffix +
"U",
107 title + group.titleSuffix +
" U-side" + axisTitle,
108 nb1, 0, m_noInjectionTime));
113 title =
"SVDBunchNumVSNStrips - ";
114 title += m_histogramDirectoryName;
115 title +=
";Bunch No.;Number of fired strips;Events / bin";
116 h_bunchNumVsNHits =
new TH2F(
"SVDBunchNumVSNStrips", title, 1280, 0, 1280, 10, 0, 10000);
121 void SVDDQMDoseModule::initialize()
126 m_rawTTD.isOptional();
127 m_digits.isOptional(m_SVDShaperDigitsName);
128 m_trgSummary.isOptional();
131 static bool nStripsComputed =
false;
134 nStripsComputed =
true;
136 for (
const auto& layer : geo.
getLayers(VXD::SensorInfoBase::SVD)) {
137 for (
const auto& ladder : geo.
getLadders(layer)) {
138 for (
const auto& sensor : geo.
getSensors(ladder)) {
139 const auto& sInfo = VXD::GeoCache::get(sensor);
141 if (group.contains(sensor)) {
143 group.nStripsU += sInfo.getUCells();
151 void SVDDQMDoseModule::beginRun()
153 h_nEvtsVsTime->Reset();
154 h_nEvtsVsTime1->Reset();
155 for (
const auto& histPtr : m_groupOccupanciesU)
157 for (
const auto& histPtr : m_groupNHitsU)
159 for (
const auto& histPtr : m_groupNHits1U)
161 h_bunchNumVsNHits->Reset();
164 void SVDDQMDoseModule::event()
168 static vector<int> groupHitsU(c_sensorGroups.size(), 0);
170 if (m_trgTypes.size()) {
171 if (!m_trgSummary.isValid()) {
172 B2WARNING(
"Missing TRGSummary, SVDDQMDose is skipped.");
175 auto ttyp = m_trgSummary->getTimType();
176 bool discardEvent =
true;
177 for (
const auto& ttyp2 : m_trgTypes) {
179 discardEvent =
false;
187 if (!m_rawTTD.isValid()) {
188 B2WARNING(
"Missing RawFTSW, SVDDQMDose is skipped.");
191 if (!m_digits.isValid()) {
192 B2WARNING(
"Missing SVDShaperDigit " << m_SVDShaperDigitsName
193 <<
", SVDDQMDose is skipped.");
197 if (m_rawTTD.getEntries() == 0)
201 const bool isHER = theTTD->
GetIsHER(0);
202 const EEventType eventType = timeSinceInj > m_noInjectionTime ? c_NoInjection : (isHER ? c_HERInjection : c_LERInjection);
203 if (((
unsigned int)eventType & m_eventFilter) == 0U)
205 const double timeInCycle = timeSinceInj - (int)(timeSinceInj / c_revolutionTime) * c_revolutionTime;
208 for (
int& count : groupHitsU) count = 0;
212 const VxdID& sensorID = hit.getSensorID();
213 if (hit.isUStrip()) {
214 for (
unsigned int i = 0; i < c_sensorGroups.size(); i++) {
215 if (c_sensorGroups[i].contains(sensorID)) {
217 m_groupNHitsU[i]->Fill(timeSinceInj, timeInCycle);
218 m_groupNHits1U[i]->Fill(timeSinceInj);
225 h_nEvtsVsTime->Fill(timeSinceInj, timeInCycle);
226 h_nEvtsVsTime1->Fill(timeSinceInj);
229 for (
unsigned int i = 0; i < c_sensorGroups.size(); i++)
230 m_groupOccupanciesU[i]->Fill(groupHitsU[i] * 100.0 / c_sensorGroups[i].nStripsU);
233 h_bunchNumVsNHits->Fill(theTTD->
GetBunchNumber(0), m_digits.getEntries());
236 const std::vector<SVDDQMDoseModule::SensorGroup> SVDDQMDoseModule::c_sensorGroups = {
237 {
"L3XX",
"L3", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 3; }},
238 {
"L4XX",
"L4", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 4; }},
239 {
"L5XX",
"L5", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 5; }},
240 {
"L6XX",
"L6", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 6; }},
241 {
"L31X",
"L3.1", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 3 && s.getLadderNumber() == 1; }},
242 {
"L32X",
"L3.2", c_defaultNBins, c_defaultOccuMin, c_defaultOccuMax, [](
const VxdID & s) {
return s.getLayerNumber() == 3 && s.getLadderNumber() == 2; }}
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
int GetIsHER(int n)
HER injection = 1 or LER injection = 0.
unsigned int GetTimeSinceLastInjection(int n)
Get time since the last injection.
unsigned int GetBunchNumber(int n)
Get a bunch number.
The SVD ShaperDigit class.
The SVD dose-monitoring DQM module.
EEventType
Bits definition for the bitmask that selects the events to put in the histograms.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
A struct to define non-trivial histograms in a human-readable way.