2828 * 3. Writes HEL::flip, RUN/HEL::scaler, and RUN::unix to new tag-1 events
2929 * 4. Runs post-processing, writing tag-1 information to all events
3030 * 5. Adds .hipo to the output filename, if necessary
31- *
31+ * 6. Outputs a parallel file of select trigger bits with a raw schema
3232 * @author baltzell
3333 */
3434public class Clas12Writer extends HipoToHipoWriter {
@@ -44,6 +44,8 @@ public class Clas12Writer extends HipoToHipoWriter {
4444 DaqScalersSequence scalers ;
4545 SchemaFactory fullSchema ;
4646 boolean postprocess ;
47+ HipoWriterSorted rawWriter ;
48+ long rawTriggerMask ;
4749
4850 private void init (JSONObject opts ) {
4951 fullSchema = new SchemaFactory ();
@@ -56,6 +58,7 @@ private void init(JSONObject opts) {
5658 eventUnix = new TreeMap <>();
5759 conman .init ("/runcontrol/hwp" ,"/runcontrol/helicity" );
5860 postprocess = opts .optBoolean ("postprocess" , false );
61+ rawTriggerMask = opts .optLong ("rawTriggerMask" , -1 );
5962 if (opts .has ("variation" )) conman .setVariation (opts .getString ("variation" ));
6063 if (opts .has ("timestamp" )) conman .setTimeStamp (opts .getString ("timestamp" ));
6164 tag1banks = new Bank [TAG1BANKS .length ];
@@ -70,6 +73,11 @@ protected HipoWriterSorted createWriter(Path file, JSONObject opts) throws Event
7073 HipoWriterSorted w = new HipoWriterSorted ();
7174 super .configure (w , opts );
7275 w .open (file .toString ().endsWith (".hipo" ) ? file .toString () : file .toString ()+".hipo" );
76+ if (rawTriggerMask > 0 ) {
77+ rawWriter = new HipoWriterSorted ();
78+ rawWriter .getSchemaFactory ().copy (fullSchema );
79+ rawWriter .open ("raw_" +file .toString ().substring (file .toString ().indexOf ("_" )));
80+ }
7381 return w ;
7482 } catch (Exception e ) {
7583 throw new EventWriterException (e );
@@ -90,6 +98,14 @@ protected void writeEvent(Object event) throws EventWriterException {
9098 Event t = CLASDecoder4 .createTaggedEvent ((Event )event , runConfig , tag1banks );
9199 if (!t .isEmpty ()) writer .addEvent (t , 1 );
92100 super .writeEvent (event );
101+ if (rawTriggerMask > 0 ) {
102+ if (runConfig .getRows () > 0 ) {
103+ if ((runConfig .getLong ("trigger" ,0 ) & rawTriggerMask ) != 0 ) {
104+ rawWriter .addEvent ((Event )event );
105+ }
106+ }
107+ if (!t .isEmpty ()) rawWriter .addEvent (t , 1 );
108+ }
93109 }
94110
95111 @ Override
@@ -101,6 +117,7 @@ protected void closeWriter() {
101117 // keep the latest helicity/scaler reading for the next file:
102118 while (helicities .size () > 60 ) helicities .pollFirst ();
103119 scalers .clear (10 );
120+ if (rawTriggerMask > 0 ) rawWriter .close ();
104121 }
105122
106123 /**
0 commit comments