This repository has been archived by the owner on May 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new branch 5.0 including jevio 6.0 and hipo 3.0
- Loading branch information
1 parent
f51348b
commit 3a8bd6b
Showing
45 changed files
with
738 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
...on-tools/clas-detector/src/main/java/org/jlab/detector/decode/AbsDetectorDataDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.jlab.detector.decode; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.jlab.detector.base.DetectorType; | ||
import org.jlab.io.base.DataBank; | ||
import org.jlab.io.base.DataEvent; | ||
import org.jlab.jnp.hipo.packing.DataPacking; | ||
import org.jlab.utils.groups.IndexedTable; | ||
|
||
/** | ||
* | ||
* @author gavalian | ||
*/ | ||
public class AbsDetectorDataDecoder implements DetectorDataDecoder { | ||
|
||
private String detectorName = "UNKNOWN"; | ||
private String detectorTable = "UNKNOWN"; | ||
private IndexedTable translationTable = null; | ||
private DataPacking dataPacker = new DataPacking(); | ||
private ByteBuffer pulseBuffer = null; | ||
|
||
public AbsDetectorDataDecoder(String name, String table){ | ||
detectorName = name; | ||
detectorTable = table; | ||
byte[] array = new byte[500*1024]; | ||
pulseBuffer = ByteBuffer.wrap(array); | ||
pulseBuffer.order(ByteOrder.LITTLE_ENDIAN); | ||
} | ||
|
||
public String getName(){ | ||
return detectorName; | ||
} | ||
|
||
public String getTable(){ | ||
return detectorTable; | ||
} | ||
|
||
public void setConstantsTable(IndexedTable table){ | ||
this.translationTable = table; | ||
} | ||
|
||
@Override | ||
public List<DetectorDataDgtz> decode(List<DetectorDataDgtz> dgtzData) { | ||
if(this.translationTable==null){ | ||
System.out.println("[AbsDetectorDataDecoder] **** error *** the table for [" | ||
+ detectorName + "] is not present."); | ||
return new ArrayList<DetectorDataDgtz>(); | ||
} | ||
|
||
DetectorType type = DetectorType.getType(detectorName); | ||
List<DetectorDataDgtz> data = new ArrayList<DetectorDataDgtz>(); | ||
for(DetectorDataDgtz dgtz : dgtzData){ | ||
int crate = dgtz.getDescriptor().getCrate(); | ||
int slot = dgtz.getDescriptor().getSlot(); | ||
int channel = dgtz.getDescriptor().getChannel(); | ||
if(translationTable.hasEntry(crate,slot,channel)==true){ | ||
int sector = translationTable.getIntValue("sector", crate,slot,channel); | ||
int layer = translationTable.getIntValue("layer", crate,slot,channel); | ||
int component = translationTable.getIntValue("component", crate,slot,channel); | ||
int order = translationTable.getIntValue("order", crate,slot,channel); | ||
dgtz.getDescriptor().setSectorLayerComponent(sector, layer, component); | ||
dgtz.getDescriptor().setOrder(order); | ||
dgtz.getDescriptor().setType(type); | ||
data.add(dgtz); | ||
} | ||
} | ||
return data; | ||
} | ||
|
||
@Override | ||
public List<DataBank> createBanks(List<DetectorDataDgtz> dgtzData, DataEvent event) { | ||
List<DetectorDataDgtz> translatedData = this.decode(dgtzData); | ||
List<DetectorDataDgtz> tdc = AbsDetectorDataDecoder.getTDCData(translatedData); | ||
List<DetectorDataDgtz> adc = AbsDetectorDataDecoder.getADCData(translatedData); | ||
//System.out.println(String.format("%8s: data size = %8d , decoded data size = %d ADC = %d , TDC = %d",this.getName(), | ||
// dgtzData.size(),translatedData.size(),adc.size(),tdc.size())); | ||
|
||
List<DataBank> dataBanks = new ArrayList<DataBank>(); | ||
if(tdc.size()>0){ | ||
DataBank bankTDC = event.createBank(detectorName+"::tdc", tdc.size()); | ||
if(bankTDC==null){ | ||
System.out.println(" ERROR Trying to create bank " + detectorName+"::tdc"); | ||
System.out.println(" TDC ARRAY LENGTH = " + tdc.size()); | ||
for(DetectorDataDgtz d : tdc){ | ||
System.out.println(d); | ||
} | ||
} | ||
if(bankTDC!=null){ | ||
for(int i = 0; i < tdc.size(); i++){ | ||
bankTDC.setByte("sector", i, (byte) tdc.get(i).getDescriptor().getSector()); | ||
bankTDC.setByte("layer", i, (byte) tdc.get(i).getDescriptor().getLayer()); | ||
bankTDC.setShort("component", i, (short) tdc.get(i).getDescriptor().getComponent()); | ||
bankTDC.setByte("order", i, (byte) tdc.get(i).getDescriptor().getOrder()); | ||
bankTDC.setInt("TDC", i, tdc.get(i).getTDCData(0).getTime()); | ||
} | ||
dataBanks.add(bankTDC); | ||
} | ||
} | ||
|
||
/** | ||
* Write ADC pulses | ||
*/ | ||
if(adc.size()>0){ | ||
byte[] bufferArray = new byte[256]; | ||
ByteBuffer buffer = ByteBuffer.wrap(bufferArray); | ||
buffer.order(ByteOrder.LITTLE_ENDIAN); | ||
pulseBuffer.rewind(); | ||
int position = 0; | ||
for(int i = 0; i < adc.size(); i++){ | ||
DetectorDataDgtz data = adc.get(i); | ||
short[] pulse = data.getADCData(0).getPulseArray(); | ||
this.dataPacker.pack(buffer, pulse, 0); | ||
|
||
pulseBuffer.putInt(data.getDescriptor().getHashCode()); | ||
position +=4; | ||
short packedLength = (short) buffer.limit(); | ||
pulseBuffer.putShort(position, (short) buffer.limit()); | ||
position +=2; | ||
|
||
System.arraycopy(buffer.array(), 0, pulseBuffer.array(), position, packedLength); | ||
position += packedLength; | ||
//System.out.print(String.format("%08X : ", data.getDescriptor().getHashCode())); | ||
//System.out.println( | ||
// data.getDescriptor().toString() + " PULSE SIZE = " | ||
// + pulse.length*2 + " LENGTH = " + buffer.limit()); | ||
|
||
} | ||
DataBank bankPULSES = event.createBank(getName() + "::pulse", position); | ||
for(int i = 0; i < position; i++) bankPULSES.setByte("data", i, pulseBuffer.get(i)); | ||
dataBanks.add(bankPULSES); | ||
} | ||
return dataBanks; | ||
} | ||
/** | ||
* returns a list of values from the list that are TDC values. | ||
* used to filter out TDC values for creating the banks | ||
* @param dgtzData the list containing all digitized data | ||
* @return list that contains only TDC digitized data | ||
*/ | ||
public static List<DetectorDataDgtz> getTDCData(List<DetectorDataDgtz> dgtzData){ | ||
List<DetectorDataDgtz> tdc = new ArrayList<DetectorDataDgtz>(); | ||
for(DetectorDataDgtz dgtz : dgtzData){ | ||
if(dgtz.getTDCSize()>0){ | ||
tdc.add(dgtz); | ||
} | ||
} | ||
return tdc; | ||
} | ||
|
||
public static List<DetectorDataDgtz> getADCData(List<DetectorDataDgtz> dgtzData){ | ||
List<DetectorDataDgtz> adc = new ArrayList<DetectorDataDgtz>(); | ||
for(DetectorDataDgtz dgtz : dgtzData){ | ||
if(dgtz.getADCSize()>0){ | ||
for(int i = 0; i < dgtz.getADCSize(); i++){ | ||
//System.out.println(" ADC " + i + " PULSE SIZE = " + dgtz.getADCData(i).getPulseSize()); | ||
} | ||
adc.add(dgtz); | ||
} | ||
} | ||
return adc; | ||
} | ||
|
||
} |
Oops, something went wrong.