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

Iss1053 -- add "no spacing" capability to MC readout #1057

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ public class SvtDigitizationWithPulserDataMergingReadoutDriver extends ReadoutDr

// readout period time offset in ns
private double readoutOffset = 0.0;
private double readoutLatency = 280.0;
private double readoutLatency = 248.0;
private double pileupCutoff = 300.0;
private String readout = "TrackerHits";
private double timeOffset = 30.0;
private double triggerOffset = 256.0;
private boolean noPileup = false;
private boolean addNoise = true;

Expand Down Expand Up @@ -195,6 +196,16 @@ public void setReadoutLatency(double readoutLatency) {
this.readoutLatency = readoutLatency;
}

/**
* Set offset of SVT and trigger;
* this should be 0 for no-spacing
* and 256 for the spaced MC
* @param offset - the trigger offset to use
*/
public void setTriggerOffset(double offset) {
this.triggerOffset = offset;
}

/**
* Sets whether to use manually defined timing conditions, or if
* they should be loaded from the conditions database.
Expand Down Expand Up @@ -263,7 +274,7 @@ public void detectorChanged(Detector detector) {
if(useTimingConditions) {
SvtTimingConstants timingConstants = DatabaseConditionsManager.getInstance().getCachedConditions(SvtTimingConstants.SvtTimingConstantsCollection.class, "svt_timing_constants").getCachedData().get(0);
readoutOffset = 4 * (timingConstants.getOffsetPhase() + 3);
readoutLatency = 248.0 + timingConstants.getOffsetTime();
readoutLatency = readoutLatency + timingConstants.getOffsetTime();
}
}

Expand Down Expand Up @@ -292,6 +303,8 @@ public void process(EventHeader event) {
if(pulserHitQueues[channel] == null) {
pulserHitQueues[channel] = new PriorityQueue<StripHit>();
}
if(debug)
System.out.println(this.getClass().getName()+":: adding pulser-data strip hit for channel = "+channel+" at time = "+pulserHit.time);
pulserHitQueues[channel].add(pulserHit);
}

Expand All @@ -306,7 +319,10 @@ public void process(EventHeader event) {
if(hitQueues[channel] == null) {
hitQueues[channel] = new PriorityQueue<StripHit>();
}
hitQueues[channel].add(stripHit);
if(debug)
System.out.println(this.getClass().getName()+":: adding simulated strip hit for channel = "+channel+" at time = "+stripHit.time);

hitQueues[channel].add(stripHit);
}

// Hits older than a certain time frame should no longer
Expand Down Expand Up @@ -628,9 +644,15 @@ protected Collection<TriggeredLCIOData<?>> getOnTriggerData(double triggerTime)
List<SimTrackerHit> truthHits = new ArrayList<SimTrackerHit>();
List<LCRelation> trueHitRelations = new ArrayList<LCRelation>();
// Calculate time of first sample
double firstSample = Math.floor(((triggerTime + 256) - readoutLatency - readoutOffset) / HPSSVTConstants.SAMPLING_INTERVAL)
double firstSample = Math.floor(((triggerTime + triggerOffset) - readoutLatency - readoutOffset) / HPSSVTConstants.SAMPLING_INTERVAL)
* HPSSVTConstants.SAMPLING_INTERVAL + readoutOffset;

if(debug){
System.out.println(this.getClass().getName()+":: trigger time = "+triggerTime+
"; trigger offset = "+triggerOffset+"; readout latency = "+readoutLatency+
"; readout offset = "+readoutOffset);

System.out.println(this.getClass().getName()+":: svt first sample time for trigger = "+firstSample);
}
List<StripHit> processedHits = new ArrayList<StripHit>();

for(SiSensor sensor : sensors) {
Expand Down Expand Up @@ -693,11 +715,19 @@ protected Collection<TriggeredLCIOData<?>> getOnTriggerData(double triggerTime)
// across all size samples.
StringBuffer signalBuffer = new StringBuffer("\t\t\t\tSample Pulse :: [");
for(int sampleN = 0; sampleN < 6; sampleN++) {
//add the time offset to this.
// double sampleTime = firstSample + sampleN * HPSSVTConstants.SAMPLING_INTERVAL-timeOffset;
double sampleTime = firstSample + sampleN * HPSSVTConstants.SAMPLING_INTERVAL;
shape.setParameters(channel, (HpsSiSensor) sensor);
double signalAtTime = hit.amplitude * shape.getAmplitudePeakNorm(sampleTime - hit.time);
totalContrib += signalAtTime;

totalContrib += signalAtTime;
signal[sampleN] += signalAtTime;
if(debug){
System.out.println(this.getClass().getName()+":: making pulse: sample time = "
+sampleTime+"; hit time = "+hit.time);
System.out.println(this.getClass().getName()+":: signal from pulse @ time() = "+signalAtTime+"; total ADC = "+signal[sampleN]);
}
meanNoise += ((HpsSiSensor) sensor).getNoise(channel, sampleN);

signalBuffer.append(signalAtTime + " (" + sampleTime + ")");
Expand Down Expand Up @@ -736,6 +766,8 @@ protected Collection<TriggeredLCIOData<?>> getOnTriggerData(double triggerTime)
// be passed through to readout.
if(readoutCuts(hit)) {
// Add the hit to the readout hits collection.
if(debug)
System.out.println(this.getClass().getName()+":: adding svt hit to triggered event");
hits.add(hit);
// Associate the truth hits with the raw hit and
// add them to the truth hits collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public abstract class RawConverterReadoutDriver extends ReadoutDriver {
* conditions database should be skipped when producing hits.
*/
protected boolean skipBadChannels = false;


private double checkAheadTime = 4.0;

protected RawConverterReadoutDriver(String defaultInputCollectionName, String defaultOutputCollectionName) {
inputCollectionName = defaultInputCollectionName;
outputCollectionName = defaultOutputCollectionName;
Expand All @@ -71,14 +73,20 @@ public final void detectorChanged(Detector detector) {
public final void process(EventHeader event) {
// Check the data management driver to determine whether the
// input collection is available or not.
if(!ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + 4.0)) {
if(doNoSpacing)
localTime=ReadoutDataManager.getCurrentTime(); // just overwrite local time on every event
if(!doNoSpacing&&!ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + checkAheadTime)) {
if(debug)System.out.println("Skipping RawConverterReadout because collection = "+inputCollectionName+" doesn't exist at "+(localTime+ checkAheadTime));
return;
}

// Get all of the raw hits in the current clock-cycle.
Collection<RawCalorimeterHit> rawHits = ReadoutDataManager.getData(localTime, localTime + 4.0, inputCollectionName, RawCalorimeterHit.class);
Collection<RawCalorimeterHit> rawHits = ReadoutDataManager.getData(localTime, localTime + checkAheadTime, inputCollectionName, RawCalorimeterHit.class);

// Increment the local time.

if(debug)System.out.println(this.getClass().getName()+":: collection = "+inputCollectionName+" has "+rawHits.size()+" found between time = "+localTime+" and "+(localTime+checkAheadTime));

// Increment the local time.
localTime += 4.0;

// Pass the raw hits to the raw converter to obtain proper
Expand All @@ -96,11 +104,11 @@ public final void process(EventHeader event) {
if(skipBadChannels && isBadChannel(newHit.getCellID())) {
continue;
}
if(debug)System.out.println(this.getClass().getName()+":: made newHit with time = "+newHit.getTime());
// Add the new hit.
newHits.add(newHit);
}
if(debug)System.out.println(this.getClass().getName()+":: outputting collection = "+outputCollectionName+" with size = "+newHits.size());
// Add the calorimeter hit collection to the data manager.
ReadoutDataManager.addData(outputCollectionName, newHits, CalorimeterHit.class);
}
Expand Down Expand Up @@ -246,4 +254,12 @@ public void setSkipBadChannels(boolean state) {
public void setReadoutWindow(int window) {
getConverter().setWindowSamples(window);
}
/**
* Sets the amount of time (+ ns) to check for possible
* seed clusters.
* @param value - time in ns
*/
public void setCheckAheadTime(double value) {
checkAheadTime = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ public class GTPClusterReadoutDriver extends ReadoutDriver {
* This is calculated automatically.
*/
private double localTimeDisplacement = 0;

/**
* The amount of time (ns) to check ahead/behind
* for ecal clusters.
* This can be large for no-spacing running (like 192)
* but should be 4.0 for spaced running
*/

private double checkAheadTime = 4.0;

// ==============================================================
// ==== Driver Parameters =======================================
Expand Down Expand Up @@ -185,19 +194,23 @@ public void detectorChanged(Detector etector) {

@Override
public void process(EventHeader event) {
// Check the data management driver to determine whether the

if(doNoSpacing)
localTime=ReadoutDataManager.getCurrentTime(); // just overwrite local time on every event
// Check the data management driver to determine whether the
// input collection is available or not.
if(!ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + temporalWindow + 4.0)) {
return;
if(!doNoSpacing&&!ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + temporalWindow + checkAheadTime)) {
if(debug)System.out.println("Skipping GTP Readout with because collection doesn't exist at "+(localTime+temporalWindow + checkAheadTime));
return;
}

// Get the hits that occur during the present clock-cycle, as
// well as the hits that occur in the verification window
// both before and after the current clock-cycle.
// TODO: Simplify this?
Collection<CalorimeterHit> seedCandidates = ReadoutDataManager.getData(localTime, localTime + 4.0, inputCollectionName, CalorimeterHit.class);
Collection<CalorimeterHit> seedCandidates = ReadoutDataManager.getData(localTime, localTime + checkAheadTime, inputCollectionName, CalorimeterHit.class);
Collection<CalorimeterHit> foreHits = ReadoutDataManager.getData(localTime - temporalWindow, localTime, inputCollectionName, CalorimeterHit.class);
Collection<CalorimeterHit> postHits = ReadoutDataManager.getData(localTime + 4.0, localTime + temporalWindow + 4.0, inputCollectionName, CalorimeterHit.class);
Collection<CalorimeterHit> postHits = ReadoutDataManager.getData(localTime + checkAheadTime, localTime + temporalWindow + checkAheadTime, inputCollectionName, CalorimeterHit.class);

// Increment the local time.
localTime += 4.0;
Expand All @@ -208,16 +221,22 @@ public void process(EventHeader event) {
allHits.addAll(foreHits);
allHits.addAll(seedCandidates);
allHits.addAll(postHits);

if(debug){
System.out.println(this.getClass().getName()+":: "+inputCollectionName+":: local time = "+localTime+
" temporalWindow = "+temporalWindow+" checkAheadTime = "+checkAheadTime);
System.out.println(this.getClass().getName()+":: "+inputCollectionName+":: current time = "+ReadoutDataManager.getCurrentTime()+" number of seeds = "+seedCandidates.size()+"; all hits = "+allHits.size());
}
// Store newly created clusters.
List<Cluster> gtpClusters = new ArrayList<Cluster>();

// Iterate over all seed hit candidates.
seedLoop:
for(CalorimeterHit seedCandidate : seedCandidates) {
if(debug)System.out.println(this.getClass().getName()+":: looping through seeds: seed energy = "+seedCandidate.getRawEnergy());
// A seed candidate must meet a minimum energy cut to be
// considered for clustering.
if(seedCandidate.getRawEnergy() < seedEnergyThreshold) {
if(debug)System.out.println(this.getClass().getName()+":: failed seed energy: threshold = "+seedEnergyThreshold);
continue seedLoop;
}

Expand Down Expand Up @@ -254,7 +273,8 @@ public void process(EventHeader event) {
// cluster should be formed.
gtpClusters.add(createBasicCluster(seedCandidate, clusterHits));
}


if(debug)System.out.println(this.getClass().getName()+":: adding gtpClusters to data manager size = "+gtpClusters.size());
// Pass the clusters to the data management driver.
ReadoutDataManager.addData(outputCollectionName, gtpClusters, Cluster.class);
}
Expand Down Expand Up @@ -336,7 +356,10 @@ protected Collection<TriggeredLCIOData<?>> getOnTriggerData(double triggerTime)

@Override
protected double getTimeDisplacement() {
return localTimeDisplacement;
if(doNoSpacing)
return 0;
else
return localTimeDisplacement;
}

@Override
Expand Down Expand Up @@ -384,5 +407,13 @@ public void setClusterWindow(int value) {
*/
public void setSeedEnergyThreshold(double value) {
seedEnergyThreshold = value;
}
}
/**
* Sets the amount of time (+/-ns) to check for possible
* seed clusters.
* @param value - time in ns
*/
public void setCheckAheadTime(double value) {
checkAheadTime = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ public void actionPerformed(ActionEvent e) {
}

@Override
public void process(EventHeader event) {

public void process(EventHeader event) {
if(doNoSpacing)
localTime=ReadoutDataManager.getCurrentTime(); // just overwrite local time on every event

// Check the data management driver to determine whether the
// input collection is available or not.
if (!ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + localTimeDisplacement)) {
if (!doNoSpacing && !ReadoutDataManager.checkCollectionStatus(inputCollectionName, localTime + localTimeDisplacement)) {
if(debug)System.out.println(this.getClass().getName()+":: "+inputCollectionName+" doesn't exist at time = "+(localTime + localTimeDisplacement));
return;
}

Expand All @@ -162,7 +165,7 @@ public void process(EventHeader event) {
Collection<CalorimeterHit> fadcHits = ReadoutDataManager.getData(
localTime - (persistentTime - timeEarlierThanEcal), localTime + timeEarlierThanEcal + 4.0,
inputCollectionName, CalorimeterHit.class);

if(debug)System.out.println(this.getClass().getName()+":: number of fadcHits found = "+fadcHits.size());
// Increment the local time.
localTime += 4.0;

Expand Down Expand Up @@ -279,6 +282,7 @@ public void process(EventHeader event) {
}

// At leaset there is a hodo tilt/cluster hit in any layer, then the pattern list is added into data manager
if(flag == true && debug) if(debug)System.out.println(this.getClass().getName()+":: outputting "+outputCollectionName+" with size = "+hodoPatterns.size());
if(flag == true) ReadoutDataManager.addData(outputCollectionName, hodoPatterns, HodoscopePattern.class);
}

Expand Down Expand Up @@ -345,7 +349,10 @@ private void populateChannelCollections() {

@Override
protected double getTimeDisplacement() {
return localTimeDisplacement;
if(doNoSpacing)
return 0;
else
return localTimeDisplacement;
}

@Override
Expand Down Expand Up @@ -421,4 +428,5 @@ public void setTimeEarlierThanEcal(double timeEarlierThanEcal) {
public void setGainFactor(double gainFactor) {
this.gainFactor = gainFactor;
}

}
Loading
Loading