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());
      }
   }
}