def test_I3ModuleGeo(self): module = dataclasses.I3ModuleGeo() module.pos = dataclasses.I3Position(0, 0, 0) module.orientation = dataclasses.I3Orientation(1, 0, 0, 0, 1, 0) module.radius = 99. module.module_type = dataclasses.I3ModuleGeo.IceCube self.assertEqual( module.dir, dataclasses.I3Direction(90 * I3Units.degree, 180 * I3Units.degree), "didn't get the direction i was looking for.") self.assertEqual(module.radius, 99., "set/get isn't working.") self.assertEqual(module.pos, dataclasses.I3Position(0, 0, 0), "set/get isn't working.") self.assertEqual(module.orientation, dataclasses.I3Orientation(1, 0, 0, 0, 1, 0), "set/get isn't working.") self.assertEqual(module.module_type, dataclasses.I3ModuleGeo.IceCube, "set/get isn't working.") module2 = dataclasses.I3ModuleGeo() module2.pos = dataclasses.I3Position(0, 0, 0) module2.orientation = dataclasses.I3Orientation(1, 0, 0, 0, 1, 0) module2.radius = 99. module2.module_type = dataclasses.I3ModuleGeo.IceCube self.assertEqual(module, module2, "testing the equal operator.")
def test_I3OMGeo(self): omgeo1 = dataclasses.I3OMGeo() omgeo1.omtype = dataclasses.I3OMGeo.OMType.IceCube omgeo1.position = dataclasses.I3Position(0,0,0) omgeo1.orientation = dataclasses.I3Orientation(1,0,0,0,1,0) omgeo1.area = 42. omgeo2 = dataclasses.I3OMGeo() omgeo2.omtype = dataclasses.I3OMGeo.OMType.IceCube omgeo2.position = dataclasses.I3Position(0,0,0) omgeo2.orientation = dataclasses.I3Orientation(1,0,0,0,1,0) omgeo2.area = 42. self.assertEqual(omgeo1, omgeo2, "these should be the same.")
def generateOMString(stringNumber, startPos, numDoms, spacing, direction): orientation = dataclasses.I3Orientation( 0, 0, -1, 1, 0, 0) # same orientation as icecube DOMs (dir=down) area = 0.5857538 * I3Units.meter2 # same area as KM3NET MDOMs geomap = dataclasses.I3OMGeoMap() x = startPos.x y = startPos.y z = startPos.z dx = [spacingVal * direction.x for spacingVal in spacing] dy = [spacingVal * direction.y for spacingVal in spacing] dz = [spacingVal * direction.z for spacingVal in spacing] # create OMKeys and I3OMGeo for DOMs on string and add them to the map for i in xrange(0, numDoms): omkey = OMKey(stringNumber, i, 0) omGeometry = dataclasses.I3OMGeo() omGeometry.omtype = dataclasses.I3OMGeo.OMType.IceCube omGeometry.orientation = orientation omGeometry.area = area omGeometry.position = dataclasses.I3Position(x + dx[i] * i, y + dy[i] * i, z + dz[i] * i) geomap[omkey] = omGeometry return geomap
def DAQ(self, frame): # only inject it once if self.has_been_injected: self.PushFrame(frame) return self.has_been_injected = True geometry = dataclasses.I3Geometry() calibration = dataclasses.I3Calibration() detectorStatus = dataclasses.I3DetectorStatus() # fill the geometry map omgeomap = geometry.omgeo domcalmap = calibration.dom_cal domstatusmap = detectorStatus.dom_status for i, pos in enumerate(omPositions): shiftedPos = pos shiftedPos[0] += self.xCoord * I3Units.m shiftedPos[1] += self.yCoord * I3Units.m shiftedPos[2] += self.zCoord * I3Units.m omkey = omKeys[i] newomgeo = dataclasses.I3OMGeo() newomgeo.omtype = dataclasses.I3OMGeo.OMType.IceCube newomgeo.orientation = dataclasses.I3Orientation( dataclasses.I3Direction(0., 0., -1.)) newomgeo.position = dataclasses.I3Position(shiftedPos[0], shiftedPos[1], shiftedPos[2]) omgeomap[omkey] = newomgeo newdomcal = dataclasses.I3DOMCalibration() newdomcal.relative_dom_eff = 1.0 domcalmap[omkey] = newdomcal newdomstatus = dataclasses.I3DOMStatus() newdomstatus.pmt_hv = 1345. * I3Units.V # some arbitrary setting: >0 and not NaN domstatusmap[omkey] = newdomstatus # make GCD frames and fill them with objects Gframe = icetray.I3Frame(icetray.I3Frame.Geometry) Cframe = icetray.I3Frame(icetray.I3Frame.Calibration) Dframe = icetray.I3Frame(icetray.I3Frame.DetectorStatus) Gframe["I3Geometry"] = geometry Cframe["I3Calibration"] = calibration Dframe["I3DetectorStatus"] = detectorStatus # push the new GCD frames self.PushFrame(Gframe) self.PushFrame(Cframe) self.PushFrame(Dframe) # push the original Q-frame self.PushFrame(frame)
def test_I3Orientation_setOrientation(self): # create I3Orientation instance orientationInstance = dataclasses.I3Orientation() # create 3 vectors v1 = [1,0,0] v2 = [0,1,0] # perpendicular to v1 v3 = [2,0,0] # not perpendicular to v1 orientationInstance.set_orientation(v1[0],v1[1],v1[2],v2[0],v2[1],v2[2]) # this is supposed to work try: orientationInstance.set_orientation(v1[0],v1[1],v1[2],v3[0],v3[1],v3[2]) # this is supposed to chrash raise ValueError('I3Orientation::SetOrientation(v1,v2) is supposed to throw a RuntimeError if v1 and v2 are not perpendicular, but it does not!') except RuntimeError: pass
# fill the geometry map omgeomap = geometry.omgeo domcalmap = calibration.dom_cal domstatusmap = detectorStatus.dom_status for i, pos in enumerate(omPositions): shiftedPos = pos shiftedPos[0] += options.XPOS*I3Units.m shiftedPos[1] += options.YPOS*I3Units.m shiftedPos[2] += options.ZPOS*I3Units.m omkey = omKeys[i] newomgeo = dataclasses.I3OMGeo() newomgeo.omtype = dataclasses.I3OMGeo.OMType.IceCube newomgeo.orientation = dataclasses.I3Orientation(dataclasses.I3Direction(0.,0.,-1.)) newomgeo.position = dataclasses.I3Position(shiftedPos[0], shiftedPos[1], shiftedPos[2]) omgeomap[omkey] = newomgeo newdomcal = dataclasses.I3DOMCalibration() newdomcal.relative_dom_eff = 1.0 domcalmap[omkey] = newdomcal newdomstatus = dataclasses.I3DOMStatus() newdomstatus.pmt_hv = 1345.*I3Units.V # some arbitrary setting: >0 and not NaN domstatusmap[omkey] = newdomstatus