Belle II Software  release-08-00-10
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 
25 PXDGatedDHCDQMModule::PXDGatedDHCDQMModule() : HistoModule()
26 {
27  //Set module properties
28  setDescription("Monitor Gating after Injection");
30  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
31  std::string("PXDINJ"));
32 }
33 
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 
47 {
48  REG_HISTOGRAM
49  m_storeDAQEvtStats.isRequired();
50  m_rawTTD.isRequired();
51 }
52 
54 {
55  // Assume that everthing is non-zero ;-)
56  hGateAfterInjLER->Reset();
57  hGateAfterInjHER->Reset();
58 }
59 
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
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
TH2F * hGateAfterInjHER
Histogram after HER injection.
StoreObjPtr< PXDDAQStatus > m_storeDAQEvtStats
Input array for DAQ Status.
TH2F * hGateAfterInjLER
Histogram after LER injection.
StoreArray< RawFTSW > m_rawTTD
Input array for DAQ Status.
void defineHisto() override final
defineHisto function
void event() override final
event function
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
void beginRun() override final
beginRun function
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
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.