Commit 94229c5b authored by Daniel Hynds's avatar Daniel Hynds
Browse files

added optional MC truth residual distribution

parent 5bec5161
#include "DUTAnalysis.h" #include "DUTAnalysis.h"
#include "objects/Cluster.h" #include "objects/Cluster.h"
#include "objects/Pixel.h" #include "objects/Pixel.h"
#include "objects/MCParticle.h"
#include "objects/SpidrSignal.h" #include "objects/SpidrSignal.h"
#include "objects/Track.h" #include "objects/Track.h"
...@@ -10,6 +11,7 @@ DUTAnalysis::DUTAnalysis(Configuration config, std::vector<Detector*> detectors) ...@@ -10,6 +11,7 @@ DUTAnalysis::DUTAnalysis(Configuration config, std::vector<Detector*> detectors)
: Algorithm(std::move(config), std::move(detectors)) { : Algorithm(std::move(config), std::move(detectors)) {
m_digitalPowerPulsing = m_config.get<bool>("digitalPowerPulsing", false); m_digitalPowerPulsing = m_config.get<bool>("digitalPowerPulsing", false);
m_DUT = m_config.get<std::string>("DUT"); m_DUT = m_config.get<std::string>("DUT");
m_useMCtruth = m_config.get<bool>("useMCtruth", false);
} }
void DUTAnalysis::initialise() { void DUTAnalysis::initialise() {
...@@ -40,6 +42,10 @@ void DUTAnalysis::initialise() { ...@@ -40,6 +42,10 @@ void DUTAnalysis::initialise() {
hUnassociatedTracksGlobalPosition = hUnassociatedTracksGlobalPosition =
new TH2F("hUnassociatedTracksGlobalPosition", "hUnassociatedTracksGlobalPosition", 200, -10, 10, 200, -10, 10); new TH2F("hUnassociatedTracksGlobalPosition", "hUnassociatedTracksGlobalPosition", 200, -10, 10, 200, -10, 10);
if(m_useMCtruth){
residualsXMCtruth = new TH1F("residualsXMCtruth", "residualsXMCtruth", 400, -0.2, 0.2);
}
// Initialise member variables // Initialise member variables
m_eventNumber = 0; m_eventNumber = 0;
m_nAlignmentClusters = 0; m_nAlignmentClusters = 0;
...@@ -121,6 +127,12 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) { ...@@ -121,6 +127,12 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
LOG(DEBUG) << "No DUT clusters on the clipboard"; LOG(DEBUG) << "No DUT clusters on the clipboard";
} }
// Get the MC particles from the clipboard
MCParticles* mcParticles = (MCParticles*)clipboard->get(m_DUT, "mcparticles");
if(mcParticles == NULL) {
LOG(DEBUG) << "No DUT MC particles on the clipboard";
}
// Loop over all tracks // Loop over all tracks
bool first_track = true; bool first_track = true;
for(auto& track : (*tracks)) { for(auto& track : (*tracks)) {
...@@ -238,6 +250,24 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) { ...@@ -238,6 +250,24 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
m_nAlignmentClusters++; m_nAlignmentClusters++;
hAssociatedTracksGlobalPosition->Fill(globalIntercept.X(), globalIntercept.Y()); hAssociatedTracksGlobalPosition->Fill(globalIntercept.X(), globalIntercept.Y());
// Get associated MC particle info and plot
if(m_useMCtruth){
if(mcParticles == nullptr) continue;
// Find the closest MC particle
double smallestDistance(DBL_MAX); ROOT::Math::XYZPoint particlePosition;
for(auto& particle : (*mcParticles)) {
ROOT::Math::XYZPoint entry = particle->getLocalStart();
ROOT::Math::XYZPoint exit = particle->getLocalEnd();
ROOT::Math::XYZPoint centre( (entry.X()+exit.X())/2., (entry.Y()+exit.Y())/2., (entry.Z()+exit.Z())/2. );
double distance = sqrt( (centre.X() - cluster->localX())*(centre.X() - cluster->localX()) +
(centre.Y() - cluster->localY())*(centre.Y() - cluster->localY()) );
if(distance < smallestDistance){
particlePosition.SetXYZ(centre.X(),centre.Y(),centre.Z());
}
}
residualsXMCtruth->Fill(cluster->localX() - particlePosition.X());
}
// Fill power pulsing response // Fill power pulsing response
if((m_shutterOpenTime != 0 && m_shutterCloseTime == 0) || if((m_shutterOpenTime != 0 && m_shutterCloseTime == 0) ||
(m_shutterOpenTime != 0 && (m_shutterOpenTime != 0 &&
......
...@@ -34,6 +34,8 @@ namespace corryvreckan { ...@@ -34,6 +34,8 @@ namespace corryvreckan {
TH2F* clusterToTVersusTime; TH2F* clusterToTVersusTime;
TH2F* residualsTimeVsTime; TH2F* residualsTimeVsTime;
TH1F* residualsXMCtruth;
TH2F* hAssociatedTracksGlobalPosition; TH2F* hAssociatedTracksGlobalPosition;
TH2F* hUnassociatedTracksGlobalPosition; TH2F* hUnassociatedTracksGlobalPosition;
...@@ -44,6 +46,7 @@ namespace corryvreckan { ...@@ -44,6 +46,7 @@ namespace corryvreckan {
std::string m_DUT; std::string m_DUT;
int m_eventNumber; int m_eventNumber;
int m_nAlignmentClusters; int m_nAlignmentClusters;
bool m_useMCtruth;
long long int m_powerOnTime; long long int m_powerOnTime;
long long int m_powerOffTime; long long int m_powerOffTime;
long long int m_shutterOpenTime; long long int m_shutterOpenTime;
......
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