Commit 3104ff9d authored by Simon Spannagel's avatar Simon Spannagel
Browse files

algorithms: remove further calls to parameters->detectors

parent 26bec447
......@@ -26,7 +26,7 @@ void BasicTracking::initialise(Parameters* par) {
trackAngleY = new TH1F("trackAngleY", "trackAngleY", 2000, -0.01, 0.01);
// Loop over all Timepix3
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
string detectorID = detector->name();
if(detector->type() != "Timepix3")
......@@ -54,7 +54,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard) {
// Loop over all Timepix3 and get clusters
bool firstDetector = true;
std::string seedPlane;
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
string detectorID = detector->name();
......@@ -195,7 +195,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard) {
LOG_PROGRESS(STATUS, "basic_tracking") << "Produced " << (int)nTracksTotal << " tracks";
// Clean up tree objects
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
if(trees.count(detector->name()) != 0)
delete trees[detector->name()];
}
......
......@@ -113,7 +113,7 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
LOG(TRACE) << "New pixel: " << col << "," << row << " with tot " << tot;
// If this pixel is masked, do not save it
if(parameters->detector[detectorID]->masked(col, row))
if(get_detector(detectorID)->masked(col, row))
continue;
Pixel* pixel = new Pixel(detectorID, row, col, tot, 0);
pixels->push_back(pixel);
......
......@@ -82,8 +82,8 @@ void Clicpix2Correlator::finalise() {
for(double angle = angleStart; angle < angleStop; angle += angleStep) {
// Set the angle
parameters->detector[dutID]->rotationX(angle);
parameters->detector[dutID]->update();
get_detector(dutID)->rotationX(angle);
get_detector(dutID)->update();
int event;
for(event = 0; event < m_eventNumber; event++) {
......@@ -98,7 +98,7 @@ void Clicpix2Correlator::finalise() {
Track* track = tracks[iTrack];
// Get the track intercept with the clicpix plane (global co-ordinates)
PositionVector3D<Cartesian3D<double>> trackIntercept = parameters->detector[dutID]->getIntercept(track);
PositionVector3D<Cartesian3D<double>> trackIntercept = get_detector(dutID)->getIntercept(track);
// Loop over all clusters from this event
for(int iCluster = 0; iCluster < clusters.size(); iCluster++) {
......
......@@ -115,7 +115,7 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
tot++;
// If this pixel is masked, do not save it
if(parameters->detector[detectorID]->masked(col, row))
if(get_detector(detectorID)->masked(col, row))
continue;
Pixel* pixel = new Pixel(detectorID, row, col, tot, 0);
pixels->push_back(pixel);
......
......@@ -369,8 +369,8 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
// Get the pixel global position
LOG(TRACE) <<"New pixel, row = "<<(*itPixel)->m_row<<", column = "<<(*itPixel)->m_column;
PositionVector3D<Cartesian3D<double> > pixelPositionLocal = parameters->detector[dutID]->getLocalPosition((*itPixel)->m_row,(*itPixel)->m_column);
PositionVector3D<Cartesian3D<double> > pixelPositionGlobal = *(parameters->detector[dutID]->m_localToGlobal) * pixelPositionLocal;
PositionVector3D<Cartesian3D<double> > pixelPositionLocal = get_detector(dutID)->getLocalPosition((*itPixel)->m_row,(*itPixel)->m_column);
PositionVector3D<Cartesian3D<double> > pixelPositionGlobal = *(get_detector(dutID)->m_localToGlobal) * pixelPositionLocal;
// Check if it is close to the track
if( fabs( pixelPositionGlobal.X() - trackIntercept.X() ) > m_associationCut ||
......@@ -467,9 +467,10 @@ 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);
// Get the intercept of the interested track at the dut
bool close = false;
PositionVector3D<Cartesian3D<double>> trackIntercept = parameters->detector[dutID]->getIntercept(track);
PositionVector3D<Cartesian3D<double>> trackIntercept = detector->getIntercept(track);
// Loop over all other tracks and check if they intercept close to the track
// we are considering
......@@ -479,7 +480,7 @@ bool ClicpixAnalysis::checkProximity(Track* track, Tracks* tracks) {
// Get the track
Track* track2 = (*itTrack);
// Get the track intercept with the clicpix plane (global co-ordinates)
PositionVector3D<Cartesian3D<double>> trackIntercept2 = parameters->detector[dutID]->getIntercept(track2);
PositionVector3D<Cartesian3D<double>> trackIntercept2 = detector->getIntercept(track2);
// If track == track2 do nothing
if(trackIntercept.X() == trackIntercept2.X() && trackIntercept.Y() == trackIntercept2.Y())
continue;
......@@ -494,7 +495,7 @@ bool ClicpixAnalysis::checkProximity(Track* track, Tracks* tracks) {
void ClicpixAnalysis::fillClusterHistos(Clusters* clusters) {
// Pick up column to generate unique pixel id
int nCols = parameters->detector[dutID]->nPixelsX();
int nCols = get_detector(dutID)->nPixelsX();
Clusters::iterator itc;
// Check if this is a new clicpix frame (each frame may be in several events)
......@@ -539,6 +540,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);
// Loop over pixels in the cluster and show their distance from the track
// intercept
Pixels* pixels = cluster->pixels();
......@@ -548,10 +550,8 @@ void ClicpixAnalysis::fillResponseHistos(double trackInterceptX, double trackInt
// Get the pixel
Pixel* pixel = (*itp);
// Get the pixel local then global position
PositionVector3D<Cartesian3D<double>> pixelPositionLocal =
parameters->detector[dutID]->getLocalPosition(pixel->m_row, pixel->m_column);
PositionVector3D<Cartesian3D<double>> pixelPositionGlobal =
*(parameters->detector[dutID]->m_localToGlobal) * pixelPositionLocal;
PositionVector3D<Cartesian3D<double>> pixelPositionLocal = detector->getLocalPosition(pixel->m_row, pixel->m_column);
PositionVector3D<Cartesian3D<double>> pixelPositionGlobal = *(detector->m_localToGlobal) * pixelPositionLocal;
// Fill the response histograms
hPixelResponseX->Fill(pixelPositionGlobal.X() - trackInterceptX);
......
......@@ -59,7 +59,7 @@ void FileReader::initialise(Parameters* par) {
if(objectType == "pixels" || objectType == "clusters") {
// Loop over all detectors and search for data
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the detector ID and type
string detectorID = detector->name();
......@@ -118,7 +118,7 @@ StatusCode FileReader::run(Clipboard* clipboard) {
if(objectType == "pixels" || objectType == "clusters") {
// Loop over all detectors
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the detector and object ID
string detectorID = detector->name();
......
......@@ -57,7 +57,7 @@ void FileWriter::initialise(Parameters* par) {
if(objectType == "pixels" || objectType == "clusters") {
// Loop over all detectors and make trees for data
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the detector ID and type
string detectorID = detector->name();
......@@ -108,7 +108,7 @@ StatusCode FileWriter::run(Clipboard* clipboard) {
if(objectType == "pixels" || objectType == "clusters") {
// Loop over all detectors
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the detector and object ID
string detectorID = detector->name();
......@@ -181,7 +181,7 @@ void FileWriter::finalise() {
if(objectType == "pixels" || objectType == "clusters") {
// Loop over all detectors
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the detector and object ID
string detectorID = detector->name();
......
......@@ -41,7 +41,7 @@ void GUI::initialise(Parameters* par) {
addPlot(trackCanvas, "/corryvreckan/BasicTracking/trackAngleX");
// Per detector histograms
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
string hitmap = "/corryvreckan/TestAlgorithm/hitmap_" + detector->name();
addPlot(hitmapCanvas, hitmap, "colz");
......
......@@ -11,7 +11,7 @@ void GenericAlgorithm::initialise(Parameters* par) {
parameters = par;
// Initialise histograms per device
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
if(detector->type() != "Timepix3")
......@@ -33,7 +33,7 @@ void GenericAlgorithm::initialise(Parameters* par) {
StatusCode GenericAlgorithm::run(Clipboard* clipboard) {
// Loop over all Timepix3 and make plots
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
if(detector->type() != "Timepix3")
......
......@@ -57,7 +57,7 @@ void OnlineMonitor::initialise(Parameters* par) {
AddButton("ChargeDistributions", "ChargeDistributionCanvas");
// Per detector histograms
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
string detectorID = detector->name();
string hitmap = "/corryvreckan/TestAlgorithm/hitmap_" + detectorID;
......
......@@ -20,7 +20,7 @@ SpatialClustering::SpatialClustering(Configuration config, std::vector<Detector*
void SpatialClustering::initialise(Parameters*) {
// Initialise histograms per device
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix1
if(detector->type() != "ATLASpix" && detector->type() != "Timepix1" && detector->type() != "CLICpix")
......@@ -34,7 +34,7 @@ void SpatialClustering::initialise(Parameters*) {
StatusCode SpatialClustering::run(Clipboard* clipboard) {
// Loop over all detectors of this algorithm:
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
LOG(TRACE) << "Executing loop for detector " << detector->name();
// Check if they are a Timepix1
......
......@@ -32,7 +32,7 @@ void SpatialTracking::initialise(Parameters* par) {
trackAngleY = new TH1F("trackAngleY", "trackAngleY", 2000, -0.01, 0.01);
// Loop over all Timepix1
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
// if(detector->type() != "Timepix1")
// continue;
......@@ -59,7 +59,7 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
// Loop over all Timepix1 and get clusters
double minZ = 1000.;
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix1
string detectorID = detector->name();
......@@ -183,7 +183,7 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
}
// Clean up tree objects
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
if(trees.count(detector->name()) != 0)
delete trees[detector->name()];
}
......
......@@ -14,7 +14,7 @@ void TestAlgorithm::initialise(Parameters* par) {
parameters = par;
// Make histograms for each Timepix3
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
LOG(DEBUG) << "Booking histograms for detector " << detector->name();
// Simple hit map
......@@ -55,7 +55,7 @@ void TestAlgorithm::initialise(Parameters* par) {
StatusCode TestAlgorithm::run(Clipboard* clipboard) {
// Loop over all Timepix3 and make plots
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Get the pixels
Pixels* pixels = (Pixels*)clipboard->get(detector->name(), "pixels");
if(pixels == NULL) {
......
......@@ -14,7 +14,7 @@ void Timepix1Correlator::initialise(Parameters* par) {
parameters = par;
// Initialise histograms per device
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
string detectorID = detector->name();
......@@ -58,7 +58,7 @@ StatusCode Timepix1Correlator::run(Clipboard* clipboard) {
}
// Loop over all Timepix1 and make plots
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix1
string detectorID = detector->name();
......
......@@ -172,17 +172,19 @@ StatusCode Timepix1EventLoader::run(Clipboard* clipboard) {
m_fileOpen = false;
}
// Store all of the data on the clipboard
for(int nDetector = 0; nDetector < detectors.size(); nDetector++) {
// Check if this detector has been seen before, if not then register it
string detID = detectors[nDetector];
if(std::find(parameters->detectors.begin(), parameters->detectors.end(), detID) == parameters->detectors.end())
parameters->registerDetector(detID);
// Put the pixels on the clipboard
clipboard->put(detID, "pixels", dataContainers[detID]);
LOG(DEBUG) << "Loaded " << dataContainers[detID]->size() << " pixels from device " << detID;
// Loop over all detectors found and store the data on the clipboard
for(auto& detID : detectors) {
// Check if this detector has been seen before
try {
auto detector = get_detector(detID);
// Put the pixels on the clipboard
clipboard->put(detID, "pixels", dataContainers[detID]);
LOG(DEBUG) << "Loaded " << dataContainers[detID]->size() << " pixels from device " << detID;
} catch(AlgorithmError& e) {
LOG(WARNING) << "Unknown detector \"" << detID << "\"";
}
}
LOG(DEBUG) << "Loaded " << detectors.size() << " detectors in this event";
......
......@@ -22,7 +22,7 @@ bool sortByTime(Pixel* pixel1, Pixel* pixel2) {
StatusCode Timepix3Clustering::run(Clipboard* clipboard) {
// Loop over all Timepix3 and for each device perform the clustering
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
if(detector->type() != "Timepix3")
......@@ -162,14 +162,13 @@ void Timepix3Clustering::calculateClusterCentre(Cluster* cluster) {
row /= tot;
column /= tot;
auto detector = get_detector(detectorID);
// Create object with local cluster position
PositionVector3D<Cartesian3D<double>> positionLocal(
parameters->detector[detectorID]->pitchX() * (column - parameters->detector[detectorID]->nPixelsX() / 2),
parameters->detector[detectorID]->pitchY() * (row - parameters->detector[detectorID]->nPixelsY() / 2),
0);
detector->pitchX() * (column - detector->nPixelsX() / 2), detector->pitchY() * (row - detector->nPixelsY() / 2), 0);
// Calculate global cluster position
PositionVector3D<Cartesian3D<double>> positionGlobal =
*(parameters->detector[detectorID]->m_localToGlobal) * positionLocal;
PositionVector3D<Cartesian3D<double>> positionGlobal = *(detector->m_localToGlobal) * positionLocal;
// Set the cluster parameters
cluster->setRow(row);
......
......@@ -133,7 +133,7 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
int loadedData = 0;
// Loop through all registered detectors
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
string detectorID = detector->name();
......
......@@ -12,7 +12,7 @@ void Timepix3MaskCreator::initialise(Parameters* par) {
parameters = par;
//
// // Make histograms for each Timepix3
// for(auto& detector : m_detectors){
// for(auto& detector : get_detectors()){
//
// // Check if they are a Timepix3
// if(detector->type() != "Timepix3") continue;
......@@ -28,7 +28,7 @@ void Timepix3MaskCreator::initialise(Parameters* par) {
StatusCode Timepix3MaskCreator::run(Clipboard* clipboard) {
// Loop over all Timepix3 and for each device perform the clustering
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
if(detector->type() != "Timepix3")
......@@ -58,7 +58,7 @@ StatusCode Timepix3MaskCreator::run(Clipboard* clipboard) {
void Timepix3MaskCreator::finalise() {
// Loop through all registered detectors
for(auto& detector : m_detectors) {
for(auto& detector : get_detectors()) {
// Check if they are a Timepix3
if(detector->type() != "Timepix3")
......
......@@ -77,6 +77,7 @@ namespace corryvreckan {
return (*it);
}
private:
std::vector<Detector*> m_detectors;
};
}
......
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