3 A simple drift simulation using response functions. No diffusion. 9 from math
import radians, sin, cos
12 Hit = collections.namedtuple(
"Hit",
"x y z t q")
15 return (sin(radians(deg)), cos(radians(deg)))
19 Simulate the response to a distribution of charge. 23 - for each hit, find all rf's for the hits impact, use each 24 region number as offset to hit's wire number, fill frame. 29 nwires=(2400,2400,3456),
32 velocity=1.6*units.mm/units.us,
37 Create a mini simulation. 39 - pib :: a response.PlaneImpactBlocks object 49 (0.0, 0.5*self.pitch)))
59 Return the location of a hit in terms of (wire number, impact). 64 for iplane
in range(3):
67 pwidth = self.pitch * self.nwires[iplane]/2
69 wiredist = pit/self.pitch
70 wire = numpy.asarray(numpy.round(wiredist), dtype=int)
71 impact = numpy.round((wiredist-wire)/self.impact) * self.impact
72 ret.append(numpy.vstack((wire, impact)).T)
78 Apply block array to plane array with ich and itick offsets 80 dch = block.shape[0]//2
82 chp =
int(
min(ich+dch, self.nwires[iplane]-1))
85 tfinebin_min =
int(time/self.pib.tbin)
86 tfinebin_jmp =
int(self.tick/self.pib.tbin)
89 sampled = block[:,tfinebin_min::tfinebin_jmp]
92 tsampbin_num = len(sampled[0])
93 tsampbin_min =
int(time/self.tick)
94 tsampbin_max =
min(tsampbin_min+tsampbin_num, len(self.
frame[iplane][0]))
95 print 'samp bin:',tsampbin_num, tsampbin_min, tsampbin_max*self.tick/units.us
97 self.
frame[iplane][chm:chp+1, tsampbin_min:tsampbin_max] = sampled
102 Initialize a new frame. 105 for nwires
in self.nwires:
106 frame.append(numpy.zeros((nwires, self.nticks)))
107 self.
frame = tuple(frame)
112 Add response to hits to current frame. 115 for iplane, chimps
in enumerate(nearest_chimps):
117 x,y,z,q,t = hit = hits[ihit]
118 block = self.pib.region_block(
"uvw"[iplane], imp)
119 self.
apply_block(block, iplane, ch, (t-self.pib.tmin) + (x-self.pib.xstart)/self.velocity)
def __getattr__(self, key)
def __init__(self, pib, kwds)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def apply_block(self, block, iplane, ich, time)
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
def wire_space(self, hits)