Commit 8d057535 authored by fpipper's avatar fpipper
Browse files

Fix trigger timestamp in ImproveReferenceTimestamp EventLoader plus some small...

Fix trigger timestamp in ImproveReferenceTimestamp EventLoader plus some small changes to DUTAnalysis (adding one histogram and adapting histogram ranges to work with and without calibration)
parent 377b8451
Pipeline #258177 passed with stages
in 4 minutes and 56 seconds
......@@ -23,9 +23,9 @@ void DUTAnalysis::initialise() {
residualsX = new TH1F("residualsX", "residualsX", 400, -0.2, 0.2);
residualsY = new TH1F("residualsY", "residualsY", 400, -0.2, 0.2);
clusterTotAssociated = new TH1F("clusterTotAssociated", "clusterTotAssociated", 250, 0, 10000);
clusterTotAssociated = new TH1F("clusterTotAssociated", "clusterTotAssociated", 20000, 0, 100000);
clusterSizeAssociated = new TH1F("clusterSizeAssociated", "clusterSizeAssociated", 30, 0, 30);
residualsTime = new TH1F("residualsTime", "residualsTime", 2000, -0.000001, 0.000001);
residualsTime = new TH1F("residualsTime", "residualsTime", 20000, -0.000001, 0.000001);
hTrackCorrelationX = new TH1F("hTrackCorrelationX", "hTrackCorrelationX", 4000, -10., 10.);
hTrackCorrelationY = new TH1F("hTrackCorrelationY", "hTrackCorrelationY", 4000, -10., 10.);
......@@ -33,6 +33,8 @@ void DUTAnalysis::initialise() {
clusterToTVersusTime = new TH2F("clusterToTVersusTime", "clusterToTVersusTime", 300000, 0., 300., 200, 0, 1000);
residualsTimeVsTime = new TH2F("residualsTimeVsTime", "residualsTimeVsTime", 20000, 0, 200, 400, -0.0005, 0.0005);
residualsTimeVsSignal =
new TH2F("residualsTimeVsSignal", "residualsTimeVsSignal", 20000, 0, 100000, 400, -0.000001, 0.000001);
tracksVersusPowerOnTime = new TH1F("tracksVersusPowerOnTime", "tracksVersusPowerOnTime", 1200000, -0.01, 0.11);
associatedTracksVersusPowerOnTime =
......@@ -193,8 +195,8 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
Cluster* cluster = (*clusters)[itCluster];
// Check if the cluster is close in time
// if( abs(cluster->timestamp() - track->timestamp()) > timingCut)
continue;
// if( abs(cluster->timestamp() - track->timestamp()) > timingCut)
// continue;
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
......@@ -208,6 +210,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
residualsTime->Fill(Units::convert(track->timestamp() - cluster->timestamp(), "s"));
residualsTimeVsTime->Fill(Units::convert(track->timestamp(), "s"),
Units::convert(track->timestamp() - cluster->timestamp(), "s"));
residualsTimeVsSignal->Fill(cluster->tot(), Units::convert(track->timestamp() - cluster->timestamp(), "s"));
}
}
......
......@@ -33,6 +33,7 @@ namespace corryvreckan {
TH1F* residualsTime;
TH2F* clusterToTVersusTime;
TH2F* residualsTimeVsTime;
TH2F* residualsTimeVsSignal;
TH1F* residualsXMCtruth;
......
......@@ -8,6 +8,7 @@ ImproveReferenceTimestamp::ImproveReferenceTimestamp(Configuration config, std::
: Algorithm(std::move(config), std::move(detectors)) {
m_method = m_config.get<int>("improvementMethod", 1);
m_source = m_config.get<std::string>("signalSource", "W0013_G02");
m_triggerLatency = m_config.get<double>("triggerLatency", Units::convert(0, "ns"));
}
void ImproveReferenceTimestamp::initialise() {
......@@ -29,7 +30,7 @@ StatusCode ImproveReferenceTimestamp::run(Clipboard* clipboard) {
// Get the signal
SpidrSignal* signal = (*spidrData)[iSig];
if(signal->type() == "trigger") {
trigger_times.push_back(signal->timestamp());
trigger_times.push_back(signal->timestamp() - m_triggerLatency);
}
}
LOG(DEBUG) << "Number of triggers found: " << trigger_times.size();
......@@ -50,18 +51,17 @@ StatusCode ImproveReferenceTimestamp::run(Clipboard* clipboard) {
// Use trigger timestamp
if(m_method == 0) {
// Find trigger timestamp clostest in time
// Find trigger timestamp closest in time
double diff = std::numeric_limits<double>::max();
for(auto& trigger_time : trigger_times) {
LOG(DEBUG) << " track: " << track->timestamp() << " trigger: " << trigger_time
<< " diff: " << Units::display(abs(trigger_time - track->timestamp()), {"ns", "us", "s"})
<< " diff stored cycles: " << diff * (4096. * 40000000.);
<< " diff stored: " << Units::display(diff, {"ns", "us", "s"});
if(abs(trigger_time - track->timestamp()) < diff) {
improved_time = trigger_time;
diff = abs(trigger_time - track->timestamp());
}
}
// trigger latency is ~175 ns, still missing
}
// Use average track timestamp
......
......@@ -35,6 +35,7 @@ namespace corryvreckan {
int m_method;
bool m_stop;
std::string m_source;
double m_triggerLatency;
};
} // namespace corryvreckan
#endif // ImproveReferenceTimestamp_H
......@@ -8,6 +8,7 @@ Replaces the existing reference timestamp (earliest hit on reference plane) by e
#### Parameters
* `improvementMethod`: Determines which method to use. Trigger timestamp is 0, average track timestamp is 1. Default value is `1`.
* `signalSource`: Determines which detector plane carries the trigger signals. Only relevant for method 0. Default value is `"W0013_G02"`.
* `triggerLatency`: Adds a latency to the trigger timestamp and shifts time histogrammes back to zero. Default value is `0`.
#### Plots produced
No plots are produced.
......@@ -17,5 +18,6 @@ No plots are produced.
[ImproveReferenceTimestamp]
improvementMethod = 0
signalSource = "W0013_G02"
triggerLatency = 20ns
```
Parameters to be used in multiple algorithms can also be defined globally at the top of the configuration file. This is highly encouraged for parameters such as `DUT` and `reference`.
......@@ -530,8 +530,7 @@ bool Timepix3EventLoader::loadData(Clipboard* clipboard, Detector* detector, Pix
m_syncTimeTDC[detectorID] = timestamp_raw;
timestamp = timestamp_raw + ((unsigned long long int)(m_TDCoverflowCounter[detectorID]) << 35);
double triggerTime = (timestamp * 25e-9 + stamp * 25e-9 / 12.) / 8; // 320 MHz clock
// triggerTime -= m_triggerLatency * 1e-9;
double triggerTime = (timestamp + stamp / 12.) / (8. * 0.04); // 320 MHz clock
SpidrSignal* triggerSignal = new SpidrSignal("trigger", triggerTime);
spidrData->push_back(triggerSignal);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment