Belle II Software development
TOPOffsetCollectorModule.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 <top/modules/collectors/TOPOffsetCollectorModule.h>
10#include <framework/logging/Logger.h>
11#include <TH1F.h>
12
13
14using namespace std;
15
16namespace Belle2 {
21
22 //-----------------------------------------------------------------
24 //-----------------------------------------------------------------
25
26 REG_MODULE(TOPOffsetCollector);
27
28 //-----------------------------------------------------------------
29 // Implementation
30 //-----------------------------------------------------------------
31
33 {
34 // set module description and processing properties
35 setDescription("A collector for eventT0 and fill pattern offset calibrations");
37
38 }
39
41 {
42 m_recBunch.isRequired();
43 m_eventT0.isRequired();
44
45 m_names[Const::SVD] = "svdOffset";
46 m_names[Const::CDC] = "cdcOffset";
47 for (const auto& x : m_names) {
48 registerObject<TH1F>(x.second, new TH1F(x.second.c_str(), "Event T0 difference w.r.t TOP; #Delta T_{0} [ns]",
49 500, -50, 50));
50 }
51
52 int RFBuckets = m_bunchStructure->getRFBucketsPerRevolution();
53 registerObject<TH1F>("fillPattern", new TH1F("fillPattern", "Fill pattern from DB; bucket number",
54 RFBuckets, 0, RFBuckets));
55 registerObject<TH1F>("recBuckets", new TH1F("recBuckets", "Reconstructed buckets; bucket number",
56 RFBuckets, 0, RFBuckets));
57 }
58
59
61 {
62 auto h = getObjectPtr<TH1F>("fillPattern");
63 if (m_bunchStructure->isSet()) {
64 int RFBuckets = m_bunchStructure->getRFBucketsPerRevolution();
65 for (int i = 0; i < RFBuckets; i++) {
66 if (m_bunchStructure->getBucket(i)) h->SetBinContent(i + 1, 1);
67 }
68 }
69 }
70
71
73 {
74 if (not m_recBunch->isReconstructed()) return;
75
76 for (const auto& x : m_names) {
77 const auto& detector = x.first;
78 if (m_eventT0->hasTemporaryEventT0(detector)) {
79 auto eventT0s = m_eventT0->getTemporaryEventT0s(detector);
80 if (eventT0s.empty()) continue;
81 if (detector == Const::CDC and eventT0s.back().algorithm != "chi2") continue;
82 double t0 = eventT0s.back().eventT0;
83 auto h = getObjectPtr<TH1F>(x.second);
84 h->Fill(t0 - m_recBunch->getTime());
85 }
86 }
87
88 auto h = getObjectPtr<TH1F>("recBuckets");
89 h->Fill(m_recBunch->getBucketNumber(0, m_bunchStructure->getRFBucketsPerRevolution()));
90 }
91
93}
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
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
std::map< Const::EDetector, std::string > m_names
histogram names
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
StoreObjPtr< EventT0 > m_eventT0
event T0
DBObjPtr< BunchStructure > m_bunchStructure
fill pattern
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
virtual void collect() final
Replacement for event().
virtual void startRun() final
Replacement for beginRun().
virtual void prepare() final
Replacement for initialize().
Abstract base class for different kinds of events.
STL namespace.