Print

Print


Hi Gene,

> This is what I'm trying to do.  I have a class called
> MCPart_from_CalClust.java which extends AbstractProcessor.  I add this
> to the class ClusterStudyCheat.java, which extends Driver.  Inside of
> MCPart_from_CalClust, I make a Vector with one entry per event.  I want
> to calculate the median of the numbers in this Vector after analyzing
> all of the events.  The problem is that AbstractProcessor doesn't have a
> method called afterLastEvent, so I cannot calculate the median.  Since a
> Driver does have this method, I tried to do my analysis with a class
> that extends Driver.  But then, I cannot access the calorimeter
> information via LCDEvent's getEMClusters method -- the analysis fails
> because of java.lang.NoClassDefFoundError.

AbstractProcessor does have start() and stop() methods which can be used for
doing calculations at the beginning/end of a run.

> My question is this:
>
> (1) Is there a way to pass information between a Driver and an
> AbstractProcessor added to a Driver?

Yes, you could do something like this:

class MyDriver extend Driver
{
   private MyProcessor p;
   MyDriver()
   {
      p = new MyProcessor();
      add(p);
   }
   myExtraDriverMethod()
  {
      p.myExtraProcessorMethod();
  }
}

> (2) Why can't I access the calorimeter information from a driver, while
> I can from an AbstractProcessor?

I dont know, NoClassDefFoundError sounds like a strange error to get. If you
see it again maybe you can send me the code and I will look at it.

> (3) Is there a simple way to calculate the median of a list of numbers
> in the JAS framework?

There are no utilities for calculating medians, so what you are trying to do
sounds right. Be careful that the things you store into your vector are
things that you create. I.e.

   ClusterList cl = event.getClusterList();
   myVector.addElement(new Integer(cl.getNClusters()));

is fine, but

   myVector.addElement(cl);

would not work as you expect, since event objects such as the clusterlist
are reused from one event to the next.

Tony