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