14 <contact>Benjamin.Schwenker@phys.uni-goettingen.de</contact>
16 Plot the efficiency to find a cluster for a given truehit for all layers of
26 from ROOT
import Belle2
27 b2.set_log_level(b2.LogLevel.ERROR)
29 b2.set_random_seed(10346)
34 theta_params = [90, 0.1]
39 Plot Efficiency to find a U and V cluster for each given truehit.
44 Create ROOT TProfiles for all layers and momenta.
49 self.
rfilerfile = ROOT.TFile(
"ClusterEfficiency.root",
"RECREATE")
56 def profile(name, title, text, contact):
57 """small helper function to create a phi profile and set the names
59 prof = ROOT.TProfile(name, title, 60, -180, 180)
60 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Description", text))
61 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Contact", contact))
62 prof.GetListOfFunctions().Add(ROOT.TNamed(
"Check",
"Should be close to 1 everywhere"))
68 prof_name =
"ClusterEfficiency_layer{layer}_{p:.1f}GeV"
69 prof_title =
"Cluster Efficiency in #phi, layer={layer}, "\
70 +
"p={p:.1f} GeV;#phi in degrees;efficiency"
71 prof_text =
"Efficiency to find a U and V cluster for any given truehit "\
72 +
"in layer {layer} when simulation muons with p={p:.1f} GeV uniformly "\
73 +
"in phi and theta={theta[0]}+-{theta[1]} degree. phi is the angle "\
74 +
"of the generated particle, not the truehit position."
77 True:
"Benjamin Schwenker <Benjamin.Schwenker@phys.uni-goettingen.de>",
78 False:
"Andrzej Bozek <bozek@belle2.ifj.edu.pl>",
82 for layer
in range(1, 7):
83 self.
effeff[layer] = {}
85 name = prof_name.format(p=p, layer=layer)
86 title = prof_title.format(p=p, layer=layer)
87 text = prof_text.format(p=p, layer=layer, theta=theta_params)
88 self.
effeff[layer][p] = profile(name, title, text, prof_contact[layer < 3])
92 Format all profiles and write the ROOT file.
98 minBin = prof.GetMinimumBin()
100 minVal = min(minVal, (prof.GetBinContent(minBin) - prof.GetBinError(minBin)) * 0.95)
104 prof.SetMinimum(max(0, minVal))
105 prof.SetMaximum(1.02)
108 self.
rfilerfile.Write()
109 self.
rfilerfile.Close()
113 Loop over all truehits for a track with the given angle phi and momentum
114 p and update the efficiency profiles.
117 for i, truehit
in enumerate(truehits):
119 if truehits.weight(i) < 0:
123 layer = truehit.getSensorID().getLayerNumber()
126 clusters = truehit.getRelationsFrom(
"SVDClusters")
129 clusters = truehit.getRelationsFrom(
"PXDClusters")
132 has_cluster = {
False: 0,
True: 0}
133 for j, cls
in enumerate(clusters):
136 if clusters.weight(j) < 100:
142 has_cluster[
True] = 1
143 has_cluster[
False] = 1
147 has_cluster[cls.isUCluster()] = 1
150 self.
effeff[layer][p].Fill(phi, has_cluster[
True] & has_cluster[
False])
154 Update the efficiencies by iterating over all primary particles
157 for mcp
in mcparticles:
159 if not mcp.hasStatus(1):
164 p = mcp.getMomentum()
167 if abs(p.R() - i) < 0.05:
173 b2.B2WARNING(
"Strange particle momentum: %f, expected one of %s" %
174 (p.R(),
", ".join(str()
for p
in momenta)))
178 pxdtruehits = mcp.getRelationsTo(
"PXDTrueHits")
179 self.
fill_truehitsfill_truehits(math.degrees(p.Phi()), p_gen, pxdtruehits)
180 svdtruehits = mcp.getRelationsTo(
"SVDTrueHits")
181 self.
fill_truehitsfill_truehits(math.degrees(p.Phi()), p_gen, svdtruehits)
186 main = b2.create_path()
187 main.add_module(
"EventInfoSetter", evtNumList=[10000])
188 main.add_module(
"Gearbox")
190 main.add_module(
"Geometry", components=[
'MagneticFieldConstant4LimitedRSVD',
191 'BeamPipe',
'PXD',
'SVD'])
192 particlegun = main.add_module(
"ParticleGun")
195 "pdgCodes": [13, -13],
197 "momentumGeneration":
'discrete',
198 "momentumParams": momenta + [1]*len(momenta),
199 "thetaGeneration":
'normal',
200 "thetaParams": theta_params,
202 main.add_module(
"FullSim")
209 main.add_module(clusterefficiency)
210 main.add_module(
"Progress")
A (simplified) python wrapper for StoreArray.
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
eff
layer/momentum hierarchy of all profiles
rfile
Output file to store all plots.
profiles
flat list of all profiles for easy access
def fill_truehits(self, phi, p, truehits)
def add_pxd_reconstruction(path, clusterName=None, digitsName=None, usePXDClusterShapes=False, spacePointsName='PXDSpacePoints')
def add_pxd_simulation(path, digitsName=None, activatePixelMasks=True, activateGainCorrection=True)
def add_svd_simulation(path, useConfigFromDB=False, daqMode=2, relativeShift=9)
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)