-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implemented a new service to be used in DCALIGN cooking, #380
Open
gavalian
wants to merge
5
commits into
development
Choose a base branch
from
iss-379
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f1cac1a
implemented a new service to be used in DCALIGN cooking, contains inf…
gavalian 3b9d1a5
removed commented sections
gavalian be62d8a
updated the MLDC engine to include AITrack banks if found
gavalian 007e11f
moved the new bank definitions to the end of json
gavalian 92eda86
added MLDC service to all YAMLs
gavalian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
165 changes: 165 additions & 0 deletions
165
reconstruction/mltn/src/main/java/org/jlab/service/mltn/MLDCEngine.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,165 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template | ||
*/ | ||
package org.jlab.service.mltn; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.jlab.clas.reco.ReconstructionEngine; | ||
import org.jlab.io.base.DataBank; | ||
import org.jlab.io.base.DataEvent; | ||
import org.jlab.io.hipo.HipoDataBank; | ||
import org.jlab.jnp.hipo4.data.Bank; | ||
import org.jlab.jnp.hipo4.data.CompositeBank; | ||
|
||
/** | ||
* | ||
* @author gavalian | ||
*/ | ||
public class MLDCEngine extends ReconstructionEngine { | ||
|
||
|
||
public MLDCEngine(){ | ||
super("MLDC","gavalian","1.0"); | ||
} | ||
|
||
@Override | ||
public boolean init() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean processDataEvent(DataEvent de) { | ||
|
||
List<ByteBuffer> trackBuffers = new ArrayList<>(); | ||
|
||
if(de.hasBank("TimeBasedTrkg::TBTracks")&&de.hasBank("TimeBasedTrkg::TBClusters")){ | ||
//System.out.println("writing trakcing bank"); | ||
DataBank tbt = de.getBank("TimeBasedTrkg::TBTracks"); | ||
DataBank tbc = de.getBank("TimeBasedTrkg::TBClusters"); | ||
ByteBuffer bb = getTracks(tbt,tbc,10); | ||
trackBuffers.add(bb); | ||
/*DataBank output = de.createBank("MLDC::tracks", bb.array().length); | ||
for(int j = 0; j < bb.array().length; j++) | ||
output.setByte("bytes", j,bb.array()[j]); | ||
de.appendBank(output);*/ | ||
} | ||
|
||
if(de.hasBank("TimeBasedTrkg::AITracks")&&de.hasBank("TimeBasedTrkg::AIClusters")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the banks with the AI prefix are created only when data-aicv.yaml is used. When data-ai.yaml is used, the tracking banks have the TB prefix even if AI tracking is used. |
||
DataBank tbt = de.getBank("TimeBasedTrkg::AITracks"); | ||
DataBank tbc = de.getBank("TimeBasedTrkg::AIClusters"); | ||
ByteBuffer bb = getTracks(tbt,tbc,20); | ||
trackBuffers.add(bb); | ||
} | ||
|
||
if(trackBuffers.size()>0){ | ||
int[] lengths = new int[trackBuffers.size()]; | ||
int[] offsets = new int[trackBuffers.size()]; | ||
int size = 0; | ||
for(int k = 0; k < offsets.length; k++){ | ||
lengths[k] = trackBuffers.get(k).array().length; | ||
offsets[k] = size; | ||
size += trackBuffers.get(k).array().length; | ||
} | ||
byte[] buffer = new byte[size]; | ||
for(int k = 0; k < trackBuffers.size(); k++){ | ||
System.arraycopy(trackBuffers.get(k).array(), 0, buffer, offsets[k], lengths[k]); | ||
} | ||
DataBank output = de.createBank("MLDC::tracks", buffer.length); | ||
for(int j = 0; j < buffer.length; j++) | ||
output.setByte("bytes", j,buffer[j]); | ||
de.appendBank(output); | ||
} | ||
|
||
if(de.hasBank("DC::tdc")==true){ | ||
DataBank bank = de.getBank("DC::tdc"); | ||
DataBank output = de.createBank("MLDC::dc", bank.rows()); | ||
|
||
HipoDataBank hbank = (HipoDataBank) bank; | ||
byte[] sector = hbank.getByte("sector"); | ||
byte[] layer = hbank.getByte("layer"); | ||
short[] wire = hbank.getShort("component"); | ||
int[] tdc = hbank.getInt("TDC"); | ||
|
||
for(int j = 0; j < bank.rows(); j++){ | ||
int id = (sector[j]-1)*(112*36) + (layer[j]-1)*112 + (wire[j]-1); | ||
output.setShort("id", j, (short) id); | ||
output.setShort("value", j, (short) tdc[j]); | ||
} | ||
de.appendBank(output); | ||
} | ||
return true; | ||
} | ||
|
||
public static Map<Integer,Integer> getMap(DataBank bank){ | ||
Map<Integer,Integer> map = new HashMap<>(); | ||
int[] ids = bank.getInt("id"); | ||
for(int j = 0; j < ids.length; j++) | ||
map.put(ids[j], j); | ||
return map; | ||
} | ||
|
||
|
||
public static ByteBuffer getTracks(DataBank trkg, DataBank clusters, int status){ | ||
Map<Integer,Integer> map = getMap(clusters); | ||
int size = trkg.rows(); | ||
int bsize = 110; | ||
byte[] bytes = new byte[size*bsize]; | ||
ByteBuffer b = ByteBuffer.wrap(bytes); | ||
b.order(ByteOrder.LITTLE_ENDIAN); | ||
HipoDataBank ht = (HipoDataBank) trkg; | ||
HipoDataBank hc = (HipoDataBank) clusters; | ||
int[] cid = new int[6]; | ||
for(int j = 0; j < size; j++){ | ||
int offset = j*bsize; | ||
int charge = (int) ht.getByte("q",j); | ||
int ps = status + (charge<0?2:1); | ||
//System.out.printf(" row = %4d , status = %5d, charge = %3d, pstat = %5d\n", | ||
// j,status,charge,ps); | ||
b.putShort(offset+0, (short) ps); | ||
b.putFloat(offset+2, 0.0f); | ||
b.putShort(offset+6, (short) ht.getByte("sector",j)); | ||
b.putShort(offset+8, (short) ht.getByte("q",j)); | ||
b.putFloat(offset+10, ht.getFloat("chi2", j)); | ||
b.putFloat(offset+14, ht.getFloat("p0_x", j)); | ||
b.putFloat(offset+18, ht.getFloat("p0_y", j)); | ||
b.putFloat(offset+22, ht.getFloat("p0_z", j)); | ||
|
||
b.putFloat(offset+26, ht.getFloat("Vtx0_x", j)); | ||
b.putFloat(offset+30, ht.getFloat("Vtx0_y", j)); | ||
b.putFloat(offset+34, ht.getFloat("Vtx0_z", j)); | ||
|
||
cid[0] = ht.getShort("Cluster1_ID", j); | ||
cid[1] = ht.getShort("Cluster2_ID", j); | ||
cid[2] = ht.getShort("Cluster3_ID", j); | ||
cid[3] = ht.getShort("Cluster4_ID", j); | ||
cid[4] = ht.getShort("Cluster5_ID", j); | ||
cid[5] = ht.getShort("Cluster6_ID", j); | ||
|
||
b.putInt(offset+38, cid[0]); | ||
b.putInt(offset+42, cid[1]); | ||
b.putInt(offset+46, cid[2]); | ||
b.putInt(offset+50, cid[3]); | ||
b.putInt(offset+54, cid[4]); | ||
b.putInt(offset+58, cid[5]); | ||
|
||
|
||
for(int i = 0; i < 6; i++){ | ||
if(map.containsKey(cid[i])==true){ | ||
float avg = hc.getFloat("avgWire", map.get(cid[i])); | ||
b.putFloat(offset+i*4+62, avg); | ||
b.putFloat(offset+i*4+62+4*6, avg); | ||
} else { | ||
b.putFloat(offset+i*4+62, 0.0f); | ||
b.putFloat(offset+i*4+62+4*6, 0.0f); | ||
} | ||
} | ||
} | ||
return b; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dcalign.yaml is really only used for straight tracks/alignment runs. The new service should be added to data-ai.yaml or data-cv.yaml or data-aicv.yaml.