Belle II Software  release-05-01-25
PXDGatedDHCDQMModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Bjoern Spruck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <pxd/modules/pxdDQM/PXDGatedDHCDQMModule.h>
12 #include "TDirectory.h"
13 
14 using namespace std;
15 using namespace Belle2;
16 using namespace Belle2::PXD;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 REG_MODULE(PXDGatedDHCDQM)
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
28 {
29  //Set module properties
30  setDescription("Monitor Gating after Injection");
31  setPropertyFlags(c_ParallelProcessingCertified);
32  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
33  std::string("PXDINJ"));
34 }
35 
36 void PXDGatedDHCDQMModule::defineHisto()
37 {
38  TDirectory* oldDir = gDirectory;
39  oldDir->mkdir(m_histogramDirectoryName.c_str());// do not rely on return value, might be ZERO
40  oldDir->cd(m_histogramDirectoryName.c_str());//changing to the right directory
41 
42  hGateAfterInjLER = new TH2F("PXDGateingInjLER", "PXDGateingInjLER/Time;Time in #mus;Flags", 100000, 0, 50000, 64, 0, 64);
43  hGateAfterInjHER = new TH2F("PXDGateingInjHER", "PXDGateingInjHER/Time;Time in #mus;Flags", 100000, 0, 50000, 64, 0, 64);
44  // cd back to root directory
45  oldDir->cd();
46 }
47 
48 void PXDGatedDHCDQMModule::initialize()
49 {
50  REG_HISTOGRAM
51  m_storeDAQEvtStats.isRequired();
52  m_rawTTD.isRequired();
53 }
54 
55 void PXDGatedDHCDQMModule::beginRun()
56 {
57  // Assume that everthing is non-zero ;-)
58  hGateAfterInjLER->Reset();
59  hGateAfterInjHER->Reset();
60 }
61 
62 void PXDGatedDHCDQMModule::event()
63 {
64 
65  for (auto& it : m_rawTTD) {
66  B2DEBUG(29, "TTD FTSW : " << hex << it.GetTTUtime(0) << " " << it.GetTTCtime(0) << " EvtNr " << it.GetEveNo(0) << " Type " <<
67  (it.GetTTCtimeTRGType(0) & 0xF) << " TimeSincePrev " << it.GetTimeSincePrevTrigger(0) << " TimeSinceInj " <<
68  it.GetTimeSinceLastInjection(0) << " IsHER " << it.GetIsHER(0) << " Bunch " << it.GetBunchNumber(0));
69 
70  // get last injection time
71  auto difference = it.GetTimeSinceLastInjection(0);
72  // check time overflow, too long ago
73  if (difference != 0x7FFFFFFF) {
74  float diff2 = difference / 127.; // 127MHz clock ticks to us, inexact rounding
75  bool isher = it.GetIsHER(0);
76  for (auto& pkt : *m_storeDAQEvtStats) {
77  for (auto& dhc : pkt) {
78  int value = dhc.getDHCID() * 4 + dhc.getGatedFlag() * 2 + dhc.getGatedHER();
79  if (isher) {
80  hGateAfterInjHER->Fill(diff2, value);
81  } else {
82  hGateAfterInjLER->Fill(diff2, value);
83  }
84  }
85  }
86  }
87 
88  break;
89  }
90 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::PXD::PXDGatedDHCDQMModule
The PXD Gatint after Injection DQM module.
Definition: PXDGatedDHCDQMModule.h:46
Belle2::PXD
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Definition: PXDCalibrationUtilities.h:28
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::HistoModule
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29