6 <contact>ritter</contact>
8 Plot the efficiency to find a cluster for a given truehit for all layers of
16 from ROOT
import PyConfig
17 PyConfig.IgnoreCommandLineOptions = 1
21 from ROOT
import Belle2
22 set_log_level(LogLevel.ERROR)
24 set_random_seed(10346)
29 theta_params = [90, 0.1]
34 Plot Efficiency to find a U and V cluster for each given truehit.
38 Create ROOT TProfiles for all layers and momenta.
43 self.
rfile = ROOT.TFile(
"ClusterEfficiency.root",
"RECREATE")
50 def profile(name, title, text, contact):
51 """small helper function to create a phi profile and set the names
53 prof = ROOT.TProfile(name, title, 60, -180, 180)
54 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Description", text))
55 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Contact", contact))
56 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Check",
"Should be close to 1 everywhere"))
62 prof_name =
"ClusterEfficiency_layer{layer}_{p:.1f}GeV"
63 prof_title =
"Cluster Efficiency in #phi, layer={layer}, "\
64 +
"p={p:.1f} GeV;#phi in degrees;efficiency"
65 prof_text =
"Efficiency to find a U and V cluster for any given truehit "\
66 +
"in layer {layer} when simulation muons with p={p:.1f} GeV uniformly "\
67 +
"in phi and theta={theta[0]}+-{theta[1]} degree. phi is the angle "\
68 +
"of the generated particle, not the truehit position."
71 True:
"Benjamin Schwenker <Benjamin.Schwenker@phys.uni-goettingen.de>",
72 False:
"Andrzej Bozek <bozek@belle2.ifj.edu.pl>",
76 for layer
in range(1, 7):
79 name = prof_name.format(p=p, layer=layer)
80 title = prof_title.format(p=p, layer=layer)
81 text = prof_text.format(p=p, layer=layer, theta=theta_params)
82 self.
eff[layer][p] = profile(name, title, text, prof_contact[layer < 3])
86 Format all profiles and write the ROOT file.
92 minBin = prof.GetMinimumBin()
94 minVal = min(minVal, (prof.GetBinContent(minBin) - prof.GetBinError(minBin)) * 0.95)
98 prof.SetMinimum(max(0, minVal))
107 Loop over all truehits for a track with the given angle phi and momentum
108 p and update the efficiency profiles.
111 for i, truehit
in enumerate(truehits):
113 if truehits.weight(i) < 0:
117 layer = truehit.getSensorID().getLayerNumber()
120 clusters = truehit.getRelationsFrom(
"SVDClusters")
123 clusters = truehit.getRelationsFrom(
"PXDClusters")
126 has_cluster = {
False: 0,
True: 0}
127 for j, cls
in enumerate(clusters):
130 if clusters.weight(j) < 100:
136 has_cluster[
True] = 1
137 has_cluster[
False] = 1
141 has_cluster[cls.isUCluster()] = 1
144 self.
eff[layer][p].Fill(phi, has_cluster[
True] & has_cluster[
False])
148 Update the efficienies by iterating over all primary particles
151 for mcp
in mcparticles:
153 if not mcp.hasStatus(1):
158 p = mcp.getMomentum()
161 if abs(p.Mag() - i) < 0.05:
167 B2WARNING(
"Strange particle momentum: %f, expected one of %s" %
168 (p.Mag(),
", ".join(str()
for p
in momenta)))
172 pxdtruehits = mcp.getRelationsTo(
"PXDTrueHits")
173 self.
fill_truehits(math.degrees(p.Phi()), p_gen, pxdtruehits)
174 svdtruehits = mcp.getRelationsTo(
"SVDTrueHits")
175 self.
fill_truehits(math.degrees(p.Phi()), p_gen, svdtruehits)
180 main.add_module(
"EventInfoSetter", evtNumList=[10000])
181 main.add_module(
"Gearbox")
183 main.add_module(
"Geometry", components=[
'MagneticFieldConstant4LimitedRSVD',
184 'BeamPipe',
'PXD',
'SVD'])
185 particlegun = main.add_module(
"ParticleGun")
188 "pdgCodes": [13, -13],
190 "momentumGeneration":
'discrete',
191 "momentumParams": momenta + [1]*len(momenta),
192 "thetaGeneration":
'normal',
193 "thetaParams": theta_params,
195 main.add_module(
"FullSim")
196 add_pxd_simulation(main)
197 add_svd_simulation(main)
198 add_pxd_reconstruction(main)
199 add_svd_reconstruction(main)
202 main.add_module(clusterefficiency)
203 main.add_module(
"Progress")