Author: [log in to unmask] Date: Tue Sep 22 17:30:32 2015 New Revision: 3672 Log: Use exception types for future flexibility. Add check for errors in the SVT header. Modified: java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java java/trunk/evio/src/main/java/org/hps/evio/EvioReader.java java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java Modified: java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java Tue Sep 22 17:30:32 2015 @@ -140,8 +140,9 @@ * @param event - EVIO event to process * @param lcsimEvent - LCSim event to put collections into * @return true if the EVIO was processed successfully, false otherwise - */ - public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) { + * @throws SvtEvioReaderException + */ + public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) throws SvtEvioReaderException { return this.makeHits(event, lcsimEvent); } @@ -153,8 +154,9 @@ * @param event - EVIO event to process * @param lcsimEvent - LCSim event to put collections into * @return true if the raw hits were created successfully, false otherwise - */ - public boolean makeHits(EvioEvent event, EventHeader lcsimEvent) { + * @throws SvtEvioReaderException + */ + public boolean makeHits(EvioEvent event, EventHeader lcsimEvent) throws SvtEvioReaderException { logger.fine("Physics Event: " + event.toString()); @@ -197,8 +199,8 @@ // If the ROC bank doesn't contain any data, raise an exception if (rocBank.getChildCount() == 0) { - throw new RuntimeException("[ " + this.getClass().getSimpleName() - + " ]: SVT bank doesn't contain any data banks."); + throw new SvtEvioReaderException("[ " + this.getClass().getSimpleName() + + " ]: SVT bank doesn't contain any data banks."); } // Get the data banks containing the SVT samples. @@ -223,13 +225,17 @@ - this.getDataTailLength(); logger.fine("Total number of samples: " + sampleCount); if (sampleCount % 4 != 0) { - throw new RuntimeException("[ " + throw new SvtEvioReaderException("[ " + this.getClass().getSimpleName() + " ]: Size of samples array is not divisible by 4"); } // extract header and tail information SvtHeaderDataInfo headerData = this.extractSvtHeader(dataBank.getHeader().getNumber(), data); + + // Check the integrity of the SVT header data + this.checkSvtHeaderData(headerData); + // Check that the multisample count is consistent if( sampleCount != SvtEvioUtils.getSvtTailMultisampleCount(headerData.getTail())*4) @@ -271,11 +277,19 @@ // Add SVT header data to the event this.addSvtHeadersToEvents(headers, lcsimEvent); - + + + return true; } + /** + * Check if the SVT headers are as expected. + * @param headers - list of headers to check + */ + protected abstract void checkSvtHeaderData(SvtHeaderDataInfo header) throws SvtEvioHeaderException; + /** * Extract the header information and store it in a {@link SvtHeaderDataInfo} object. * @param num - bank num (ROC id) Modified: java/trunk/evio/src/main/java/org/hps/evio/EvioReader.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/EvioReader.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/EvioReader.java Tue Sep 22 17:30:32 2015 @@ -24,9 +24,10 @@ * @param event : The EVIO event to read the raw data from * @param lcsimEvent : The LCSim event to write the collections to * @return True if the appropriate EVIO bank is found, false otherwise + * @throws Exception * */ - abstract boolean makeHits(EvioEvent event, EventHeader lcsimEvent); + abstract boolean makeHits(EvioEvent event, EventHeader lcsimEvent) throws Exception; /** * Set the hit collection name. Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java Tue Sep 22 17:30:32 2015 @@ -135,8 +135,12 @@ // Make SVT RawTrackerHits. try { svtReader.makeHits(evioEvent, lcsimEvent); + } catch (final SvtEvioHeaderException e) { + LOGGER.log(Level.SEVERE, "Error reading header information from the SVT.",e); + } catch (final SvtEvioReaderException e) { + LOGGER.log(Level.SEVERE, "Error making SVT hits.",e); } catch (final Exception e) { - LOGGER.log(Level.SEVERE, "Error making SVT hits.", e); + LOGGER.log(Level.SEVERE, "Error making SVT hits. Don't think I should be able to get here?", e); } // Write the current EPICS data into this event. Modified: java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/SvtEvioReader.java Tue Sep 22 17:30:32 2015 @@ -164,9 +164,10 @@ * @param event - EVIO event to process * @param lcsimEvent - LCSim event to put collections into * @return true if the EVIO was processed successfully, false otherwise - */ - @Override - public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) { + * @throws SvtEvioReaderException + */ + @Override + public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) throws SvtEvioReaderException { // Make RawTrackerHits. This will also search for and store banks containing // the configuration of the SVT. @@ -215,5 +216,19 @@ return new SvtHeaderDataInfo(num, svtHeader, svtTail); } + @Override + protected void checkSvtHeaderData(SvtHeaderDataInfo header) throws SvtEvioHeaderException { + int tail = header.getTail(); + if( SvtEvioUtils.getSvtTailSyncErrorBit(tail) != 0) { + throw new SvtEvioHeaderException("This header had a SyncError"); + } + else if( SvtEvioUtils.getSvtTailOFErrorBit(tail) != 0) { + throw new SvtEvioHeaderException("This header had a OverFlowError"); + } + else if( SvtEvioUtils.getSvtTailMultisampleSkipCount(tail) != 0) { + throw new SvtEvioHeaderException("This header had a skipCount " + SvtEvioUtils.getSvtTailMultisampleSkipCount(tail)); + } + } + } Modified: java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/TestRunSvtEvioReader.java Tue Sep 22 17:30:32 2015 @@ -170,6 +170,13 @@ return null; } + @Override + protected void checkSvtHeaderData(SvtHeaderDataInfo header) + throws SvtEvioHeaderException { + // TODO Auto-generated method stub + + } +