/** * * @author jgill */ package main; import org.lcsim.event.*; import org.lcsim.util.*; //import org.lcsim.util.event.*; import org.lcsim.util.loop.*; import hep.aida.*; import java.util.*; import java.io.*; //import gangedhits.*; //import org.lcsim.mc.fast.*; //import hep.physics.vec.*; public class StauMass extends Driver { IAnalysisFactory af; ITree tree; IHistogramFactory hf; IHistogram1D tauE; IFitFactory ff; IFunctionFactory funcf; IPlotterFactory pf; IFitter fitter; IFunction func1; IPlotter plotter; public static void main(String[] argv) { String fileName = "/nfs/data33/nlc/jgill/stau/stau.slcio"; File file = new File(fileName); LCSimLoop loop = new LCSimLoop(); try { loop.setLCIORecordSource(file); } catch (IOException x){ System.out.println("Couldn't set record source "+fileName+": "+x.getMessage()); } // // Add Drivers // //loop.add(new CheatClusterDriver()); //loop.add(new GangedHits2x2OffsetDriver()); //loop.add(new NearestNeighborClusterDriver(4,4,3,12)); loop.add(new StauMass()); // // Set number of events to run // try { loop.loop(-1); } catch (Exception x) { System.out.println("Exception in loop: "+x.getMessage()); } /* catch (LoopSourceExhaustedException x) { System.out.println("EOF!"); } catch (LoopException x) { System.out.println("LoopException: "+x.getMessage()); } catch (IOException x) { System.out.println("IOException in loop: "+x.getMessage()); } */ try { loop.reset(); } catch (IOException x) { System.out.println("IOException in loop.reset(): "+x.getMessage()); } loop.dispose(); } public StauMass() { af = IAnalysisFactory.create(); tree = af.createTreeFactory().create(); hf = af.createHistogramFactory(tree); ff = af.createFitFactory(); pf = af.createPlotterFactory(); funcf = af.createFunctionFactory(tree); fitter = ff.createFitter(); func1 = funcf.createFunctionFromScript("f1",1,"a*(atan(b*(x[0]-c)) - atan(b*(x[0]-(c + e))))","a,b,c,e","first fitting function"); tauE = hf.createHistogram1D("tau energy",100,0.,50); plotter = pf.create("It's a Plotter!"); } public void process(EventHeader event) { super.process(event); if (event.getEventNumber()%100 == 0) { System.out.println("\nANALYZING EVENT "+event.getEventNumber()+"\n"); } List mcList = event.getMCParticles(); for (MCParticle mcp : mcList) { if (mcp.getType().getName().equals("tau-")) { tauE.fill(mcp.getEnergy()); } } } public void endOfData(){ func1.setParameter("a",100.); func1.setParameter("b",4.25); func1.setParameter("c",8.); func1.setParameter("e",12.); IFitResult fit1 = fitter.fit(tauE,func1); IFunction fittedfunc1 = fit1.fittedFunction(); IPlotterStyle style = pf.createPlotterStyle(); ILineStyle lineStyle = pf.createLineStyle(); style.xAxisStyle().setLabel("Energy GeV"); style.yAxisStyle().setLabel("Number of Events"); style.dataStyle().fillStyle().setColor("red"); lineStyle.setColor("black"); lineStyle.setThickness(3); style.dataStyle().setLineStyle(lineStyle); plotter.region(0).plot(tauE, style); plotter.region(0).plot(fittedfunc1,style); plotter.show(); } }