Belle II Software  release-08-01-10
trgcdct3dDQM.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # -----------------------------------------------------------------------------------
13 #
14 # CDCTRGT3D Unpacker and Converter
15 #
16 # usage : %> basf2 trgcdct3dUnpackerConverter -i [input sroot file name] -o [output root file name]
17 #
18 # -----------------------------------------------------------------------------------
19 
20 import basf2
21 import ROOT.Belle2
22 
23 import sys # get argv
24 argvs = sys.argv # get arg
25 argc = len(argvs) # of arg
26 
27 if argc == 3:
28  inname = argvs[1]
29  histname = argvs[2]
30  # outname=argvs[2]
31  # histname=argvs[3]
32 else:
33  sys.exit("trgcdct3dDQM.py> # of arg is strange. Exit.")
34 
35 
36 # class is2DSkim(basf2.Module):
37 # def event(self):
38 # Tracks = ROOT.Belle2.PyStoreArray("Tracks")
39 # TRGGRLT3DUnpackerStores = ROOT.Belle2.PyStoreArray("TRGCDCT3DUnpackerStores")
40 #
41 # isTwoTrack = False
42 # if len(Tracks) == 2:
43 # isTwoTrack = True
44 #
45 # areTracksClean = True
46 # for track in Tracks:
47 # trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
48 # if trackResult.getPValue() > 0.1:
49 # areTracksClean = False
50 #
51 # enoughHits = True
52 # for track in Tracks:
53 # trackResult = track.getTrackFitResultWithClosestMass(ROOT.Belle2.Const.pion)
54 # nHitStSl = 0
55 # nHitAxSl = 0
56 # for iAx in range(5):
57 # if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iAx) > 3):
58 # nHitAxSl += 1
59 # for iSt in range(4):
60 # if (trackResult.getHitPatternCDC().getSLayerNHits(2 * iSt + 1) > 3):
61 # nHitStSl += 1
62 # if nHitStSl < 3:
63 # enoughHits = False
64 # if nHitAxSl < 4:
65 # enoughHits = False
66 #
67 # is2D = False
68 # for iClk, data in enumerate(TRGGRLT3DUnpackerStores):
69 # if (data.m_t2d_fnf != 0):
70 # is2D = True
71 #
72 # self.return_value(isTwoTrack and is2D and areTracksClean and enoughHits)
73 
74 
75 if __name__ == '__main__':
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)