Commit fe7fa074 authored by Jens Kroeger's avatar Jens Kroeger Committed by Simon Spannagel
Browse files

Tracking4D: requireDetector is now an empty string by default, i.e. it doesn't...

Tracking4D: requireDetector is now an empty string by default, i.e. it doesn't need to be set by the user if not required
parent f9c6384d
......@@ -16,7 +16,6 @@ AlignmentMillepede::AlignmentMillepede(Configuration config, std::vector<std::sh
: Module(std::move(config), std::move(detectors)) {
m_excludeDUT = m_config.get<bool>("exclude_dut", false);
m_excludeTLU = m_config.get<bool>("exclude_tlu", true);
m_numberOfTracksForAlignment = m_config.get<size_t>("number_of_tracks", 20000);
m_dofs = m_config.getArray<bool>("dofs", {});
m_nIterations = m_config.get<size_t>("iterations", 5);
......@@ -104,8 +103,8 @@ void AlignmentMillepede::finalise() {
if(det->isDUT() && m_excludeDUT) {
nPlanes--;
}
if(det->type() == "TLU" && m_excludeTLU) {
LOG(DEBUG) << "Excluding TLU.";
if(det->isAuxiliary()) {
LOG(INFO) << "Excluding auxiliary detector " << det->name();
nPlanes--;
}
}
......
......@@ -155,8 +155,6 @@ namespace corryvreckan {
bool m_fix_all;
/// It can be also reasonable to include the DUT in the alignemnt
bool m_excludeDUT;
/// Flag to exclude the TLU from the alignment as it has not pixel hits anyway
bool m_excludeTLU;
};
} // namespace corryvreckan
......
......@@ -13,8 +13,6 @@ The modules stops if the convergence, i.e. the absolute sum of all corrections o
### Parameters
* `exclude_dut` : Exclude the DUT from the alignment procedure. Default value
is `false`.
* `exclude_tlu` : Exclude the TLU from the alignment procedure. Default value
is `true`.
* `number_of_tracks`: Number of tracks used in the alignment method chosen. Default value is `20000`.
* `iterations`: Number of times the chosen alignment method is to be iterated. Default value is `3`.
* `dofs`: Degrees of freedom to be aligned. This parameter should be given as vector of six boolean values for the parameters "Translation X", "Translation Y", "Translation Z", "Rotation X", "Rotation Y" and "Rotation Z". The default setting is an alignment of all parameters except for "Translation Z", i.e. `dofs = true, true, false, true, true, true`.
......
......@@ -308,6 +308,9 @@ StatusCode AnalysisEfficiency::run(std::shared_ptr<Clipboard> clipboard) {
return StatusCode::Success;
}
for(auto& pixel : (*pixels)) {
if(pixel->column() > m_detector->nPixels().X() || pixel->row() > m_detector->nPixels().Y()) {
continue;
}
prev_hit_ts.at(static_cast<size_t>(pixel->column())).at(static_cast<size_t>(pixel->row())) = pixel->timestamp();
}
......
......@@ -195,7 +195,7 @@ void EventLoaderATLASpix::initialise() {
-10,
200);
std::string histTitle = "hPixelTriggerTimeResidualOverTime_0;time [us];trigger_ts - pixel_ts [us];# entries";
std::string histTitle = "hPixelTriggerTimeResidualOverTime_0;time [s];pixel_ts - trigger_ts [us];# entries";
hPixelTriggerTimeResidualOverTime =
new TH2D("hPixelTriggerTimeResidualOverTime_0", histTitle.c_str(), 3e3, 0, 3e3, 1e4, -50, 50);
......@@ -269,7 +269,7 @@ StatusCode EventLoaderATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
// check if histogram exists already, if not: create it
if(hPixelTriggerTimeResidual.find(iTrigger) == hPixelTriggerTimeResidual.end()) {
std::string histName = "hPixelTriggerTimeResidual_" + to_string(iTrigger);
std::string histTitle = histName + ";trigger_ts - pixel_ts [us];# entries";
std::string histTitle = histName + ";pixel_ts - trigger_ts [us];# entries";
hPixelTriggerTimeResidual[iTrigger] = new TH1D(histName.c_str(), histTitle.c_str(), 2e5, -100, 100);
}
// use iTrigger, not trigger ID (=trigger.first) (which is unique and continuously incrementing over the runtime)
......
......@@ -16,9 +16,9 @@ EventLoaderEUDAQ2::EventLoaderEUDAQ2(Configuration config, std::shared_ptr<Detec
: Module(std::move(config), detector), m_detector(detector) {
m_filename = m_config.getPath("file_name", true);
get_time_residuals = m_config.get<bool>("get_time_residuals", false);
m_get_time_residuals = m_config.get<bool>("get_time_residuals", false);
m_skip_time = m_config.get("skip_time", 0.);
adjust_event_times = m_config.getMatrix<std::string>("adjust_event_times", {});
m_adjust_event_times = m_config.getMatrix<std::string>("adjust_event_times", {});
// Forward all settings to EUDAQ
// WARNING: the EUDAQ Configuration class is not very flexible and e.g. booleans have to be passed as 1 and 0.
......@@ -80,7 +80,7 @@ void EventLoaderEUDAQ2::initialise() {
hTriggersPerEvent = new TH1D("hTriggersPerEvent", "hTriggersPerEvent;triggers per event;entries", 20, 0, 20);
if(get_time_residuals) {
if(m_get_time_residuals) {
hPixelTimeEventBeginResidual =
new TH1F("hPixelTimeEventBeginResidual",
"hPixelTimeEventBeginResidual;pixel_ts - clipboard event begin [us]; # entries",
......@@ -103,7 +103,7 @@ void EventLoaderEUDAQ2::initialise() {
2.1e4,
-10,
200);
std::string histTitle = "hPixelTriggerTimeResidualOverTime_0;time [us];trigger_ts - pixel_ts [us];# entries";
std::string histTitle = "hPixelTriggerTimeResidualOverTime_0;time [us];pixel_ts - trigger_ts [us];# entries";
hPixelTriggerTimeResidualOverTime =
new TH2D("hPixelTriggerTimeResidualOverTime_0", histTitle.c_str(), 3e3, 0, 3e3, 1e4, -50, 50);
}
......@@ -117,8 +117,8 @@ void EventLoaderEUDAQ2::initialise() {
throw InvalidValueError(m_config, "file_path", "Parsing error!");
}
// Check if all elements of adjust_event_times have a valid size of 3, if not throw error.
for(auto& shift_times : adjust_event_times) {
// Check if all elements of m_adjust_event_times have a valid size of 3, if not throw error.
for(auto& shift_times : m_adjust_event_times) {
if(shift_times.size() != 3) {
throw InvalidValueError(
m_config,
......@@ -197,8 +197,8 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
<< ", event_end = " << Units::display(event_end, "us");
// If adjustment of event start/end is required:
const auto it = std::find_if(adjust_event_times.begin(),
adjust_event_times.end(),
const auto it = std::find_if(m_adjust_event_times.begin(),
m_adjust_event_times.end(),
[evt](const std::vector<std::string>& x) { return x.front() == evt->GetDescription(); });
// Skip if later start is requested:
......@@ -215,7 +215,7 @@ EventLoaderEUDAQ2::EventPosition EventLoaderEUDAQ2::is_within_event(std::shared_
LOG(DEBUG) << "Defining Corryvreckan event: " << Units::display(event_start, {"us", "ns"}) << " - "
<< Units::display(event_end, {"us", "ns"}) << ", length "
<< Units::display(event_end - event_start, {"us", "ns"});
if(it != adjust_event_times.end()) {
if(it != m_adjust_event_times.end()) {
shift_start = corryvreckan::from_string<double>(it->at(1));
shift_end = corryvreckan::from_string<double>(it->at(2));
event_start += shift_start;
......@@ -368,7 +368,7 @@ StatusCode EventLoaderEUDAQ2::run(std::shared_ptr<Clipboard> clipboard) {
}
// Loop over pixels for plotting
if(get_time_residuals) {
if(m_get_time_residuals) {
for(auto& pixel : (*pixels)) {
hPixelTimeEventBeginResidual->Fill(
static_cast<double>(Units::convert(pixel->timestamp() - event->start(), "us")));
......@@ -383,7 +383,7 @@ StatusCode EventLoaderEUDAQ2::run(std::shared_ptr<Clipboard> clipboard) {
// check if histogram exists already, if not: create it
if(hPixelTriggerTimeResidual.find(iTrigger) == hPixelTriggerTimeResidual.end()) {
std::string histName = "hPixelTriggerTimeResidual_" + to_string(iTrigger);
std::string histTitle = histName + ";trigger_ts - pixel_ts [us];# entries";
std::string histTitle = histName + ";pixel_ts - trigger_ts [us];# entries";
hPixelTriggerTimeResidual[iTrigger] = new TH1D(histName.c_str(), histTitle.c_str(), 2e5, -100, 100);
}
// use iTrigger, not trigger ID (=trigger.first) (which is unique and continuously incrementing over the
......
......@@ -81,9 +81,9 @@ namespace corryvreckan {
std::shared_ptr<Detector> m_detector;
std::string m_filename{};
bool get_time_residuals;
bool m_get_time_residuals;
double m_skip_time{};
Matrix<std::string> adjust_event_times;
Matrix<std::string> m_adjust_event_times;
// EUDAQ file reader instance to retrieve data from
eudaq::FileReaderUP reader_;
......
......@@ -13,9 +13,8 @@ Clusters from the first plane in Z (named the seed plane) are related to cluster
* `spatial_cut`: Maximum spatial distance in the XY plane allowed between clusters for association for the telescope planes. Default value is `0.2mm`.
* `min_hits_on_track`: Minium number of associated clusters needed to create a track, equivalent to the minimum number of planes required for each track. Default value is `6`.
* `exclude_dut`: Boolean to choose if the DUT plane is included in the track finding. Default value is `true`.
* `require_detector`: Name of detector which is required to have a cluster on the track. If empty, no detector is required. Default is empty.
* `use_avg_cluster_timestamp`: Boolean to choose how track timestamp is determined. If `true`, the average timestamp of all clusters on the track will be used. If `false` a detector can be defined using the `detector_to_set_track_timestamp`. Default is `true`.
* `detector_to_set_track_timestamp`: If `use_avg_cluster_timestamp = false`, a detector can be defined to provide the track timestamp. This detector also needs to be chosen set as `required_detector`.
* `require_detectors`: Names of detectors which are required to have a cluster on the track. If a track does not have a cluster from all detectors listed here, it is rejected. If empty, no detector is required. Default is empty.
* `timestamp_from`: Defines the detector which provides the track timestamp. This detector also needs to be set as `required_detector`. If empty, the average timestamp of all clusters on the track will be used. Empty by default.
### Plots produced
* Track chi^2 histogram
......@@ -43,4 +42,5 @@ min_hits_on_track = 4
spatial_cut = 300um
timing_cut = 200ns
exclude_dut = true
require_detectors = "ExampleDetector_0", "ExampleDetector_1"
```
......@@ -14,9 +14,8 @@ Tracking4D::Tracking4D(Configuration config, std::vector<std::shared_ptr<Detecto
spatialCut = m_config.get<double>("spatial_cut", Units::get<double>(200, "um"));
minHitsOnTrack = m_config.get<size_t>("min_hits_on_track", 6);
excludeDUT = m_config.get<bool>("exclude_dut", true);
requireDetector = m_config.get<std::string>("require_detector", "");
useAvgClusterTimestamp = m_config.get<bool>("use_avg_cluster_timestamp", true);
detectorToSetTrackTimestamp = m_config.get<std::string>("detector_to_set_track_timestamp", "Timepix3_0");
requireDetectors = m_config.getArray<std::string>("require_detectors", {""});
timestampFrom = m_config.get<std::string>("timestamp_from", {});
}
void Tracking4D::initialise() {
......@@ -195,9 +194,17 @@ StatusCode Tracking4D::run(std::shared_ptr<Clipboard> clipboard) {
track->addCluster(closestCluster);
} //*/
// check if track has required detector:
if(!requireDetector.empty() && !track->hasDetector(requireDetector)) {
LOG(DEBUG) << "No cluster from required detector " << requireDetector << " on the track.";
// check if track has required detector(s):
auto foundRequiredDetector = [this](Track* t) {
for(auto& requireDet : requireDetectors) {
if(!requireDet.empty() && !t->hasDetector(requireDet)) {
LOG(DEBUG) << "No cluster from required detector " << requireDet << " on the track.";
return false;
}
}
return true;
};
if(!foundRequiredDetector(track)) {
delete track;
continue;
}
......@@ -242,7 +249,7 @@ StatusCode Tracking4D::run(std::shared_ptr<Clipboard> clipboard) {
residualsYwidth3[detectorID]->Fill(intercept.Y() - trackCluster->global().y());
}
if(useAvgClusterTimestamp) {
if(timestampFrom.empty()) {
// Improve the track timestamp by taking the average of all planes
double avg_track_time = 0;
for(auto& trackCluster : trackClusters) {
......@@ -253,10 +260,10 @@ StatusCode Tracking4D::run(std::shared_ptr<Clipboard> clipboard) {
LOG(DEBUG) << "Using average cluster timestamp of "
<< Units::display(avg_track_time / static_cast<double>(track->nClusters()), "us")
<< " as track timestamp.";
} else if(!detectorToSetTrackTimestamp.empty() && track->hasDetector(detectorToSetTrackTimestamp)) {
} else if(track->hasDetector(timestampFrom)) {
// use timestamp of required detector:
double track_timestamp = track->getClusterFromDetector(detectorToSetTrackTimestamp)->timestamp();
LOG(DEBUG) << "Found cluster for detector " << detectorToSetTrackTimestamp << ", adding timestamp "
double track_timestamp = track->getClusterFromDetector(timestampFrom)->timestamp();
LOG(DEBUG) << "Found cluster for detector " << timestampFrom << ", adding timestamp "
<< Units::display(track_timestamp, "us") << " to track.";
track->setTimestamp(track_timestamp);
} else {
......
......@@ -46,9 +46,8 @@ namespace corryvreckan {
double spatialCut;
size_t minHitsOnTrack;
bool excludeDUT;
std::string requireDetector;
bool useAvgClusterTimestamp;
std::string detectorToSetTrackTimestamp;
std::vector<std::string> requireDetectors;
std::string timestampFrom;
};
} // namespace corryvreckan
#endif // TRACKING4D_H
......@@ -147,7 +147,7 @@ bool Track::isAssociated(Cluster* cluster) const {
return false;
}
bool Track::hasDetector(std::string detectorID) {
bool Track::hasDetector(std::string detectorID) const {
auto it = find_if(m_trackClusters.begin(), m_trackClusters.end(), [&detectorID](Cluster* cluster) {
return cluster->getDetectorID() == detectorID;
});
......
......@@ -71,7 +71,7 @@ namespace corryvreckan {
* @param detectorID DetectorID of the detector to check
* @return True if detector has a cluster on this track, false if not.
*/
bool hasDetector(std::string detectorID);
bool hasDetector(std::string detectorID) const;
/**
* @brief Get a track cluster from a given detector
......
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