Skip to content

Commit

Permalink
Reading ADC status for ADC values =-1; handling out-of-range ADCs
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegler committed Sep 3, 2024
1 parent bf917b9 commit 5476ff3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ else if(Constants.getInstance().useOnlyBMTC50PercTruthHits && hit.getType()==BMT
* @param omitHemisphere
* @param status
*/
public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, IndexedTable status) {
public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere,
IndexedTable status, IndexedTable adcStatus) {

if (event.hasBank("BST::adc") == false) {
//System.err.println("there is no BST bank ");
_SVTHits = new ArrayList<>();

return;
}

Expand All @@ -239,6 +239,21 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, In
int rows = bankDGTZ.rows();

if (event.hasBank("BST::adc") == true) {
//pass event
//In RGA Spring 2018 data there should be no BST::adc.ADC=-1 and if found, the event is corrupted.
//In which case all the SVT hits are unreliable and they should all be discarted
//Starting from Fall 2018 all events would have ADC=-1 and this is normal.
//This ADC=-1 status is in a ccdb table
boolean pass=true;
int adcStat = adcStatus.getIntValue("adcstatus", 0, 0, 0);
for (int i = 0; i < rows; i++) {
int ADC = bankDGTZ.getInt("ADC", i);
if(ADCConvertor.isEventCorrupted(ADC, adcStat)==false) {
pass=false;
}
}
if(pass==false)
return;
//bankDGTZ.show();
// first get tdcs
Map<Integer, Double> tdcs = new HashMap<>();
Expand Down Expand Up @@ -328,16 +343,21 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, In
//if(adcConv.SVTADCtoDAQ(ADC[i], event)<50)
// continue;
// create the strip object with the adc value converted to daq value used for cluster-centroid estimate
Strip SvtStrip = new Strip(strip, ADCConvertor.SVTADCtoDAQ(ADC), time);

boolean isMC = event.hasBank("MC::Particle");
double E = ADCConvertor.SVTADCtoDAQ(ADC, isMC);
if(E==-1)
continue;
Strip SvtStrip = new Strip(strip, E, time);
SvtStrip.setPitch(SVTGeometry.getPitch());
// get the strip line
SvtStrip.setLine(Geometry.getInstance().getSVT().getStrip(layer, sector, strip));
SvtStrip.setModule(Geometry.getInstance().getSVT().getModule(layer, sector));
SvtStrip.setNormal(Geometry.getInstance().getSVT().getNormal(layer, sector));
// if the hit is useable in the analysis its status is =0
if (SvtStrip.getEdep() == 0) {
SvtStrip.setStatus(1);
}
//if (SvtStrip.getEdep() == 0) {
// SvtStrip.setStatus(1);
//}
//get status from ccdb
SvtStrip.setStatus(status.getIntValue("status", sector, layer, strip));
// create the hit object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@ public ADCConvertor() {

}

/**
public static boolean isEventCorrupted(int adc, int adcstat) {
boolean pass = true;
if(adc==-1 && adc*adcstat==0) //0: event corrupted; -1 event is OK
pass=false;

return pass;
}
/**
*
* @param adc ADC value Converts ADC values to DAQ units -- used for BST
* test stand analysis
* @return
*/
public static double SVTADCtoDAQ(int adc) {
if (adc == -5) {
public static double SVTADCtoDAQ(int adc, boolean isMC) {

if(isMC && adc == -5) {
return 1; // this is for running with Geantinos. Geantinos have adc -5
}
if (adc < 0 || adc > 7) {
return 0;
return -1;
}

int START[] = new int[8];
int END[] = new int[8];
for (int i = 0; i < 8; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,15 @@ public boolean processDataEvent(DataEvent event) {
IndexedTable bmtStripVoltage = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_strip_voltage");
IndexedTable bmtStripThreshold = this.getConstantsManager().getConstants(run, "/calibration/mvt/bmt_strip_voltage_thresholds");
IndexedTable beamPos = this.getConstantsManager().getConstants(run, "/geometry/beam/position");
IndexedTable adcStatus = this.getConstantsManager().getConstants(run, "/calibration/svt/adcstatus");

Geometry.getInstance().initialize(this.getConstantsManager().getVariation(), run, svtLorentz, bmtVoltage);

CVTReconstruction reco = new CVTReconstruction(swimmer);

List<ArrayList<Hit>> hits = reco.readHits(event, svtStatus, bmtStatus, bmtTime,
bmtStripVoltage, bmtStripThreshold);
bmtStripVoltage, bmtStripThreshold,
adcStatus);
List<ArrayList<Cluster>> clusters = reco.findClusters();
List<ArrayList<Cross>> crosses = reco.findCrosses();

Expand Down Expand Up @@ -466,7 +468,8 @@ public void initConstantsTables() {
"/calibration/mvt/bmt_voltage",
"/calibration/mvt/bmt_strip_voltage",
"/calibration/mvt/bmt_strip_voltage_thresholds",
"/geometry/beam/position"
"/geometry/beam/position",
"/calibration/svt/adcstatus"
};
requireConstants(Arrays.asList(tables));
this.getConstantsManager().setVariation("default");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ public CVTReconstruction(Swim swimmer) {

public List<ArrayList<Hit>> readHits(DataEvent event, IndexedTable svtStatus,
IndexedTable bmtStatus, IndexedTable bmtTime,
IndexedTable bmtStripVoltage, IndexedTable bmtStripVoltageThresh) {
IndexedTable bmtStripVoltage, IndexedTable bmtStripVoltageThresh,
IndexedTable adcStatus) {

HitReader hitRead = new HitReader();
hitRead.fetch_SVTHits(event, -1, -1, svtStatus);
hitRead.fetch_SVTHits(event, -1, -1, svtStatus, adcStatus);
if(Constants.getInstance().svtOnly==false)
hitRead.fetch_BMTHits(event, swimmer, bmtStatus, bmtTime,
bmtStripVoltage, bmtStripVoltageThresh);
Expand Down

0 comments on commit 5476ff3

Please sign in to comment.