Commit 714e48c0 authored by CLICdp Telescope's avatar CLICdp Telescope
Browse files

updated tracking - new version commented until debugged. Removed cout...

updated tracking - new version commented until debugged. Removed cout statements and added member variables for cuts


Former-commit-id: fc1811b22c0d100f05b4c8c91143b0bfafb2b47d
parent bb447768
......@@ -13,6 +13,7 @@ void BasicTracking::initialise(Parameters* par){
// Set up histograms
trackChi2 = new TH1F("trackChi2","trackChi2",150,0,150);
tracksPerEvent = new TH1F("tracksPerEvent","tracksPerEvent",100,0,100);
// Loop over all Timepix3
for(int det = 0; det<parameters->nDetectors; det++){
......@@ -24,6 +25,11 @@ void BasicTracking::initialise(Parameters* par){
name = "residualsY_"+detectorID;
residualsY[detectorID] = new TH1F(name.c_str(),name.c_str(),400,-0.2,0.2);
}
// Default values for cuts
timinigCut = 200./1000000000.; // 10 ns
spatialCut = 0.2; // 200 um
minHitsOnTrack = 6;
}
......@@ -46,7 +52,7 @@ int BasicTracking::run(Clipboard* clipboard){
// Get the clusters
Timepix3Clusters* tempClusters = (Timepix3Clusters*)clipboard->get(detectorID,"clusters");
if(tempClusters == NULL){
tcout<<"Detector "<<detectorID<<" does not have any clusters on the clipboard"<<endl;
if(debug) tcout<<"Detector "<<detectorID<<" does not have any clusters on the clipboard"<<endl;
}else{
// Store them
clusters[detectorID] = tempClusters;
......@@ -77,19 +83,36 @@ int BasicTracking::run(Clipboard* clipboard){
// 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];
// // Don't look for clusters if there are none, or if it is the reference device
// if(detectorID == reference) continue;
// if(clusters[detectorID] == NULL) continue;
// // If the detector is excluded from tracking ignore it
// if(parameters->excludedFromTracking.count(detectorID) != 0) continue;
// // Get the closest cluster
// Timepix3Cluster* newCluster = getNearestCluster(cluster, used, clusters[detectorID]);
// if(newCluster == NULL) continue;
// // Add the cluster to the track
// track->addCluster(newCluster);
// used[newCluster] = true;
// }
// Loop over each subsequent plane and look for a cluster within 100 ns
for(int det=0; det<detectors.size(); det++){
if(detectors[det] == reference) continue;
if(clusters[detectors[det]] == NULL) continue;
if(parameters->excludedFromTracking.count(detectors[det]) != 0) continue;
Timepix3Cluster* newCluster = getNearestCluster(timestamp, (*clusters[detectors[det]]) );
if( ((newCluster->timestamp() - timestamp) / (4096.*40000000.)) > (10./1000000000.) ) continue;
// Check if spatially more than 200 um
if( abs(cluster->globalX() - newCluster->globalX()) > 0.2 || abs(cluster->globalY() - newCluster->globalY()) > 0.2 ) continue;
if( abs(cluster->globalX() - newCluster->globalX()) > spatialCut || abs(cluster->globalY() - newCluster->globalY()) > spatialCut ) continue;
track->addCluster(newCluster);
}
// Now should have a track with one cluster from each plane
if(track->nClusters() < 6){
if(track->nClusters() < minHitsOnTrack){
delete track;
continue;
}
......@@ -114,11 +137,14 @@ int BasicTracking::run(Clipboard* clipboard){
}
tcout<<"Made "<<tracks->size()<<" tracks"<<endl;
if(tracks->size() > 0) clipboard->put("Timepix3","tracks",(TestBeamObjects*)tracks);
if(tracks->size() > 0){
clipboard->put("Timepix3","tracks",(TestBeamObjects*)tracks);
tracksPerEvent->Fill(tracks->size());
}
return 1;
}
Timepix3Cluster* BasicTracking::getNearestCluster(long long int timestamp, Timepix3Clusters clusters){
Timepix3Cluster* bestCluster = NULL;
......@@ -128,10 +154,36 @@ Timepix3Cluster* BasicTracking::getNearestCluster(long long int timestamp, Timep
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];
// // Check if within time window
// if( abs((double)((candidate->timestamp() - cluster->timestamp()) / (4096.*40000000.))) > timinigCut ) continue;
// // Check how close it is (2D - assumes z-axis parallel to beam)
// if(bestCluster == NULL){ bestCluster = candidate; continue; }
// double distanceX = candidate->globalX() - cluster->globalX();
// double distanceY = candidate->globalY() - cluster->globalY();
// double approach = sqrt(distanceX*distanceX + distanceY*distanceY);
// // Check if it is closer than previous clusters, and apply spatial cut
// if( approach < closestApproach && approach < spatialCut){
// bestCluster = candidate;
// closestApproach = approach;
// }
// }
//
// return bestCluster;
//}
void BasicTracking::finalise(){
......
......@@ -22,13 +22,22 @@ public:
int run(Clipboard*);
void finalise();
// Timepix3Cluster* getNearestCluster(Timepix3Cluster*, map<Timepix3Cluster*, bool>, Timepix3Clusters*);
Timepix3Cluster* getNearestCluster(long long int, Timepix3Clusters);
// Member variables
// Histograms
TH1F* trackChi2;
TH1F* tracksPerEvent;
map<string,TH1F*> residualsX;
map<string,TH1F*> residualsY;
// Cuts for tracking
double timinigCut;
double spatialCut;
int minHitsOnTrack;
};
#endif // BASICTRACKING_H
Supports Markdown
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