Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .containers/coatjava.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#syntax=docker/dockerfile:1

FROM ubuntu:noble

LABEL name="coatjava"
LABEL maintainer="Whitney Armstrong <whit@jlab.org>"
LABEL architecture="amd64"

USER root


RUN apt update && apt upgrade -y
RUN apt install cmake vim maven groovy git ca-certificates wget curl python-is-python3 \
openjdk-17-jdk openjdk-17-jre openjdk-17-jdk-headless openjdk-17-jre-headless \
python3-sqlalchemy -y && update-ca-certificates

# CA certificates
ADD https://pki.jlab.org/JLabCA.crt /etc/ssl/certs/JLabCA.crt
#RUN trust anchor --store /image/JLabCA.crt

ARG REF_NAME=development
# build coatjava
RUN java --version && cd /opt && \
git clone https://code.jlab.org/hallb/alert/coatjava.git && cd coatjava && \
git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh --nomaps
31 changes: 31 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "webide"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "development"'
- if: '$CI_COMMIT_TAG'

default:
image: ubuntu:noble
retry: 2

coatjava_build:
image: gcr.io/kaniko-project/executor:debug
script:
- echo "${CI_COMMIT_REF_NAME}"
- >-
/kaniko/executor
--context $CI_PROJECT_DIR/docker
--dockerfile $CI_PROJECT_DIR/.containers/coatjava.Dockerfile
--destination $CI_REGISTRY_IMAGE/coatjava:${CI_COMMIT_REF_NAME}
--build-arg REF_NAME=${CI_COMMIT_REF_NAME}

alert_testing:
needs: ["coatjava_build"]
variables:
REF_NAME: "$CI_COMMIT_REF_NAME"
trigger:
project: hallb/alert/c12
strategy: depend
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public enum DetectorType {
BAND (21, "BAND"),
RASTER (22, "RASTER"),
URWELL (23, "URWELL"),
AHDC (24, "AHDC"),
ATOF (25, "ATOF"),
TARGET (100, "TARGET"),
MAGNETS (101, "MAGNETS"),
ECIN (110, "ECIN"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public List<DetectorDataDgtz> getEntriesADC(DetectorType type,
public List<DetectorDataDgtz> getEntriesTDC(DetectorType type){
return getEntriesTDC(type,dataList);
}

/**
* returns TDC entries from decoded data for given detector type
* @param type detector type
Expand Down Expand Up @@ -290,6 +291,31 @@ public Bank getDataBankTDC(String name, DetectorType type){
return tdcBANK;
}

public Bank getDataBankTDCPetiroc(String name, DetectorType type){

List<DetectorDataDgtz> tdcDGTZ = this.getEntriesTDC(type);
if(schemaFactory.hasSchema(name)==false){
System.out.println("WARNING: No schema for TDC type : " + type);
return null;
}
Bank tdcBANK = new Bank(schemaFactory.getSchema(name), tdcDGTZ.size());

if(tdcBANK==null) return null;

// Not sure why the schemea information isn't used here.
for(int i = 0; i < tdcDGTZ.size(); i++){
tdcBANK.putByte("sector", i, (byte) tdcDGTZ.get(i).getDescriptor().getSector());
tdcBANK.putByte("layer", i, (byte) tdcDGTZ.get(i).getDescriptor().getLayer());
tdcBANK.putShort("component", i, (short) tdcDGTZ.get(i).getDescriptor().getComponent());
tdcBANK.putByte("order", i, (byte) tdcDGTZ.get(i).getDescriptor().getOrder());
tdcBANK.putInt("TDC", i, tdcDGTZ.get(i).getTDCData(0).getTime());
tdcBANK.putInt("ToT", i, tdcDGTZ.get(i).getTDCData(0).getToT());
//System.err.println("event: " + tdcDGTZ.get(i).toString());
}
return tdcBANK;
}


public Bank getDataBankTimeStamp(String name, DetectorType type) {

List<DetectorDataDgtz> tdcDGTZ = this.getEntriesTDC(type);
Expand All @@ -300,7 +326,8 @@ public Bank getDataBankTimeStamp(String name, DetectorType type) {
int hash = ((desc.getCrate()<<8)&0xFF00) | (desc.getSlot()&0x00FF);
if(tsMap.containsKey(hash)) {
if(tsMap.get(hash).getTimeStamp() != tdc.getTimeStamp())
System.out.println("WARNING: inconsistent timestamp for DCRB crate/slot " + desc.getCrate() + "/" + desc.getSlot());
System.out.println("WARNING: inconsistent timestamp for DCRB crate/slot "
+ desc.getCrate() + "/" + desc.getSlot());
}
else {
tsMap.put(hash, tdc);
Expand Down Expand Up @@ -393,16 +420,24 @@ public Event getDataEvent(){

Event event = new Event();

String[] adcBankNames = new String[]{"FTOF::adc","ECAL::adc","FTCAL::adc","FTHODO::adc","FTTRK::adc",
String[] adcBankNames = new String[]{"FTOF::adc","ECAL::adc","FTCAL::adc","FTHODO::adc","FTTRK::adc",
"HTCC::adc","BST::adc","CTOF::adc","CND::adc","LTCC::adc","BMT::adc",
"FMT::adc","HEL::adc","RF::adc","BAND::adc","RASTER::adc"};
DetectorType[] adcBankTypes = new DetectorType[]{DetectorType.FTOF,DetectorType.ECAL,DetectorType.FTCAL,DetectorType.FTHODO,DetectorType.FTTRK,
DetectorType.HTCC,DetectorType.BST,DetectorType.CTOF,DetectorType.CND,DetectorType.LTCC,DetectorType.BMT,
DetectorType.FMT,DetectorType.HEL,DetectorType.RF,DetectorType.BAND, DetectorType.RASTER};

String[] tdcBankNames = new String[]{"FTOF::tdc","ECAL::tdc","DC::tdc","HTCC::tdc","LTCC::tdc","CTOF::tdc","CND::tdc","RF::tdc","RICH::tdc","BAND::tdc"};
DetectorType[] tdcBankTypes = new DetectorType[]{DetectorType.FTOF,DetectorType.ECAL,
DetectorType.DC,DetectorType.HTCC,DetectorType.LTCC,DetectorType.CTOF,DetectorType.CND,DetectorType.RF,DetectorType.RICH,DetectorType.BAND};
DetectorType[] adcBankTypes = new DetectorType[]{DetectorType.FTOF,DetectorType.ECAL,DetectorType.FTCAL,
DetectorType.FTHODO,DetectorType.FTTRK,
DetectorType.HTCC,DetectorType.BST,DetectorType.CTOF,
DetectorType.CND,DetectorType.LTCC,DetectorType.BMT,
DetectorType.FMT,DetectorType.HEL,DetectorType.RF,
DetectorType.BAND, DetectorType.RASTER};

String[] tdcBankNames = new String[]{"FTOF::tdc","ECAL::tdc","DC::tdc",
"HTCC::tdc","LTCC::tdc","CTOF::tdc",
"CND::tdc","RF::tdc","RICH::tdc",
"BAND::tdc"};
DetectorType[] tdcBankTypes = new DetectorType[]{DetectorType.FTOF,DetectorType.ECAL,
DetectorType.DC,DetectorType.HTCC,DetectorType.LTCC,
DetectorType.CTOF,DetectorType.CND,DetectorType.RF,
DetectorType.RICH,DetectorType.BAND};

for(int i = 0; i < adcBankTypes.length; i++){
Bank adcBank = getDataBankADC(adcBankNames[i],adcBankTypes[i]);
Expand All @@ -421,6 +456,18 @@ public Event getDataEvent(){
}
}
}
try {
// Do ATOF
Bank tdcBank = getDataBankTDCPetiroc("ATOF::tdc",DetectorType.ATOF);
if(tdcBank!=null){
if(tdcBank.getRows()>0){
event.write(tdcBank);
}
}
} catch(Exception e) {
e.printStackTrace();
}


try {
Bank tsBank = getDataBankTimeStamp("DC::jitter", DetectorType.DC);
Expand All @@ -432,10 +479,10 @@ public Event getDataEvent(){
} catch(Exception e) {
e.printStackTrace();
}

/**
* Adding un-decoded banks to the event
*/

try {
Bank adcBankUD = this.getDataBankUndecodedADC("RAW::adc", DetectorType.UNDEFINED);
if(adcBankUD!=null){
Expand Down Expand Up @@ -671,6 +718,8 @@ public Bank createHelicityDecoderBank(EvioDataEvent event) {
public static void main(String[] args){

OptionParser parser = new OptionParser("decoder");

parser.setDescription("CLAS12 Data Decoder");
parser.addOption("-n", "-1", "maximum number of events to process");
parser.addOption("-c", "2", "compression type (0-NONE, 1-LZ4 Fast, 2-LZ4 Best, 3-GZIP)");
parser.addOption("-d", "0","debug mode, set >0 for more verbose output");
Expand Down Expand Up @@ -721,8 +770,8 @@ public static void main(String[] args){
writer.setCompressionType(compression);
writer.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4"));

Bank rawScaler = new Bank(writer.getSchemaFactory().getSchema("RAW::scaler"));
Bank rawRunConf = new Bank(writer.getSchemaFactory().getSchema("RUN::config"));
Bank rawScaler = new Bank(writer.getSchemaFactory().getSchema("RAW::scaler"));
Bank rawRunConf = new Bank(writer.getSchemaFactory().getSchema("RUN::config"));
Bank helicityAdc = new Bank(writer.getSchemaFactory().getSchema("HEL::adc"));
Event scalerEvent = new Event();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,12 @@ else if(node.getTag()==57622){
else if(node.getTag()==57636){
// RICH TDC data
return this.getDataEntries_57636(crate, node, event);
} else if(node.getTag()==57641){
// RTPC data decoding
return this.getDataEntries_57641(crate, node, event);
} else if (node.getTag() == 57657) {
// ATOF Petiroc TDC data
return this.getDataEntries_57657(crate, node, event);
} else if (node.getTag() == 57641) {
// RTPC data decoding
return this.getDataEntries_57641(crate, node, event);
}
}
return bankEntries;
Expand Down Expand Up @@ -1013,6 +1016,79 @@ public List<DetectorDataDgtz> getDataEntries_57636(Integer crate, EvioNode node
return entries;
}

/**
* Bank TAG=57657 used for ATOF PETIROC TDC values
* @param crate
* @param node
* @param event
* @return
*
* <dictEntry name="PETIROC Composite Data" tag="0xe139" num="0" type="composite">
* <description format="c,i,l,N(c,i,i)">
* c "slot number"
* i "trigger number"
* l "time stamp"
* N "number of channels fired"
* c "channel number"
* i "tdc value"
* i "width value"
* </description>
* </dictEntry>
*/
public List<DetectorDataDgtz> getDataEntries_57657(Integer crate, EvioNode node, EvioDataEvent event){

ArrayList<DetectorDataDgtz> entries = new ArrayList<>();

if(node.getTag()==57657){
try {
//System.err.println("Decoding ATOF PETIROC event!");
ByteBuffer compBuffer = node.getByteData(true);
CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder());

List<DataType> cdatatypes = compData.getTypes();
List<Object> cdataitems = compData.getItems();

if(cdatatypes.get(3) != DataType.NVALUE){
System.err.println("[EvioRawDataSource] ** error ** corrupted "
+ " bank. tag = " + node.getTag() + " num = " + node.getNum());
return null;
}

int position = 0;
while(position<cdatatypes.size()-4){
Byte slot = (Byte) cdataitems.get(position+0);
Integer trig_num = (Integer) cdataitems.get(position+1);
Long time_stamp = (Long) cdataitems.get(position+2);
Integer nchannels = (Integer) cdataitems.get(position+3);
position += 4;
int counter = 0;
while(counter<nchannels){
Byte channel = (Byte) cdataitems.get(position+0);
Integer tdc = (Integer) cdataitems.get(position+1);
// width over threshold
Integer tot = (Integer) cdataitems.get(position+2);


// Not sure what is going on here yet...
DetectorDataDgtz bank = new DetectorDataDgtz(crate,slot.intValue(),channel.intValue());
bank.addTDC(new TDCData(tdc,tot));
entries.add(bank);
position += 3;
counter++;
//System.err.println("event: " + bank.toString());
}
}

return entries;
} catch (EvioException ex) {
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
}
}
return entries;
}



public void getDataEntries_EPICS(EvioDataEvent event){
epicsData = new JsonObject();
List<EvioTreeBranch> branches = this.getEventBranches(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.jlab.detector.helicity.HelicityState;
import org.jlab.utils.data.DataUtils;

/**
/**
*
* @author gavalian
*/
Expand Down Expand Up @@ -162,10 +162,9 @@ public static List<DetectorDataDgtz> getDataADC(List<DetectorDataDgtz> list,Det
return filtered;
}

/**
* a class to hold ADC values
/** ADC Data holder.
* A class to hold ADC values (FADC)
*/

public static class ADCData implements Comparable<ADCData> {

private int adcOrder = 0;
Expand Down Expand Up @@ -325,25 +324,29 @@ public int compareTo(ADCData o) {
}
}

/**
* a class to hold TDC data
*/

/** TDC Data.
* A class to hold Multihit TDC data
*
*/
public static class TDCData implements Comparable<TDCData>{

private int tdcOrder = 0;
private int tdcTime = 0;
private int tdcOrder = 0; // Used for sorting
private int tdcTime = 0;
private int tdcToT = 0; // Time over threshold

public TDCData() {}
public TDCData(int time) { this.tdcTime = time;}
public TDCData(int time, int ToT) { this.tdcTime = time; this.tdcToT = ToT;}
public int getTime() { return this.tdcTime;}
public int getOrder() { return tdcOrder;}
public TDCData setOrder(int order) { tdcOrder = order;return this;}
public TDCData setTime(short time) { tdcTime = time;return this;}
public int getToT() { return this.tdcToT;}
public int getOrder() { return tdcOrder;}
public TDCData setOrder(int order) { tdcOrder = order;return this;}
public TDCData setTime(short time) { tdcTime = time;return this;}
public TDCData setToT(short ToT) { tdcToT = ToT;return this;}

@Override
public String toString(){
return String.format("TDC (%d) : %5d", getOrder(),getTime());
return String.format("TDC (%d) : %5d : %5d", getOrder(),getTime(),getToT());
}

public int compareTo(TDCData o) {
Expand Down
Loading