Commit 6b0b9a5c authored by Daniel Hynds's avatar Daniel Hynds
Browse files

updated return code


Former-commit-id: fb52ead9e16dd703351da3aa6571539880eb171c
parent f58f0e66
......@@ -2,6 +2,7 @@
#include "Timepix3Pixel.h"
#include "Timepix3Cluster.h"
#include "Timepix3Track.h"
#include "SpidrSignal.h"
DUTAnalysis::DUTAnalysis(bool debugging)
: Algorithm("DUTAnalysis"){
......@@ -29,12 +30,22 @@ void DUTAnalysis::initialise(Parameters* par){
residualsY = new TH1F("residualsY","residualsY",400,-0.2,0.2);
residualsTime = new TH1F("residualsTime","residualsTime",2000,-0.000001,0.000001);
tracksVersusPowerOnTime = new TH1F("tracksVersusPowerOnTime","tracksVersusPowerOnTime",1200000,-0.01,0.11);
associatedTracksVersusPowerOnTime = new TH1F("associatedTracksVersusPowerOnTime","associatedTracksVersusPowerOnTime",1200000,-0.01,0.11);
// Initialise member variables
m_eventNumber = 0;
m_nAlignmentClusters = 0;
m_powerOnTime = 0;
m_powerOffTime = 0;
}
int DUTAnalysis::run(Clipboard* clipboard){
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;
// Timing cut for association
double timingCut = 200./1000000000.; // 200 ns
......@@ -46,18 +57,46 @@ int DUTAnalysis::run(Clipboard* clipboard){
// Track chi2/ndof cut
double chi2ndofCut = 7.;
// 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_powerOffTime != 0 && m_powerOffTime > m_powerOnTime) m_powerOnTime = 0;
if(m_powerOnTime != 0 && m_powerOnTime > m_powerOffTime) m_powerOffTime = 0;
// Now update the power pulsing with any new signals
SpidrSignals* spidrData = (SpidrSignals*)clipboard->get(parameters->DUT,"SpidrSignals");
// If there are new signals
if(spidrData != NULL){
// Loop over all signals registered
int nSignals = spidrData->size();
for(int iSig=0;iSig<nSignals;iSig++){
// Get the signal
SpidrSignal* signal = (*spidrData)[iSig];
// Register the power on or power off time
if(signal->type() == "powerOn"){
m_powerOnTime = signal->timestamp();
// tcout<<"Power on time: "<<m_powerOnTime/(4096. * 40000000.)<<endl;
}
if(signal->type() == "powerOff"){
m_powerOffTime = signal->timestamp();
// tcout<<"Power off time: "<<m_powerOffTime/(4096. * 40000000.)<<endl;
}
}
}
// Get the tracks from the clipboard
Timepix3Tracks* tracks = (Timepix3Tracks*)clipboard->get("Timepix3","tracks");
if(tracks == NULL){
if(debug) tcout<<"No tracks on the clipboard"<<endl;
return 1;
return Success;
}
// Get the DUT clusters from the clipboard
Timepix3Clusters* clusters = (Timepix3Clusters*)clipboard->get(parameters->DUT,"clusters");
if(clusters == NULL){
if(debug) tcout<<"No DUT clusters on the clipboard"<<endl;
return 1;
return Success;
}
// Loop over all tracks
......@@ -71,10 +110,16 @@ int DUTAnalysis::run(Clipboard* clipboard){
// Cut on the chi2/ndof
if(track->chi2ndof() > chi2ndofCut) continue;
tracksVersusTime->Fill( (double)track->timestamp() / (4096.*40000000.) );
// Check time since power on (if power pulsing).
// If power off time not known it will be 0. If it is known, then the track should arrive before the power goes off
if( m_powerOnTime != 0 && m_powerOffTime == 0 ||
m_powerOnTime != 0 && (m_powerOffTime - track->timestamp()) > 0){
timeSincePowerOn = (double)(track->timestamp() - m_powerOnTime) / (4096.*40000000.);
tracksVersusPowerOnTime->Fill(timeSincePowerOn);
}
// Loop over all DUT clusters
for(int itCluster=0;itCluster<clusters->size();itCluster++){
......@@ -98,6 +143,12 @@ int DUTAnalysis::run(Clipboard* clipboard){
track->addAssociatedCluster(cluster);
m_nAlignmentClusters++;
// Fill power pulsing response
if( m_powerOnTime != 0 && m_powerOffTime == 0 ||
m_powerOnTime != 0 && (m_powerOffTime - track->timestamp()) > 0){
associatedTracksVersusPowerOnTime->Fill(timeSincePowerOn);
}
// Only allow one associated cluster per track
break;
......@@ -108,9 +159,9 @@ int DUTAnalysis::run(Clipboard* clipboard){
// Increment event counter
m_eventNumber++;
// if(m_nAlignmentClusters > 10000) return 0;
// if(m_nAlignmentClusters > 10000) return Failure;
// Return value telling analysis to keep running
return 1;
return Success;
}
void DUTAnalysis::finalise(){
......
......@@ -16,7 +16,7 @@ public:
// Functions
void initialise(Parameters*);
int run(Clipboard*);
StatusCode run(Clipboard*);
void finalise();
// Histograms
......@@ -26,9 +26,16 @@ public:
TH1F* residualsY;
TH1F* residualsTime;
TH1F* tracksVersusPowerOnTime;
TH1F* associatedTracksVersusPowerOnTime;
// Member variables
int m_eventNumber;
int m_nAlignmentClusters;
// bool m_powerOn;
long long int m_powerOnTime;
long long int m_powerOffTime;
};
......
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