[Clas12_software] A useful utility (at least for me)

David Heddle david.heddle at cnu.edu
Thu Jul 10 17:26:26 EDT 2014


If you are writing java you may be in the same situation as me--you are
creating arrays that correspond to the columns in the bankdef xmls. For
every column in every xml I have to
1) declare the array with the correct type (I make them public)
2) get the array from clas-io
3) nullify (clear) the array when a new event arrives.

Since many/most of the xmls already have ~100 columns, this is ripe for the
possibility of cut&paste and typo errors. (Also the xmls will evolve). This
should not be a manual process, so I wrote a small utility that reads the
bankdef xml and spits out text that is in java form and can be pasted into
a source file.

I used a naming convention that every array name is section_column, all
lower case. Also, I assumed I am getting the arrays from a clas-io
EvioDataEvent named event. For example, when I run this on DC.xml (which
presently has 136 columns) I get 3*136 = 408 lines of java code (plus java
doc generated from the xml info attribute) which I can cut and paste rather
than type in, with no worries for typos. It looks like this (for a few of
the 136 columns)


//declaration section

/** ID of the first particle entering the sensitive volume */

public int[] true_pid;

/** ID of the mother of the first particle entering the sensitive volume */

public int[] true_mpid;

/** Track ID of the first particle entering the sensitive volume */

public int[] true_tid;

/** superlayer */

public int[] hbsegments_superlayer;

/** associated cross ID */

public int[] hbsegments_crossid;

/** associated track ID */

public int[] hbsegments_trackid;

//get from clas-io event bank

hbclusters_id = event.getInt("HitBasedTrkg::HBClusters.ID");

hbclusters_sector = event.getInt("HitBasedTrkg::HBClusters.sector");

hbclusters_superlayer = event.getInt("HitBasedTrkg::HBClusters.superlayer");

hbclusters_segmentid = event.getInt("HitBasedTrkg::HBClusters.segmentID");

hbclusters_crossid = event.getInt("HitBasedTrkg::HBClusters.crossID");

hbclusters_trackid = event.getInt("HitBasedTrkg::HBClusters.trackID");

hbsegments_id = event.getInt("HitBasedTrkg::HBSegments.ID");

hbsegments_sector = event.getInt("HitBasedTrkg::HBSegments.sector");

hbsegments_superlayer = event.getInt("HitBasedTrkg::HBSegments.superlayer");

hbsegments_crossid = event.getInt("HitBasedTrkg::HBSegments.crossID");

//nullify

true_mtid = null;

true_otid = null;

true_tracke = null;

true_totedep = null;

true_avgx = null;

true_avgy = null;

true_avgz = null;

true_avglx = null;

true_avgly = null;

true_avglz = null;
If this is potentially useful but you have a different naming convention
for the arrays (or don't want them to be public) we can handle that with
command line options.


-- 
David P. Heddle, Ph.D.
Associate Professor of Physics
Christopher Newport University
Newport News, VA 23606

757.594.8434 (CNU)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.jlab.org/pipermail/clas12_software/attachments/20140710/cb606627/attachment-0002.html>


More information about the Clas12_software mailing list