Linear Collider Forum

Home » Software Tools » org.lcsim » Two naive questions for using Driver
Re: Two naive questions for using Driver [message #1155 is a reply to message #1154] Thu, 27 September 2007 13:50 Go to previous message
Messages: 138
Registered: January 2004

zhaohw wrote on Thu, 27 September 2007 13:14


I have two naive questions for using org.lcsim Driver class:

1. How to output some printout into a txt file ?
For example, I want to write out the values of a variable,
say, the energies of particles, into a ASCII file,
myfile.txt, How to do in a Driver ? Can you give me a
code template ?

Here is an example:
import org.lcsim.event.EventHeader;
import org.lcsim.util.Driver;

public class PrintDriver extends Driver
   private PrintWriter writer;
   public PrintDriver() throws IOException
      writer = new PrintWriter(new FileWriter("c:\\myFile.txt"));   
   protected void process(EventHeader event)
      writer.println("Got "+event);
   protected void suspend()
      // Not really necessary, but just to be safe.


2. How to use a Driver in a Driver ?
As I know, My question is: Supposing Driver A has a method
A.setSomethingOnA(), how do I use this method in
Driver C ?

Your last example looks about right,

   public class C extends Driver
      public C(){        
        Driver a = new A();    
        add(new B()); // just construct B

Read Message
Read Message
Previous Topic:How to use hep.lcd classes in lcsim ?
Next Topic:Reconstructing Events
Goto Forum:

Current Time: Mon Sep 16 18:08:54 Pacific Daylight Time 2019
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.1.
Copyright ©2001-2010 FUDforum Bulletin Board Software