Ejemplo n.º 1
0
#!/usr/bin/python

print "Test with neutrals"

from vertigo import RaveVertexFactory, EventFactory, RaveConstantMagneticField, RaveVacuumPropagator, LoopSettings, RaveTrackContainer

LoopSettings.Instance().setVerbosity(0)

ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator() )

def printVertex ( vertex ):
  print "pos=( %(x).4f, %(y).4f, %(z).4f ) chi2=%(chi2).3f ntrks=%(n)d" % \
    { "x": vertex.position().x(), "y": vertex.position().y(), "z": vertex.position().z(), \
      "chi2": vertex.chiSquared(), "n": len (vertex.tracks())  }

eventfactory=EventFactory ( "input23.txt" )

# methods = [ "kalman", "avf", "mvf" ]
methods = [ "kalman", "avf-smoothing:0", "avf-smoothing:1", "avr", "tkf", "mvf" ]

for event in eventfactory:
  for method in methods:
    print method+":"
    vertices=ravefactory.create ( event.tracks(), method )
    for vertex in vertices:
      printVertex ( vertex  )
Ejemplo n.º 2
0
#!/usr/bin/python

print "Tests the track to vertex covariance."

## 1. In rave::Vertex: do the tk-to-vtx covariance matrices 
##                     belong to original track or refitted track?
## 2. In VertexTrackFactory: create cov matrix!

from vertigo import RaveVertexFactory, EventFactory, RaveConstantMagneticField, \
         RaveVacuumPropagator, LoopSettings, RaveTrackContainer, RaveException

LoopSettings.Instance().setVerbosity(0)

ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator() )

def printVertex ( vertex ):
    import sys
    a=sys.argv[0].replace(".py","").replace("./","")
    print "[%(a)s] pos=( %(x).4f, %(y).4f, %(z).4f ) chi2=%(chi2).3f ntrks=%(n)d" % \
        { "a": a, "x": vertex.position().x(), "y": vertex.position().y(), 
          "z": vertex.position().z(), "chi2": vertex.chiSquared(), 
          "n": len (vertex.tracks())  }
    t=vertex.tracks()[0]
    has=vertex.hasTrackToVertexCovariance()
    # print "[%s] has covs %d" % ( a, has )
    if has: print "[test21] cov =",vertex.trackToVertexCovariance( t )

eventfactory=EventFactory ( "input1.txt" )

for event in eventfactory:
    vertices=ravefactory.create ( event.tracks(), "kalman-smoothing:1" )
Ejemplo n.º 3
0
                    LoopSettings, RavePoint3D, RaveCovariance3D
from vertigo import ObserverManager
import dataharvester

writer=dataharvester.Writer_file("x.root;x.txt")

muonmass  = 0.1056583
muonsigma = 0.0000000001
Zmass     = 91.187
Zsigma    = 2.4952
magneticfield = RaveConstantMagneticField( 0., 0., 4. )
beamspot=RaveEllipsoid3D( RavePoint3D(), RaveCovariance3D( .0015**2,0.,0.,.0015**2,0.,5.3**2 ) )                                              

eventfactory  = EventFactory ( "gun:kinematics" )
# eventfactory  = EventFactory ( "file:input6.txt" )
vertexfactory = RaveVertexFactory ( magneticfield, RaveVacuumPropagator(), beamspot )
treefactory   = RaveKTreeFactory( magneticfield, RaveVacuumPropagator(), beamspot )

def discussTrack ( simtrk, rectrk, name, eventid, d ):
    t=dataharvester.Tuple( name )
    t["rpt"]=rectrk.pt()
    t["spt"]=simtrk.pt()
    t["dpt"]=abs ( simtrk.pt() - rectrk.pt() )
    t["eventid"]=eventid
    t["rectrkid"]=rectrk.id()
    t["simtrkid"]=simtrk.id()
    for (k,v) in d.items():
        t[k]=v
    t["name"]=name
    writer.save(t)
Ejemplo n.º 4
0
#!/usr/bin/python

""" This will be a test for rave's two-jet feature """

width=0.0015
length=5.3

from vertigo import RaveVertexFactory, EventFactory, RaveConstantMagneticField, \
       RaveVacuumPropagator, LoopSettings, RaveTrackContainer, WeightedRaveTrack, \
       ObserverManager_Instance, RaveCovariance3D, RaveEllipsoid3D, RavePoint3D

c=RaveCovariance3D( width**2, 0,0,width**2,0,length**2 )
e=RaveEllipsoid3D( RavePoint3D(),c )

LoopSettings.Instance().setVerbosity(0)
ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator(), e, "avr-primcut:3.0" )
eventfactory=EventFactory ( "bjets.170.1.txt.gz" )
event=eventfactory.next()

for simvtx in event.simVertices():
   print simvtx

print len(event.jets()),"jets in event."
print len(event.tracks()),"tracks in event."

primaries=RaveTrackContainer()
first=True

secondaries=None

for jet in event.jets():
Ejemplo n.º 5
0
#!/usr/bin/python

from vertigo import RaveVertexFactory, EventFactory, RaveConstantMagneticField, RaveVacuumPropagator, LoopSettings, RaveTrackContainer, RaveLogger

LoopSettings.Instance().setVerbosity(0)

ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator() )

RaveLogger().writeToFile ( "rave_log.txt" )

event=EventFactory ( "input1.txt" ).next()

ravefactory.create ( event.tracks(), "avr" )

Ejemplo n.º 6
0
#!/usr/bin/python

print "Simple btagging test."

from vertigo import RaveVertexFactory, RaveFlavorTagFactory, RaveConstantMagneticField,\
                    RaveVacuumPropagator, EventFactory, RavePoint3D, LoopSettings, RaveTrackContainer

method="avr-primcut:1.8-seccut:6.0-primT:256-secT:256-primr:0.25-secr:0.25-smoothing:0-weightthreshold:0.001-minweight:0.5"

ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator(), method )
btagfactory=RaveFlavorTagFactory ( ravefactory )
# btagfactory=RaveFlavorTagFactory ( )

set=LoopSettings.Instance()
set.setVerbosity(0)

eventfactory=EventFactory ( "bb.1.txt" )

for event in eventfactory:
  primary=ravefactory.create ( event.tracks(), "avf" )
  jets=event.jets()
  print len(jets),"jets. Primary vertex at ",primary[0].position()
  for jet in jets:
    # print "has flavor tagging: ", btagfactory.hasFlavorTagging()
    # print jet.tracks().__class__
    # print primary[0].__class__
    # print jet.momentum().__class__

    tag=btagfactory.tag ( jet.tracks(), primary[0], jet.momentum() )
    
    print "Tagging jet: %(mc)s %(tag).2f jet axis: %(axis)s (pt %(pt).4f) %(sz)d tracks" % \
Ejemplo n.º 7
0
#!/usr/bin/python

print "Test the avf with beamspot and a single track!"

from vertigo import RaveVertexFactory, RaveFlavorTagFactory, RaveConstantMagneticField,\
                    RaveVacuumPropagator, EventFactory, RavePoint3D, LoopSettings, RaveTrackContainer,\
                    RaveEllipsoid3D, RaveCovariance3D

ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator(), "avr" )
beamspot=RaveEllipsoid3D( RavePoint3D(), RaveCovariance3D( .0015**2,0.,0.,.0015**2,0.,5.3**2 ) )
ravefactory.setBeamSpot ( beamspot )

eventfactory=EventFactory ( "onetrack.txt" )

event=eventfactory.next()
primary=ravefactory.create ( event.tracks(), "avf", True )
print "Vtx Pos: (%.4f, %.4f, %.4f)  %d tracks" % ( primary[0].position().x(),primary[0].position().y(),primary[0].position().z(),len(primary[0].tracks()))
print "%.4f" % primary[0].weightedTracks()[0][0]
Ejemplo n.º 8
0
#!/usr/bin/python

print "running vertigo/tests/ktest.py ..."

from vertigo import LoopSettings, EventFactory, RaveConstantMagneticField, RaveVacuumPropagator, RaveKTransientTrackParticle, RaveVertexFactory, RaveKTreeFactory, RaveKParticleContainer, RaveKTreeContainer, RaveKConstraintBuilder

LoopSettings.Instance().setVerbosity(100)

muonmass  = 0.1056583
muonsigma = 0.0000000001
kchi2 = 0.
kndf  = 0.
magneticfield = RaveConstantMagneticField( 0., 0., 4. )

eventfactory  = EventFactory ( "gun:kinematics" )
vertexfactory = RaveVertexFactory ( magneticfield, RaveVacuumPropagator() )
treefactory   = RaveKTreeFactory( magneticfield )

muonmass  = 0.1056583
muonsigma = 0.0000000001
Zmass     = 91.187
Zsigma    = 2.4952

#print "\nskipping the first shot"
#eventfactory.skip(2)
#print "using the following shot"
event = eventfactory.next()

tracks = event.tracks()
print "\nfound ", len( tracks ), " generated tracks"
Ejemplo n.º 9
0
def pprint ( vtx ):
  print "Vtx Pos: (%.4f, %.4f, %.4f) chi2=%.3f ndf=%.3f" % ( vtx.position().x(),vtx.position().y(),vtx.position().z(), 
                                                             vtx.chiSquared(), vtx.ndf() )
  # print vtx
  rftrks=vtx.refittedTracks()

  ctr=0
  for wtrk in sorted ( vtx.weightedTracks() ):
    # wtrk=WeightedRaveTrack ( tmp )
    if wtrk[0] > 1.e-8:
      print "w=%0.3f"%wtrk[0], "  Orig.pz(): %0.3f"%wtrk[1].state().pz(),"  Refitted.pz(): %0.3f"% vtx.refittedTrack ( wtrk[1] ).state().pz()
      ##  print "w=%0.3f"%wtrk[0]," %i" %wtrk[1].id(), "  Orig.pz(): %0.3f"%wtrk[1].state().pz(),"  Refitted.pz(): %0.3f"% vtx.refittedTrack ( wtrk[1] ).state().pz()
    ctr=ctr+1

LoopSettings.Instance().setVerbosity(0)
ravefactory=RaveVertexFactory ( RaveConstantMagneticField(0.,0.,4.), RaveVacuumPropagator() )
eventfactory=EventFactory ( "input8.txt" )
event=eventfactory.next()

if doAvr:
  vertices=ravefactory.create ( event.tracks(), "avr-primcut:2.0-seccut:3.0-smoothing:1-minweight:0.5" )
  print "[avr]"
  for vertex in vertices:
    pprint ( vertex )

print


if doAvf:
  print "[avf]"
  vertex=ravefactory.create ( event.tracks(), "avf-sigmacut:2.0-smoothing:1-ratio:0.0078125" )[0]