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 Process(self): if not self.geometry: self.geometry = True geometry = dc.I3Geometry() for string in self.strings: for dom in self.doms: omkey= icetray.OMKey(string,dom) geometry.omgeo[omkey] = dc.I3OMGeo() x=random.uniform(-500,500) y=random.uniform(-500,500) z=random.uniform(-300,300) geometry.omgeo[omkey].position = dc.I3Position(x,y,z) frame = icetray.I3Frame(icetray.I3Frame.Geometry); frame.Put('I3Geometry',geometry) self.PushFrame(frame) pulsesmap= dc.I3RecoPulseSeriesMap() for string in self.strings: for dom in self.doms: omkey= icetray.OMKey(string,dom) pulse= dc.I3RecoPulse() pulse.charge= random.uniform(0.3,6.)#pulses are not used in the algorithm of this module, #just put a single pulse with any value of the charge pulsesmap[omkey]= dc.I3RecoPulseSeries([pulse]) frame = icetray.I3Frame(icetray.I3Frame.Physics); frame.Put("TestPulseSeriesMap",pulsesmap) self.PushFrame(frame)
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 make_geometry(): geo = dataclasses.I3Geometry() for omkey in doms: geo.omgeo[omkey] = dataclasses.I3OMGeo() geo.omgeo[icetray.OMKey(1, 1)].position = dataclasses.I3Position(0, 0, 0) geo.omgeo[icetray.OMKey(1, 2)].position = dataclasses.I3Position(0, 0, 50) geo.omgeo[icetray.OMKey(1, 3)].position = dataclasses.I3Position(0, 0, 100) geo.omgeo[icetray.OMKey(1, 4)].position = dataclasses.I3Position(0, 0, 500) geo.omgeo[icetray.OMKey(2, 4)].position = dataclasses.I3Position(0, 50, 500) return geo
def makeGeometry(positions, DOMOversizeFactor=5., spacing=30): #print positions import math string, dom = 0, 1 lastx, lasty = float('nan'), float('nan') DOMRadius = 0.16510 * icetray.I3Units.m # 13" diameter omGeos = dataclasses.I3OMGeoMap() moduleGeos = dataclasses.I3ModuleGeoMap() subdetectors = dataclasses.I3MapModuleKeyString() offsets = dict() for i, pos in enumerate(positions): if not math.hypot(pos.x - lastx, pos.y - lasty) < spacing: lastx, lasty = pos.x, pos.y string += 1 dom = 1 key = icetray.OMKey(string, dom) mkey = dataclasses.ModuleKey(string, dom) dom += 1 omGeo = dataclasses.I3OMGeo() moduleGeo = dataclasses.I3ModuleGeo() omGeo.position = pos omGeo.omtype = omGeo.IceCube moduleGeo.pos = pos moduleGeo.radius = DOMRadius moduleGeo.module_type = moduleGeo.IceCube omGeos[key] = omGeo moduleGeos[mkey] = moduleGeo subdetectors[mkey] = "IceCube" offsets[i] = key frame = icetray.I3Frame() frame['I3OMGeoMap'] = omGeos frame['I3ModuleGeoMap'] = moduleGeos frame['Subdetectors'] = subdetectors simplegeo = clsim.I3CLSimSimpleGeometryFromI3Geometry( DOMRadius, DOMOversizeFactor, frame) return simplegeo
#I3DetectorStatus print('Testing I3DectorStatus') ds = dataclasses.I3DetectorStatus() dmstat = ds.dom_status adom = dataclasses.I3DOMStatus() adom.pmt_hv = 1500 * icetray.I3Units.V dmstat[icetray.OMKey(1, 1)] = adom mykey = icetray.OMKey(1, 1) ENSURE(mykey in dmstat, 'Can not find my new dom status') #Also...see Fix_Trigger_In_GCD.py test # I3Geometry example? (olivas have one?) print("Testing I3Geometry") omg = dataclasses.I3OMGeo() omg.position.x = 100.0 omg.position.y = 101.0 omg.position.z = 102.0 print(type(omg.position), omg.position) i3g = dataclasses.I3Geometry() i3g.omgeo[icetray.OMKey(1, 1)] = omg ENSURE(icetray.OMKey(1, 1) in i3g.omgeo, 'can not find my omkey in i3geo') ENSURE((icetray.OMKey(1, 2) not in i3g.omgeo), 'found a bad omkey in i3geo') newom = i3g.omgeo[icetray.OMKey(1, 1)] print(type(newom.position), vars(newom.position), newom.position) ENSURE(newom.position.x > 99.0, 'Failed to get the right OMGeo position back') # I3Calibratoim example? (olivas have one?) ## See the Fix_Cals_in_GCD.py script for full example
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] += 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