From 5476ff3f2200e9837152603935ac732edd5a512b Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 3 Sep 2024 11:28:46 -0400 Subject: [PATCH 1/6] Reading ADC status for ADC values =-1; handling out-of-range ADCs --- .../org/jlab/rec/cvt/banks/HitReader.java | 32 +++++++++++++++---- .../org/jlab/rec/cvt/hit/ADCConvertor.java | 18 ++++++++--- .../org/jlab/rec/cvt/services/CVTEngine.java | 7 ++-- .../rec/cvt/services/CVTReconstruction.java | 5 +-- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index 5b9beb5950..ffc03d5871 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -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; } @@ -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 tdcs = new HashMap<>(); @@ -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 diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java index 3e98e1aa6b..e54e522591 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java @@ -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++) { diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTEngine.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTEngine.java index e278b0c9c7..46bed5aa18 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTEngine.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTEngine.java @@ -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> hits = reco.readHits(event, svtStatus, bmtStatus, bmtTime, - bmtStripVoltage, bmtStripThreshold); + bmtStripVoltage, bmtStripThreshold, + adcStatus); List> clusters = reco.findClusters(); List> crosses = reco.findCrosses(); @@ -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"); diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java index 2e282dfbe1..5f42394595 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java @@ -40,10 +40,11 @@ public CVTReconstruction(Swim swimmer) { public List> 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); From 79d40c2c93d01925741dfba9018e4b851d882b94 Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 17 Sep 2024 10:11:08 -0400 Subject: [PATCH 2/6] Keeping all hits which do not have signs of corrupted data (bad channel number or ADC out of range). --- .../org/jlab/rec/cvt/banks/HitReader.java | 26 ++++++++++++------- .../org/jlab/rec/cvt/hit/ADCConvertor.java | 2 +- .../main/java/org/jlab/rec/cvt/hit/Hit.java | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index ffc03d5871..7e9b77cdfb 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -222,6 +222,7 @@ else if(Constants.getInstance().useOnlyBMTC50PercTruthHits && hit.getType()==BMT * @param omitLayer * @param omitHemisphere * @param status + * @param adcStatus */ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, IndexedTable status, IndexedTable adcStatus) { @@ -246,14 +247,14 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, //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; +// 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 tdcs = new HashMap<>(); @@ -348,6 +349,7 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, 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 @@ -365,9 +367,13 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, hit.setId(id); if (Constants.getInstance().flagSeeds) hit.MCstatus = order; - + if(!ADCConvertor.isEventUnCorrupted(ADC, adcStat)) { + hit.isCorrupted=true; + } // add this hit - if(hit.getRegion()!=Constants.getInstance().getRmReg()) { + + if(hit.getRegion()!=Constants.getInstance().getRmReg() + && !hit.isCorrupted) { if(Constants.getInstance().useOnlyMCTruthHits() ) { if(hit.MCstatus==0) hits.add(hit); diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java index e54e522591..0ea57e58f5 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java @@ -11,7 +11,7 @@ public ADCConvertor() { } - public static boolean isEventCorrupted(int adc, int adcstat) { + public static boolean isEventUnCorrupted(int adc, int adcstat) { boolean pass = true; if(adc==-1 && adc*adcstat==0) //0: event corrupted; -1 event is OK pass=false; diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/Hit.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/Hit.java index 3c7116bb38..296a82605c 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/Hit.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/Hit.java @@ -33,6 +33,7 @@ public class Hit implements Comparable { public boolean newClustering = false; public int MCstatus = -1; + public boolean isCorrupted; // constructor public Hit(DetectorType detector, BMTType type, int sector, int layer, Strip strip) { From 961da3afcc12c27db9a6e3f71d299197c28d0b4c Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 27 Jan 2025 09:39:46 -0500 Subject: [PATCH 3/6] remove MC if statement from method SVTADCtoDAQ. Use of adcstatus clarification. --- .../java/org/jlab/rec/cvt/banks/HitReader.java | 8 ++++++-- .../java/org/jlab/rec/cvt/hit/ADCConvertor.java | 16 +++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index 7e9b77cdfb..b2123c9aae 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -245,6 +245,7 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, //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 + //The value adcStatus in ccdb is 1 for runs where ADC=-1 is not permitted and 0 for runs where ADC=-1 is permitted boolean pass=true; int adcStat = adcStatus.getIntValue("adcstatus", 0, 0, 0); // for (int i = 0; i < rows; i++) { @@ -345,11 +346,14 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, // continue; // create the strip object with the adc value converted to daq value used for cluster-centroid estimate - boolean isMC = event.hasBank("MC::Particle"); - double E = ADCConvertor.SVTADCtoDAQ(ADC, isMC); + //boolean isMC = event.hasBank("MC::Particle"); + double E = ADCConvertor.SVTADCtoDAQ(ADC); if(E==-1) continue; + if(event.hasBank("MC::Particle") && ADC==-5) { //geantinos + E=1; + } Strip SvtStrip = new Strip(strip, E, time); SvtStrip.setPitch(SVTGeometry.getPitch()); // get the strip line diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java index 0ea57e58f5..a491438c95 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java @@ -12,10 +12,15 @@ public ADCConvertor() { } public static boolean isEventUnCorrupted(int adc, int adcstat) { + //The value adcStatus is 1 for runs where adc=-1 is permitted and 0 for runs where adc=-1 is NOT permitted + // boolean pass = true; - if(adc==-1 && adc*adcstat==0) //0: event corrupted; -1 event is OK - pass=false; - + if(adc==-1) { + if(adcstat==0) //0: event corrupted; 1 event is OK + pass=false; + if(adcstat==1) + pass=true; + } return pass; } /** @@ -24,11 +29,8 @@ public static boolean isEventUnCorrupted(int adc, int adcstat) { * test stand analysis * @return */ - public static double SVTADCtoDAQ(int adc, boolean isMC) { + public static double SVTADCtoDAQ(int adc) { - if(isMC && adc == -5) { - return 1; // this is for running with Geantinos. Geantinos have adc -5 - } if (adc < 0 || adc > 7) { return -1; } From 729f4ad6eac6eb6661549abe7c61c49332aaae3c Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 29 Jan 2025 15:38:13 -0500 Subject: [PATCH 4/6] remove if statement for geantinos that is no longer relevant --- .../cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index b2123c9aae..07fe27641d 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -351,9 +351,6 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, if(E==-1) continue; - if(event.hasBank("MC::Particle") && ADC==-5) { //geantinos - E=1; - } Strip SvtStrip = new Strip(strip, E, time); SvtStrip.setPitch(SVTGeometry.getPitch()); // get the strip line From d5f02d879dbc5889fda6745ad1135ce37e4bd3f2 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 30 Jan 2025 17:12:49 -0500 Subject: [PATCH 5/6] Switch the meaning of adcStatus --- .../src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java index a491438c95..0875bea2b9 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/ADCConvertor.java @@ -12,13 +12,13 @@ public ADCConvertor() { } public static boolean isEventUnCorrupted(int adc, int adcstat) { - //The value adcStatus is 1 for runs where adc=-1 is permitted and 0 for runs where adc=-1 is NOT permitted + //The value adcStatus is 0 for runs where adc=-1 is permitted and 1 for runs where adc=-1 is NOT permitted // boolean pass = true; if(adc==-1) { - if(adcstat==0) //0: event corrupted; 1 event is OK + if(adcstat==1) //1: event corrupted; 0 event is OK pass=false; - if(adcstat==1) + if(adcstat==0) pass=true; } return pass; From d5571b2ca8488e54d7b118ec5d633cef255b0802 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 30 Jan 2025 17:49:32 -0500 Subject: [PATCH 6/6] put back condition to reject the event based on hit corruption status. --- .../org/jlab/rec/cvt/banks/HitReader.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index 07fe27641d..86174629b7 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -246,16 +246,15 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, //Starting from Fall 2018 all events would have ADC=-1 and this is normal. //This ADC=-1 status is in a ccdb table //The value adcStatus in ccdb is 1 for runs where ADC=-1 is not permitted and 0 for runs where ADC=-1 is permitted - 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; + for (int i = 0; i < rows; i++) { + int ADC = bankDGTZ.getInt("ADC", i); + if(ADCConvertor.isEventUnCorrupted(ADC, adcStat)==false) { + return; + } + } + //bankDGTZ.show(); // first get tdcs Map tdcs = new HashMap<>(); @@ -368,13 +367,8 @@ public void fetch_SVTHits(DataEvent event, int omitLayer, int omitHemisphere, hit.setId(id); if (Constants.getInstance().flagSeeds) hit.MCstatus = order; - if(!ADCConvertor.isEventUnCorrupted(ADC, adcStat)) { - hit.isCorrupted=true; - } // add this hit - - if(hit.getRegion()!=Constants.getInstance().getRmReg() - && !hit.isCorrupted) { + if(hit.getRegion()!=Constants.getInstance().getRmReg()) { if(Constants.getInstance().useOnlyMCTruthHits() ) { if(hit.MCstatus==0) hits.add(hit);