[Feedback][Tutorial Contents][Welcome Page]
![]()
There are utilities for finding jets and analyzing event shapes in the hep.physics.jets package. The examples below show how to use this package.
The Jetset event shape and thrust routines have been converted to Java and
can be found in the hep.physics.jets.EventShape
class. To use the utility it is first necessary to create EventShape object, and
then to use its setEvent method to pass in the data to be analyzed. The argument
to the setEvent method is an Enumeration of either 3-vectors (hep.physics.Hep3Vector
)
or 4-vectors (hep.physics.HepLorentzVector
),
and optionally a hep.physics.predicate.Predicate
which is used to select which elements of the Enumeration are actually used
in the event shape calculations. The example below passes an Enumeration of the
MC truth particles to the setEvent method, along with a predicate which accepts
only final-state, charged.particles.
import hep.analysis.*;
import hep.lcd.event.*;
import hep.lcd.util.driver.*;
import hep.physics.*;
import hep.physics.jets.*;
import hep.physics.predicate.*;
import java.util.*;
final public class ShapeAnalysis extends Driver
{
// Create an instance of the EventShape utility
EventShape es = new EventShape();
// Create a Predicate that accepts final state charged particles
Predicate predicate = new Predicate()
{
public boolean accept(Object in)
{
Particle p = (Particle) in;
if (p.getStatusCode() != Particle.FINALSTATE) return false;
if (p.getType().getCharge() == 0) return false;
return true;
}
};
public void process(LCDEvent event)
{
// We will use the MC truth in this example
ParticleVector pv = event.getMCParticles();
es.setEvent(pv.particles(),predicate);
histogram("Thrust").fill(es.thrust().x());
histogram("Oblateness").fill(es.oblateness());
}
}

The jet finder consists of an interface hep.physics.jets.JetFinder
which is implemented by all jet finding algorithms, and a set of concrete jet
finding algorithms. Currently there are several concrete JetFinder classes
including hep.physics.jets.JadeEJetFinder
and hep.physics.jets.DurhamJetFinder
.
So far the JadeEJetFinder appears to work best for LCD events. To use a jet
finder it is first necessary to create an instance of the the jet finder, and
then invoke the setEvent method to pass it the data to be analysed. The
argument(s) to the setEvent method is(are) the same as for the EventShape class
described above. The following example program uses the same predicate as the
previous example.
import hep.analysis.*;
import hep.lcd.event.*;
import hep.lcd.util.driver.*;
import hep.physics.jets.*;
import hep.physics.predicate.*;
import hep.physics.*;
import java.util.*;
final public class JetFinder extends Driver
{
// Create a JadeEJetFinder with a ycut of 0.02
AbstractJetFinder jetFinder = new JadeEJetFinder(0.02);
// Create a Predicate that accepts final state charged particles
Predicate predicate = new Predicate()
{
public boolean accept(Object in)
{
Particle p = (Particle) in;
if (p.getStatusCode() != Particle.FINALSTATE) return false;
if (p.getType().getCharge() == 0) return false;
return true;
}
};
public void process(LCDEvent event)
{
// We will use the MC truth in this example to find jets
ParticleVector pv = event.getMCParticles();
jetFinder.setEvent(pv.particles(),predicate);
// Fill some diagnostic histograms
histogram("Njets").fill(jetFinder.njets());
histogram("Fewest Tracks").fill(jetFinder.fewestTracks());
double totalJetEnergy = 0;
double totalParticleEnergy = 0;
for (int ijet =0; ijet<jetFinder.njets(); ijet++)
{
totalJetEnergy += jetFinder.jet(ijet).t();
histogram("Jet Energy").fill(jetFinder.jet(ijet).t());
histogram("Particles in Jet").fill(jetFinder.nParticlesPerJet(ijet));
// loop over all the tracks in the jet, and add up there energy
// (should be the same as the jet energy)
double etot = 0;
Enumeration e = jetFinder.particlesInJet(ijet);
while (e.hasMoreElements())
etot += ((Particle) e.nextElement()).getEnergy();
histogram("Etot").fill(etot);
totalParticleEnergy += etot;
}
histogram("Total Jet Energy").fill(totalJetEnergy);
histogram("Total Particle Energy").fill(totalParticleEnergy);
}
}

To display the found jets on the LCD event display it is only necessary to fill the jet vectors into the event header. This can be achieved by adding the following three lines after the call to jetFinder.setEvent in the above example.
Vector v = new Vector(); for (int i=0; i<jetFinder.njets(); i++) v.addElement(jetFinder.jet(i)); event.put("Jets",v);
This should result in event displays looking something like this (the WIRED event display does not yet support displaying jets):


This example shows how to vary the Jet Finders y-cut to create a histogram showing how the average number of jets varies as a function of y-cut. Note that the jet finder automatically reruns the jet finding algorithm when the y-cut is changed.
import hep.analysis.*;
import hep.lcd.event.*;
import hep.lcd.util.driver.*;
import hep.physics.predicate.*;
import hep.physics.*;
import hep.physics.jets.*;
import java.util.*;
final public class YCut extends Driver
{
// Create a DurhamJetFinder with a ycut of 0.02
DurhamJetFinder jetFinder = new DurhamJetFinder(0.02);
// Create a Predicate that accepts final state charged particles
Predicate predicate = new Predicate()
{
public boolean accept(Object in)
{
Particle p = (Particle) in;
if (p.getStatusCode() != Particle.FINALSTATE) return false;
if (p.getType().getCharge() == 0) return false;
return true;
}
};
public YCut()
{
new ProfilePlot("NJets vs Y Cut");
}
public void process(LCDEvent event )
{
// We will use the MC truth in this example to find jets
ParticleVector pv = event.getMCParticles();
jetFinder.setEvent(pv.particles(),predicate);
// Fill some diagnostic histograms
for (double ycut=0.001; ycut<0.1; ycut += 0.002)
{
jetFinder.setYCut(ycut);
histogram("NJets vs Y Cut").fillW(ycut,jetFinder.njets());
}
}
}
