def test2(self):
     "read events and check them"
     from mccomponents.detector.reduction_utils import readevents
     evts = readevents(eventfilename)
     self.assertEqual(len(evts), 1)
     evt = evts[0]
     longpixelID, tofchannel, probability = evt
     self.assertEqual(longpixelID,
                      pixelID + npixels * (tubeID + ntubes * (packID)))
     self.assertEqual(tofchannel, int((neutronT - tofmin) / tofstep))
     self.assertEqual(probability, prob)
     return
    def test2(self):
        "read events and check them"
        from mccomponents.detector.reduction_utils import readevents

        evts = readevents(eventfilename)
        self.assertEqual(len(evts), 1)
        evt = evts[0]
        longpixelID, tofchannel, probability = evt
        self.assertEqual(longpixelID, pixelID + npixels * (tubeID + ntubes * (packID)))
        self.assertEqual(tofchannel, int((neutronT - tofmin) / tofstep))
        self.assertEqual(probability, prob)
        return
Exemple #3
0
def main():
    from sim_params import instrument, tofparams, eventsdat, Idpt_filename as filename

    from mccomponents.detector.reduction_utils import readevents
    events = readevents(eventsdat)

    Idpt = events2Idpt(events, instrument, tofparams)

    #save to file
    import os
    if os.path.exists(filename): os.remove(filename)
    import histogram.hdf as hh
    hh.dump(Idpt, filename, '/', 'c')
    return
Exemple #4
0
def main():
    from sim_params import instrument, tofparams, eventsdat, Idpt_filename as filename
    
    from mccomponents.detector.reduction_utils import readevents
    events = readevents( eventsdat )

    Idpt = events2Idpt( events, instrument, tofparams )
    
    #save to file
    import os
    if os.path.exists(filename): os.remove( filename )
    import histogram.hdf as hh
    hh.dump( Idpt, filename, '/', 'c' )
    return
    def test1a(self):
        from mccomponents.detector.reduction_utils import readevents
        events = readevents( outfilename )
        n = len(events)
        print "number of cases where absorption happen: ", n
        self.assert_( abs(n-(nevents*absorption_weight)) < 3*N.sqrt(n) )

        p = sum([ e[2] for e in events ] )
        print "absorbed neutrons: ", p
        self.assert_( abs( p-(nevents*0.91) ) < 3*N.sqrt(p) )

        t = L/vi
        tchannel = int( (t-tmin)/tstep )
        for e in events:
            # should hit center of tube
            self.assert_( abs(e[0] - (npixelsperdet*((packindexat0+0.5)*ndetsperpack)) ) <= 1 )
            # tof channel
            self.assert_( abs(e[1] - tchannel) <= 1 )
            continue
        return
Exemple #6
0
    def test1a(self):
        "simple. one detector -- verify"
        from mccomponents.detector.reduction_utils import readevents
        events = readevents( 'events.dat' )
        n = len(events)
        self.assert_( abs(n-(nevents*absorption_weight)) < 3*N.sqrt(n) )

        p = sum([ e[2] for e in events ] )
        # print "%s should be almost equalt to %s" % (p, nevents*absorption_probability)
        self.assert_( abs( p-(nevents*absorption_probability) ) < 3*N.sqrt(p) )
        # self.assert_( abs( p-(nevents*0.908484) ) < 3*N.sqrt(p) )

        t = L/vi
        tchannel = int( (t-tmin)/tstep )
        for e in events:
            # should hit center of tube
            self.assert_( abs(e[0] - (npixels/2)) <= 1 )
            self.assertEqual( e[1], tchannel )
            # 
            continue
        return
Exemple #7
0
    def test1a(self):
        from mccomponents.detector.reduction_utils import readevents
        events = readevents(outfilename)
        n = len(events)
        print "number of cases where absorption happen: ", n
        self.assert_(abs(n - (nevents * absorption_weight)) < 3 * N.sqrt(n))

        p = sum([e[2] for e in events])
        print "absorbed neutrons: ", p
        self.assert_(abs(p - (nevents * 0.91)) < 3 * N.sqrt(p))

        t = L / vi
        tchannel = int((t - tmin) / tstep)
        for e in events:
            # should hit center of tube
            self.assert_(
                abs(e[0] - (npixelsperdet *
                            ((packindexat0 + 0.5) * ndetsperpack))) <= 1)
            # tof channel
            self.assert_(abs(e[1] - tchannel) <= 1)
            continue
        return