Belle II Software  release-08-01-10
SVDTimeValidationCollectorModule.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/svdTimeValidationCollector/SVDTimeValidationCollectorModule.h>
9 
10 using namespace std;
11 using namespace Belle2;
12 
13 //-----------------------------------------------------------------
14 // Register the Module
15 //-----------------------------------------------------------------
16 REG_MODULE(SVDTimeValidationCollector);
17 
18 //-----------------------------------------------------------------
19 // Implementation
20 //-----------------------------------------------------------------
21 
22 SVDTimeValidationCollectorModule::SVDTimeValidationCollectorModule() : CalibrationCollectorModule()
23 {
24  //Set module properties
25 
26  setDescription("Collector module used to create the histograms needed for the SVD 6-Sample CoG, 3-Sample CoG and 3-Sample ELS Time calibration");
28 
29  addParam("SVDClustersName", m_svdClusters, "Name of the SVDClusters list", m_svdClusters);
30  addParam("SVDClustersOnTracksName", m_svdClustersOnTracks, "Name of the SVDClustersOnTracks list", m_svdClustersOnTracks);
31  addParam("EventT0Name", m_eventTime, "Name of the EventT0 list", m_eventTime);
32  addParam("RecoTracksName", m_recotrack, "Name of the RecoTracks list", m_recotrack);
33  addParam("TracksName", m_track, "Name of the Tracks list", m_track);
34 }
35 
37 {
38 
39  auto hEventT0 = new TH1F("hEventT0", "EventT0", 300, -150, 150);
40  registerObject<TH1F>("hEventT0", hEventT0);
41 
44  m_eventT0.isRequired(m_eventTime);
46  m_trk.isRequired(m_track);
47 
49  std::vector<Belle2::VxdID> allSensors;
50  for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD))
51  for (auto ladder : geoCache.getLadders(layer))
52  for (Belle2::VxdID sensor : geoCache.getSensors(ladder))
53  allSensors.push_back(sensor);
54 
55  int numberOfSensorBin = 2 * int(allSensors.size());
56  B2INFO("Number of SensorBin: " << numberOfSensorBin);
57 
58  TH2F* __hClsTimeOnTracks__ = new TH2F("__hClsTimeOnTracks__", "clsTimeOnTracks",
59  300, -150, 150,
60  numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
61  TH2F* __hClsTimeAll__ = new TH2F("__hClsTimeAll__", "clsTimeAll",
62  300, -150, 150,
63  numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
64  TH2F* __hClsDiffTimeOnTracks__ = new TH2F("__hClsDiffTimeOnTracks__", "clsDiffTimeOnTracks",
65  300, -150, 150,
66  numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
67  TH3F* __hClusterSizeVsTimeResidual__ = new TH3F("__hClusterSizeVsTimeResidual__",
68  "ClusterSize vs Time Residual",
69  100, -25., 25., 10, 0.5, + 10.5,
70  numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
71  TH1F* __hBinToSensorMap__ = new TH1F("__hBinToSensorMap__", "__BinToSensorMap__",
72  numberOfSensorBin, + 0.5, numberOfSensorBin + 0.5);
73  __hClsTimeOnTracks__->GetYaxis()->SetTitle("sensor");
74  __hClsTimeOnTracks__->GetXaxis()->SetTitle("clsTime_onTracks (ns)");
75  __hClsTimeAll__->GetYaxis()->SetTitle("sensor");
76  __hClsTimeAll__->GetXaxis()->SetTitle("clsTime_all (ns)");
77  __hClsDiffTimeOnTracks__->GetYaxis()->SetTitle("sensor");
78  __hClsDiffTimeOnTracks__->GetXaxis()->SetTitle("clsDiffTime_onTracks (ns)");
79  __hClusterSizeVsTimeResidual__->GetZaxis()->SetTitle("Sensor");
80  __hClusterSizeVsTimeResidual__->GetYaxis()->SetTitle("Cluster Size");
81  __hClusterSizeVsTimeResidual__->GetXaxis()->SetTitle("Cluster Time - EventT0 (ns)");
82 
83  int tmpBinCnt = 0;
84  for (auto sensor : allSensors) {
85  for (auto view : {'U', 'V'}) {
86  tmpBinCnt++;
87  TString binLabel = TString::Format("L%iL%iS%i%c",
88  sensor.getLayerNumber(),
89  sensor.getLadderNumber(),
90  sensor.getSensorNumber(),
91  view);
92  __hBinToSensorMap__->GetXaxis()->SetBinLabel(tmpBinCnt, binLabel);
93  }
94  }
95  registerObject<TH2F>(__hClsTimeOnTracks__->GetName(), __hClsTimeOnTracks__);
96  registerObject<TH2F>(__hClsTimeAll__->GetName(), __hClsTimeAll__);
97  registerObject<TH2F>(__hClsDiffTimeOnTracks__->GetName(), __hClsDiffTimeOnTracks__);
98  registerObject<TH1F>(__hBinToSensorMap__->GetName(), __hBinToSensorMap__);
99  registerObject<TH3F>(__hClusterSizeVsTimeResidual__->GetName(), __hClusterSizeVsTimeResidual__);
100 }
101 
103 {
104  getObjectPtr<TH1F>("hEventT0")->Reset();
105  getObjectPtr<TH2F>("__hClsTimeOnTracks__")->Reset();
106  getObjectPtr<TH2F>("__hClsTimeAll__")->Reset();
107  getObjectPtr<TH2F>("__hClsDiffTimeOnTracks__")->Reset();
108  getObjectPtr<TH1F>("__hBinToSensorMap__")->Reset();
109  getObjectPtr<TH3F>("__hClusterSizeVsTimeResidual__")->Reset();
110 }
111 
113 {
114  if (m_eventT0->hasEventT0()) {
115  float eventT0 = m_eventT0->getEventT0();
116  getObjectPtr<TH1F>("hEventT0")->Fill(eventT0);
117 
118  // Fill histograms clusters on tracks
119  for (const auto& svdCluster : m_svdClsOnTrk) {
120  // get cluster time
121  float clusterTime = svdCluster.getClsTime();
122  int clusterSize = svdCluster.getSize();
123 
124  TString binLabel = TString::Format("L%iL%iS%i%c",
125  svdCluster.getSensorID().getLayerNumber(),
126  svdCluster.getSensorID().getLadderNumber(),
127  svdCluster.getSensorID().getSensorNumber(),
128  svdCluster.isUCluster() ? 'U' : 'V');
129  int sensorBin = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->FindBin(binLabel.Data());
130  double sensorBinCenter = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->GetBinCenter(sensorBin);
131 
132  getObjectPtr<TH2F>("__hClsTimeOnTracks__")->Fill(clusterTime, sensorBinCenter);
133  getObjectPtr<TH2F>("__hClsDiffTimeOnTracks__")->Fill(clusterTime - eventT0, sensorBinCenter);
134  getObjectPtr<TH3F>("__hClusterSizeVsTimeResidual__")->Fill(clusterTime - eventT0, clusterSize, sensorBinCenter);
135  };
136 
137  // Fill histograms with all clusters
138  for (const auto& svdCluster : m_svdCls) {
139  // get cluster time
140  float clusterTime = svdCluster.getClsTime();
141 
142  TString binLabel = TString::Format("L%iL%iS%i%c",
143  svdCluster.getSensorID().getLayerNumber(),
144  svdCluster.getSensorID().getLadderNumber(),
145  svdCluster.getSensorID().getSensorNumber(),
146  svdCluster.isUCluster() ? 'U' : 'V');
147  int sensorBin = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->FindBin(binLabel.Data());
148  double sensorBinCenter = getObjectPtr<TH1F>("__hBinToSensorMap__")->GetXaxis()->GetBinCenter(sensorBin);
149 
150  getObjectPtr<TH2F>("__hClsTimeAll__")->Fill(clusterTime, sensorBinCenter);
151  };
152  }
153 }
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
StoreArray< SVDCluster > m_svdClsOnTrk
SVDClusters store array.
void prepare() override final
Initialize the module.
StoreObjPtr< EventT0 > m_eventT0
EventT0 store object pointer.
StoreArray< SVDCluster > m_svdCls
SVDClusters store array.
StoreArray< Track > m_trk
Tracks store object pointer.
StoreArray< RecoTrack > m_recoTrk
RecoTracks store object pointer.
void startRun() override final
Called when entering a new run.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.