Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:22

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
0019 #
0020 
0021 """
0022 tokg4.py 
0023 =============================================
0024 
0025 Loads test events from Opticks and Geant4 and 
0026 created by OKG4Test and 
0027 compares their bounce histories.
0028 
0029 """
0030 import os, sys, logging, argparse, numpy as np
0031 log = logging.getLogger(__name__)
0032 
0033 from opticks.ana.main import opticks_main
0034 from opticks.ana.ab   import AB
0035 from opticks.ana.nbase import vnorm
0036 from opticks.ana.seq import seq2msk
0037 
0038 
0039 
0040 if __name__ == '__main__':
0041     ok = opticks_main(doc=__doc__, tag="1", src="torch", det="g4live", pfx="source", tagoffset=0)
0042     #ok = opticks_main(doc=__doc__)  
0043 
0044     log.info(ok.brief)
0045 
0046     ab = AB(ok)
0047     ab.dump()
0048 
0049     rc = ab.RC
0050 
0051     level = "fatal" if rc > 0 else "info"
0052     getattr(log, level)(" RC 0x%.2x %s " % (rc,bin(rc)) )
0053 
0054 
0055     if not ok.ipython:
0056         log.info("early exit as non-interactive")
0057         sys.exit(rc)
0058     else:
0059         pass
0060     pass
0061 
0062     a = ab.a
0063     b = ab.b
0064 
0065     
0066 
0067 
0068 
0069 
0070 if 0:
0071     if a.valid:
0072         a0 = a.rpost_(0)
0073         #a0r = np.linalg.norm(a0[:,:2],2,1)
0074         a0r = vnorm(a0[:,:2])
0075         if len(a0r)>0:
0076             print " ".join(map(lambda _:"%6.3f" % _, (a0r.min(),a0r.max())))
0077 
0078     if b.valid:
0079         b0 = b.rpost_(0)
0080         #b0r = np.linalg.norm(b0[:,:2],2,1)
0081         b0r = vnorm(b0[:,:2])
0082         if len(b0r)>0:
0083             print " ".join(map(lambda _:"%6.3f" % _, (b0r.min(),b0r.max())))
0084 
0085