Belle II Software development
SVDClusterTimeShifterCollectorModule.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 <svd/modules/svdTimeCalibrationCollector/SVDClusterTimeShifterCollectorModule.h>
9
10using namespace Belle2;
11
12//-----------------------------------------------------------------
13// Register the Module
14//-----------------------------------------------------------------
15REG_MODULE(SVDClusterTimeShifterCollector);
16
17//-----------------------------------------------------------------
18// Implementation
19//-----------------------------------------------------------------
20
22{
23 //Set module properties
24
25 setDescription("Collector module used to create the histograms needed for the SVD 6-Sample CoG, 3-Sample CoG and 3-Sample ELS Time calibration. "
26 "This is for the cluster-size dependent correction of the calibrated time.");
28
29 addParam("SVDClustersOnTrackPrefix", m_svdClustersOnTrackPrefix, "set prefix of the list of clusters on track",
31 addParam("TimeAlgorithms", m_timeAlgorithms, "set list of time algorithms", m_timeAlgorithms);
32 addParam("MaxClusterSize", m_maxClusterSize, "Maximum size of SVD clusters", m_maxClusterSize);
33 addParam("EventT0Name", m_eventT0Name, "Name of the EventT0 list", m_eventT0Name);
34}
35
37{
38
39 for (auto alg : m_timeAlgorithms) {
41 m_svdClustersOnTrack[alg].isRequired((m_svdClustersOnTrackPrefix + '_' + alg).data());
42 }
43 m_eventT0.isRequired(m_eventT0Name);
44
45 // getting all the svd sensors
47 std::vector<Belle2::VxdID> allSensors;
48 for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD))
49 for (auto ladder : geoCache.getLadders(layer)) {
50 for (Belle2::VxdID sensor : geoCache.getSensors(ladder))
51 allSensors.push_back(sensor);
52 break;
53 }
54
55 int numberOfSensorBin = 2 * int(allSensors.size());
56 B2INFO("Number of SensorBin: " << numberOfSensorBin);
57
58 for (auto alg : m_timeAlgorithms) {
59 TH3F* __hClusterSizeVsTimeResidual__ = new TH3F(("__hClusterSizeVsTimeResidual__" + alg).data(),
60 ("ClusterSize vs " + alg + " Time Residual").data(),
61 400, -50., 50., m_maxClusterSize, 0.5, m_maxClusterSize + 0.5,
62 numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
63 __hClusterSizeVsTimeResidual__->GetZaxis()->SetTitle("Sensor");
64 __hClusterSizeVsTimeResidual__->GetYaxis()->SetTitle("Cluster Size");
65 __hClusterSizeVsTimeResidual__->GetXaxis()->SetTitle("Cluster Time - EventT0 (ns)");
66 registerObject<TH3F>(__hClusterSizeVsTimeResidual__->GetName(), __hClusterSizeVsTimeResidual__);
67 }
68
69 TH1F* __hBinToSensorMap__ = new TH1F("__hBinToSensorMap__", "__BinToSensorMap__",
70 numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
71 int tmpBinCnt = 0;
72 for (auto sensor : allSensors) {
73 for (auto view : {'U', 'V'}) {
74 tmpBinCnt++;
75 TString binLabel = TString::Format("L%iS%iS%c", sensor.getLayerNumber(), sensor.getSensorNumber(), view);
76 __hBinToSensorMap__->GetXaxis()->SetBinLabel(tmpBinCnt, binLabel);
77 }
78 }
79 registerObject<TH1F>(__hBinToSensorMap__->GetName(), __hBinToSensorMap__);
80}
81
83{
84 for (auto alg : m_timeAlgorithms)
85 getObjectPtr<TH3F>(("__hClusterSizeVsTimeResidual__" + alg).data())->Reset();
86 getObjectPtr<TH1F>("__hBinToSensorMap__")->Reset();
87}
88
90{
91 float eventT0 = 0;
92 // Set the CDC event t0 value if it exists
93 if (m_eventT0->hasTemporaryEventT0(Const::EDetector::CDC)) {
94 const auto evtT0CDC = m_eventT0->getBestCDCTemporaryEventT0();
95 eventT0 = evtT0CDC->eventT0;
96 } else {return;}
97
98 // Fill histograms clusters on tracks
99 for (auto alg : m_timeAlgorithms) {
100
101 if (!m_svdClustersOnTrack[alg].isValid()) {
102 B2WARNING("!!!! List is not Valid: isValid() = " << m_svdClustersOnTrack[alg].isValid());
103 return;
104 }
105 for (const auto& svdCluster : m_svdClustersOnTrack[alg]) {
106
107 // get cluster time
108 float clusterTime = svdCluster.getClsTime();
109 int clusterSize = svdCluster.getSize();
110 if (clusterSize > m_maxClusterSize) clusterSize = m_maxClusterSize;
111
112 TString binLabel = TString::Format("L%iS%iS%c",
113 svdCluster.getSensorID().getLayerNumber(),
114 svdCluster.getSensorID().getSensorNumber(),
115 svdCluster.isUCluster() ? 'U' : 'V');
116 int sensorBin = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->FindBin(binLabel.Data());
117 double sensorBinCenter = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->GetBinCenter(sensorBin);
118 getObjectPtr<TH3F>(("__hClusterSizeVsTimeResidual__" + alg).data())->Fill(clusterTime - eventT0, clusterSize, sensorBinCenter);
119 }
120 } // loop over alg
121}
Calibration collector module base class.
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
StoreObjPtr< EventT0 > m_eventT0
EventT0 store object pointer.
std::string m_svdClustersOnTrackPrefix
Name Prefix of the SVDClustersOnTracks store array.
std::string m_eventT0Name
Name of the EventT0 store object pointer used as parameter of the module.
void startRun() override final
Called when entering a new run.
std::vector< std::string > m_timeAlgorithms
List of time algorithms to calibrate.
std::map< TString, StoreArray< SVDCluster > > m_svdClustersOnTrack
SVDClusters store array.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
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.