Belle II Software development
trgcdct3dUnpackerConverter.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
20from ROOT import Belle2 # noqa: make Belle2 namespace available
21import ROOT.Belle2
22
23
24class is2DSkim(basf2.Module):
25 """check the 2D skim with Tracks StoreArray"""
26
27 def event(self):
28 """event function of the is2DSkim class"""
29 Tracks = ROOT.Belle2.PyStoreArray("Tracks")
30 TRGGRLT3DUnpackerStores = ROOT.Belle2.PyStoreArray("TRGCDCT3DUnpackerStores")
31
32 isTwoTrack = False
33 if len(Tracks) == 2:
34 isTwoTrack = True
35
36 areTracksClean = True
37 for track in Tracks:
38 trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
39 if trackResult.getPValue() > 0.1:
40 areTracksClean = False
41
42 enoughHits = True
43 for track in Tracks:
44 trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
45 nHitStSl = 0
46 nHitAxSl = 0
47 for iAx in range(5):
48 if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iAx) > 3):
49 nHitAxSl += 1
50 for iSt in range(4):
51 if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iSt + 1) > 3):
52 nHitStSl += 1
53 if nHitStSl < 3:
54 enoughHits = False
55 if nHitAxSl < 4:
56 enoughHits = False
57
58 is2D = False
59 for iClk, data in enumerate(TRGGRLT3DUnpackerStores):
60 if (data.m_t2d_fnf != 0):
61 is2D = True
62
63 self.return_value(isTwoTrack and is2D and areTracksClean and enoughHits)
64
65
66if __name__ == '__main__':
67
68 basf2.use_central_database("development")
69 # Hot fix for CDCFudgeFactorFromSigma
70 basf2.use_local_database(ROOT.Belle2.FileSystem.findFile("data/trg/cdc/db_CDCFudgeFactorsForSigma.txt"), "localdb")
71
72 empty_path = basf2.create_path()
73 skim = basf2.register_module(is2DSkim())
74 skim.if_value('=0', empty_path, basf2.AfterConditionPath.END)
75
76 # Create main path
77 main = basf2.create_path()
78 # Add modules to main path
79 main.add_module('RootInput')
80 main.add_module('TRGCDCT3DUnpacker')
81 main.add_module(skim)
82 main.add_module('Gearbox')
83 main.add_module('TRGCDCT3DConverter',
84 hitCollectionName='FirmCDCTriggerSegmentHits',
85 addTSToDatastore=True,
86 EventTimeName='FirmBinnedEventT0',
87 addEventTimeToDatastore=True,
88 inputCollectionName='FirmTRGCDC2DFinderTracks',
89 add2DFinderToDatastore=True,
90 outputCollectionName='FirmTRGCDC3DFitterTracks',
91 add3DToDatastore=True,
92 fit3DWithTSIM=0,
93 firmwareResultCollectionName='TRGCDCT3DUnpackerStores',
94 isVerbose=0)
95 main.add_module(
96 'RootOutput',
97 branchNames=[
98 'TRGCDCT3DUnpackerStores',
99 'FirmCDCTriggerSegmentHits',
100 'FirmBinnedEventT0',
101 'FirmTRGCDC2DFinderTracks',
102 'FirmTRGCDC3DFitterTracks'])
103 # Process all events
104 basf2.process(main)
105 print(basf2.statistics)