Belle II Software development
trgcdct3dDQM.py
1#!/usr/bin/env python
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# CDCTRGT3D Unpacker and Converter
14#
15# usage : %> basf2 trgcdct3dUnpackerConverter -i [input sroot file name] -o [output root file name]
16#
17# -----------------------------------------------------------------------------------
18
19import basf2
20
21import sys # get argv
22argvs = sys.argv # get arg
23argc = len(argvs) # of arg
24
25if argc == 3:
26 inname = argvs[1]
27 histname = argvs[2]
28 # outname=argvs[2]
29 # histname=argvs[3]
30else:
31 sys.exit("trgcdct3dDQM.py> # of arg is strange. Exit.")
32
33
34# class is2DSkim(basf2.Module):
35# def event(self):
36# Tracks = ROOT.Belle2.PyStoreArray("Tracks")
37# TRGGRLT3DUnpackerStores = ROOT.Belle2.PyStoreArray("TRGCDCT3DUnpackerStores")
38#
39# isTwoTrack = False
40# if len(Tracks) == 2:
41# isTwoTrack = True
42#
43# areTracksClean = True
44# for track in Tracks:
45# trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
46# if trackResult.getPValue() > 0.1:
47# areTracksClean = False
48#
49# enoughHits = True
50# for track in Tracks:
51# trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
52# nHitStSl = 0
53# nHitAxSl = 0
54# for iAx in range(5):
55# if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iAx) > 3):
56# nHitAxSl += 1
57# for iSt in range(4):
58# if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iSt + 1) > 3):
59# nHitStSl += 1
60# if nHitStSl < 3:
61# enoughHits = False
62# if nHitAxSl < 4:
63# enoughHits = False
64#
65# is2D = False
66# for iClk, data in enumerate(TRGGRLT3DUnpackerStores):
67# if (data.m_t2d_fnf != 0):
68# is2D = True
69#
70# self.return_value(isTwoTrack and is2D and areTracksClean and enoughHits)
71
72
73if __name__ == '__main__':
74 from ROOT import Belle2 # noqa: make Belle2 namespace available
75 import ROOT.Belle2
76
77 basf2.use_central_database("development")
78# Hot fix for CDCFudgeFactorFromSigma
79 basf2.use_local_database(ROOT.Belle2.FileSystem.findFile("data/trg/cdc/db_CDCFudgeFactorsForSigma.txt"), "localdb")
80
81 empty_path = basf2.create_path()
82# skim = basf2.register_module(is2DSkim())
83# skim.if_value('=0', empty_path, basf2.AfterConditionPath.END)
84
85 # Create main path
86 main = basf2.create_path()
87 # Add modules to main path
88 main.add_module('RootInput', inputFileName=inname)
89# main.add_module('SeqRootInput', inputFileName=inname)
90
91 nmod = [0, 1, 2, 3]
92 for mod in nmod:
93 main.add_module('TRGCDCT3DUnpacker', T3DMOD=mod)
94
95 main.add_module('Gearbox')
96
97 for mod in nmod:
98 # main.add_module(skim)
99 main.add_module('TRGCDCT3DConverter',
100 hitCollectionName='FirmCDCTriggerSegmentHits' + str(mod),
101 addTSToDatastore=True,
102 EventTimeName='FirmBinnedEventT0' + str(mod),
103 addEventTimeToDatastore=True,
104 inputCollectionName='FirmTRGCDC2DFinderTracks' + str(mod),
105 add2DFinderToDatastore=True,
106 outputCollectionName='FirmTRGCDC3DFitterTracks' + str(mod),
107 add3DToDatastore=True,
108 fit3DWithTSIM=0,
109 firmwareResultCollectionName='TRGCDCT3DUnpackerStore' + str(mod),
110 isVerbose=0)
111
112 for mod in nmod:
113 main.add_module('TRGCDCT3DDQM', postScriptName=histname, T3DMOD=mod)
114
115 main.add_module('HistoManager', histoFileName=histname)
116
117 # Process all events
118 basf2.process(main)
119 print(basf2.statistics)