Belle II Software development
SVDClusterEvaluationTrueInfoModule.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 <svd/modules/svdPerformance/SVDClusterEvaluationTrueInfoModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <mdst/dataobjects/MCParticle.h>
12#include <svd/dataobjects/SVDShaperDigit.h>
13#include <svd/dataobjects/SVDRecoDigit.h>
14#include <svd/dataobjects/SVDCluster.h>
15#include <svd/dataobjects/SVDTrueHit.h>
16
17#include <TCanvas.h>
18#include <TFile.h>
19#include <TGraphErrors.h>
20#include <TText.h>
21
22#include <string>
23
24
25using namespace Belle2;
26
27
28REG_MODULE(SVDClusterEvaluationTrueInfo);
29
30
32{
33 setDescription("This modules generates performance plots on SVD clustering.");
34
35 addParam("outputFileName", m_outputFileName, "output rootfile name", std::string("SVDClusterEvaluationTrueInfo.root"));
36 addParam("SVDEventInfo", m_svdEventInfoName, "Defines the name of the EventInfo", std::string(""));
37}
38
39
40SVDClusterEvaluationTrueInfoModule::~SVDClusterEvaluationTrueInfoModule()
41{
42}
43
44
46{
47
48 /* initialize useful store array */
49 StoreArray<SVDShaperDigit> SVDShaperDigits;
50 StoreArray<SVDRecoDigit> SVDRecoDigits;
51 StoreArray<SVDCluster> SVDClusters;
52 StoreArray<SVDTrueHit> SVDTrueHits;
53
54 SVDShaperDigits.isRequired();
55 SVDRecoDigits.isRequired();
56 SVDClusters.isRequired();
57 SVDTrueHits.isRequired();
58 if (!m_storeSVDEvtInfo.isOptional(m_svdEventInfoName)) m_svdEventInfoName = "SVDEventInfoSim";
60
61
62 m_outputFile = new TFile(m_outputFileName.c_str(), "RECREATE");
63
73 m_histoList_THinCluster = new TList;
74 m_histoList_THinClusterTM = new TList;
77 m_graphList = new TList;
78 //Control List
79 m_histoList_Control = new TList;
80
81 for (int i = 0; i < m_Nsets; i ++) {
82
83 if (i % 2 == 0) { //even index, U side
84 NameOfHisto = "histo_ClusterUPositionResolution_" + IntExtFromIndex(i) + "_" + FWFromIndex(i);
85 TitleOfHisto = "U-Cluster Position Resolution (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ")";
87 "U_reco - U_true (cm)",
89
90 NameOfHisto = "histo_ClusterUPositionPull_" + IntExtFromIndex(i) + "_" + FWFromIndex(i);
91 TitleOfHisto = "U-Cluster Position Pull (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ")";
93 "(U_reco - U_true)/U_sigma",
95 } else { //odd index, V side
96 NameOfHisto = "histo_ClusterVPositionResolution_" + IntExtFromIndex(i) + "_" + FWFromIndex(i);
97 TitleOfHisto = "V-Cluster Position Resolution (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ")";
99 "V_reco - V_true (cm)", m_histoList_ClusterPositionResolution);
100
101 NameOfHisto = "histo_ClusterVPositionPull_" + IntExtFromIndex(i) + "_" + FWFromIndex(i);
102 TitleOfHisto = "Cluster V Position Pull (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ")";
104 "(V_reco- V_true)/V_sigma", m_histoList_ClusterPositionPull);
105 }
106
107 NameOfHisto = "histo_StripTimeResolution_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
108 TitleOfHisto = "Strip Time Resolution (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(i) + ")";
109 m_histo_StripTimeResolution[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
111
112 NameOfHisto = "histo_ClusterTimeResolution_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
113 TitleOfHisto = "Cluster Time Resolution (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(i) + ")";
114 m_histo_ClusterTimeResolution[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
116
117 NameOfHisto = "histo_ClusterTimeResolution_bin1_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
118 TitleOfHisto = "Cluster Time Resolution TriggerBin=1(" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(
119 i) + ")";
120 m_histo_ClusterTimeResolution_bin1[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
122 NameOfHisto = "histo_ClusterTimeResolution_bin2_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
123 TitleOfHisto = "Cluster Time Resolution TriggerBin=2(" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(
124 i) + ")";
125 m_histo_ClusterTimeResolution_bin2[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
127 NameOfHisto = "histo_ClusterTimeResolution_bin3_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
128 TitleOfHisto = "Cluster Time Resolution TriggerBin=3(" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(
129 i) + ")";
130 m_histo_ClusterTimeResolution_bin3[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
132 NameOfHisto = "histo_ClusterTimeResolution_bin4_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
133 TitleOfHisto = "Cluster Time Resolution TriggerBin=4(" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(
134 i) + ")";
135 m_histo_ClusterTimeResolution_bin4[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 400, -100, 100, "t_reco - t_true (ns)",
137
138 NameOfHisto = "histo_ClusterTimePull_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
139 TitleOfHisto = "Cluster Time Pull (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(i) + ")";
140 m_histo_ClusterTimePull[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 210, -10, 11, "(t_reco - t_true)/t_sigma",
142
143 NameOfHisto = "histo2D_TresVsPosres_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
144 TitleOfHisto = "Time Residuals Vs U/V Position Residuals (" + IntExtFromIndex(
145 i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(i) + ")";
146 m_histo2D_TresVsPosres[i] = createHistogram2D(NameOfHisto, TitleOfHisto, 200, -0.1, 0.1, "U/V_reco - U/V_true (cm)", 180, -120, 60,
147 "t_reco - t_true (ns)", m_histo2DList_TresVsPosres);
148
149 NameOfHisto = "histo_PurityInsideTMCluster_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
150 TitleOfHisto = "Fraction of Truth-Matched RecoDigits inside a Truth-Matched Cluster (" + IntExtFromIndex(i) + ", " + FWFromIndex(
151 i) + ", side" + UVFromIndex(i) + ")";
153 "number of TM recoDigits / cluster size",
155
156 NameOfHisto = "histo2D_PurityInsideTMCluster_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
157 TitleOfHisto = "Number of Truth-matched Recos vs Number of Recos inside a Truth-matched Cluster (" + IntExtFromIndex(
158 i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(i) + ")";
159 m_histo2D_PurityInsideTMCluster[i] = createHistogram2D(NameOfHisto, TitleOfHisto, 42, 0, 42, "cluster size", 42, 0, 42,
160 "number of TM recos", m_histo2DList_PurityInsideTMCluster);
161
162 NameOfHisto = "histo_PurityInsideNOTMCluster_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
163 TitleOfHisto = "Fraction of Truth-matched RecoDigits inside a NOT Truth-matched Cluster (" + IntExtFromIndex(
164 i) + ", " + FWFromIndex(
165 i) + ", side" + UVFromIndex(i) + ")";
167 "number of TM recoDigits / cluster size",
169
170 NameOfHisto = "histo_THinCluster_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
171 TitleOfHisto = "Number of True Hits inside a Cluster (" + IntExtFromIndex(i) + ", " + FWFromIndex(i) + ", side" + UVFromIndex(
172 i) + ")";
173 m_histo_THinCluster[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 15, 0, 15, "number of TH per cluster",
175
176 NameOfHisto = "histo_THinClusterTM_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
177 TitleOfHisto = "Number of True Hits inside a Truth-matched Cluster (" + IntExtFromIndex(i) + ", " + FWFromIndex(
178 i) + ", side" + UVFromIndex(i) + ")";
179 m_histo_THinClusterTM[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 15, 0, 15, "number of TH per TM cluster",
181
182 NameOfHisto = "histo_GoodTHinClusterTM_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
183 TitleOfHisto = "Number of Good True Hits inside a Truth-matched Cluster (" + IntExtFromIndex(i) + ", " + FWFromIndex(
184 i) + ", side" + UVFromIndex(i) + ")";
185 m_histo_GoodTHinClusterTM[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 15, 0, 15, "number of Good TH per TM cluster",
187
188 NameOfHisto = "histo_GoodTHinClusterTMGood_" + IntExtFromIndex(i) + "_" + FWFromIndex(i) + "_Side" + UVFromIndex(i);
189 TitleOfHisto = "Number of Good True Hits inside a Good Truth-matched Cluster (" + IntExtFromIndex(i) + ", " + FWFromIndex(
190 i) + ", side" + UVFromIndex(i) + ")";
191 m_histo_GoodTHinClusterTMGood[i] = createHistogram1D(NameOfHisto, TitleOfHisto, 15, 0, 15, "number of Good TH per Good TM cluster",
193 }
194
195 //Control Histos
196 m_histoControl_MCcharge = createHistogram1D("m_histoControl_MCcharge", "m_histoControl_MCcharge", 5, -2, 3,
197 "charge of the first MC particle related to a True Hit", m_histoList_Control);
198 m_histoControl_MCisPrimary = createHistogram1D("m_histoControl_MCisPrimary", "m_histoControl_MCisPrimary", 2, 0, 2,
199 "isPrimary of the first MC particle related to a True Hit", m_histoList_Control);
200 m_histoControl_THToMCsize = createHistogram1D("m_histoControl_THToMCsize", "m_histoControl_THToMCsize", 10, -1, 9,
201 "size of the THToMC relation arrau", m_histoList_Control);
202}
203
204
205
207{
208
209 SVDModeByte modeByte = m_storeSVDEvtInfo->getModeByte();
210
211 StoreArray<SVDShaperDigit> SVDShaperDigits;
212 StoreArray<SVDRecoDigit> SVDRecoDigits;
213 StoreArray<SVDCluster> SVDClusters;
214 StoreArray<SVDTrueHit> SVDTrueHits;
215
217 //STRIPS//
219
220 //loop on ShaperDigits
221 for (const SVDShaperDigit& shape : SVDShaperDigits) {
222 indexForHistosAndGraphs = indexFromLayerSensorSide(shape.getSensorID().getLayerNumber(), shape.getSensorID().getSensorNumber(),
223 shape.isUStrip());
224
226
227 //efficiency shaper to reco
229 if (relatVectorShaperToReco.size() > 0)
231 }
232 //close loop on ShaperDigits
233
234 //loop on RecoDigits
235 for (const SVDRecoDigit& reco : SVDRecoDigits) {
236 indexForHistosAndGraphs = indexFromLayerSensorSide(reco.getSensorID().getLayerNumber(), reco.getSensorID().getSensorNumber(),
237 reco.isUStrip());
238
240
241 //strip time resolution
242 if (relatVectorRecoToTH.size() > 0)
243 m_histo_StripTimeResolution[indexForHistosAndGraphs]->Fill(reco.getTime() - (relatVectorRecoToTH[0])->getGlobalTime());
244
245 }
246 //close loop on RecoDigits
247
249 //CLUSTERS//
251
252 //loop on TrueHits
253 for (const SVDTrueHit& trhi : SVDTrueHits) {
254
255 if (goodTrueHit(&trhi)) { //enter only if the TH is related to a primary and charged MC particle
256 indexForHistosAndGraphs = indexFromLayerSensorSide(trhi.getSensorID().getLayerNumber(), trhi.getSensorID().getSensorNumber(), 1);
257
259
260 //efficiencies TH to cluster
263
264 bool hasU = false;
265 bool hasV = false;
266
267 for (int j = 0; j < (int) relatVectorTHToClus.size(); j ++) {
268 indexForHistosAndGraphs = indexFromLayerSensorSide(relatVectorTHToClus[j]->getSensorID().getLayerNumber(),
269 relatVectorTHToClus[j]->getSensorID().getSensorNumber(), relatVectorTHToClus[j]->isUCluster());
270
271 if (relatVectorTHToClus[j]->isUCluster() && ! hasU) {
273 hasU = true;
274 } else if (!relatVectorTHToClus[j]->isUCluster() && ! hasV) {
276 hasV = true;
277 }
278 }
279 }
280 }
281 //close loop on TrueHits
282
283 //loop on Clusters
284 for (const SVDCluster& clus : SVDClusters) {
285 indexForHistosAndGraphs = indexFromLayerSensorSide(clus.getSensorID().getLayerNumber(), clus.getSensorID().getSensorNumber(),
286 clus.isUCluster());
287
289
290 //purity "outside" clusters
292 if (relatVectorClusToTH.size() > 0)
294
295 //fill the THinCluster histo with the number of TH a cluster is composed of
296 m_histo_THinCluster[indexForHistosAndGraphs]->Fill(relatVectorClusToTH.size());
297
298 //loop on the TH related to the cluster
299 for (int q = 0; q < (int)relatVectorClusToTH.size(); q ++) {
300 //cluster time resolution and pull
301 m_histo_ClusterTimeResolution[indexForHistosAndGraphs]->Fill(clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime());
302
303 //get trigger bin
304 int triggerBin = 0;
305 triggerBin = (int)modeByte.getTriggerBin();
306
307 if (triggerBin == 0)
308 m_histo_ClusterTimeResolution_bin1[indexForHistosAndGraphs]->Fill(clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime());
309 else if (triggerBin == 1)
310 m_histo_ClusterTimeResolution_bin2[indexForHistosAndGraphs]->Fill(clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime());
311 else if (triggerBin == 2)
312 m_histo_ClusterTimeResolution_bin3[indexForHistosAndGraphs]->Fill(clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime());
313 else if (triggerBin == 3)
314 m_histo_ClusterTimeResolution_bin4[indexForHistosAndGraphs]->Fill(clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime());
315
316 m_histo_ClusterTimePull[indexForHistosAndGraphs]->Fill((clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()) /
317 (clus.getClsTimeSigma()));
318
319 //cluster position resolution and pull, also correlation between time res and position res
320 if (clus.isUCluster()) {
321 m_histo_ClusterUPositionResolution[indexForHistosAndGraphs / 2]->Fill(clus.getPosition((relatVectorClusToTH[q])->getV()) -
322 (relatVectorClusToTH[q])->getU());
323 m_histo_ClusterUPositionPull[indexForHistosAndGraphs / 2]->Fill((clus.getPosition((relatVectorClusToTH[q])->getV()) -
324 (relatVectorClusToTH[q])->getU()) / (clus.getPositionSigma()));
325 m_histo2D_TresVsPosres[indexForHistosAndGraphs]->Fill((clus.getPosition((relatVectorClusToTH[q])->getV()) -
326 (relatVectorClusToTH[q])->getU()), (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
327 } else {
328 m_histo_ClusterVPositionResolution[(indexForHistosAndGraphs - 1) / 2]->Fill(clus.getPosition() - (relatVectorClusToTH[q])->getV());
329 m_histo_ClusterVPositionPull[(indexForHistosAndGraphs - 1) / 2]->Fill((clus.getPosition() - (relatVectorClusToTH[q])->getV()) /
330 (clus.getPositionSigma()));
331 m_histo2D_TresVsPosres[indexForHistosAndGraphs]->Fill((clus.getPosition() - (relatVectorClusToTH[q])->getV()),
332 (clus.getClsTime() - (relatVectorClusToTH[q])->getGlobalTime()));
333 }
334 }
335
337 //enter only if the cluster is TM
338 if (relatVectorClusToTH.size() > 0) {
339
340 //fill the THinCluster histo with the number of TH (and good TH) a TM cluster (and a Good TM cluster) is composed of
341 m_histo_THinClusterTM[indexForHistosAndGraphs]->Fill(relatVectorClusToTH.size());
342 int numberOfGoodTHInACluster = 0;
343 int numberOfGoodTHInAClusterGood = 0;
344 for (int k = 0; k < (int)(relatVectorClusToTH.size()); k ++) {
345 if (goodTrueHit(relatVectorClusToTH[k])) {
346 numberOfGoodTHInACluster ++;
347 numberOfGoodTHInAClusterGood ++;
348 }
349 }
350 m_histo_GoodTHinClusterTM[indexForHistosAndGraphs]->Fill(numberOfGoodTHInACluster);
351 if (numberOfGoodTHInAClusterGood > 0)
352 m_histo_GoodTHinClusterTMGood[indexForHistosAndGraphs]->Fill(numberOfGoodTHInAClusterGood);
353
354 //count number of recodigit, composing the Truth-matched cluster, that are linked with a TH (internal purity)
356 for (int k = 0; k < (int)relatVectorClusToReco.size(); k++) { //loop on the recodigits composing the TM cluster
357 RelationVector<SVDTrueHit> relatVectorRecoFromClusToTH = DataStore::getRelationsWithObj<SVDTrueHit>(relatVectorClusToReco[k]);
358
359 if (relatVectorRecoFromClusToTH.size() > 0)
361 }
362
365
366 }
367 //count number of recodigit, composing a NOT Truth-matched cluster, that are linked with a TH
368 else {
369
371 for (int k = 0; k < (int)relatVectorClusToReco.size(); k++) { //loop on the recodigits composing the NOTM cluster
372 RelationVector<SVDTrueHit> relatVectorRecoFromClusToTH = DataStore::getRelationsWithObj<SVDTrueHit>(relatVectorClusToReco[k]);
373
374 if (relatVectorRecoFromClusToTH.size() > 0)
376 }
377
379
380 }
381 }
382 //close loop on clusters
383}
384
385
387{
388
389 //extract mean and sigma values from histos to plot them in graphs
390 for (int k = 0; k < m_Nsets; k ++) {
393
396
399
400 m_mean_THinCluster[k] = m_histo_THinCluster[k]->GetMean();
401 m_RMS_THinCluster[k] = m_histo_THinCluster[k]->GetRMS() / sqrt(m_histo_THinCluster[k]->GetEntries());
402
404 m_RMS_THinClusterTM[k] = m_histo_THinClusterTM[k]->GetRMS() / sqrt(m_histo_THinClusterTM[k]->GetEntries());
405
408
411 }
412 for (int k = 0; k < m_NsetsRed; k ++) {
415
418 }
419
420 //GRAPHS
421 createEfficiencyGraph("recoEff", "Strip Fit Efficiency ( RecoDigits / ShaperDigits )", m_NumberOfRecoDigit, m_NumberOfShaperDigit,
422 "set", "efficiency", m_graphList);
423
424 createEfficiencyGraph("clusterEff", "Clustering Efficiency ( Truth-Matched Clusters / TrueHits )", m_NumberOfClustersRelatedToTH,
425 m_NumberOfTH, "set", "efficiency", m_graphList);
426
427 createEfficiencyGraph("clusterPurity", "Purity of Clusters ( Truth-Matched Clusters / All Clusters )", m_NumberOfTMClusters,
428 m_NumberOfClusters, "set", "purity", m_graphList);
429
430 //means-from-histos graphs
431 createArbitraryGraphErrorChooser("stripTime_Means", "Strip Time Resolution", m_OrderingVec, m_NullVec, m_mean_StripTimeResolution,
432 m_RMS_StripTimeResolution, "set", "time residuals (ns)", m_graphList, m_Nsets);
433
434 createArbitraryGraphErrorChooser("clusterTime_Means", "Cluster Time Resolution", m_OrderingVec, m_NullVec,
436
437 createArbitraryGraphErrorChooser("clusterUposition_Means", "Cluster U Position Resolution", m_OrderingVec, m_NullVec,
439 m_NsetsRed);
440
441 createArbitraryGraphErrorChooser("clusterVposition_Means", "Cluster V Position Resolution", m_OrderingVec, m_NullVec,
443 m_NsetsRed);
444
445 createArbitraryGraphErrorChooser("clusterInternalPurity_Means", "Fraction of Truth-matched Recos inside a Truth-matched Cluster",
447 "number of TM recos / cluster size", m_graphList, m_Nsets);
448
449 createArbitraryGraphErrorChooser("THinCluster_Means", "Number of True Hits inside a Cluster", m_OrderingVec, m_NullVec,
450 m_mean_THinCluster, m_RMS_THinCluster, "set", "number of TH per cluster", m_graphList, m_Nsets);
451
452 createArbitraryGraphErrorChooser("THinClusterTM_Means", "Number of True Hits inside a TM Cluster", m_OrderingVec, m_NullVec,
453 m_mean_THinClusterTM, m_RMS_THinClusterTM, "set", "number of TH per TM cluster", m_graphList, m_Nsets);
454
455 createArbitraryGraphErrorChooser("goodTHinClusterTM_Means", "Number of Good True Hits inside a TM Cluster", m_OrderingVec,
456 m_NullVec,
457 m_mean_GoodTHinClusterTM, m_RMS_GoodTHinClusterTM, "set", "number of Good TH per TM cluster", m_graphList, m_Nsets);
458
459 createArbitraryGraphErrorChooser("goodTHinClusterTMGood_Means", "Number of Good True Hits inside a Good TM Cluster", m_OrderingVec,
460 m_NullVec,
461 m_mean_GoodTHinClusterTMGood, m_RMS_GoodTHinClusterTMGood, "set", "number of Good TH per Good TM cluster", m_graphList, m_Nsets);
463 //WRITE HISTOS AND GRAPHS//
465
466 if (m_outputFile != nullptr) {
467 m_outputFile->cd();
468
469 TDirectory* oldDir = gDirectory;
470 TObject* obj;
471
472 TDirectory* dir_strtime = oldDir->mkdir("strip_time");
473 dir_strtime->cd();
474 TIter nextH_strtime(m_histoList_StripTimeResolution);
475 while ((obj = nextH_strtime()))
476 obj->Write();
477
478 TDirectory* dir_cltime = oldDir->mkdir("cluster_time");
479 dir_cltime->cd();
480 TIter nextH_cltime(m_histoList_ClusterTimeResolution);
481 while ((obj = nextH_cltime()))
482 obj->Write();
483
484 TDirectory* dir_cltimepull = oldDir->mkdir("cluster_time_pull");
485 dir_cltimepull->cd();
486 TIter nextH_cltimepull(m_histoList_ClusterTimePull);
487 while ((obj = nextH_cltimepull()))
488 obj->Write();
489
490 TDirectory* dir_clpos = oldDir->mkdir("cluster_position");
491 dir_clpos->cd();
492 TIter nextH_clpos(m_histoList_ClusterPositionResolution);
493 while ((obj = nextH_clpos()))
494 obj->Write();
495
496 TDirectory* dir_clpospull = oldDir->mkdir("cluster_position_pull");
497 dir_clpospull->cd();
498 TIter nextH_clpospull(m_histoList_ClusterPositionPull);
499 while ((obj = nextH_clpospull()))
500 obj->Write();
501
502 TDirectory* dir_clpostime = oldDir->mkdir("cluster_timeVSposition");
503 dir_clpostime->cd();
504 TIter nextH_clpostime(m_histo2DList_TresVsPosres);
505 while ((obj = nextH_clpostime()))
506 obj->Write();
507
508 TDirectory* dir_clinpurTM = oldDir->mkdir("intra_cluster_purity_TM");
509 dir_clinpurTM->cd();
510 TIter nextH_clinpurTM(m_histoList_PurityInsideTMCluster);
511 while ((obj = nextH_clinpurTM()))
512 obj->Write();
513
514 TDirectory* dir_clinpurTM2D = oldDir->mkdir("intra_cluster_purity_TM2D");
515 dir_clinpurTM2D->cd();
516 TIter nextH_clinpurTM2D(m_histo2DList_PurityInsideTMCluster);
517 while ((obj = nextH_clinpurTM2D()))
518 obj->Write();
519
520 TDirectory* dir_clinpurNOTM = oldDir->mkdir("intra_cluster_purity_NOTM");
521 dir_clinpurNOTM->cd();
522 TIter nextH_clinpurNOTM(m_histoList_PurityInsideNOTMCluster);
523 while ((obj = nextH_clinpurNOTM()))
524 obj->Write();
525
526 TDirectory* dir_puddle = oldDir->mkdir("trueHits_in_cluster");
527 dir_puddle->cd();
528 TIter nextH_puddle(m_histoList_THinCluster);
529 while ((obj = nextH_puddle()))
530 obj->Write();
531
532 TDirectory* dir_puddleTM = oldDir->mkdir("trueHits_in_TMcluster");
533 dir_puddleTM->cd();
534 TIter nextH_puddleTM(m_histoList_THinClusterTM);
535 while ((obj = nextH_puddleTM()))
536 obj->Write();
537
538 TDirectory* dir_goodPuddleTM = oldDir->mkdir("goodTrueHits_in_TMcluster");
539 dir_goodPuddleTM->cd();
540 TIter nextH_GoodPuddleTM(m_histoList_GoodTHinClusterTM);
541 while ((obj = nextH_GoodPuddleTM()))
542 obj->Write();
543
544 TDirectory* dir_goodPuddleTMGood = oldDir->mkdir("goodTrueHits_in_GoodTMcluster");
545 dir_goodPuddleTMGood->cd();
546 TIter nextH_GoodPuddleTMGood(m_histoList_GoodTHinClusterTMGood);
547 while ((obj = nextH_GoodPuddleTMGood()))
548 obj->Write();
549
550 TDirectory* dir_graph = oldDir->mkdir("graphs");
551 dir_graph->cd();
552 TIter nextH_graph(m_graphList);
553 while ((obj = nextH_graph()))
554 obj->Write();
555
556 TDirectory* dir_controlsMC = oldDir->mkdir("controlMC");
557 dir_controlsMC->cd();
558 TIter nextH_controlsMC(m_histoList_Control);
559 while ((obj = nextH_controlsMC()))
560 obj->Write();
561
562 m_outputFile->Close();
563 }
564}
565
566
567
569//EXTRA FUNCTIONS//
571
572TH1F* SVDClusterEvaluationTrueInfoModule::createHistogram1D(const char* name, const char* title,
573 Int_t nbins, Double_t min, Double_t max,
574 const char* xtitle, TList* histoList)
575{
576 TH1F* h = new TH1F(name, title, nbins, min, max);
577
578 h->GetXaxis()->SetTitle(xtitle);
579
580 if (histoList)
581 histoList->Add(h);
582
583 return h;
584}
585
586TH2F* SVDClusterEvaluationTrueInfoModule::createHistogram2D(const char* name, const char* title,
587 Int_t nbinsX, Double_t minX, Double_t maxX,
588 const char* titleX,
589 Int_t nbinsY, Double_t minY, Double_t maxY,
590 const char* titleY, TList* histoList)
591{
592
593 TH2F* h = new TH2F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY);
594
595 h->GetXaxis()->SetTitle(titleX);
596 h->GetYaxis()->SetTitle(titleY);
597
598 if (histoList)
599 histoList->Add(h);
600
601 return h;
602}
603
604int SVDClusterEvaluationTrueInfoModule::indexFromLayerSensorSide(int LayerNumber, int SensorNumber, int UVNumber)
605{
606 int Index;
607
608 if (LayerNumber == 3) { //L3
609 if (UVNumber) //U
610 Index = 0;
611 else //V
612 Index = 1;
613 } else { //L456
614 if (SensorNumber == 1) { //FW
615 if (UVNumber) //U
616 Index = 2;
617 else //V
618 Index = 3;
619 } else { //barrel
620 if (UVNumber) //U
621 Index = 4;
622 else //V
623 Index = 5;
624 }
625 }
626
627 return Index;
628}
629
631{
632 TString name = "";
633
634 if (idx < 2)
635 name = "L3";
636 else
637 name = "L456";
638
639 return name;
640}
641
643{
644 TString name = "";
645
646 if (idx == 2 || idx == 3)
647 name = "FWD";
648 else
649 name = "Barrel";
650
651 return name;
652}
653
655{
656 TString name = "";
657
658 if (idx % 2 == 0)
659 name = "U";
660 else
661 name = "V";
662
663 return name;
664}
665
666void SVDClusterEvaluationTrueInfoModule::createEfficiencyGraph(const char* name, const char* title, const int vNum[m_Nsets],
667 const int vDen[m_Nsets],
668 TString xTitle, TString yTitle, TList* list)
669{
670
671 float ratio[m_Nsets];
672 float ratioErr[m_Nsets];
673 float x[m_Nsets];
674 float xErr[m_Nsets];
675
676 for (int set = 0; set < m_Nsets; set++) {
677
678 x[set] = set + 1;
679 xErr[set] = 0;
680
681 if (vDen[set] > 0) {
682 ratio[set] = (float)vNum[set] / (float)vDen[set];
683 ratioErr[set] = sqrt(ratio[set] * (1 - ratio[set]) / (float)vDen[set]);
684 }
685
686 }
687
688 TCanvas* c = new TCanvas(name, title);
689 TGraphErrors* g = new TGraphErrors(m_Nsets, x, ratio, xErr, ratioErr);
690 g->SetName(name);
691 g->SetTitle(title);
692 g->GetXaxis()->SetTitle(xTitle.Data());
693 g->GetYaxis()->SetTitle(yTitle.Data());
694 g->GetYaxis()->SetRangeUser(0.00001, 1.10);
695 g->Draw("AP");
696 g->SetMarkerStyle(20);
697 g->SetMarkerSize(0.8);
698 TAxis* xAxis = g->GetXaxis();
699
700 TText* t = new TText();
701 t->SetTextAlign(32);
702 t->SetTextSize(0.035);
703 t->SetTextFont(72);
704 TString labels[m_Nsets] = {"3U", "3V", "456FU", "456FV", "456BU", "456BV"};
705 for (Int_t i = 0; i < m_Nsets; i++) {
706 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
707 }
708
709 if (list)
710 list->Add(c);
711
712}
713
714void SVDClusterEvaluationTrueInfoModule::createArbitraryGraphErrorChooser(const char* name, const char* title, float x[m_Nsets],
715 float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList* list, int len)
716{
717 if (len == m_NsetsRed)
718 createArbitraryGraphError_Red(name, title, x, xErr, y, yErr, xTitle, yTitle, list);
719 else if (len == m_Nsets)
720 createArbitraryGraphError_Std(name, title, x, xErr, y, yErr, xTitle, yTitle, list);
721 else
722 B2INFO("ERROR, WRONG LENGTH FOR MEANS TGRAPH CREATION!!!");
723}
724
725void SVDClusterEvaluationTrueInfoModule::createArbitraryGraphError_Std(const char* name, const char* title, float x[m_Nsets],
726 float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList* list)
727{
728
729 TCanvas* c = new TCanvas(name, title);
730 TGraphErrors* g = new TGraphErrors(m_Nsets, x, y, xErr, yErr);
731 g->SetName(name);
732 g->SetTitle(title);
733 g->GetXaxis()->SetTitle(xTitle.Data());
734 g->GetYaxis()->SetTitle(yTitle.Data());
735 g->Draw("AP");
736 g->SetMarkerStyle(20);
737 g->SetMarkerSize(0.8);
738 TAxis* xAxis = g->GetXaxis();
739
740 TText* t = new TText();
741 t->SetTextAlign(32);
742 t->SetTextSize(0.035);
743 t->SetTextFont(72);
744 TString labels[m_Nsets] = {"3U", "3V", "456FU", "456FV", "456BU", "456BV"};
745 for (Int_t i = 0; i < m_Nsets; i++) {
746 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
747 }
748
749 if (list)
750 list->Add(c);
751
752}
753
754void SVDClusterEvaluationTrueInfoModule::createArbitraryGraphError_Red(const char* name, const char* title, float x[m_NsetsRed],
755 float xErr[m_NsetsRed], float y[m_NsetsRed], float yErr[m_NsetsRed], TString xTitle, TString yTitle, TList* list)
756{
757
758 TCanvas* c = new TCanvas(name, title);
759 TGraphErrors* g = new TGraphErrors(m_NsetsRed, x, y, xErr, yErr);
760 g->SetName(name);
761 g->SetTitle(title);
762 g->GetXaxis()->SetTitle(xTitle.Data());
763 g->GetYaxis()->SetTitle(yTitle.Data());
764 g->Draw("AP");
765 g->SetMarkerStyle(20);
766 g->SetMarkerSize(0.8);
767 TAxis* xAxis = g->GetXaxis();
768
769 TText* t = new TText();
770 t->SetTextAlign(32);
771 t->SetTextSize(0.035);
772 t->SetTextFont(72);
773 TString labels[m_NsetsRed] = {"3", "456F", "456B"};
774 for (Int_t i = 0; i < m_NsetsRed; i++) {
775 xAxis->SetBinLabel(xAxis->FindBin(i + 1), labels[i].Data());
776 }
777
778 if (list)
779 list->Add(c);
780
781}
782
784{
785
786
787 bool isGood = false;
788
789 RelationVector<MCParticle> relatVectorTHToMC = thino->getRelationsFrom<MCParticle>();
790
791 if (relatVectorTHToMC.size() > 0) {
792
793 m_histoControl_THToMCsize->Fill(relatVectorTHToMC.size());
794
795 float charge = relatVectorTHToMC[0]->getCharge();
796 bool primary = relatVectorTHToMC[0]->isPrimaryParticle();
797
798 m_histoControl_MCcharge->Fill(charge);
799 m_histoControl_MCisPrimary->Fill(primary);
800
801 if (charge != 0 && primary)
802 isGood = true;
803 }
804
805 return isGood;
806}
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
Definition DataStore.h:412
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
TH1F * m_histo_StripTimeResolution[m_Nsets]
Vector of histograms depicting Strip Time Residuals.
TList * m_histoList_StripTimeResolution
Lists used to easily Draw the corresponding histos; last one is used to draw the TGraphs.
float m_RMS_GoodTHinClusterTM[m_Nsets]
good true hits in cluster truth matched rms
float m_mean_ClusterTimeResolution[m_Nsets]
average cl time resid
TString NameOfHisto
Strings to pass names of the histos in the vectors of hitos.
static TString UVFromIndex(int idx)
Function returning "U" or "V" depending on the index.
int m_NumberOfClustersRelatedToTH[m_Nsets]
number of clusters related to true hits
TString TitleOfHisto
Strings to pass titles of the histos in the vectors of hitos.
TH1F * m_histoControl_MCcharge
Control Histos and List to check if the function used to define a TH as "good" is working fine.
static void createArbitraryGraphErrorChooser(const char *name, const char *title, float x[m_Nsets], float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList *list, int len)
Function choosing between the two following functions depending on the length of the provided arrays.
TList * m_histoList_PurityInsideTMCluster
histo list truth matched cluster purity (2D)
float m_RMS_ClusterTimeResolution[m_Nsets]
rms cluster time resid
TH1F * m_histo_ClusterUPositionPull[m_NsetsRed]
Vector of histograms depicting Cluster U Position Pull (Reduced length!)
static void createArbitraryGraphError_Red(const char *name, const char *title, float x[m_NsetsRed], float xErr[m_NsetsRed], float y[m_NsetsRed], float yErr[m_NsetsRed], TString xTitle, TString yTitle, TList *list)
Function returning an arbitrarily defined TGraph with arrays length equal to m_NsetsRed.
TH1F * m_histo_ClusterUPositionResolution[m_NsetsRed]
Vector of histograms depicting Cluster U Position Residual (Reduced length!)
TList * m_histoList_ClusterTimeResolution
histo list cluster time resolution
int m_NumberOfShaperDigit[m_Nsets]
Vectors used to compute the quantities depicted in Histos and Graphs.
static void createEfficiencyGraph(const char *name, const char *title, const int vNum[m_Nsets], const int vDen[m_Nsets], TString xTitle, TString yTitle, TList *list)
Function returning a TGraph with Y axis limited to 1 given numerator and denumerator vectors and plot...
float m_RMS_THinClusterTM[m_Nsets]
true hits in truth matched cluster rms
virtual void initialize() override
Initialize the SVDClusterEvaluationTrueInfo.
TList * m_histo2DList_TresVsPosres
histo list ime tresol VS position resol
int m_NumberOfTMRecoInNOTMCluster
number of truth matched reco digits in not truth matched clusters
int indexForHistosAndGraphs
Index used for the lists and for the vectors of histograms: it indicates the set of sensors we are lo...
TH1F * m_histo_ClusterVPositionPull[m_NsetsRed]
Vector of histograms depicting Cluster U Position Pull (Reduced length!)
virtual void event() override
This method is the core of the SVDClusterEvaluationTrueInfo.
float m_mean_GoodTHinClusterTM[m_Nsets]
good true hits in cluster truth matched average
int m_NumberOfTMClusters[m_Nsets]
number of truth matched clusters
float m_mean_ClusterVPositionResolution[m_Nsets]
average cl V position reosl
TH2F * createHistogram2D(const char *name, const char *title, Int_t nbinsX, Double_t minX, Double_t maxX, const char *titleX, Int_t nbinsY, Double_t minY, Double_t maxY, const char *titleY, TList *histoList)
Function returning TH2F.
TH1F * m_histo_ClusterTimeResolution_bin1[m_Nsets]
Vector of histograms depicting Cluster Time Residuals, divided by TriggerBin.
TH1F * m_histo_THinCluster[m_Nsets]
Vector of histograms depicting Number of TH inside a Cluster.
virtual void endRun() override
This method is called if the current run ends.
float m_mean_ClusterUPositionResolution[m_Nsets]
average cl U position resol
TH2F * m_histo2D_TresVsPosres[m_Nsets]
Vector of 2D histograms depicting Time Residuals Vs Position (U/V) Residuals for Histos.
TH1F * m_histo_GoodTHinClusterTM[m_Nsets]
Vector of histograms depicting Number of Good TH inside a TM Cluster.
TList * m_histoList_ClusterTimePull
histo list cluster time pull
TList * m_histoList_GoodTHinClusterTMGood
histo list goo true hits in cluster truth match good
float m_RMS_StripTimeResolution[m_Nsets]
rms of strip time residual
float m_mean_THinClusterTM[m_Nsets]
true hits in truth matched cluster average
float m_RMS_ClusterVPositionResolution[m_Nsets]
rms cl V position resol
float m_OrderingVec[m_Nsets]
Vectors used to Draw the TGraphs (defined in the cc) depicting the averages and the means of the hist...
TList * m_histoList_ClusterPositionPull
histo list cluster position pull
TList * m_histo2DList_PurityInsideTMCluster
histo list truth matched cluster purity (2D)
TList * m_histoList_PurityInsideNOTMCluster
histo list not truth matched cluster purity
TH1F * m_histo_PurityInsideTMCluster[m_Nsets]
Vector of histograms depicting Cluster Internal Purity (TM Recos over Reco inside a Cluster)
static TString FWFromIndex(int idx)
Function returning "Forward" or "Backward" depending on the index.
TH1F * m_histo_ClusterTimeResolution[m_Nsets]
Vector of histograms depicting Cluster Time Residuals.
TH1F * m_histo_ClusterTimePull[m_Nsets]
Vector of histograms depicting Cluster Time Pull.
static int indexFromLayerSensorSide(int LayerNumber, int SensorNumber, int UVNumber)
Function returning the index used for Histos.
TList * m_histoList_GoodTHinClusterTM
histo list good true hits in cluster truth matched
float m_mean_PurityInsideTMCluster[m_Nsets]
cluster purity average
bool goodTrueHit(const SVDTrueHit *thino)
Function defining if a TH is good (based on charge and primaryness)
float m_RMS_ClusterUPositionResolution[m_Nsets]
rms cl U position resol
static TString IntExtFromIndex(int idx)
Function returning "Internal" or "External" depending on the index.
float m_RMS_GoodTHinClusterTMGood[m_Nsets]
good true hits in cluster truth match good rms
std::string m_svdEventInfoName
Name of the SVDEventInfo object.
TH1F * m_histo_GoodTHinClusterTMGood[m_Nsets]
Vector of histograms depicting Number of Good TH inside a Good TM Cluster.
TH1F * createHistogram1D(const char *name, const char *title, Int_t nbins, Double_t min, Double_t max, const char *xtitle, TList *histoList)
Function returning a TH1F.
TH1F * m_histoControl_THToMCsize
control histo: true hit to mc size
TH1F * m_histo_ClusterVPositionResolution[m_NsetsRed]
Vector of histograms depicting Cluster V Position Residual (Reduced length!)
TList * m_histoList_THinCluster
histo list true hits in cluster
TH2F * m_histo2D_PurityInsideTMCluster[m_Nsets]
Vector of 2D histograms depicting TM Reco Vs Total Reco inside a TM Cluster.
float m_mean_GoodTHinClusterTMGood[m_Nsets]
good true hits in cluster truth match good average
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo
Storage for SVDEventInfo object.
TList * m_histoList_ClusterPositionResolution
histo list cluster position resolution
static void createArbitraryGraphError_Std(const char *name, const char *title, float x[m_Nsets], float xErr[m_Nsets], float y[m_Nsets], float yErr[m_Nsets], TString xTitle, TString yTitle, TList *list)
Function returning an arbitrarily defined TGraph with arrays length equal to m_Nsets.
TH1F * m_histo_PurityInsideNOTMCluster[m_Nsets]
Vector of histograms depicting TM Cluster Internal Purity (TM Recos over Reco inside a Cluster)
static const int m_Nsets
number of sets: L3-barrel-U, L3-barrel-V, L456-barrel-U, L456-barrel-V, L456-slanted-U,...
int m_NumberOfTMRecoInTMCluster
number of true match reco digit in truth match cluster
float m_mean_StripTimeResolution[m_Nsets]
Vectors of floats containing the mean and the RMS from the corresponding histo.
TH1F * m_histo_THinClusterTM[m_Nsets]
Vector of histograms depicting Number of TH inside a TM Cluster.
TList * m_histoList_THinClusterTM
histo list true hits in clsuter truth match
float m_mean_THinCluster[m_Nsets]
true hits in cluster average
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition SVDCluster.h:29
Class to store SVD mode information.
Definition SVDModeByte.h:69
baseType getTriggerBin() const
Get the triggerBin id.
The SVD RecoDigit class.
The SVD ShaperDigit class.
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition SVDTrueHit.h:33
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.