From 5476ff3f2200e9837152603935ac732edd5a512b Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 3 Sep 2024 11:28:46 -0400 Subject: [PATCH] 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 5b9beb595..ffc03d587 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 3e98e1aa6..e54e52259 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 e278b0c9c..46bed5aa1 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 2e282dfbe..5f4239459 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);