Commit 6dda2684 authored by fpipper's avatar fpipper
Browse files

Include comments

parent 50a32f24
......@@ -186,36 +186,31 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
// If no DUT clusters then continue to the next track
if(clusters == NULL)
continue;
/*
// Correlation plot
for(int itCluster=0;itCluster<clusters->size();itCluster++){
// Get the cluster pointer
Cluster* cluster = (*clusters)[itCluster];
// Check if the cluster is close in time
// if( abs(cluster->timestamp() - track->timestamp()) > timingCutInt )
continue;
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
// 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.));
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.));
}
for(int itCluster = 0; itCluster < clusters->size(); itCluster++) {
// Get the cluster pointer
Cluster* cluster = (*clusters)[itCluster];
// Check if the cluster is close in time
// if( abs(cluster->timestamp() - track->timestamp()) > timingCutInt )
continue;
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
// 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.));
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.));
}
}
*/
// Loop over all DUT clusters
bool associated = false;
......
......@@ -3,7 +3,7 @@ CORRYVRECKAN_ALGORITHM(ALGORITHM_NAME)
# Add source files to library
CORRYVRECKAN_ALGORITHM_SOURCES(${ALGORITHM_NAME}
ImproveTimestamp.cpp
ImproveReferenceTimestamp.cpp
# ADD SOURCE FILES HERE...
)
......
#include "ImproveTimestamp.h"
#include "ImproveReferenceTimestamp.h"
#include "objects/SpidrSignal.h"
using namespace corryvreckan;
using namespace std;
ImproveTimestamp::ImproveTimestamp(Configuration config, std::vector<Detector*> detectors)
ImproveReferenceTimestamp::ImproveReferenceTimestamp(Configuration config, std::vector<Detector*> detectors)
: 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_stop = m_config.get<bool>("allowOutoftimeEvents", true);
}
void ImproveTimestamp::initialise() {
void ImproveReferenceTimestamp::initialise() {
// Initialise member variables
m_eventNumber = 0;
}
StatusCode ImproveTimestamp::run(Clipboard* clipboard) {
StatusCode ImproveReferenceTimestamp::run(Clipboard* clipboard) {
// Recieved triggers
std::vector<long long int> trigger_times;
// Get trigger signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get("W0013_G02", "SpidrSignals");
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(m_source, "SpidrSignals");
if(spidrData != NULL) {
// Loop over all signals registered
int nSignals = spidrData->size();
......@@ -47,27 +49,30 @@ StatusCode ImproveTimestamp::run(Clipboard* clipboard) {
long long int improved_time = track->timestamp();
// Use trigger timestamp
if(m_method == 0) {
// Find trigger timestamp clostest in time
long long int diff = 999999999999999;
int imin = -1;
if(trigger_times.size() > 0) {
for(int i = 0; i < trigger_times.size(); i++) {
LOG(DEBUG) << " track: " << track->timestamp() << " trigger: " << trigger_times.at(i)
<< " diff: " << abs((int)(trigger_times.at(i) - track->timestamp()))
<< " diff stored cycles: " << diff
<< " diff stored secs: " << (double)(diff) / (4096. * 40000000.);
if(abs((int)(trigger_times.at(i) - track->timestamp())) < diff) {
imin = i;
diff = abs((int)(trigger_times.at(i) - track->timestamp()));
}
long long int diff = std::numeric_limits<long long int>::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) {
improved_time = trigger_time;
diff = abs((long long int)(trigger_time - track->timestamp()));
}
improved_time = trigger_times.at(imin);
// trigger latency is 175 ns, still missing
}
// if(m_stop == false) {
// if(diff > 5e-7) {
// return NoData;
// }
// }
// trigger latency is ~175 ns, still missing
}
if(m_method == 1) {
// Use average track timestamp
else if(m_method == 1) {
int nhits = 0;
long long int avg_track_time = 0;
for(auto& cluster : track->clusters()) {
......@@ -93,7 +98,7 @@ StatusCode ImproveTimestamp::run(Clipboard* clipboard) {
return Success;
}
void ImproveTimestamp::finalise() {
void ImproveReferenceTimestamp::finalise() {
LOG(DEBUG) << "Analysed " << m_eventNumber << " events";
}
#ifndef ImproveTimestamp_H
#define ImproveTimestamp_H 1
#ifndef ImproveReferenceTimestamp_H
#define ImproveReferenceTimestamp_H 1
#include <cmath>
#include <iostream>
......@@ -12,12 +12,12 @@
#include "objects/Track.h"
namespace corryvreckan {
class ImproveTimestamp : public Algorithm {
class ImproveReferenceTimestamp : public Algorithm {
public:
// Constructors and destructors
ImproveTimestamp(Configuration config, std::vector<Detector*> detectors);
~ImproveTimestamp() {}
ImproveReferenceTimestamp(Configuration config, std::vector<Detector*> detectors);
~ImproveReferenceTimestamp() {}
// Functions
void initialise();
......@@ -33,6 +33,8 @@ namespace corryvreckan {
// Member variables
int m_eventNumber;
int m_method;
bool m_stop;
std::string m_source;
};
} // namespace corryvreckan
#endif // ImproveTimestamp_H
#endif // ImproveReferenceTimestamp_H
......@@ -3,17 +3,21 @@
**Status**: Work in progress
#### Description
Improves the existing track timestamp (earliest hit on reference plane) by either the trigger timestamp (method 0) or the average track timestamp (method 1).
Improves the existing reference timestamp (earliest hit on reference plane) by either the trigger timestamp (method 0) or the average track timestamp (method 1). For method 0 to work, a trigger timestamp has to be saved as SPIDR signal during data taking.
#### Parameters
* `m_method`: Determines which method to use. Trigger timestamp is 0, average track timestamp is 1. Default value is `1`.
* `m_source`: Determines which detector plane carries the trigger signals. Only relevant for method 0. Default value is `"W0013_G02"`.
* `m_stop`: Determines whether to allow out of time trigger timestamps or not. Only relevant for method 0. Default value is `true`.
#### Plots produced
#### Usage
```toml
[ImproveTimestamp]
improvementMethod = 1
[ImproveReferenceTimestamp]
improvementMethod = 0
signalSource = "W0013_G02"
allowOutoftimeEvents = false;
```
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`.
Supports Markdown
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