Belle II Software development
CDCTriggerETFModule.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#include "trg/cdc/modules/trgcdc/CDCTriggerETFModule.h"
9
10#include <TH1.h>
11
12using namespace std;
13using namespace Belle2;
14
15//this line registers the module with the framework and actually makes it available
16//in steering files or the the module list (basf2 -m).
17REG_MODULE(CDCTriggerETF);
18
20{
22 "The Event Time Finder module of the CDC trigger.\n"
23 "Uses fastest time of CDCTriggerSegmentHits to find the event time.\n"
24 );
26 addParam("hitCollectionName",
28 "Name of the input StoreArray of CDCTriggerSegmentHits.",
29 string(""));
30 addParam("EventTimeName", m_EventTimeName,
31 "Name of the output StoreObjPtr.",
32 string(""));
33 addParam("trueEventTime",
35 "If true, always output 0 (assuming this is the true event time for MC).",
36 false);
37 addParam("threshold",
39 "Event time is given by first timing bin with more than threshold hits.",
40 unsigned(3));
41}
42
43void
45{
46 // register DataStore elements
49}
50
51void
53{
55
56 if (m_trueEventTime) {
57 m_eventTime->addBinnedEventT0(0, Const::CDC);
58 return;
59 }
60
61 // counter for hits per super layer and clock cycle
62 int cnt[9][64] = {};
63 // histogram for fastest timings
64 TH1* h = new TH1D("h", "h", 1000, -500, 499);
65 // loop over clock cycles to get time ordered hits
66 for (int iClk = 0; iClk < 64; ++iClk) {
67 for (int iTS = 0; iTS < m_hits.getEntries(); ++iTS) {
68 int foundT = m_hits[iTS]->foundTime();
69 if (foundT / 16 + 31 != iClk)
70 continue;
71 int fastestT = m_hits[iTS]->fastestTime();
72 int whdiff = foundT - fastestT;
73 if (whdiff <= 256) {
74 // loop over super layers to get hits ordered by layer
75 for (int iSL = 0; iSL < 9; ++iSL) {
76 if (m_hits[iTS]->getISuperLayer() != iSL)
77 continue;
78 cnt[iSL][iClk] += 1;
79 if (cnt[iSL][iClk] <= 10) {
80 h->Fill(fastestT);
81 B2DEBUG(100, "fill fastestT " << fastestT);
82 }
83 }
84 }
85 }
86 }
87
88 // find first histogram entry above threshold
89 bool foundT0 = false;
90 int T0 = 500;
91 for (int i = 450; i < 600; ++i) {
92 if (h->GetBinContent(i) > m_threshold) {
93 foundT0 = true;
94 T0 = i - 500;
95 break;
96 }
97 }
98 delete h;
99
100 // save event time
101 if (foundT0) {
102 // add the event time as int for the following trigger modules
103 m_eventTime->addBinnedEventT0(T0, Const::CDC);
104 }
105}
void addBinnedEventT0(int eventT0, Const::EDetector detector)
Store a binned event t0 for the given detector replacing any other hypothesis for this detector.
std::string m_EventTimeName
name of the output StoreObjPtr holding the event time
virtual void initialize() override
Initialize the module and register DataStore arrays.
virtual void event() override
Run the ETF for an event.
unsigned m_threshold
bin threshold for event time
CDCTriggerETFModule()
Constructor, for setting module description and parameters.
StoreArray< CDCTriggerSegmentHit > m_hits
list of input track segment hits
bool m_trueEventTime
if true, always output 0 (assuming this is the true event time for MC)
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr holding the event time.
std::string m_hitCollectionName
name of the input track segment hit StoreArray
Base class for Modules.
Definition: Module.h:72
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
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
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
Abstract base class for different kinds of events.
STL namespace.