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

Remove parameters->DUT and parameters->reference, we now get them from the inherited global config

parent bff91969
......@@ -16,6 +16,9 @@ void ATLASpixEventLoader::initialise(Parameters* par) {
// Take input directory from global parameters
string inputDirectory = m_config.get<std::string>("inputDirectory") + "/ATLASpix";
// Assume that the ATLASpix is the DUT (if running this algorithm
string detectorID = m_config.get<std::string>("DUT");
// Open the root directory
DIR* directory = opendir(inputDirectory.c_str());
if(directory == NULL) {
......@@ -52,9 +55,6 @@ void ATLASpixEventLoader::initialise(Parameters* par) {
StatusCode ATLASpixEventLoader::run(Clipboard* clipboard) {
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = parameters->DUT;
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
m_file.close();
......@@ -89,8 +89,10 @@ StatusCode ATLASpixEventLoader::run(Clipboard* clipboard) {
int tot = std::stoi(sm[4]);
int trg_index = std::stoi(sm[7]);
auto detector = (*find_if(
m_detectors.begin(), m_detectors.end(), [this](Detector* obj) { return obj->name() == detectorID; }));
// If this pixel is masked, do not save it
if(parameters->detector[detectorID]->masked(col, row)) {
if(detector->masked(col, row)) {
continue;
}
......
......@@ -36,6 +36,7 @@ namespace corryvreckan {
// Member variables
int m_eventNumber;
std::string detectorID;
std::string m_filename;
std::ifstream m_file;
......
......@@ -241,7 +241,7 @@ void Alignment::finalise() {
for(int ndet = 0; ndet < parameters->nDetectors; ndet++) {
string detectorID = parameters->detectors[ndet];
// Do not align the reference plane
if(detectorID == parameters->reference)
if(detectorID == m_config.get<std::string>("reference"))
continue;
if(parameters->excludedFromTracking.count(detectorID) != 0)
continue;
......@@ -326,7 +326,7 @@ void Alignment::finalise() {
for(int ndet = 0; ndet < parameters->nDetectors; ndet++) {
string detectorID = parameters->detectors[ndet];
// Do not align the reference plane
if(detectorID == parameters->reference)
if(detectorID == m_config.get<std::string>("reference"))
continue;
if(parameters->excludedFromTracking.count(detectorID) != 0)
continue;
......
......@@ -53,7 +53,7 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
// LOG(TRACE) <<"Running";
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = parameters->DUT;
string detectorID = m_config.get<std::string>("DUT");
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
......
......@@ -11,7 +11,7 @@ void Clicpix2Correlator::initialise(Parameters* par) {
parameters = par;
// Get the DUT ID
dutID = parameters->DUT;
dutID = m_config.get<std::string>("DUT");
// Initialise histograms
hTrackDiffX["standard"] = new TH1F("hTrackDiffX_standard", "hTrackDiffX_standard", 4000, -20, 20);
......
......@@ -52,7 +52,7 @@ void Clicpix2EventLoader::initialise(Parameters* par) {
StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = parameters->DUT;
string detectorID = m_config.get<std::string>("DUT");
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
......
......@@ -27,7 +27,7 @@ void ClicpixAnalysis::initialise(Parameters* par) {
// Initialise member variables
m_eventNumber = 0;
m_triggerNumber = 0;
dutID = parameters->DUT;
dutID = m_config.get<std::string>("DUT");
m_lostHits = 0.;
// Cluster/pixel histograms
......@@ -152,16 +152,19 @@ void ClicpixAnalysis::initialise(Parameters* par) {
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 =
(*find_if(m_detectors.begin(), m_detectors.end(), [this](Detector* obj) { return obj->name() == dutID; }));
m_nBinsX = 32;
m_nBinsY = 32;
hMapClusterSizeAssociated = new TH2F("hMapClusterSizeAssociated",
"hMapClusterSizeAssociated",
m_nBinsX,
0,
parameters->detector[dutID]->nPixelsX(),
detector->nPixelsX(),
m_nBinsY,
0,
parameters->detector[dutID]->nPixelsY());
detector->nPixelsY());
for(int x = 0; x < m_nBinsX; x++) {
for(int y = 0; y < m_nBinsY; y++) {
......@@ -208,18 +211,22 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
// Get the track
Track* track = (*itTrack);
if(!track)
if(!track) {
continue;
}
// Cut on the track chi2/ndof
if(track->chi2ndof() < 3.0)
if(track->chi2ndof() < 3.0) {
continue;
}
// Get the DUT detector:
auto detector =
(*find_if(m_detectors.begin(), m_detectors.end(), [this](Detector* obj) { return obj->name() == dutID; }));
// Get the track intercept with the clicpix plane (global and local
// co-ordinates)
PositionVector3D<Cartesian3D<double>> trackIntercept = parameters->detector[dutID]->getIntercept(track);
PositionVector3D<Cartesian3D<double>> trackInterceptLocal =
*(parameters->detector[dutID]->m_globalToLocal) * trackIntercept;
PositionVector3D<Cartesian3D<double>> trackIntercept = detector->getIntercept(track);
PositionVector3D<Cartesian3D<double>> trackInterceptLocal = *(detector->m_globalToLocal) * trackIntercept;
// Plot the difference between track intercepts and all clicpix clusters
// Also record which cluster is the closest
......@@ -260,18 +267,17 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
}
// Get the track intercept position along the chip
double chipInterceptCol = parameters->detector[dutID]->getColumn(trackInterceptLocal);
double chipInterceptRow = parameters->detector[dutID]->getRow(trackInterceptLocal);
double chipInterceptCol = detector->getColumn(trackInterceptLocal);
double chipInterceptRow = detector->getRow(trackInterceptLocal);
// Get the track intercept position along the pixel
double pixelInterceptX = parameters->detector[dutID]->inPixelX(trackInterceptLocal);
double pixelInterceptY = parameters->detector[dutID]->inPixelY(trackInterceptLocal);
double pixelInterceptX = detector->inPixelX(trackInterceptLocal);
double pixelInterceptY = detector->inPixelY(trackInterceptLocal);
// Cut on the track intercept - this makes sure that it actually went
// through the chip
if(chipInterceptCol < 0.5 || chipInterceptRow < 0.5 ||
chipInterceptCol > (parameters->detector[dutID]->nPixelsX() - 0.5) ||
chipInterceptRow > (parameters->detector[dutID]->nPixelsY() - 0.5))
if(chipInterceptCol < 0.5 || chipInterceptRow < 0.5 || chipInterceptCol > (detector->nPixelsX() - 0.5) ||
chipInterceptRow > (detector->nPixelsY() - 0.5))
continue;
// Check if the hit is near a masked pixel
......@@ -333,8 +339,8 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
if((*bestCluster)->size() == 1) {
hClusterTOTAssociated1pix->Fill((*bestCluster)->tot());
hInterceptClusterSize1->Fill(pixelInterceptX, pixelInterceptY);
int id = floor(chipInterceptCol * m_nBinsX / parameters->detector[dutID]->nPixelsX()) +
floor(chipInterceptRow * m_nBinsY / parameters->detector[dutID]->nPixelsY()) * m_nBinsX;
int id = floor(chipInterceptCol * m_nBinsX / detector->nPixelsX()) +
floor(chipInterceptRow * m_nBinsY / detector->nPixelsY()) * m_nBinsX;
hMapClusterTOTAssociated1pix[id]->Fill((*bestCluster)->tot());
}
if((*bestCluster)->size() == 2) {
......@@ -428,6 +434,10 @@ void ClicpixAnalysis::finalise() {
// Check if a track has gone through or near a masked pixel
bool ClicpixAnalysis::checkMasked(double chipInterceptRow, double chipInterceptCol) {
// Get the DUT detector:
auto detector =
(*find_if(m_detectors.begin(), m_detectors.end(), [this](Detector* obj) { return obj->name() == dutID; }));
// Get the pixel row and column number
int rowNumber = ceil(chipInterceptRow);
int colNumber = ceil(chipInterceptCol);
......
......@@ -8,7 +8,8 @@ using namespace corryvreckan;
DUTAnalysis::DUTAnalysis(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) {
m_digitalPowerPulsing = false;
m_digitalPowerPulsing = m_config.get<bool>("digitalPowerPulsing", false);
m_DUT = m_config.get<std::string>("DUT");
}
void DUTAnalysis::initialise(Parameters* par) {
......@@ -78,7 +79,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
m_shutterCloseTime = 0;
// Now update the power pulsing with any new signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(parameters->DUT, "SpidrSignals");
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(m_DUT, "SpidrSignals");
// If there are new signals
if(spidrData != NULL) {
// Loop over all signals registered
......@@ -115,7 +116,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
}
// Get the DUT clusters from the clipboard
Clusters* clusters = (Clusters*)clipboard->get(parameters->DUT, "clusters");
Clusters* clusters = (Clusters*)clipboard->get(m_DUT, "clusters");
if(clusters == NULL) {
LOG(DEBUG) << "No DUT clusters on the clipboard";
}
......@@ -125,17 +126,23 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
for(auto& track : (*tracks)) {
// Cut on the chi2/ndof
if(track->chi2ndof() > chi2ndofCut)
if(track->chi2ndof() > chi2ndofCut) {
continue;
}
// Get the DUT detector:
auto detector =
(*find_if(m_detectors.begin(), m_detectors.end(), [this](Detector* obj) { return obj->name() == m_DUT; }));
// Check if it intercepts the DUT
PositionVector3D<Cartesian3D<double>> globalIntercept = parameters->detector[parameters->DUT]->getIntercept(track);
if(!parameters->detector[parameters->DUT]->hasIntercept(track, 1.))
PositionVector3D<Cartesian3D<double>> globalIntercept = detector->getIntercept(track);
if(!detector->hasIntercept(track, 1.)) {
continue;
}
// Check that it doesn't go through/near a masked pixel
if(parameters->detector[parameters->DUT]->hitMasked(track, 1.))
if(detector->hitMasked(track, 1.)) {
continue;
}
tracksVersusTime->Fill((double)track->timestamp() / (4096. * 40000000.));
......
......@@ -39,6 +39,7 @@ namespace corryvreckan {
TH1F* associatedTracksVersusPowerOnTime;
// Member variables
std::string m_DUT;
int m_eventNumber;
int m_nAlignmentClusters;
long long int m_powerOnTime;
......
......@@ -66,7 +66,7 @@ void FileReader::initialise(Parameters* par) {
string detectorType = detector->type();
// If only reading information for the DUT
if(m_onlyDUT && detectorID != parameters->DUT)
if(m_onlyDUT && detectorID != m_config.get<std::string>("DUT"))
continue;
LOG(DEBUG) << "Looking for " << objectType << " for device " << detectorID;
......@@ -126,7 +126,7 @@ StatusCode FileReader::run(Clipboard* clipboard) {
string objectID = detectorID + "_" + objectType;
// If only writing information for the DUT
if(m_onlyDUT && detectorID != parameters->DUT)
if(m_onlyDUT && detectorID != m_config.get<std::string>("DUT"))
continue;
// If there is no data for this device, continue
......
......@@ -64,7 +64,7 @@ void FileWriter::initialise(Parameters* par) {
string detectorType = detector->type();
// If only writing information for the DUT
if(m_onlyDUT && detectorID != parameters->DUT)
if(m_onlyDUT && detectorID != m_config.get<std::string>("DUT"))
continue;
// Create the tree
......@@ -115,7 +115,7 @@ StatusCode FileWriter::run(Clipboard* clipboard) {
string objectID = detectorID + "_" + objectType;
// If only writing information for the DUT
if(m_onlyDUT && detectorID != parameters->DUT)
if(m_onlyDUT && detectorID != m_config.get<std::string>("DUT"))
continue;
// Get the objects, if they don't exist then continue
......
......@@ -46,7 +46,7 @@ void GUI::initialise(Parameters* par) {
addPlot(hitmapCanvas, hitmap, "colz");
string residualHisto = "/corryvreckan/BasicTracking/residualsX_" + detector->name();
if(detector->name() == parameters->DUT)
if(detector->name() == m_config.get<std::string>("DUT"))
residualHisto = "/corryvreckan/DUTAnalysis/residualsX";
addPlot(residualsCanvas, residualHisto);
......
......@@ -35,7 +35,7 @@ void OnlineMonitor::initialise(Parameters* par) {
// track chi2
AddHisto("OverviewCanvas", "/corryvreckan/BasicTracking/trackChi2");
// reference plane map, residuals
string reference = parameters->reference;
string reference = m_config.get<std::string>("reference");
string tot = "/corryvreckan/TestAlgorithm/clusterTot_" + reference;
AddHisto("OverviewCanvas", tot);
string hitmap = "/corryvreckan/TestAlgorithm/hitmap_" + reference;
......
......@@ -79,9 +79,10 @@ StatusCode TestAlgorithm::run(Clipboard* clipboard) {
}
// Get clusters from reference detector
Clusters* referenceClusters = (Clusters*)clipboard->get(parameters->reference, "clusters");
Clusters* referenceClusters = (Clusters*)clipboard->get(m_config.get<std::string>("DUT"), "clusters");
if(referenceClusters == NULL) {
LOG(DEBUG) << "Reference detector " << parameters->reference << " does not have any clusters on the clipboard";
LOG(DEBUG) << "Reference detector " << m_config.get<std::string>("DUT")
<< " does not have any clusters on the clipboard";
// continue;
}
......
......@@ -50,7 +50,7 @@ void Timepix1Correlator::initialise(Parameters* par) {
StatusCode Timepix1Correlator::run(Clipboard* clipboard) {
// Get the clusters for the reference detector
string referenceDetector = parameters->reference;
string referenceDetector = m_config.get<std::string>("reference");
Clusters* referenceClusters = (Clusters*)clipboard->get(referenceDetector, "clusters");
if(referenceClusters == NULL) {
LOG(DEBUG) << "Detector " << referenceDetector << " does not have any clusters on the clipboard";
......
......@@ -223,7 +223,7 @@ bool Timepix3EventLoader::loadData(Detector* detector, Pixels* devicedata, Spidr
// if(detectorID != "W0019_F07") debug = false;
bool extra = false; // temp
// if(detectorID == parameters->DUT) extra = true;
// if(detectorID == m_config.get<std::string>("DUT")) extra = true;
// if(detectorID == "W0002_J05") extra = true;
LOG(DEBUG) << "Loading data for device " << detectorID;
......@@ -343,7 +343,7 @@ bool Timepix3EventLoader::loadData(Detector* detector, Pixels* devicedata, Spidr
if(header == 0x0) {
// Only want to read these packets from the DUT
if(detectorID != parameters->DUT)
if(detectorID != m_config.get<std::string>("DUT"))
continue;
// Get the second part of the header
......
......@@ -177,12 +177,8 @@ void Analysis::load_detectors() {
// FIXME reimplement - std::sort(m_parameters->detectors.begin(), m_parameters->detectors.end(), sortByZ);
//
// Define DUT and reference
m_parameters->DUT = global_config.get<std::string>("DUT");
m_parameters->reference = global_config.get<std::string>("reference");
m_parameters->detectorToAlign = m_parameters->DUT;
m_parameters->excludedFromTracking[m_parameters->DUT] = true;
m_parameters->detectorToAlign = global_config.get<std::string>("DUT");
m_parameters->excludedFromTracking[global_config.get<std::string>("DUT")] = true;
if(global_config.has("excludeFromTracking")) {
std::vector<std::string> excluding = global_config.getArray<std::string>("excludeFromTracking");
......
......@@ -51,9 +51,7 @@ namespace corryvreckan {
// Member variables
std::vector<std::string> detectors;
int nDetectors{0};
std::string reference;
double currentTime;
std::string DUT;
std::map<std::string, bool> excludedFromTracking;
std::map<std::string, bool> masked;
std::string detectorToAlign;
......
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