Commit c4d43463 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'units' into 'master'

Consistently use units

See merge request simonspa/corryvreckan!16
parents 7e8a7ba2 02f7441e
Pipeline #259288 passed with stages
in 8 minutes and 5 seconds
......@@ -12,7 +12,6 @@ ATLASpixEventLoader::ATLASpixEventLoader(Configuration config, std::vector<Detec
m_inputDirectory = m_config.get<std::string>("inputDirectory");
m_calibrationFile = m_config.get<std::string>("calibrationFile");
m_eventLength = m_config.get<double>("eventLength", 0.000010);
m_startTime - m_config.get<double>("startTime", 0.);
m_toaMode = m_config.get<bool>("toaMode", false);
......@@ -158,6 +157,9 @@ StatusCode ATLASpixEventLoader::run(Clipboard* clipboard) {
toa -= corr * (4096. * 40000000.);
}
// Convert TOA to nanoseconds:
toa /= (4096. * 0.04);
Pixel* pixel = new Pixel(detectorID, row, col, cal_tot, toa);
pixels->push_back(pixel);
hHitMap->Fill(col, row);
......
......@@ -7,9 +7,10 @@ using namespace std;
BasicTracking::BasicTracking(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) {
// Default values for cuts
timingCut = m_config.get<double>("timingCut", 200. / 1000000000.); // 200 ns
spatialCut = m_config.get<double>("spatialCut", 0.2); // 200 um
timingCut = m_config.get<double>("timingCut", Units::convert(200, "ns"));
spatialCut = m_config.get<double>("spatialCut", Units::convert(0.2, "mm"));
spatialCut_DUT = m_config.get<double>("spatialCutDUT", Units::convert(0.2, "mm"));
minHitsOnTrack = m_config.get<int>("minHitsOnTrack", 6);
excludeDUT = m_config.get<bool>("excludeDUT", true);
......@@ -131,7 +132,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard) {
// Get all neighbours within 200 ns
LOG(DEBUG) << "Searching for neighbouring cluster on " << detectorID;
LOG(DEBUG) << "- cluster time is " << cluster->timestamp();
LOG(DEBUG) << "- cluster time is " << Units::display(cluster->timestamp(), {"ns", "us", "s"});
Cluster* closestCluster = NULL;
double closestClusterDistance = spatialCut;
Clusters neighbours = trees[detectorID]->getAllClustersInTimeWindow(cluster, timingCut);
......
......@@ -85,8 +85,8 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
string name;
istringstream header(data);
header >> name >> timeInt;
shutterStartTime = (double)timeInt / (40000000.);
LOG(TRACE) << "Shutter rise time: " << shutterStartTime;
shutterStartTime = (double)timeInt / (0.04);
LOG(TRACE) << "Shutter rise time: " << Units::display(shutterStartTime, {"ns", "us", "s"});
continue;
}
if(data.find("SHT_FALL") != string::npos) {
......@@ -95,14 +95,13 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
string name;
istringstream header(data);
header >> name >> timeInt;
shutterStopTime = (double)timeInt / (40000000.);
LOG(TRACE) << "Shutter fall time: " << shutterStopTime;
shutterStopTime = (double)timeInt / (0.04);
LOG(TRACE) << "Shutter fall time: " << Units::display(shutterStopTime, {"ns", "us", "s"});
continue;
}
// Otherwise load data
int row, col, counter, tot(0);
long int time;
LOG(TRACE) << "Pixel data: " << data;
istringstream pixelData(data);
pixelData >> col >> row >> counter >> tot;
......
......@@ -122,9 +122,9 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
hPixelToT->Fill(tot);
}
// Now set the event time so that the Timepix3 data is loaded correctly
shutterStartTime = shutterStartTimeInt * 25. / 1000000000.;
shutterStopTime = shutterStopTimeInt * 25. / 1000000000.;
// Now set the event time so that the Timepix3 data is loaded correctly, unit is nanoseconds
shutterStartTime = shutterStartTimeInt / 0.04;
shutterStopTime = shutterStopTimeInt / 0.04;
clipboard->put_persistent("currentTime", shutterStartTime);
m_config.set<double>("eventLength", (shutterStopTime - shutterStartTime));
......
......@@ -9,8 +9,8 @@ using namespace std;
ClicpixAnalysis::ClicpixAnalysis(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) {
m_associationCut = m_config.get<double>("associationCut", 0.05); // 100 um
m_proximityCut = m_config.get<double>("proximityCut", 0.0005); // 125 um
m_associationCut = m_config.get<double>("associationCut", Units::convert(100, "um"));
m_proximityCut = m_config.get<double>("proximityCut", Units::convert(125, "um"));
timepix3Telescope = m_config.get<bool>("timepix3Telescope", false);
}
......
......@@ -12,6 +12,7 @@ DUTAnalysis::DUTAnalysis(Configuration config, std::vector<Detector*> detectors)
m_digitalPowerPulsing = m_config.get<bool>("digitalPowerPulsing", false);
m_DUT = m_config.get<std::string>("DUT");
m_useMCtruth = m_config.get<bool>("useMCtruth", false);
timingCut = m_config.get<double>("timingCut", Units::convert(200, "ns"));
}
void DUTAnalysis::initialise() {
......@@ -22,16 +23,17 @@ 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", 2500, 0, 100000);
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, -1000, +1000);
hTrackCorrelationX = new TH1F("hTrackCorrelationX", "hTrackCorrelationX", 4000, -10., 10.);
hTrackCorrelationY = new TH1F("hTrackCorrelationY", "hTrackCorrelationY", 4000, -10., 10.);
hTrackCorrelationTime = new TH1F("hTrackCorrelationTime", "hTrackCorrelationTime", 2000000, -0.005, 0.005);
hTrackCorrelationTime = new TH1F("hTrackCorrelationTime", "hTrackCorrelationTime", 2000000, -5000, 5000);
clusterToTVersusTime = new TH2F("clusterToTVersusTime", "clusterToTVersusTime", 300000, 0., 300., 200, 0, 1000);
residualsTimeVsTime = new TH2F("residualsTimeVsTime", "residualsTimeVsTime", 20000, 0, 200, 400, -0.0005, 0.0005);
residualsTimeVsTime = new TH2F("residualsTimeVsTime", "residualsTimeVsTime", 20000, 0, 200, 1000, -1000, +1000);
residualsTimeVsSignal = new TH2F("residualsTimeVsSignal", "residualsTimeVsSignal", 20000, 0, 100000, 1000, -1000, +1000);
tracksVersusPowerOnTime = new TH1F("tracksVersusPowerOnTime", "tracksVersusPowerOnTime", 1200000, -0.01, 0.11);
associatedTracksVersusPowerOnTime =
......@@ -57,16 +59,12 @@ void DUTAnalysis::initialise() {
StatusCode DUTAnalysis::run(Clipboard* clipboard) {
LOG(TRACE) << "Power on time: " << m_powerOnTime / (4096. * 40000000.);
LOG(TRACE) << "Power off time: " << m_powerOffTime / (4096. * 40000000.);
LOG(TRACE) << "Power on time: " << Units::display(m_powerOnTime, {"ns", "us", "s"});
LOG(TRACE) << "Power off time: " << Units::display(m_powerOffTime, {"ns", "us", "s"});
// if(clipboard->get_persistent("currentTime") < 13.5)
// return Success;
// Timing cut for association
double timingCut = 200. / 1000000000.; // 200 ns
long long int timingCutInt = (timingCut * 4096. * 40000000.);
// Spatial cut
double spatialCut = 0.2; // 200 um
......@@ -98,18 +96,20 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
if(signal->type() == "shutterOpen") {
// There may be multiple power on/off in 1 time window. At the moment,
// take earliest if within 1ms
if(fabs(double(signal->timestamp() - m_shutterOpenTime) / (4096. * 40000000.)) < 0.001)
if(abs(Units::convert(signal->timestamp() - m_shutterOpenTime, "s")) < 0.001) {
continue;
}
m_shutterOpenTime = signal->timestamp();
LOG(TRACE) << "Shutter opened at " << double(m_shutterOpenTime) / (4096. * 40000000.);
LOG(TRACE) << "Shutter opened at " << Units::display(m_shutterOpenTime, {"ns", "us", "s"});
}
if(signal->type() == "shutterClosed") {
// There may be multiple power on/off in 1 time window. At the moment,
// take earliest if within 1ms
if(fabs(double(signal->timestamp() - m_shutterCloseTime) / (4096. * 40000000.)) < 0.001)
if(abs(Units::convert(signal->timestamp() - m_shutterCloseTime, "s")) < 0.001) {
continue;
}
m_shutterCloseTime = signal->timestamp();
LOG(TRACE) << "Shutter closed at " << double(m_shutterCloseTime) / (4096. * 40000000.);
LOG(TRACE) << "Shutter closed at " << Units::display(m_shutterCloseTime, {"ns", "us", "s"});
}
}
}
......@@ -155,14 +155,14 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
continue;
}
tracksVersusTime->Fill((double)track->timestamp() / (4096. * 40000000.));
tracksVersusTime->Fill(Units::convert(track->timestamp(), "s"));
timeSincePowerOn = (double)(track->timestamp() - m_shutterOpenTime) / (4096. * 40000000.);
if(timeSincePowerOn > 0. && timeSincePowerOn < 0.0002) {
LOG(TRACE) << "Track at time " << double(track->timestamp()) / (4096. * 40000000.)
<< " has time shutter open of " << timeSincePowerOn;
LOG(TRACE) << "Shutter open time is " << double(m_shutterOpenTime) / (4096. * 40000000.)
<< ", shutter close time is " << double(m_shutterCloseTime) / (4096. * 40000000.);
timeSincePowerOn = track->timestamp() - m_shutterOpenTime;
if(timeSincePowerOn > 0. && timeSincePowerOn < Units::convert(200, "us")) {
LOG(TRACE) << "Track at time " << Units::display(track->timestamp(), {"ns", "us", "s"})
<< " has time shutter open of " << Units::display(timeSincePowerOn, {"ns", "us", "s"});
LOG(TRACE) << "Shutter open time is " << Units::display(m_shutterOpenTime, {"ns", "us", "s"})
<< ", shutter close time is " << Units::display(m_shutterCloseTime, {"ns", "us", "s"});
}
// Check time since power on (if power pulsing).
......@@ -172,15 +172,15 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
(m_shutterOpenTime != 0 &&
((m_shutterCloseTime > m_shutterOpenTime && m_shutterCloseTime - track->timestamp() > 0) ||
(m_shutterOpenTime > m_shutterCloseTime && track->timestamp() - m_shutterOpenTime >= 0)))) {
timeSincePowerOn = (double)(track->timestamp() - m_shutterOpenTime) / (4096. * 40000000.);
timeSincePowerOn = track->timestamp() - m_shutterOpenTime;
tracksVersusPowerOnTime->Fill(timeSincePowerOn);
// if(timeSincePowerOn < (0.0002)){
// LOG(TRACE) <<"Track at time "<<clipboard->get_persistent("currentTime")<<" has
// time shutter open of "<<timeSincePowerOn;
// LOG(TRACE) <<"Shutter open time is
// "<<double(m_shutterOpenTime)/(4096.*40000000.)<<", shutter close
// time is "<<double(m_shutterCloseTime)/(4096.*40000000.);
// }
if(timeSincePowerOn < 200000) {
LOG(TRACE) << "Track at time " << Units::display(clipboard->get_persistent("currentTime"), {"ns", "us", "s"})
<< " has time shutter open of " << Units::display(timeSincePowerOn, {"ns", "us", "s"});
LOG(TRACE) << "Shutter open time is " << Units::display(m_shutterOpenTime, {"ns", "us", "s"})
<< ", shutter close time is " << Units::display(m_shutterCloseTime, {"ns", "us", "s"});
}
}
// If no DUT clusters then continue to the next track
......@@ -194,8 +194,8 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
Cluster* cluster = (*clusters)[itCluster];
// Check if the cluster is close in time
// if( abs(cluster->timestamp() - track->timestamp()) > timingCutInt )
continue;
// if( abs(cluster->timestamp() - track->timestamp()) > timingCut)
// continue;
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
......@@ -203,12 +203,13 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
// Fill the correlation plot
hTrackCorrelationX->Fill(intercept.X() - cluster->globalX());
hTrackCorrelationY->Fill(intercept.Y() - cluster->globalY());
hTrackCorrelationTime->Fill((double)(track->timestamp() - cluster->timestamp()) / (4096. * 40000000.));
hTrackCorrelationTime->Fill(Units::convert(track->timestamp() - cluster->timestamp(), "ns"));
if(fabs(intercept.X() - cluster->globalX()) < 0.1 && fabs(intercept.Y() - cluster->globalY()) < 0.1) {
residualsTime->Fill((double)(track->timestamp() - cluster->timestamp()) / (4096. * 40000000.));
residualsTimeVsTime->Fill((double)track->timestamp() / (4096. * 40000000.),
(double)(track->timestamp() - cluster->timestamp()) / (4096. * 40000000.));
residualsTime->Fill(Units::convert(track->timestamp() - cluster->timestamp(), "ns"));
residualsTimeVsTime->Fill(Units::convert(track->timestamp(), "ns"),
Units::convert(track->timestamp() - cluster->timestamp(), "ns"));
residualsTimeVsSignal->Fill(cluster->tot(), Units::convert(track->timestamp() - cluster->timestamp(), "ns"));
}
}
......@@ -218,10 +219,10 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
// Fill the tot histograms on the first run
if(first_track == 0)
clusterToTVersusTime->Fill((double)cluster->timestamp() / (4096. * 40000000.), cluster->tot());
clusterToTVersusTime->Fill(Units::convert(cluster->timestamp(), "ns"), cluster->tot());
// Check if the cluster is close in time
if(!m_digitalPowerPulsing && abs(cluster->timestamp() - track->timestamp()) > timingCutInt)
if(!m_digitalPowerPulsing && abs(cluster->timestamp() - track->timestamp()) > timingCut)
continue;
// Check distance between track and cluster
......@@ -236,7 +237,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
// We now have an associated cluster! Fill plots
associated = true;
LOG(TRACE) << "Found associated cluster";
associatedTracksVersusTime->Fill((double)track->timestamp() / (4096. * 40000000.));
associatedTracksVersusTime->Fill(Units::convert(track->timestamp(), "s"));
residualsX->Fill(xdistance);
residualsY->Fill(ydistance);
clusterTotAssociated->Fill(cluster->tot());
......
......@@ -33,6 +33,7 @@ namespace corryvreckan {
TH1F* residualsTime;
TH2F* clusterToTVersusTime;
TH2F* residualsTimeVsTime;
TH2F* residualsTimeVsSignal;
TH1F* residualsXMCtruth;
......@@ -52,6 +53,7 @@ namespace corryvreckan {
long long int m_shutterOpenTime;
long long int m_shutterCloseTime;
bool m_digitalPowerPulsing;
double timingCut;
};
} // namespace corryvreckan
#endif // DUTAnalysis_H
......@@ -10,8 +10,9 @@ Using the appropriate parameter settings in the configuration file, plots using
#### Parameters
* `DUT`: Name of the DUT plane.
* `useMCtruth`: Boolean to set if Monte-Carlo truth information is available and should be used. Default value is `false`.
* `digitalPowerPusling`: Boolean to set if power pulsing was used and that this information should be used. Default value is `false`.
* `digitalPowerPusling`: Boolean to set if power pulsing was used and that this information should be used. Default value is `false`.
* `timingCut`: maximum time difference between clusters to be taken into account. Defaults to `200ns`.
*
#### Plots produced
* Tracks vs time
* Associated tracks vs time
......
......@@ -140,8 +140,8 @@ StatusCode DataOutput::run(Clipboard* clipboard) {
v_pixelToT.push_back(pixel->m_adc);
// ToA
LOG(DEBUG) << "Gets pixel timestamp = " << pixel->m_timestamp;
v_pixelToA.push_back(pixel->m_timestamp);
LOG(DEBUG) << "Gets pixel timestamp = " << pixel->timestamp();
v_pixelToA.push_back(pixel->timestamp());
}
v_clusterNumPixels.push_back(numPixels);
}
......
......@@ -11,7 +11,7 @@ FileReader::FileReader(Configuration config, std::vector<Detector*> detectors)
m_readClusters = m_config.get<bool>("readClusters", false);
m_readTracks = m_config.get<bool>("readTracks", false);
m_fileName = m_config.get<std::string>("fileName", "outputTuples.root");
m_timeWindow = m_config.get<double>("timeWindow", 1.);
m_timeWindow = m_config.get<double>("timeWindow", Units::convert(1., "s"));
m_readMCParticles = m_config.get<bool>("readMCParticles", false);
m_currentTime = 0.;
......
......@@ -12,7 +12,7 @@ This algorithm reads in an input file containing trees with data previously writ
* `readTracks`: Boolean to choose if track objects are to be read in. Default value is `false`.
* `readMCParticles`: Boolean to choose if Monte-Carlo particle objects are to be read in. Default value is `false`.
* `fileName`: Name of the file from which data will be read. Default value is `ouyputTuples.root`.
* `timeWindow`: Data with time lower than this value will be read in. Default value is `1`.
* `timeWindow`: Data with time lower than this value will be read in. Default value is `1s`.
* `DUT`: Name of the DUT plane.
#### Plots produced
......
......@@ -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() {
......@@ -18,7 +19,7 @@ void ImproveReferenceTimestamp::initialise() {
StatusCode ImproveReferenceTimestamp::run(Clipboard* clipboard) {
// Recieved triggers
std::vector<long long int> trigger_times;
std::vector<double> trigger_times;
// Get trigger signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(m_source, "SpidrSignals");
......@@ -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();
......@@ -46,36 +47,35 @@ StatusCode ImproveReferenceTimestamp::run(Clipboard* clipboard) {
// Loop over all tracks
for(auto& track : (*tracks)) {
long long int improved_time = track->timestamp();
double improved_time = track->timestamp();
// Use trigger timestamp
if(m_method == 0) {
// Find trigger timestamp clostest in time
long long int diff = std::numeric_limits<long long int>::max();
// 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: " << abs((long long int)(trigger_time - track->timestamp()))
<< " diff stored cycles: " << diff
<< " diff stored secs: " << (double)(diff) / (4096. * 40000000.);
if(abs((long long int)(trigger_time - track->timestamp())) < diff) {
<< " diff: " << Units::display(abs(trigger_time - track->timestamp()), {"ns", "us", "s"})
<< " diff stored: " << Units::display(diff, {"ns", "us", "s"});
if(abs(trigger_time - track->timestamp()) < diff) {
improved_time = trigger_time;
diff = abs((long long int)(trigger_time - track->timestamp()));
diff = abs(trigger_time - track->timestamp());
}
}
// trigger latency is ~175 ns, still missing
}
// Use average track timestamp
else if(m_method == 1) {
int nhits = 0;
long long int avg_track_time = 0;
double avg_track_time = 0;
for(auto& cluster : track->clusters()) {
avg_track_time += cluster->timestamp();
nhits++;
}
avg_track_time = round(avg_track_time / nhits);
LOG(DEBUG) << setprecision(12) << "Reference track time " << (double)(track->timestamp()) / (4096. * 40000000.);
LOG(DEBUG) << setprecision(12) << "Average track time " << (double)(avg_track_time) / (4096. * 40000000.);
LOG(DEBUG) << setprecision(12) << "Reference track time "
<< Units::display(track->timestamp(), {"ns", "us", "s"});
LOG(DEBUG) << setprecision(12) << "Average track time " << Units::display(avg_track_time, {"ns", "us", "s"});
}
// Set improved reference 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`.
......@@ -6,8 +6,9 @@ using namespace std;
Prealignment::Prealignment(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) {
LOG(INFO) << "Starting prealignment of detectors";
max_correlation_rms = m_config.get<double>("max_correlation_rms", 6.0);
max_correlation_rms = m_config.get<double>("max_correlation_rms", Units::convert(6.0, "mm"));
damping_factor = m_config.get<double>("damping_factor", 1.0);
timingCut = m_config.get<double>("timingCut", Units::convert(100, "ns"));
LOG(DEBUG) << "Setting max_correlation_rms to : " << max_correlation_rms;
LOG(DEBUG) << "Setting damping_factor to : " << damping_factor;
}
......@@ -74,15 +75,13 @@ StatusCode Prealignment::run(Clipboard* clipboard) {
for(auto& cluster : (*clusters)) {
// Loop over reference plane pixels to make correlation plots
for(auto& refCluster : (*referenceClusters)) {
double timeDifference = (double)(refCluster->timestamp() - cluster->timestamp()) / (4096. * 40000000.);
double timeDifference = refCluster->timestamp() - cluster->timestamp();
// Correlation plots
if(abs(timeDifference) < 0.000001) {
if(abs(timeDifference) < timingCut) {
correlationX[detector->name()]->Fill(refCluster->globalX() - cluster->globalX());
correlationX2D[detector->name()]->Fill(cluster->globalX(), refCluster->globalX());
correlationX2Dlocal[detector->name()]->Fill(cluster->column(), refCluster->column());
}
if(abs(timeDifference) < 0.000001) {
correlationY[detector->name()]->Fill(refCluster->globalY() - cluster->globalY());
correlationY2D[detector->name()]->Fill(cluster->globalY(), refCluster->globalY());
correlationY2Dlocal[detector->name()]->Fill(cluster->row(), refCluster->row());
......@@ -100,13 +99,16 @@ void Prealignment::finalise() {
double rmsY = correlationY[detector->name()]->GetRMS();
if(rmsX > max_correlation_rms or rmsY > max_correlation_rms) {
LOG(ERROR) << "Detector " << detector->name() << ": RMS is too wide for prealignment shifts";
LOG(ERROR) << "Detector " << detector->name() << ": RMS X = " << rmsX << " , RMS Y = " << rmsY;
LOG(ERROR) << "Detector " << detector->name() << ": RMS X = " << Units::display(rmsX, {"mm", "um"})
<< " , RMS Y = " << Units::display(rmsY, {"mm", "um"});
}
if(detector->name() != m_config.get<std::string>("reference")) {
double mean_X = correlationX[detector->name()]->GetMean();
double mean_Y = correlationY[detector->name()]->GetMean();
LOG(INFO) << "Detector " << detector->name() << ": x = " << mean_X << " , y = " << mean_Y;
LOG(INFO) << "Move in x by = " << mean_X * damping_factor << " , and in y by = " << mean_Y * damping_factor;
LOG(INFO) << "Detector " << detector->name() << ": x = " << Units::display(mean_X, {"mm", "um"})
<< " , y = " << Units::display(mean_Y, {"mm", "um"});
LOG(INFO) << "Move in x by = " << Units::display(mean_X * damping_factor, {"mm", "um"})
<< " , and in y by = " << Units::display(mean_Y * damping_factor, {"mm", "um"});
double x = detector->displacementX();
double y = detector->displacementY();
detector->displacementX(x + damping_factor * mean_X);
......
......@@ -33,6 +33,7 @@ namespace corryvreckan {
// Parameters which can be set by user
double max_correlation_rms;
double damping_factor;
double timingCut;
};
} // namespace corryvreckan
#endif // PREALIGNMENT_H
......@@ -12,7 +12,8 @@ The required translational shifts in X and Y are calculated for each detector as
#### Parameters
* `reference`: Name of the detector used as the alignment reference plane. All other telescope planes are aligned with respect to the reference plane.
* `damping_factor`: A factor to change the percentage of the calcuated shift applied to each detector. Default value is `1`.
* `max_correlation_rms`: The maximum rms of the 1D correlation histograms allowed for the shifts to be applied. This factor should be tuned for each run, and is combat the effect of flat distributions. Default value is `6`.
* `max_correlation_rms`: The maximum RMS of the 1D correlation histograms allowed for the shifts to be applied. This factor should be tuned for each run, and is combat the effect of flat distributions. Default value is `6mm`.
* `timingCut`: maximum time difference between clusters to be taken into account. Defaults to `100ns`.
### Plots Created
For each detector the following plots are produced:
......
......@@ -153,7 +153,7 @@ void SpatialClustering::calculateClusterCentre(Detector* detector, Cluster* clus
// Get the pixels on this cluster
Pixels* pixels = cluster->pixels();
string detectorID = (*pixels)[0]->m_detectorID;
string detectorID = (*pixels)[0]->detectorID();
LOG(DEBUG) << "- cluster has " << (*pixels).size() << " pixels";
// Loop over all pixels
......
......@@ -6,7 +6,7 @@ using namespace std;
SpatialTracking::SpatialTracking(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) {
spatialCut = m_config.get<double>("spatialCut", 0.2); // 200 um
spatialCut = m_config.get<double>("spatialCut", Units::convert(200, "um"));
minHitsOnTrack = m_config.get<int>("minHitsOnTrack", 6);
excludeDUT = m_config.get<bool>("excludeDUT", true);
}
......
......@@ -9,6 +9,7 @@ This algorithm collects `pixel` and `cluster` objects from the clipboard and cre
#### Parameters
* `makeCorrelatons`: Boolean to change if correlation plots should be outputted. Default value is `false`.
* `reference`: Name of the plane to be used as the reference for the correlation plots.
* `timingCut`: maximum time difference between clusters to be taken into account. Defaults to `100ns`.
#### Plots produced
For each device the following plots are produced:
......
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