Skip to content
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

update readout system for application of DAQ configuration #905

Merged
merged 1 commit into from
Jun 22, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,20 @@ public abstract class DigitizationWithPulserDataMergingReadoutDriver<D extends S
* Defines the ADC threshold needed to initiate pulse integration
* for raw hit creation.
*/
private int integrationThreshold = 18;
protected int integrationThreshold = 18;
/**
* Defines the number of integration samples that should be
* included in the pulse integral from before the sample that
* exceeds the integration threshold.
*/
private int numSamplesBefore = 5;
protected int numSamplesBefore = 5;
/**
* Defines the number of integration samples that should be
* included in the pulse integral from after the sample that
* exceeds the integration threshold.
* Threshold-crossing sample is part of NSA.
*/
private int numSamplesAfter = 25;
protected int numSamplesAfter = 25;
/**
* The format in which readout hits should be output.
*/
Expand Down Expand Up @@ -244,7 +244,7 @@ public abstract class DigitizationWithPulserDataMergingReadoutDriver<D extends S
* org.hps.readout.ecal.updated.DigitizationReadoutDriver#readoutOffset
* readoutOffset}.
*/
private int readoutWindow = 100;
protected int readoutWindow = 100;
/**
* Sets how far from the beginning of the readout window trigger
* time should occur. A value of x, for instance would result in
Expand All @@ -256,7 +256,7 @@ public abstract class DigitizationWithPulserDataMergingReadoutDriver<D extends S
/**
* Sets time window of ADC samples in pulser data
*/
private int pulserDataWindow = 48;
protected int pulserDataWindow = 48;

/**
* To make time alignment between Ecal and hodoscope detectors, samples of
Expand Down Expand Up @@ -1130,6 +1130,7 @@ protected Collection<TriggeredLCIOData<?>> getOnTriggerData(double triggerTime)
*/
protected abstract double getPedestalConditions(long channelID);


@Override
protected boolean isPersistent() {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hps.digi;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;

import org.hps.conditions.database.DatabaseConditionsManager;
Expand All @@ -9,6 +11,10 @@
import org.lcsim.event.RawTrackerHit;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.subdetector.HPSEcal3;
import org.hps.record.daqconfig2019.ConfigurationManager2019;
import org.hps.record.daqconfig2019.DAQConfig2019;
import org.hps.record.daqconfig2019.FADCConfigEcal2019;
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;

/**
* Class <code>EcalDigitizationWithPulserDataMergingReadoutDriver</code> is an implementation of the
Expand All @@ -19,9 +25,20 @@
* @author Tongtong Cao <caot@jlab.org>
*/
public class EcalDigitizationWithPulserDataMergingReadoutDriver extends DigitizationWithPulserDataMergingReadoutDriver<HPSEcal3> {
// The DAQ configuration manager for FADC parameters.
private FADCConfigEcal2019 config = new FADCConfigEcal2019();
private boolean configStat = false; // Indicates if DAQ configuration is loaded

// The number of nanoseconds in a clock-cycle (sample).
private static final int nsPerSample = 4;


/** Stores the conditions for this subdetector. */
private EcalConditions ecalConditions = null;

/** Stores the channel collection for this subdetector. */
private EcalChannelCollection geoMap = new EcalChannelCollection();

public EcalDigitizationWithPulserDataMergingReadoutDriver() {
// Set the default values for each subdetector-dependent
// parameter.
Expand All @@ -37,11 +54,49 @@ public EcalDigitizationWithPulserDataMergingReadoutDriver() {
setPulseTimeParameter(9.6);
}

/**
* Sets whether or not the DAQ configuration is applied into the driver
* the EvIO data stream or whether to read the configuration from data files.
*
* @param state - <code>true</code> indicates that the DAQ configuration is
* applied into the readout system, and <code>false</code> that it
* is not applied into the readout system.
*/
public void setDaqConfigurationAppliedintoReadout(boolean state) {
// If the DAQ configuration should be read, attach a listener
// to track when it updates.
if (state) {
ConfigurationManager2019.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the DAQ configuration.
DAQConfig2019 daq = ConfigurationManager2019.getInstance();

// Load the DAQ settings from the configuration manager.
numSamplesAfter = daq.getEcalFADCConfig().getNSA() / nsPerSample;
numSamplesBefore = daq.getEcalFADCConfig().getNSB() / nsPerSample;
readoutWindow = daq.getEcalFADCConfig().getWindowWidth() / nsPerSample;
pulserDataWindow = readoutWindow;

// Get the FADC configuration.
config = daq.getEcalFADCConfig();
configStat = true;
integrationThreshold = config.getThreshold((int)10);
}
});
}
}


@Override
public void detectorChanged(Detector detector) {
// Get a copy of the calorimeter conditions for the detector.
ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions();

// Store the calorimeter conditions table for converting between
// geometric IDs and channel objects.
geoMap = DatabaseConditionsManager.getInstance().getCachedConditions(EcalChannelCollection.class, "ecal_channels").getCachedData();

// Run the superclass method.
super.detectorChanged(detector);
}
Expand All @@ -57,23 +112,23 @@ protected Long getID(RawTrackerHit hit) {
}

@Override
protected double getGainConditions(long channelID) {
return findChannel(channelID).getGain().getGain();
protected double getGainConditions(long cellID) {
return findChannel(cellID).getGain().getGain();
}

@Override
protected double getNoiseConditions(long channelID) {
return findChannel(channelID).getCalibration().getNoise();
}

@Override
protected double getPedestalConditions(long channelID) {
return findChannel(channelID).getCalibration().getPedestal();
}
protected double getPedestalConditions(long cellID) {
return findChannel(cellID).getCalibration().getPedestal();

}

@Override
protected double getTimeShiftConditions(long channelID) {
return findChannel(channelID).getTimeShift().getTimeShift();
protected double getTimeShiftConditions(long cellID) {
return findChannel(cellID).getTimeShift().getTimeShift();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hps.digi;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -21,6 +23,10 @@

import org.hps.conditions.hodoscope.HodoscopeConditions;

import org.hps.record.daqconfig2019.ConfigurationManager2019;
import org.hps.record.daqconfig2019.DAQConfig2019;
import org.hps.record.daqconfig2019.FADCConfigHodo2019;

/**
* Class <code>HodoscopeDigitizationWithPulserDataMergingReadoutDriver</code> is an
* implementation of the {@link
Expand All @@ -32,6 +38,13 @@
* @author Tongtong Cao <caot@jlab.org>
*/
public class HodoscopeDigitizationWithPulserDataMergingReadoutDriver extends DigitizationWithPulserDataMergingReadoutDriver<Hodoscope_v1> {
// The DAQ configuration manager for FADC parameters.
private FADCConfigHodo2019 config = new FADCConfigHodo2019();
private boolean configStat = false; // Indicates if DAQ configuration is loaded

// The number of nanoseconds in a clock-cycle (sample).
private static final int nsPerSample = 4;

/** Stores the set of all channel IDs for the hodoscope. */
private Set<Long> channelIDSet = new HashSet<Long>();
/** Maps hodoscope channels to the gain for that channel. */
Expand All @@ -42,7 +55,10 @@ public class HodoscopeDigitizationWithPulserDataMergingReadoutDriver extends Dig
private Map<Long, HodoscopeCalibration> channelToCalibrationsMap = new HashMap<Long, HodoscopeCalibration>();
/** Factor for gain conversion from self-define-unit/ADC to MeV/ADC. */
private double factorGainConversion = 0.000833333;

/** Gain scaling factor for raw energy (self-defined unit) of FADC hits.
* In DAQ configuration, gains are scaled by the gain scaling factor for two-hole tiles.
* Such gains from DAQ configuration should be divided by the factor.
*/

private HodoscopeConditions hodoConditions = null;

Expand All @@ -63,6 +79,41 @@ public HodoscopeDigitizationWithPulserDataMergingReadoutDriver() {
setPhotoelectronsPerMeV(10.0);
}

/**
* Sets whether or not the DAQ configuration is applied into the driver
* the EvIO data stream or whether to read the configuration from data files.
*
* @param state - <code>true</code> indicates that the DAQ configuration is
* applied into the readout system, and <code>false</code> that it
* is not applied into the readout system.
*/
public void setDaqConfigurationAppliedintoReadout(boolean state) {
// If the DAQ configuration should be read, attach a listener
// to track when it updates.
if (state) {
ConfigurationManager2019.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the DAQ configuration.
DAQConfig2019 daq = ConfigurationManager2019.getInstance();

// Load the DAQ settings from the configuration manager.
numSamplesAfter = daq.getHodoFADCConfig().getNSA() / nsPerSample;
numSamplesBefore = daq.getHodoFADCConfig().getNSB() / nsPerSample;
readoutWindow = daq.getHodoFADCConfig().getWindowWidth() / nsPerSample;
pulserDataWindow = readoutWindow;

// Get the FADC configuration.
config = daq.getHodoFADCConfig();
configStat = true;
integrationThreshold = config.getThreshold((int)10);
}
});
}

}


@Override
public void detectorChanged(Detector detector) {
// Get a copy of the calorimeter conditions for the detector.
Expand Down Expand Up @@ -104,11 +155,12 @@ protected double getNoiseConditions(long channelID) {
}

@Override
protected double getPedestalConditions(long channelID) {
if(channelToCalibrationsMap.containsKey(Long.valueOf(channelID))) {
protected double getPedestalConditions(long channelID) {
if (channelToCalibrationsMap.containsKey(Long.valueOf(channelID))) {
return channelToCalibrationsMap.get(Long.valueOf(channelID)).getPedestal();
} else {
throw new IllegalArgumentException("No pedestal conditions exist for hodoscope channel ID \"" + channelID + "\".");
throw new IllegalArgumentException(
"No pedestal conditions exist for hodoscope channel ID \"" + channelID + "\".");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ protected double getNoiseConditions(long cellID) {

@Override
protected double getPedestalConditions(long cellID) {
if(configStat == true) return config.getPedestal(geoMap.findGeometric(cellID));
else return findChannel(cellID).getCalibration().getPedestal();
return findChannel(cellID).getCalibration().getPedestal();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,13 @@ protected double getNoiseConditions(long channelID) {

@Override
protected double getPedestalConditions(long channelID) {
if(configStat == true) return config.getPedestal((int)channelID);
else {
if (channelToCalibrationsMap.containsKey(Long.valueOf(channelID))) {
return channelToCalibrationsMap.get(Long.valueOf(channelID)).getPedestal();
} else {
throw new IllegalArgumentException(
"No pedestal conditions exist for hodoscope channel ID \"" + channelID + "\".");
}
if (channelToCalibrationsMap.containsKey(Long.valueOf(channelID))) {
return channelToCalibrationsMap.get(Long.valueOf(channelID)).getPedestal();
} else {
throw new IllegalArgumentException(
"No pedestal conditions exist for hodoscope channel ID \"" + channelID + "\".");
}
}
}

@Override
protected double getTimeShiftConditions(long channelID) {
Expand Down
Loading