Commit 7bbd5895 authored by Daniel Hynds's avatar Daniel Hynds
Browse files

Merge branch 'master' of ssh://gitlab.cern.ch:7999/CLICdp/tbAnalysis


Former-commit-id: 593dca27c340a98f09d372a4c3e8d5f0584f20fc
parents 5530f8a6 aad88ae7
......@@ -6,6 +6,8 @@
ClicpixAnalysis::ClicpixAnalysis(bool debugging)
: Algorithm("ClicpixAnalysis"){
debug = debugging;
m_associationCut = 0.3; // 300 um
m_proximityCut = 0.3; // 300 um
}
......@@ -132,7 +134,7 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard){
return Success;
}
// If this is the first or last trigger don't use the data (trigger number set in fillClusterHistos routine)
// If this is the first or last trigger don't use the data
if( m_triggerNumber == 0 || m_triggerNumber == 19){
m_eventNumber++;
m_triggerNumber++;
......@@ -140,7 +142,7 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard){
}
// Fill the histograms that only need clusters/pixels
// fillClusterHistos(clusters);
fillClusterHistos(clusters);
//Set counters
double nClustersAssociated=0, nValidTracks=0;
......@@ -176,7 +178,7 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard){
// Look if this cluster can be considered associated.
// Cut on the distance from the track in x and y
if ( fabs(ycorr) > 0.3 || fabs(xcorr) > 0.3) continue;
if ( fabs(ycorr) > m_associationCut || fabs(xcorr) > m_associationCut) continue;
// Found a matching cluster
matched=true;
......@@ -207,12 +209,12 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard){
chipInterceptRow > (parameters->detector[dutID]->nPixelsY()-0.5) ) continue;
// Check if the hit is near a masked pixel
// bool hitMasked = checkMasked(chipInterceptRow,chipInterceptCol);
// if(hitMasked) continue;
bool hitMasked = checkMasked(chipInterceptRow,chipInterceptCol);
if(hitMasked) continue;
// Check there are no other tracks nearby
// bool proximityCut = checkProximity(track,tracks);
// if(proximityCut) continue;
bool proximityCut = checkProximity(track,tracks);
if(proximityCut) continue;
// Now have tracks that went through the device
hTrackIntercepts->Fill(trackIntercept.X(),trackIntercept.Y());
......@@ -342,5 +344,71 @@ bool ClicpixAnalysis::checkMasked(double chipInterceptRow, double chipInterceptC
return false;
}
// Check if there is another track close to the selected track.
// "Close" is defined as the intercept at the clicpix
bool ClicpixAnalysis::checkProximity(Track* track, Tracks* tracks){
// Get the intercept of the interested track at the dut
bool close = false;
PositionVector3D< Cartesian3D<double> > trackIntercept = parameters->detector[dutID]->getIntercept(track);
// Loop over all other tracks and check if they intercept close to the track we are considering
Tracks::iterator itTrack;
for (itTrack = tracks->begin(); itTrack != tracks->end(); itTrack++) {
// 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);
// If track == track2 do nothing
if(trackIntercept.X() == trackIntercept2.X() && trackIntercept.Y() == trackIntercept2.Y()) continue;
if( fabs(trackIntercept.X() - trackIntercept2.X()) <= m_proximityCut ||
fabs(trackIntercept.Y() - trackIntercept2.Y()) <= m_proximityCut ) close = true;
}
return close;
}
// Small sub-routine to fill histograms that only need clusters
void ClicpixAnalysis::fillClusterHistos(Clusters* clusters){
// Pick up column to generate unique pixel id
int nCols = parameters->detector[dutID]->nPixelsX();
Clusters::iterator itc;
// Check if this is a new clicpix frame (each frame may be in several events) and
// fill histograms
bool newFrame = false;
for (itc = clusters->begin(); itc != clusters->end(); ++itc) {
// Loop over pixels and check if there are pixels not known
Pixels pixels = (*itc)->pixels();
Pixels::iterator itp;
for (itp = pixels.begin(); itp != pixels.end(); itp++) {
// Check if this clicpix frame is still the current
int pixelID = (*itp)->m_column + nCols*(*itp)->m_row;
if( m_hitPixels[pixelID] != (*itp)->m_adc){
// New frame! Reset the stored pixels and trigger number
if(!newFrame){m_hitPixels.clear(); newFrame=true;}
m_hitPixels[pixelID] = (*itp)->m_adc;
m_triggerNumber=0;
}
hHitPixels->Fill((*itp)->m_column,(*itp)->m_row);
hColumnHits->Fill((*itp)->m_column);
hRowHits->Fill((*itp)->m_row);
}
// Fill cluster histograms
hClusterSizeAll->Fill((*itc)->size());
hClusterTOTAll->Fill((*itc)->tot());
hGlobalClusterPositions->Fill((*itc)->globalX(),(*itc)->globalY());
}
hClustersPerEvent->Fill(clusters->size());
hClustersVersusEventNo->Fill(m_eventNumber,clusters->size());
return;
}
......@@ -19,6 +19,8 @@ public:
StatusCode run(Clipboard*);
void finalise();
bool checkMasked(double, double);
void fillClusterHistos(Clusters*);
bool checkProximity(Track*, Tracks*);
// Cluster/pixel histograms
TH2F* hHitPixels;
......@@ -108,6 +110,9 @@ public:
int m_eventNumber;
int m_triggerNumber;
string dutID;
map<int,double> m_hitPixels;
double m_associationCut;
double m_proximityCut;
};
......
#include "DUTAnalysis.h"
#include "Timepix3Pixel.h"
#include "Timepix3Cluster.h"
#include "Timepix3Track.h"
#include "Pixel.h"
#include "Cluster.h"
#include "Track.h"
#include "SpidrSignal.h"
DUTAnalysis::DUTAnalysis(bool debugging)
......@@ -12,23 +12,16 @@ DUTAnalysis::DUTAnalysis(bool debugging)
void DUTAnalysis::initialise(Parameters* par){
// Pick up a copy of the parameters
parameters = par;
// Initialise histograms per device
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;
}
// Initialise single histograms
tracksVersusTime = new TH1F("tracksVersusTime","tracksVersusTime",6000000,0,60);
associatedTracksVersusTime = new TH1F("associatedTracksVersusTime","associatedTracksVersusTime",6000000,0,60);
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);
clusterToTVersusTime = new TH2F("clusterToTVersusTime","clusterToTVersusTime",10010,-0.01,10.,200,0,1000);
tracksVersusPowerOnTime = new TH1F("tracksVersusPowerOnTime","tracksVersusPowerOnTime",1200000,-0.01,0.11);
associatedTracksVersusPowerOnTime = new TH1F("associatedTracksVersusPowerOnTime","associatedTracksVersusPowerOnTime",1200000,-0.01,0.11);
......@@ -86,14 +79,14 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
}
// Get the tracks from the clipboard
Timepix3Tracks* tracks = (Timepix3Tracks*)clipboard->get("Timepix3","tracks");
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
Timepix3Clusters* clusters = (Timepix3Clusters*)clipboard->get(parameters->DUT,"clusters");
Clusters* clusters = (Clusters*)clipboard->get(parameters->DUT,"clusters");
if(clusters == NULL){
if(debug) tcout<<"No DUT clusters on the clipboard"<<endl;
return Success;
......@@ -103,7 +96,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
for(int itTrack=0;itTrack<tracks->size();itTrack++){
// Get the track pointer
Timepix3Track* track = (*tracks)[itTrack];
Track* track = (*tracks)[itTrack];
// Check if it intercepts the DUT
// if(!intercept(track,parameters->DUT)) continue;
......@@ -124,7 +117,10 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard){
for(int itCluster=0;itCluster<clusters->size();itCluster++){
// Get the cluster pointer
Timepix3Cluster* cluster = (*clusters)[itCluster];
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( abs(cluster->timestamp() - track->timestamp()) > timingCutInt ) continue;
......@@ -171,7 +167,7 @@ void DUTAnalysis::finalise(){
}
// Function to check if a track goes through a given device
//bool DUTAnalysis::intercept(Timepix3Track*, string 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());
......
......@@ -25,7 +25,8 @@ public:
TH1F* residualsX;
TH1F* residualsY;
TH1F* residualsTime;
TH2F* clusterToTVersusTime;
TH1F* tracksVersusPowerOnTime;
TH1F* associatedTracksVersusPowerOnTime;
......
......@@ -8,6 +8,7 @@ Parameters::Parameters(){
histogramFile = "outputHistograms.root";
conditionsFile = "cond.dat";
dutMaskFile = "defaultMask.dat";
inputDirectory = "";
nEvents = 0;
align = false;
......@@ -126,7 +127,6 @@ bool Parameters::writeConditions(){
}
bool Parameters::readConditions(){
// Open the conditions file to read detector information
......@@ -184,4 +184,41 @@ bool Parameters::readConditions(){
}
void Parameters::readDutMask() {
// If no masked file set, do nothing
if(dutMaskFile == "defaultMask.dat") return;
detector[this->DUT]->setMaskFile(dutMaskFile);
// Open the file with masked pixels
std::fstream inputMaskFile(dutMaskFile.c_str(), std::ios::in);
int row,col; std::string id;
std::string line;
// loop over all lines and apply masks
while(getline(inputMaskFile,line)){
inputMaskFile >> id >> row >> col;
if(id == "c") maskDutColumn(col); // Flag to mask a column
if(id == "r") maskDutRow(row); // Flag to mask a row
if(id == "p") detector[this->DUT]->maskChannel(col,row); // Flag to mask a pixel
}
return;
}
// The masking of pixels on the dut uses a map with unique
// id for each pixel given by column + row*numberColumns
void Parameters::maskDutColumn(int column){
int nRows = detector[this->DUT]->nPixelsY();
for(int row=0;row<nRows;row++) detector[this->DUT]->maskChannel(column,row);
}
void Parameters::maskDutRow(int row){
int nColumns = detector[this->DUT]->nPixelsX();
for(int column=0;column<nColumns;column++) detector[this->DUT]->maskChannel(column,row);
}
#ifndef PARAMETERS_H
#ifndef PARAMETERS_H
#define PARAMETERS_H 1
// Include files
......@@ -217,17 +217,21 @@ public:
bool readConditions();
bool writeConditions();
void readCommandLineOptions(int, char**);
void readDutMask();
void maskDutColumn(int);
void maskDutRow(int);
void registerDetector(string detectorID){
nDetectors++;
detectors.push_back(detectorID);
}
// Member variables
string conditionsFile;
string inputTupleFile;
string inputDirectory;
string outputTupleFile;
string histogramFile;
string dutMaskFile;
vector<string> detectors;
int nDetectors;
string reference;
......
......@@ -81,8 +81,12 @@ int main(int argc, char *argv[]) {
// =========================================================================
// General parameters
parameters->reference = "Mim-osa02";
parameters->DUT = "CLi-CPix";
// parameters->reference = "Mim-osa02";
// parameters->DUT = "CLi-CPix";
parameters->reference = "W0013_G03";
// parameters->DUT = "W0019_L08";
parameters->DUT = "W0019_F07";
parameters->detectorToAlign = parameters->DUT;
parameters->excludedFromTracking[parameters->DUT] = true;
......@@ -93,7 +97,7 @@ int main(int argc, char *argv[]) {
parameters->excludedFromTracking["W0019_F07"] = true;
parameters->excludedFromTracking["W0019_L08"] = true;
parameters->excludedFromTracking["W0005_H03"] = true;
// =========================================================================
// Steering file ends
// =========================================================================
......@@ -104,20 +108,23 @@ int main(int argc, char *argv[]) {
// Load alignment parameters
if(!parameters->readConditions()) return 0;
// Load mask file for the dut (if specified)
parameters->readDutMask();
// Initialise the analysis object and add algorithms to run
analysis = new Analysis(parameters);
analysis->add(tpix1EventLoader);
// analysis->add(fileReader);
// analysis->add(tpix1Clustering);
// analysis->add(spatialTracking);
// analysis->add(correlator);
// analysis->add(tpix1EventLoader);
analysis->add(fileReader);
analysis->add(tpix1Clustering);
analysis->add(spatialTracking);
analysis->add(correlator);
// analysis->add(tpix3EventLoader);
// analysis->add(tpix3Clustering);
// analysis->add(testAlgorithm);
// analysis->add(basicTracking);
// analysis->add(dutAnalysis);
// analysis->add(clicpixAnalysis);
analysis->add(fileWriter);
analysis->add(clicpixAnalysis);
// analysis->add(fileWriter);
if(parameters->align) analysis->add(alignment);
if(parameters->produceMask) analysis->add(tpix3MaskCreator);
......
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