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

Move to new DUT scheme for the rest of the modules

parent 00ac86b0
Pipeline #545112 passed with stages
in 6 minutes and 25 seconds
......@@ -41,6 +41,10 @@ Detector* Module::get_reference() {
Detector* Module::get_dut() {
auto it = find_if(m_detectors.begin(), m_detectors.end(), [](Detector* obj) { return obj->isDUT(); });
if(it == m_detectors.end()) {
return nullptr;
}
return (*it);
}
......
......@@ -142,7 +142,7 @@ namespace corryvreckan {
/**
* @brief Get the device under test
* @return Pointer to the DUT detector
* @return Pointer to the DUT detector. A nullptr is returned if no DUT is found.
* FIXME This should allow retrieval of a vector of DUTs
*/
Detector* get_dut();
......
......@@ -399,7 +399,7 @@ void Alignment::finalise() {
string detectorID = detector->name();
// Do not align the reference plane
if(detector->isReference() || (m_config.has("DUT") && detector->isDUT())) {
if(detector->isReference() || detector->isDUT()) {
continue;
}
......@@ -492,7 +492,7 @@ void Alignment::finalise() {
// Now list the new alignment parameters
for(auto& detector : get_detectors()) {
// Do not align the reference plane
if(detector->isReference() || (m_config.has("DUT") && detector->isDUT())) {
if(detector->isReference() || detector->isDUT()) {
continue;
}
......
......@@ -12,9 +12,7 @@ BasicTracking::BasicTracking(Configuration config, std::vector<Detector*> detect
timingCut = m_config.get<double>("timingCut", Units::convert(200, "ns"));
spatialCut = m_config.get<double>("spatialCut", Units::convert(0.2, "mm"));
minHitsOnTrack = m_config.get<int>("minHitsOnTrack", 6);
// checking if DUT parameter is in the configuration file, if so then check if the the DUT should be excluded, if not
// then set exclude the DUT
excludeDUT = (m_config.has("DUT") ? m_config.get<bool>("excludeDUT", true) : true);
excludeDUT = m_config.get<bool>("excludeDUT", true);
}
void BasicTracking::initialise() {
......@@ -74,7 +72,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard) {
} else {
// Store them
LOG(DEBUG) << "Picked up " << tempClusters->size() << " clusters from " << detectorID;
if(firstDetector && (!m_config.has("DUT") || !detector->isDUT())) {
if(firstDetector && !detector->isDUT()) {
referenceClusters = tempClusters;
seedPlane = detector->name();
LOG(DEBUG) << "Seed plane is " << seedPlane;
......
......@@ -9,8 +9,6 @@ CLICpixEventLoader::CLICpixEventLoader(Configuration config, std::vector<Detecto
}
void CLICpixEventLoader::initialise() {
// Assume that the CLICpix is the DUT (if running this algorithm
detectorID = m_config.get<std::string>("DUT");
// File structure is RunX/CLICpix/RunX.dat
// Take input directory from global parameters
......@@ -50,7 +48,8 @@ void CLICpixEventLoader::initialise() {
StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
// LOG(TRACE) <<"Running"
// Assume that the CLICpix is the DUT (if running this algorithm
auto detector = get_dut();
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
......@@ -109,9 +108,9 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
LOG(TRACE) << "New pixel: " << col << "," << row << " with tot " << tot;
// If this pixel is masked, do not save it
if(get_detector(detectorID)->masked(col, row))
if(detector->masked(col, row))
continue;
Pixel* pixel = new Pixel(detectorID, row, col, tot, 0);
Pixel* pixel = new Pixel(detector->name(), row, col, tot, 0);
pixels->push_back(pixel);
npixels++;
hHitMap->Fill(col, row);
......@@ -126,7 +125,7 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
LOG(TRACE) << "Loaded " << npixels << " pixels";
// Put the data on the clipboard
if(pixels->size() > 0)
clipboard->put(detectorID, "pixels", (Objects*)pixels);
clipboard->put(detector->name(), "pixels", (Objects*)pixels);
// Fill histograms
hPixelsPerFrame->Fill(npixels);
......
......@@ -32,7 +32,6 @@ namespace corryvreckan {
// Member variables
int m_eventNumber;
std::string m_filename;
std::string detectorID;
std::ifstream m_file;
TH2F* hHitMap;
......
......@@ -16,7 +16,7 @@ Clicpix2EventLoader::Clicpix2EventLoader(Configuration config, std::vector<Detec
}
void Clicpix2EventLoader::initialise() {
auto det = get_detector(m_config.get<std::string>("DUT"));
auto det = get_dut();
if(det->type() != "CLICpix2") {
LOG(ERROR) << "DUT not of type CLICpix2";
}
......@@ -154,7 +154,7 @@ void Clicpix2EventLoader::initialise() {
StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = m_config.get<std::string>("DUT");
auto detector = get_dut();
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
......@@ -221,7 +221,7 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
int row = px.first.second;
// If this pixel is masked, do not save it
if(get_detector(detectorID)->masked(col, row)) {
if(detector->masked(col, row)) {
continue;
}
......@@ -247,7 +247,7 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
hPixelToA->Fill(toa);
}
Pixel* pixel = new Pixel(detectorID, row, col, tot, shutterStartTime);
Pixel* pixel = new Pixel(detector->name(), row, col, tot, shutterStartTime);
if(tot == 0 && discardZeroToT) {
hHitMapDiscarded->Fill(col, row);
......@@ -271,7 +271,7 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
// Put the data on the clipboard
if(!pixels->empty()) {
clipboard->put(detectorID, "pixels", (Objects*)pixels);
clipboard->put(detector->name(), "pixels", (Objects*)pixels);
}
// Fill histograms
......
......@@ -24,8 +24,7 @@ void ClicpixAnalysis::initialise() {
// Initialise member variables
m_eventNumber = 0;
m_triggerNumber = 0;
dutID = m_config.get<std::string>("DUT");
auto det = get_detector(dutID);
auto det = get_dut();
m_lostHits = 0.;
int maxcounter = 256;
......@@ -190,18 +189,16 @@ void ClicpixAnalysis::initialise() {
hInterceptClusterSize3 = new TH2F("hInterceptClusterSize3", "hInterceptClusterSize3", 25, 0, 25, 25, 0, 25);
hInterceptClusterSize4 = new TH2F("hInterceptClusterSize4", "hInterceptClusterSize4", 25, 0, 25, 25, 0, 25);
// Get the DUT detector:
auto detector = get_detector(dutID);
m_nBinsX = 32;
m_nBinsY = 32;
hMapClusterSizeAssociated = new TH2F("hMapClusterSizeAssociated",
"hMapClusterSizeAssociated",
m_nBinsX,
0,
detector->nPixelsX(),
det->nPixelsX(),
m_nBinsY,
0,
detector->nPixelsY());
det->nPixelsY());
for(int x = 0; x < m_nBinsX; x++) {
for(int y = 0; y < m_nBinsY; y++) {
......@@ -216,9 +213,10 @@ void ClicpixAnalysis::initialise() {
StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
// Get the clicpix clusters in this event
Clusters* clusters = (Clusters*)clipboard->get(dutID, "clusters");
auto detector = get_dut();
Clusters* clusters = (Clusters*)clipboard->get(detector->name(), "clusters");
if(clusters == NULL) {
LOG(DEBUG) << "No clusters for " << dutID << " on the clipboard";
LOG(DEBUG) << "No clusters for " << detector->name() << " on the clipboard";
return Success;
}
......@@ -253,8 +251,6 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
continue;
}
// Get the DUT detector:
auto detector = get_detector(dutID);
// Get the track intercept with the clicpix plane (global and local
// co-ordinates)
PositionVector3D<Cartesian3D<double>> trackIntercept = detector->getIntercept(track);
......@@ -409,8 +405,8 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
// Get the pixel global position
LOG(TRACE) <<"New pixel, row = "<<(*itPixel)->row()<<", column = "<<(*itPixel)->column();
PositionVector3D<Cartesian3D<double> > pixelPositionLocal =
get_detector(dutID)->getLocalPosition((*itPixel)->row(),(*itPixel)->column()); PositionVector3D<Cartesian3D<double> >
pixelPositionGlobal = *(get_detector(dutID)->m_localToGlobal) * pixelPositionLocal;
detector->getLocalPosition((*itPixel)->row(),(*itPixel)->column()); PositionVector3D<Cartesian3D<double> >
pixelPositionGlobal = *(detector->m_localToGlobal) * pixelPositionLocal;
// Check if it is close to the track
if( fabs( pixelPositionGlobal.X() - trackIntercept.X() ) > m_associationCut ||
......@@ -473,7 +469,7 @@ void ClicpixAnalysis::finalise() {
bool ClicpixAnalysis::checkMasked(double chipInterceptRow, double chipInterceptCol) {
// Get the DUT detector:
auto detector = get_detector(dutID);
auto detector = get_dut();
// Get the pixel row and column number
int rowNumber = ceil(chipInterceptRow);
......@@ -507,7 +503,7 @@ bool ClicpixAnalysis::checkMasked(double chipInterceptRow, double chipInterceptC
// "Close" is defined as the intercept at the clicpix
bool ClicpixAnalysis::checkProximity(Track* track, Tracks* tracks) {
auto detector = get_detector(dutID);
auto detector = get_dut();
// Get the intercept of the interested track at the dut
bool close = false;
PositionVector3D<Cartesian3D<double>> trackIntercept = detector->getIntercept(track);
......@@ -535,7 +531,7 @@ bool ClicpixAnalysis::checkProximity(Track* track, Tracks* tracks) {
void ClicpixAnalysis::fillClusterHistos(Clusters* clusters) {
// Pick up column to generate unique pixel id
int nCols = get_detector(dutID)->nPixelsX();
int nCols = get_dut()->nPixelsX();
Clusters::iterator itc;
// Check if this is a new clicpix frame (each frame may be in several events)
......@@ -580,7 +576,7 @@ void ClicpixAnalysis::fillClusterHistos(Clusters* clusters) {
// track intercept for the pixel to still see charge
void ClicpixAnalysis::fillResponseHistos(double trackInterceptX, double trackInterceptY, Cluster* cluster) {
auto detector = get_detector(dutID);
auto detector = get_dut();
// Loop over pixels in the cluster and show their distance from the track
// intercept
Pixels* pixels = cluster->pixels();
......
......@@ -121,7 +121,6 @@ namespace corryvreckan {
// Member variables
int m_eventNumber;
int m_triggerNumber;
std::string dutID;
std::map<int, double> m_hitPixels;
double m_associationCut;
double m_proximityCut;
......
......@@ -10,7 +10,6 @@ using namespace corryvreckan;
DUTAnalysis::DUTAnalysis(Configuration config, std::vector<Detector*> detectors)
: Module(std::move(config), std::move(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);
chi2ndofCut = m_config.get<double>("chi2ndofCut", 3.);
}
......@@ -68,6 +67,10 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
LOG(TRACE) << "Power on time: " << Units::display(m_powerOnTime, {"ns", "us", "s"});
LOG(TRACE) << "Power off time: " << Units::display(m_powerOffTime, {"ns", "us", "s"});
// Get the DUT detector:
auto detector = get_dut();
auto dutname = detector->name();
// if(clipboard->get_persistent("eventStart") < 13.5)
// return Success;
......@@ -84,7 +87,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
m_shutterCloseTime = 0;
// Now update the power pulsing with any new signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(m_DUT, "SpidrSignals");
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(dutname, "SpidrSignals");
// If there are new signals
if(spidrData != NULL) {
// Loop over all signals registered
......@@ -123,13 +126,13 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
}
// Get the DUT clusters from the clipboard
Clusters* clusters = (Clusters*)clipboard->get(m_DUT, "clusters");
Clusters* clusters = (Clusters*)clipboard->get(dutname, "clusters");
if(clusters == NULL) {
LOG(DEBUG) << "No DUT clusters on the clipboard";
}
// Get the MC particles from the clipboard
MCParticles* mcParticles = (MCParticles*)clipboard->get(m_DUT, "mcparticles");
MCParticles* mcParticles = (MCParticles*)clipboard->get(dutname, "mcparticles");
if(mcParticles == NULL) {
LOG(DEBUG) << "No DUT MC particles on the clipboard";
}
......@@ -143,8 +146,6 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
continue;
}
// Get the DUT detector:
auto detector = get_detector(m_DUT);
// Check if it intercepts the DUT
PositionVector3D<Cartesian3D<double>> globalIntercept = detector->getIntercept(track);
if(!detector->hasIntercept(track, 1.)) {
......
......@@ -52,7 +52,6 @@ namespace corryvreckan {
TH1F* associatedTracksVersusPowerOnTime;
// Member variables
std::string m_DUT;
int m_eventNumber;
int m_nAlignmentClusters;
bool m_useMCtruth;
......
......@@ -32,9 +32,6 @@ DataOutput::DataOutput(Configuration config, std::vector<Detector*> detectors)
void DataOutput::initialise() {
LOG(DEBUG) << "Initialised DataOutput";
// DUT is necessary for this module; checking to see if this is given in the config
m_DUT = m_config.get<std::string>("DUT");
// Create output file and directories
m_outputFile = new TFile(m_fileName.c_str(), "RECREATE");
LOG(DEBUG) << "Made and moved to output file: " << m_fileName;
......@@ -63,7 +60,7 @@ StatusCode DataOutput::run(Clipboard* clipboard) {
eventID++;
// Get the DUT
auto DUT = get_detector(m_DUT);
auto DUT = get_dut();
v_intercepts.clear();
// Clear data vectors before storing the cluster information for
......@@ -167,7 +164,7 @@ StatusCode DataOutput::run(Clipboard* clipboard) {
void DataOutput::finalise() {
LOG(DEBUG) << "Finalise";
// DUT angles for output
auto DUT = get_detector(m_DUT);
auto DUT = get_dut();
auto directory = m_outputFile->mkdir("Directory");
directory->cd();
LOG(STATUS) << filledEvents << " events written to file " << m_fileName;
......
......@@ -51,7 +51,6 @@ namespace corryvreckan {
// Config parameters
std::string m_fileName;
std::string m_treeName;
std::string m_DUT;
};
} // namespace corryvreckan
#endif // DATAOUTPUT_H
......@@ -13,7 +13,7 @@ FileReader::FileReader(Configuration config, std::vector<Detector*> detectors)
m_timeWindow = m_config.get<double>("timeWindow", Units::convert(1., "s"));
m_readMCParticles = m_config.get<bool>("readMCParticles", false);
// checking if DUT parameter is in the configuration file, if so then check if should only output the DUT
m_onlyDUT = (m_config.has("DUT") ? m_config.get<bool>("onlyDUT", false) : false);
m_onlyDUT = m_config.get<bool>("onlyDUT", false);
m_currentTime = 0.;
}
......
......@@ -5,8 +5,8 @@ using namespace std;
FileWriter::FileWriter(Configuration config, std::vector<Detector*> detectors)
: Module(std::move(config), std::move(detectors)) {
// checking if DUT parameter is in the configuration file, if so then check if it is to be the only file written
m_onlyDUT = (m_config.has("DUT") ? m_config.get<bool>("onlyDUT", true) : false);
m_onlyDUT = m_config.get<bool>("onlyDUT", true);
m_writePixels = m_config.get<bool>("writePixels", true);
m_writeClusters = m_config.get<bool>("writeClusters", false);
m_writeTracks = m_config.get<bool>("writeTracks", true);
......
......@@ -151,7 +151,7 @@ void OnlineMonitor::AddPlots(std::string canvas_name, Matrix<std::string> canvas
bool log_scale = (plot.back().find("log") != std::string::npos) ? true : false;
// Replace other placeholders and add histogram
std::string name = std::regex_replace(plot.front(), std::regex("%DUT%"), m_config.get<std::string>("DUT"));
std::string name = std::regex_replace(plot.front(), std::regex("%DUT%"), get_dut()->name());
name = std::regex_replace(name, std::regex("%REFERENCE%"), get_reference()->name());
// Do we have a detector placeholder?
......
......@@ -9,7 +9,7 @@ SpatialTracking::SpatialTracking(Configuration config, std::vector<Detector*> de
spatialCut = m_config.get<double>("spatialCut", Units::convert(200, "um"));
spatialCut_DUT = m_config.get<double>("spatialCutDUT", Units::convert(200, "um"));
minHitsOnTrack = m_config.get<int>("minHitsOnTrack", 6);
excludeDUT = (m_config.has("DUT") ? m_config.get<bool>("excludeDUT", true) : true);
excludeDUT = m_config.get<bool>("excludeDUT", true);
}
/*
......@@ -51,7 +51,7 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
// Container for all clusters, and detectors in tracking
map<string, KDTree*> trees;
vector<string> detectors;
vector<Detector*> detectors;
Clusters* referenceClusters;
Clusters dutClusters;
......@@ -84,14 +84,15 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
KDTree* clusterTree = new KDTree();
clusterTree->buildSpatialTree(*tempClusters);
trees[detectorID] = clusterTree;
detectors.push_back(detectorID);
detectors.push_back(detector);
LOG(DEBUG) << "Picked up " << tempClusters->size() << " clusters on device " << detectorID;
}
}
// If there are no detectors then stop trying to track
if(detectors.size() == 0)
if(detectors.empty()) {
return Success;
}
// Keep a note of which clusters have been used
map<Cluster*, bool> used;
......@@ -116,14 +117,14 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
// the hit from the previous plane along the z axis, and look for
// a neighbour on the new plane. We started on the most upstream
// plane, so first detector is 1 (not 0)
for(auto& detectorID : detectors) {
for(auto& detector : detectors) {
auto detectorID = detector->name();
if(trees.count(detectorID) == 0) {
continue;
}
// Check if the DUT should be excluded and obey:
if(m_config.has("DUT") && excludeDUT && detectorID == m_config.get<std::string>("DUT")) {
if(excludeDUT && detector->isDUT()) {
// Keep all DUT clusters, so we can add them as associated clusters later:
Cluster* dutCluster = trees[detectorID]->getClosestNeighbour(cluster);
dutClusters.push_back(dutCluster);
......@@ -181,9 +182,6 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
}
// Add potential associated clusters from the DUT:
if(!m_config.has("DUT")) {
continue;
}
for(auto& dutcluster : dutClusters) {
// Check distance between track and cluster
......
......@@ -76,7 +76,7 @@ StatusCode TelescopeAnalysis::run(Clipboard* clipboard) {
auto name = detector->name();
// Ignore DUT
if(m_config.has("DUT") && name == m_config.get<std::string>("DUT")) {
if(detector->isDUT()) {
continue;
}
......@@ -102,10 +102,10 @@ StatusCode TelescopeAnalysis::run(Clipboard* clipboard) {
}
// Calculate telescope resolution at DUT
if(!m_config.has("DUT")) {
auto detector = get_dut();
if(detector == nullptr) {
continue;
}
auto detector = get_detector(m_config.get<std::string>("DUT"));
// Get the MC particles from the clipboard
MCParticles* mcParticles = (MCParticles*)clipboard->get(detector->name(), "mcparticles");
......
......@@ -189,12 +189,13 @@ void Timepix3EventLoader::initialise() {
// Calibration
pixelToT_beforecalibration = new TH1F("pixelToT_beforecalibration", "pixelToT_beforecalibration", 100, 0, 200);
if(m_config.has("DUT") && m_config.has("calibrationPath") && m_config.has("threshold")) {
auto dut = get_dut();
if(dut != nullptr && m_config.has("calibrationPath") && m_config.has("threshold")) {
LOG(INFO) << "Applying calibration from " << calibrationPath;
applyCalibration = true;
// get DUT plane name
std::string DUT = m_config.get<std::string>("DUT");
std::string DUT = dut->name();
// make paths to calibration files and read
int ret = 0;
......@@ -463,7 +464,7 @@ bool Timepix3EventLoader::loadData(Clipboard* clipboard, Detector* detector, Pix
if(header == 0x0) {
// Only want to read these packets from the DUT
if(m_config.has("DUT") && detectorID != m_config.get<std::string>("DUT")) {
if(detector->isDUT()) {
continue;
}
......@@ -640,7 +641,7 @@ bool Timepix3EventLoader::loadData(Clipboard* clipboard, Detector* detector, Pix
pixelToT_beforecalibration->Fill((int)tot);
// Apply calibration if applyCalibration is true
if(applyCalibration && detectorID == m_config.get<std::string>("DUT")) {
if(applyCalibration && detector->isDUT()) {
LOG(DEBUG) << "Applying calibration to DUT";
float a = vtot.at(256 * row + col).at(2);
float b = vtot.at(256 * row + col).at(3);
......
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