## 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" ) for vertex in vertices: printVertex ( vertex )
primaries=RaveTrackContainer() first=True secondaries=None for jet in event.jets(): tracks=jet.tracks() print len(tracks), "tracks in jet." if not first: # put all tracks but of "first jet" in "primaries" for track in tracks: primaries.append ( track ) else: secondaries=tracks first=False vertices=ravefactory.create ( event.tracks(), True ) print len(vertices),"vertices with all tracks" for vtx in vertices: print "Vtx Pos: (%.4f, %.4f, %.4f)" % (vtx.position().x(),vtx.position().y(),vtx.position().z() ) print len(primaries),"primary tracks." vertices=ravefactory.create ( primaries, secondaries, True ) # vertices=ravefactory.create ( primaries, True ) print len(vertices),"vertices with all tracks" for vtx in vertices: print "Vtx Pos: (%.4f, %.4f, %.4f)" % (vtx.position().x(),vtx.position().y(),vtx.position().z() ) # obs=ObserverManager_Instance().get("EventPrinter") # obs.process(event)
#!/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 )
writer.save(t) ctr=0 max=1000 while ctr<max: event = eventfactory.next() ctr=event.id() tracks=event.tracks() particles=event.particles() simtracks=event.simTracks() simvtxs=event.simVertices() print "len simvtxs=",len(simvtxs) vtces0=vertexfactory.create ( tracks, "kalman-smoothing:0" ) if len(vtces0)>0: discussVertex ( simvtxs[0], vtces0[0], "kalman", ctr ) trks0=vtces0[0].tracks() for rtrk in trks0: simtracks=event.associatedTracks ( rtrk ) if len(simtracks)!=1: print "Huh?",len(simtracks),"simtracks??" continue print "not smoothed",rtrk.state() discussTrack ( simtracks[0], rtrk, "kalmannosmooth", ctr, { "smooth": 0 } ) vtces1=vertexfactory.create ( tracks, "kalman-smoothing:1" ) if len(vtces1)>0: rtrks1=vtces1[0].refittedTracks() trks1=vtces1[0].tracks()
#!/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" )
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" % \ { "mc": jet.getMCTag(), "tag": tag, "axis": jet.momentum(), "pt":jet.momentum().perp(), "sz" : len(jet.tracks() ) }
tracks = event.tracks() print "\nfound ", len( tracks ), " generated tracks" eparticles = event.particles() print "\nfound ", len( eparticles ), " generated particles" print "\nThe simvertices are as follow:" for v in event.simVertices(): print " ", v.position(), " tag: ", v.tag() print "\nThe simparticles are as follow:" for p in event.simParticles(): print " ", p.state() print "\nreconstructing the vertex using method 'kalman'" vertices = vertexfactory.create( tracks, "kalman" ) for vertex in vertices: print vertex, "chi2=", ( int ( 1000 * vertex.chiSquared() )) / 1000.," ntrks=", len(vertex.tracks()) print "\nassigning muon mass information to the tracks to produce particles" #particles = RaveKParticleContainer() #for track in tracks: # particles.push_back( RaveKTransientTrackParticle( track, muonmass, muonsigma, kchi2, kndf ) ) particles = RaveKParticleContainer() for p in eparticles: particles.push_back(p) def printParticle( prefix, name, particle ): print prefix, name, " : ", particle.fullstate() def printTree( tree ):
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] newtracks=RaveTrackContainer() pprint ( vertex ) wtracks = vertex.weightedTracks()