Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
new branch 5.0 including jevio 6.0 and hipo 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaelladevita committed Dec 7, 2017
1 parent f51348b commit 3a8bd6b
Show file tree
Hide file tree
Showing 45 changed files with 738 additions and 201 deletions.
4 changes: 2 additions & 2 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ cd common-tools/coat-lib
mvn package
if [ $? != 0 ] ; then echo "common tools failure 2" ; exit 1 ; fi
cd -
cp common-tools/coat-lib/target/coat-libs-4.0-SNAPSHOT.jar coatjava/lib/clas/
cp common-tools/coat-lib/target/coat-libs-5.0-SNAPSHOT.jar coatjava/lib/clas/

### create local mvn repo containing coat-libs and jcsg ##
mvn deploy:deploy-file -Dfile=./common-tools/coat-lib/target/coat-libs-4.0-SNAPSHOT.jar -DgroupId=org.jlab.clas -DartifactId=common-tools -Dversion=0.0 -Dpackaging=jar -Durl=file:./myLocalMvnRepo/ -DrepositoryId=myLocalMvnRepo -DupdateReleaseInfo=true
mvn deploy:deploy-file -Dfile=./common-tools/coat-lib/target/coat-libs-5.0-SNAPSHOT.jar -DgroupId=org.jlab.clas -DartifactId=common-tools -Dversion=0.0 -Dpackaging=jar -Durl=file:./myLocalMvnRepo/ -DrepositoryId=myLocalMvnRepo -DupdateReleaseInfo=true
if [ $? != 0 ] ; then echo "failed to create local mvn repo" ; exit 1 ; fi

### dc (depends on jcsg) ###
Expand Down
6 changes: 0 additions & 6 deletions common-tools/.gitignore

This file was deleted.

16 changes: 8 additions & 8 deletions common-tools/clas-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,51 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-analysis</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../parent/pom.xml</relativePath>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab</groupId>
<artifactId>groot</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
12 changes: 6 additions & 6 deletions common-tools/clas-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../parent/pom.xml</relativePath>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>3.0-SNAPSHOT</version>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab</groupId>
<artifactId>groot</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ public static int generateHashCode(int s, int l, int c){

public int getHashCode(){
int hash = ((this.dt_SECTOR<<24)&0xFF000000)|
((this.dt_LAYER<<16)&0x00FF0000)|(this.dt_COMPONENT&0x0000FFFF);
((this.dt_LAYER<<16)&0x00FF0000)| ((this.dt_ORDER<<12) & 0x0000F000) |
(this.dt_COMPONENT&0x00000FFF);
return hash;
}




public void copy(DetectorDescriptor desc){
this.hw_SLOT = desc.hw_SLOT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ private synchronized void loadConstantsForRun(int run){
try {
IndexedTable table = provider.readTable(tableName);
desc.getMap().put(tk.get(i), table);
System.out.println("***** >>> adding : table " + tableName
+ " key = " + tk.get(i));
System.out.println(String.format("***** >>> adding : %14s / table = %s", tk.get(i),tableName));
//System.out.println("***** >>> adding : table " + tableName
// + " key = " + tk.get(i));
} catch (Exception e) {
System.out.println("[ConstantsManager] ---> error reading table : "
+ tableName);
Expand Down
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;
}

}
Loading

0 comments on commit 3a8bd6b

Please sign in to comment.