hNProtons.Fill(nProton) totalProtons += nProton if nProton == 0: continue #generate N=10 random points for x-y XY = hf.GetRandomXY(nProton, size, width, posX, posY) #print XY #convert points into a strip number for each layer Strips = hf.GetStripCoOrds(XY, pitch, angles) #print Strips #cycle through all strip combinations, find intersections of pairs of planes, see if they are within tolerance of each other #returns hit objects of form (XCoord,YCoord,[stripX,stripU,stripV],[radial distance to intersections]) allHits = hf.FindOverlaps(Strips, pitch, angles, tolerance, useHalfStrips) nRawHits += len(allHits) hRawHits.Fill(len(allHits)) for hit in allHits: myHitMap.Fill(hit[0], hit[1]) rawEff = hf.GetEfficiency(allHits, XY, pitch, tolerance) hRawEfficiency.Fill(100.0 * rawEff) nProton_RawEffCorrected += nProton * rawEff if saveStripMaps: hf.PlotHitMap("RawHits", allHits, XY, Strips, pitch, size, i, angles) #for hit in allHits: # area=hf.GetPixelArea(hit,angles,pitch)
#reconstruct hits for each tracker module TrackerHits = [] MaxNStrips = [] for module in [0, 1]: #convert simulated protons to strips Strips, meanXY = hf.GetTrackerStripCoOrds(XY, mXmY, pitch, TrackerAngles[module], TrackerZ[module]) #keep track of maximum number of strips in each module MaxNStrips.append(len(max(Strips, key=len))) #find overlap of strips and return hit objects of form (XCoord,YCoord,[stripX,stripU,stripV],[radial distance to intersections]) Hits = hf.FindOverlaps(Strips, pitch, TrackerAngles[module], stripTolerance[0], useHalfStrips) TrackerHits.append(Hits) nTrackerHits[module].append(len(Hits)) #calculate efficiency for finding correct hits by checking there is always a reco hit within tolerance of true hit eff = hf.GetEfficiency(Hits, meanXY, pitch, stripTolerance[0]) trackerEffs[module].append(100 * eff) nFakeHits = len(Hits) - (nProton * eff) #calculate ambiguity if len(Hits) > 0: ambiguity[module].append(100 * (float)(len(Hits) - nProton) / len(Hits)) correctedAmbiguity[module].append(100 * nFakeHits / len(Hits)) if saveStripMaps:
#read in hits, grouped by timestamp. Expects rosetta stile formatting: time, v1,v2,v3,v4, x1,x2,x3,x4, u1,u2,u3,u4 hitsByTimestamp = hf.ReadXUVStripCoOrds(inFile) print("Timestamps provided " + (str)(len(hitsByTimestamp))) #loop over all timestamps and find overlaps reconstructedHits = 0 for i in range(len(hitsByTimestamp)): StripX = hitsByTimestamp[i][0] StripU = hitsByTimestamp[i][1] StripV = hitsByTimestamp[i][2] #print(StripX,StripU,StripV) #find hits allHits = hf.FindOverlaps( [StripX, StripU, StripV, StripX, StripU, StripV], pitch, angles, tolerance, False ) #strips X,U,V doubled here as find overlaps expects info on which half of a plane a sensor is in... reconstructedHits += len(allHits) #add results to hit map for hit in allHits: myHitMap.Fill(hit[0], hit[1]) #tidy up based on effective pixel area allHits = hf.RemoveAdjacentHits(allHits, tolerance, pitch) for hit in allHits: myRefinedHitMap.Fill(hit[0], hit[1]) allHits = hf.RemoveAmbiguities(allHits, angles, pitch) for hit in allHits: myRefinedHitMap2.Fill(hit[0], hit[1])