[Feedback][Tutorial Contents][hep.lcd Home]
The following code segment shows how to run the FastMC with StdHEP input. The CheckFast class extends Driver (see the Tracking tutorial for an introduction to Processors and Drivers) and is configured to call two Processors, the MCFast processor which performs the FastMC simultation, followed by a user defined processor ResCheck which is defined later in the file.
import hep.analysis.*; import hep.physics.*; import hep.lcd.event.*; import hep.lcd.mc.fast.*; import hep.lcd.util.driver.*; import java.util.*; final public class CheckFast extends Driver { public CheckFast() { add(new MCFast()); add(new ResCheck()); // user analysis routine // create some special histograms histogram("pdiff vs ptot").setPartition( new FixedMeanPartition(0,10)); histogram("pdiff vs costheta").setPartition( new FixedMeanPartition(-1,1)); } } class ResCheck extends AbstractProcessor { public void process(LCDEvent event) { // Loop over tracks Enumeration e = event.getTrackList().getTracks(); while (e.hasMoreElements()) { Track t = (Track) e.nextElement(); double ptot = Math.sqrt(t.getMomentumX()*t.getMomentumX() + t.getMomentumY()*t.getMomentumY() + t.getMomentumZ()*t.getMomentumZ()); // Get associated MC particle MCParticle mc = t.getMCParticle(); double mcptot = Math.sqrt(mc.getPX()*mc.getPX() + mc.getPY()*mc.getPY() + mc.getPZ()*mc.getPZ()); double cosTheta = mc.getPZ()/mcptot; double pdiff = mcptot - ptot; // Make some plots histogram("pdiff").fill(pdiff); histogram("ptot").fill(ptot); histogram("mcptot").fill(mcptot); histogram("pdiff vs ptot").fill(ptot,pdiff); histogram("pdiff vs costheta").fill(cosTheta,pdiff); } } }