Belle II Software  release-05-02-19
CDCTriggerETFModule.cc
1 #include "trg/cdc/modules/trgcdc/CDCTriggerETFModule.h"
2 
3 #include <TH1.h>
4 
5 using namespace std;
6 using namespace Belle2;
7 
8 //this line registers the module with the framework and actually makes it available
9 //in steering files or the the module list (basf2 -m).
10 REG_MODULE(CDCTriggerETF);
11 
12 CDCTriggerETFModule::CDCTriggerETFModule() : Module::Module()
13 {
15  "The Event Time Finder module of the CDC trigger.\n"
16  "Uses fastest time of CDCTriggerSegmentHits to find the event time.\n"
17  );
19  addParam("hitCollectionName",
21  "Name of the input StoreArray of CDCTriggerSegmentHits.",
22  string(""));
23  addParam("EventTimeName", m_EventTimeName,
24  "Name of the output StoreObjPtr.",
25  string(""));
26  addParam("trueEventTime",
28  "If true, always output 0 (assuming this is the true event time for MC).",
29  false);
30  addParam("threshold",
32  "Event time is given by first timing bin with more than threshold hits.",
33  unsigned(3));
34 }
35 
36 void
38 {
39  // register DataStore elements
40  m_eventTime.registerInDataStore();
41  m_hits.isRequired(m_hitCollectionName);
42 }
43 
44 void
46 {
47  if (!m_eventTime.isValid()) m_eventTime.create();
48 
49  if (m_trueEventTime) {
50  m_eventTime->addBinnedEventT0(0, Const::CDC);
51  return;
52  }
53 
54  // counter for hits per super layer and clock cycle
55  int cnt[9][64] = {};
56  // histogram for fastest timings
57  TH1* h = new TH1D("h", "h", 1000, -500, 499);
58  // loop over clock cycles to get time ordered hits
59  for (int iClk = 0; iClk < 64; ++iClk) {
60  for (int iTS = 0; iTS < m_hits.getEntries(); ++iTS) {
61  int foundT = m_hits[iTS]->foundTime();
62  if (foundT / 16 + 31 != iClk)
63  continue;
64  int fastestT = m_hits[iTS]->fastestTime();
65  int whdiff = foundT - fastestT;
66  if (whdiff <= 256) {
67  // loop over super layers to get hits ordered by layer
68  for (int iSL = 0; iSL < 9; ++iSL) {
69  if (m_hits[iTS]->getISuperLayer() != iSL)
70  continue;
71  cnt[iSL][iClk] += 1;
72  if (cnt[iSL][iClk] <= 10) {
73  h->Fill(fastestT);
74  B2DEBUG(100, "fill fastestT " << fastestT);
75  }
76  }
77  }
78  }
79  }
80 
81  // find first histogram entry above threshold
82  bool foundT0 = false;
83  int T0 = 500;
84  for (int i = 450; i < 600; ++i) {
85  if (h->GetBinContent(i) > m_threshold) {
86  foundT0 = true;
87  T0 = i - 500;
88  break;
89  }
90  }
91  delete h;
92 
93  // save event time
94  if (foundT0) {
95  // add the event time as int for the following trigger modules
96  m_eventTime->addBinnedEventT0(T0, Const::CDC);
97  }
98 }
Belle2::CDCTriggerETFModule::m_threshold
unsigned m_threshold
bin threshold for event time
Definition: CDCTriggerETFModule.h:42
Belle2::CDCTriggerETFModule::m_trueEventTime
bool m_trueEventTime
if true, always output 0 (assuming this is the true event time for MC)
Definition: CDCTriggerETFModule.h:40
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::CDCTriggerETFModule::m_hits
StoreArray< CDCTriggerSegmentHit > m_hits
list of input track segment hits
Definition: CDCTriggerETFModule.h:52
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ 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:82
Belle2::CDCTriggerETFModule::m_eventTime
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr holding the event time.
Definition: CDCTriggerETFModule.h:50
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::CDCTriggerETFModule::m_EventTimeName
std::string m_EventTimeName
name of the output StoreObjPtr holding the event time
Definition: CDCTriggerETFModule.h:46
Belle2::CDCTriggerETFModule::event
virtual void event() override
Run the ETF for an event.
Definition: CDCTriggerETFModule.cc:45
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCTriggerETFModule::initialize
virtual void initialize() override
Initialize the module and register DataStore arrays.
Definition: CDCTriggerETFModule.cc:37
Belle2::Module::addParam
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:562
Belle2::CDCTriggerETFModule::m_hitCollectionName
std::string m_hitCollectionName
name of the input track segment hit StoreArray
Definition: CDCTriggerETFModule.h:44