Commit 2b97ec89 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

More adjustments to relateive include paths

parent 195c5e53
#include "BasicTracking.h"
#include "KDTree.h"
#include "objects/KDTree.h"
#include "TCanvas.h"
BasicTracking::BasicTracking(bool debugging)
: Algorithm("BasicTracking"){
debug = false;
// Default values for cuts
timingCut = 200./1000000000.; // 200 ns
spatialCut = 0.2; // 200 um
......@@ -15,9 +15,9 @@ BasicTracking::BasicTracking(bool debugging)
void BasicTracking::initialise(Parameters* par){
parameters = par;
// Set up histograms
trackChi2 = new TH1F("trackChi2","trackChi2",150,0,150);
trackChi2ndof = new TH1F("trackChi2ndof","trackChi2ndof",100,0,50);
......@@ -25,7 +25,7 @@ void BasicTracking::initialise(Parameters* par){
tracksPerEvent = new TH1F("tracksPerEvent","tracksPerEvent",100,0,100);
trackAngleX = new TH1F("trackAngleX","trackAngleX",2000,-0.01,0.01);
trackAngleY = new TH1F("trackAngleY","trackAngleY",2000,-0.01,0.01);
// Loop over all Timepix3
for(int det = 0; det<parameters->nDetectors; det++){
// Check if they are a Timepix3
......@@ -36,30 +36,30 @@ void BasicTracking::initialise(Parameters* par){
name = "residualsY_"+detectorID;
residualsY[detectorID] = new TH1F(name.c_str(),name.c_str(),100,-0.02,0.02);
}
nTracksTotal = 0.;
}
StatusCode BasicTracking::run(Clipboard* clipboard){
if(debug) tcout<<"Start of event"<<endl;
// Container for all clusters, and detectors in tracking
map<string,KDTree*> trees;
vector<string> detectors;
Clusters* referenceClusters;
// Output track container
Tracks* tracks = new Tracks();
// Loop over all Timepix3 and get clusters
bool firstDetector = true; int seedPlane=0;
for(int det = 0; det<parameters->nDetectors; det++){
// Check if they are a Timepix3
string detectorID = parameters->detectors[det];
if(parameters->detector[detectorID]->type() != "Timepix3") continue;
// Get the clusters
Clusters* tempClusters = (Clusters*)clipboard->get(detectorID,"clusters");
if(tempClusters == NULL){
......@@ -76,7 +76,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
detectors.push_back(detectorID);
}
}
// If there are no detectors then stop trying to track
if(detectors.size() == 0) return Success;
......@@ -96,7 +96,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
used[cluster] = true;
// Get the cluster time
long long int timestamp = cluster->timestamp();
// // Loop over each subsequent plane and look for the closest cluster in a given time window
// for(int det=0; det<detectors.size(); det++){
// string detectorID = detectors[det];
......@@ -134,15 +134,15 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
if(trees.count(detectors[det]) == 0) continue;
// If excluded from tracking ignore this plane
if(parameters->excludedFromTracking.count(detectors[det]) != 0) continue;
// Get all neighbours within 200 ns
if(debug) tcout<<"Searching for neighbouring cluster on "<<detectors[det]<<endl;
if(debug) tcout<<"- cluster time is "<<cluster->timestamp()<<endl;
Cluster* closestCluster = NULL; double closestClusterDistance = spatialCut;
Clusters neighbours = trees[detectors[det]]->getAllClustersInTimeWindow(cluster,timingCut);
if(debug) tcout<<"- found "<<neighbours.size()<<" neighbours"<<endl;
// Now look for the spatially closest cluster on the next plane
double interceptX, interceptY;
if(track->nClusters() > 1){
......@@ -154,46 +154,46 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
interceptX = cluster->globalX();
interceptY = cluster->globalY();
}
// Loop over each neighbour in time
for(int ne=0;ne<neighbours.size();ne++){
Cluster* newCluster = neighbours[ne];
// Calculate the distance to the previous plane's cluster/intercept
double distance = sqrt((interceptX - newCluster->globalX())*(interceptX - newCluster->globalX()) + (interceptY - newCluster->globalY())*(interceptY - newCluster->globalY()));
// If this is the closest keep it
if(distance < closestClusterDistance){
closestClusterDistance = distance;
closestCluster = newCluster;
}
}
if(closestCluster == NULL) continue;
// Add the cluster to the track
if(debug) tcout<<"- added cluster to track"<<endl;
track->addCluster(closestCluster);
}//*/
// Now should have a track with one cluster from each plane
if(track->nClusters() < minHitsOnTrack){
delete track;
continue;
}
// Fit the track and save it
track->fit();
tracks->push_back(track);
// Fill histograms
trackChi2->Fill(track->chi2());
clustersPerTrack->Fill(track->nClusters());
trackChi2ndof->Fill(track->chi2ndof());
trackAngleX->Fill(atan(track->m_direction.X()));
trackAngleY->Fill(atan(track->m_direction.Y()));
// Make residuals
Clusters trackClusters = track->clusters();
for(int iTrackCluster=0; iTrackCluster<trackClusters.size(); iTrackCluster++){
......@@ -203,9 +203,9 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
residualsX[detectorID]->Fill(intercept.X() - trackCluster->globalX());
residualsY[detectorID]->Fill(intercept.Y() - trackCluster->globalY());
}
}
// Save the tracks on the clipboard
if(tracks->size() > 0){
clipboard->put("tracks",(TestBeamObjects*)tracks);
......@@ -226,7 +226,7 @@ StatusCode BasicTracking::run(Clipboard* clipboard){
}
Cluster* BasicTracking::getNearestCluster(long long int timestamp, Clusters clusters){
Cluster* bestCluster = NULL;
// Loop over all clusters and return the one with the closest timestamp
for(int iCluster=0;iCluster<clusters.size();iCluster++){
......@@ -234,16 +234,16 @@ Cluster* BasicTracking::getNearestCluster(long long int timestamp, Clusters clus
if(bestCluster == NULL) bestCluster = cluster;
if(abs(cluster->timestamp() - timestamp) < abs(bestCluster->timestamp()-timestamp)) bestCluster = cluster;
}
return bestCluster;
}
//Timepix3Cluster* BasicTracking::getNearestCluster(Timepix3Cluster* cluster, map<Timepix3Cluster*, bool> used, Timepix3Clusters* clusters){
//
//
// // Loop over all clusters and return the closest in space with an acceptable time cut
// Timepix3Cluster* bestCluster = NULL;
// double closestApproach = 1000000.;
//
//
// // Loop over all clusters
// for(int iCluster=0;iCluster<clusters->size();iCluster++){
// Timepix3Cluster* candidate = (*clusters)[iCluster];
......@@ -265,6 +265,6 @@ Cluster* BasicTracking::getNearestCluster(long long int timestamp, Clusters clus
//}
void BasicTracking::finalise(){
}
#ifndef CLICpixEventLoader_H
#define CLICpixEventLoader_H 1
#include "Algorithm.h"
#include "core/Algorithm.h"
#include <iostream>
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include "objects/Pixel.h"
#include "objects/Cluster.h"
#include "objects/Track.h"
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <dirent.h>
class CLICpixEventLoader : public Algorithm {
public:
// Constructors and destructors
CLICpixEventLoader(bool);
......@@ -30,12 +30,12 @@ public:
int m_eventNumber;
string m_filename;
ifstream m_file;
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hShutterLength;
TH1F* hPixelsPerFrame;
};
#endif // CLICpixEventLoader_H
# Include the dependencies
INCLUDE_DIRECTORIES(SYSTEM ${CORRYVRECKAN_DEPS_INCLUDE_DIRS})
# Create Algorithms library
ADD_LIBRARY(CorryvreckanAlgorithms SHARED
Alignment.C
BasicTracking.C
Clicpix2Correlator.C
Clicpix2EventLoader.C
ClicpixAnalysis.C
CLICpixEventLoader.C
DataDump.C
DUTAnalysis.C
EventDisplay.C
FileReader.C
FileWriter.C
GenericAlgorithm.C
GUI.C
OnlineMonitor.C
SpatialTracking.C
TestAlgorithm.C
Timepix1Clustering.C
Timepix1Correlator.C
Timepix1EventLoader.C
Timepix3Clustering.C
Timepix3EventLoader.C
Timepix3MaskCreator.C
)
# Link the dependencies
TARGET_LINK_LIBRARIES(CorryvreckanAlgorithms ${CORRYVRECKANX_DEPS_LIBRARIES})
TARGET_LINK_LIBRARIES(CorryvreckanAlgorithms ${CORRYVRECKAN_LIBRARIES})
# Define compile-time library extension
TARGET_COMPILE_DEFINITIONS(CorryvreckanAlgorithms PRIVATE SHARED_LIBRARY_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}")
# Link the DL libraries
TARGET_LINK_LIBRARIES(CorryvreckanAlgorithms ${CMAKE_DL_LIBS})
# Create standard install target
INSTALL(TARGETS CorryvreckanAlgorithms
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
#ifndef Clicpix2Correlator_H
#define Clicpix2Correlator_H 1
#include "Algorithm.h"
#include "core/Algorithm.h"
#include <iostream>
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include "objects/Pixel.h"
#include "objects/Cluster.h"
#include "objects/Track.h"
#include <sstream>
class Clicpix2Correlator : public Algorithm {
public:
// Constructors and destructors
Clicpix2Correlator(bool);
......@@ -29,11 +29,11 @@ public:
map<int, Clusters> m_eventClusters;
map<int, Tracks> m_eventTracks;
double angleStart, angleStop, angleStep;
// Histograms
map<string,TH1F*> hTrackDiffX;
map<string,TH1F*> hTrackDiffY;
};
#endif // Clicpix2Correlator_H
#ifndef Clicpix2EventLoader_H
#define Clicpix2EventLoader_H 1
#include "Algorithm.h"
#include "core/Algorithm.h"
#include <iostream>
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include "objects/Pixel.h"
#include "objects/Cluster.h"
#include "objects/Track.h"
#include <fstream>
#include <sstream>
#include <stdio.h>
......@@ -16,7 +16,7 @@
#include <string.h>
class Clicpix2EventLoader : public Algorithm {
public:
// Constructors and destructors
Clicpix2EventLoader(bool);
......@@ -29,19 +29,19 @@ public:
// Histograms for several devices
map<string, TH2F*> plotPerDevice;
// Single histograms
TH1F* singlePlot;
// Member variables
int m_eventNumber;
string m_filename;
ifstream m_file;
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hPixelsPerFrame;
};
#endif // Clicpix2EventLoader_H
This diff is collapsed.
#include "DUTAnalysis.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include "SpidrSignal.h"
#include "objects/Pixel.h"
#include "objects/Cluster.h"
#include "objects/Track.h"
#include "objects/SpidrSignal.h"
DUTAnalysis::DUTAnalysis(bool debugging)
: Algorithm("DUTAnalysis"){
......@@ -12,7 +12,7 @@ DUTAnalysis::DUTAnalysis(bool debugging)
void DUTAnalysis::initialise(Parameters* par){
// Pick up a copy of the parameters
parameters = par;
......@@ -22,12 +22,12 @@ void DUTAnalysis::initialise(Parameters* par){
residualsX = new TH1F("residualsX","residualsX",400,-0.2,0.2);
residualsY = new TH1F("residualsY","residualsY",400,-0.2,0.2);
residualsTime = new TH1F("residualsTime","residualsTime",2000,-0.000001,0.000001);
hTrackCorrelationX = new TH1F("hTrackCorrelationX","hTrackCorrelationX",4000,-10.,10.);
hTrackCorrelationY = new TH1F("hTrackCorrelationY","hTrackCorrelationY",4000,-10.,10.);
hTrackCorrelationTime = new TH1F("hTrackCorrelationTime","hTrackCorrelationTime",2000000,-0.005,0.005);
clusterToTVersusTime = new TH2F("clusterToTVersusTime","clusterToTVersusTime",300000,0.,300.,200,0,1000);
residualsTimeVsTime = new TH2F("residualsTimeVsTime","residualsTimeVsTime",20000,0,200,400,-0.0005,0.0005);
tracksVersusPowerOnTime = new TH1F("tracksVersusPowerOnTime","tracksVersusPowerOnTime",1200000,-0.01,0.11);
......@@ -47,19 +47,19 @@ void DUTAnalysis::initialise(Parameters* par){
}
StatusCode DUTAnalysis::run(Clipboard* clipboard){
// tcout<<"Power on time: "<<m_powerOnTime/(4096. * 40000000.)<<endl;
// tcout<<"Power off time: "<<m_powerOffTime/(4096. * 40000000.)<<endl;
// tcout<<endl;
cout<<std::setprecision(10);
if(parameters->currentTime < 13.5) return Success;
// Timing cut for association
double timingCut = 200./1000000000.; // 200 ns
long long int timingCutInt = (timingCut * 4096. * 40000000.);
// Spatial cut
double spatialCut = 0.2; // 200 um
......@@ -68,11 +68,11 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
// Power pulsing variable initialisation - get signals from SPIDR for this device
double timeSincePowerOn = 0.;
// If the power was switched off/on in the last event we no longer have a power on/off time
if(m_shutterCloseTime != 0 && m_shutterCloseTime > m_shutterOpenTime) m_shutterOpenTime = 0;
if(m_shutterOpenTime != 0 && m_shutterOpenTime > m_shutterCloseTime) m_shutterCloseTime = 0;
// Now update the power pulsing with any new signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(parameters->DUT,"SpidrSignals");
// If there are new signals
......@@ -98,14 +98,14 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
}
}
}
// Get the tracks from the clipboard
Tracks* tracks = (Tracks*)clipboard->get("tracks");
if(tracks == NULL){
if(debug) tcout<<"No tracks on the clipboard"<<endl;
return Success;
}
// Get the DUT clusters from the clipboard
Clusters* clusters = (Clusters*)clipboard->get(parameters->DUT,"clusters");
if(clusters == NULL){
......@@ -114,23 +114,23 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
// Loop over all tracks
for(int itTrack=0;itTrack<tracks->size();itTrack++){
// Get the track pointer
Track* track = (*tracks)[itTrack];
// Cut on the chi2/ndof
if(track->chi2ndof() > chi2ndofCut) continue;
// Check if it intercepts the DUT
PositionVector3D<Cartesian3D<double> > globalIntercept = parameters->detector[parameters->DUT]->getIntercept(track);
if(!parameters->detector[parameters->DUT]->hasIntercept(track,1.)) continue;
// Check that it doesn't go through/near a masked pixel
if(parameters->detector[parameters->DUT]->hitMasked(track,1.)) continue;
tracksVersusTime->Fill( (double)track->timestamp() / (4096.*40000000.) );
timeSincePowerOn = (double)(track->timestamp() - m_shutterOpenTime) / (4096.*40000000.);
if(timeSincePowerOn > 0. && timeSincePowerOn < 0.0002){
// cout<<endl;
......@@ -157,10 +157,10 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
/*
// 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;
......@@ -171,7 +171,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
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.));
......@@ -179,27 +179,27 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
}
}
*/
// Loop over all DUT clusters
bool associated = false;
for(int itCluster=0;itCluster<clusters->size();itCluster++){
// Get the cluster pointer
Cluster* cluster = (*clusters)[itCluster];
// Fill the tot histograms on the first run
if(itTrack == 0) clusterToTVersusTime->Fill((double)cluster->timestamp() / (4096.*40000000.), cluster->tot());
// Check if the cluster is close in time
if( !m_digitalPowerPulsing && abs(cluster->timestamp() - track->timestamp()) > timingCutInt ) continue;
// Check distance between track and cluster
ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
double xdistance = intercept.X() - cluster->globalX();
double ydistance = intercept.Y() - cluster->globalY();
if( abs(xdistance) > spatialCut) continue;
if( abs(ydistance) > spatialCut) continue;
// We now have an associated cluster! Fill plots
associated = true;
// tcout<<"Found associated cluster"<<endl;
......@@ -209,7 +209,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
track->addAssociatedCluster(cluster);
m_nAlignmentClusters++;
hAssociatedTracksGlobalPosition->Fill(globalIntercept.X(),globalIntercept.Y());
// Fill power pulsing response
if( (m_shutterOpenTime != 0 && m_shutterCloseTime == 0) ||
(m_shutterOpenTime != 0 && ( (m_shutterCloseTime > m_shutterOpenTime && m_shutterCloseTime - track->timestamp() > 0) ||
......@@ -219,36 +219,36 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
// Only allow one associated cluster per track
break;
}
if(!associated) hUnassociatedTracksGlobalPosition->Fill(globalIntercept.X(),globalIntercept.Y());
}
// Increment event counter
m_eventNumber++;
// if(m_nAlignmentClusters > 10000) return Failure;
// Return value telling analysis to keep running
return Success;
}
void DUTAnalysis::finalise(){
if(debug) tcout<<"Analysed "<<m_eventNumber<<" events"<<endl;
}
// Function to check if a track goes through a given device
//bool DUTAnalysis::intercept(Track*, string device){
//
//
// // Get the global intercept of the track and the device
// ROOT::Math::XYZPoint intercept = track->intercept(cluster->globalZ());
//
// // Transform to the local co-ordinates
//
//
// // Check if the row/column number is outside the acceptable range
//
//
//
//
//}
#include "FileReader.h"
#include "Timepix3Pixel.h"
#include "Timepix3Cluster.h"
#include "Timepix3Track.h"
#include "objects/Timepix3Pixel.h"
#include "objects/Timepix3Cluster.h"
#include "objects/Timepix3Track.h"
FileReader::FileReader(bool debugging)
: Algorithm("FileReader"){
......@@ -16,10 +16,10 @@ FileReader::FileReader(bool debugging)
}
/*