Skip to content
Browse files

Draw AllTrackerLayersFlagEfficiency for each particle species.

  • Loading branch information...
1 parent 8b80273 commit 95e423e0de2ba13734be0dbd7fbed5ecc4d7c980 Roman Greim committed Mar 16, 2012
View
76 tools/analysis/AllTrackerLayersFlagEfficiency.cc
@@ -18,40 +18,50 @@
#include <QSpinBox>
-AllTrackerLayersFlagEfficiency::AllTrackerLayersFlagEfficiency(bool fineBinned)
+AllTrackerLayersFlagEfficiency::AllTrackerLayersFlagEfficiency(Enums::Particles particles, bool fineBinned)
: AnalysisPlot(Enums::MiscellaneousTracker)
, H1DPlot()
- , m_passedCutHistogram(0)
- , m_totalHistogram(0)
+ , m_particles(Enums::particleVector(particles))
+ , m_passedCutHistograms(0)
+ , m_totalHistograms(0)
{
QString title = "all tracker layers flag efficiency";
if (fineBinned)
title+= " fine";
setTitle(title);
QVector<double> axis = Helpers::rigidityBinning(fineBinned);
- int axisSize = 2 * axis.size();
- for (int i = 0; i < axisSize; i+= 2) {
- double value = axis.at(i);
- axis.prepend(-value);
- }
const int nBins = axis.size() - 1;
- TH1D* histogram = new TH1D(qPrintable(title), "", nBins, axis.constData());
- histogram->Sumw2();
- setAxisTitle("R / GV", "efficiency");
- addHistogram(histogram, H1DPlot::P);
+ foreach (Enums::Particle particle, m_particles) {
+ QString histogramTitle = title + ' ' + Enums::label(particle);
+
+ ParticleProperties properties(particle);
+
+ TH1D* h = 0;
+
+ h = new TH1D(qPrintable(histogramTitle), "", nBins, axis.constData());
+ h->Sumw2();
+ h->SetLineColor(properties.color());
+ h->SetMarkerColor(properties.color());
+ addHistogram(h, H1DPlot::P);
+
+ h = new TH1D(qPrintable(histogramTitle + " passed"), "", nBins, axis.constData());
+ h->Sumw2();
+ m_passedCutHistograms.append(h);
+
+ h = new TH1D(qPrintable(histogramTitle + " total"), "", nBins, axis.constData());
+ h->Sumw2();
+ m_totalHistograms.append(h);
+ }
- m_passedCutHistogram = new TH1D(qPrintable(title + " passed"), "", nBins, axis.constData());
- m_passedCutHistogram->Sumw2();
- m_totalHistogram = new TH1D(qPrintable(title + " total"), "", nBins, axis.constData());
- m_totalHistogram->Sumw2();
+ setAxisTitle("|R| / GV", "efficiency");
}
AllTrackerLayersFlagEfficiency::~AllTrackerLayersFlagEfficiency()
{
- delete m_totalHistogram;
- delete m_passedCutHistogram;
+ qDeleteAll(m_totalHistograms);
+ qDeleteAll(m_passedCutHistograms);
}
void AllTrackerLayersFlagEfficiency::processEvent(const AnalyzedEvent* event)
@@ -63,25 +73,29 @@ void AllTrackerLayersFlagEfficiency::processEvent(const AnalyzedEvent* event)
return;
//TODO: right albedo handling
- double rigidity = event->particle()->hypothesis()->rigidity();
- m_totalHistogram->Fill(rigidity);
+ const Hypothesis* h = event->particle()->hypothesis();
+ int i = m_particles.indexOf(h->particle());
+ m_totalHistograms[i]->Fill(h->absoluteRigidity());
if (!event->flagsSet(ParticleInformation::AllTrackerLayers))
return;
- m_passedCutHistogram->Fill(rigidity);
+ m_passedCutHistograms[i]->Fill(h->absoluteRigidity());
}
void AllTrackerLayersFlagEfficiency::update()
{
- for (int i = 0; i < m_totalHistogram->GetNbinsX(); ++i) {
- int reconstructed = m_passedCutHistogram->GetBinContent(i+1);
- int total = m_totalHistogram->GetBinContent(i+1);
- double efficiency = 0;
- double efficiencyError = 0;
- if (total != 0) {
- efficiency = double(reconstructed) / double(total);
- efficiencyError = sqrt(efficiency * (1 - efficiency) / double(total));
+ foreach (Enums::Particle particle, m_particles) {
+ int i = m_particles.indexOf(particle);
+ for (int bin = 0; bin < m_totalHistograms[i]->GetNbinsX(); ++bin) {
+ int reconstructed = m_passedCutHistograms[i]->GetBinContent(bin+1);
+ int total = m_totalHistograms[i]->GetBinContent(bin+1);
+ double efficiency = 0;
+ double efficiencyError = 0;
+ if (total != 0) {
+ efficiency = double(reconstructed) / double(total);
+ efficiencyError = sqrt(efficiency * (1 - efficiency) / double(total));
+ }
+ histogram(i)->SetBinContent(bin+1, efficiency);
+ histogram(i)->SetBinError(bin+1, efficiencyError);
}
- histogram()->SetBinContent(i+1, efficiency);
- histogram()->SetBinError(i+1, efficiencyError);
}
}
View
7 tools/analysis/AllTrackerLayersFlagEfficiency.hh
@@ -10,13 +10,14 @@ class TCanvas;
class AllTrackerLayersFlagEfficiency : public AnalysisPlot, public H1DPlot
{
public:
- AllTrackerLayersFlagEfficiency(bool fineBinned);
+ AllTrackerLayersFlagEfficiency(Enums::Particles, bool fineBinned);
~AllTrackerLayersFlagEfficiency();
void processEvent(const AnalyzedEvent*);
void update();
private:
- TH1D* m_passedCutHistogram;
- TH1D* m_totalHistogram;
+ QVector<Enums::Particle> m_particles;
+ QVector<TH1D*> m_passedCutHistograms;
+ QVector<TH1D*> m_totalHistograms;
};
#endif /* AllTrackerLayersFlagEfficiency_hh */
View
2 tools/analysis/Analysis.cc
@@ -406,7 +406,7 @@ void Analysis::setupPlots()
addPlot(new MeasurementTimePlot(first, last));
addPlot(new MeasurementTimeDistributionPlot(m_analysisSetting.numberOfThreads()));
addPlot(new EventTimeDifferencePlot(m_analysisSetting.numberOfThreads()));
- addPlot(new EfficiencyCollection());
+ addPlot(new EfficiencyCollection(m_analysisSetting.particles()));
}
if (m_analysisSetting.analysisTopics() & Enums::LikelihoodTopic) {
Enums::ParticleIterator end = Enums::particleEnd();
View
6 tools/analysis/EfficiencyCollection.cc
@@ -14,7 +14,7 @@
#include <QVector>
#include <QDebug>
-EfficiencyCollection::EfficiencyCollection()
+EfficiencyCollection::EfficiencyCollection(Enums::Particles particles)
: PlotCollection(Enums::FluxCalculation)
{
QWidget* widget = new QWidget;
@@ -26,10 +26,10 @@ EfficiencyCollection::EfficiencyCollection()
secondaryWidget()->layout()->addWidget(widget);
setTitle("efficiency collection");
- addPlot(new AllTrackerLayersFlagEfficiency(false));
+ addPlot(new AllTrackerLayersFlagEfficiency(particles, false));
comboBox->addItem("AllTrackerLayersFlagEfficiency");
- addPlot(new AllTrackerLayersFlagEfficiency(true));
+ addPlot(new AllTrackerLayersFlagEfficiency(particles, true));
comboBox->addItem("AllTrackerLayersFlagEfficiency fine");
addPlot(new TrackFindingEfficiency(false));
View
2 tools/analysis/EfficiencyCollection.hh
@@ -7,7 +7,7 @@ class TH1D;
class EfficiencyCollection : public PlotCollection {
public:
- EfficiencyCollection();
+ EfficiencyCollection(Enums::Particles);
~EfficiencyCollection();
};
View
2 tools/analysis/MainWindow.cc
@@ -214,8 +214,6 @@ void MainWindow::setupSettingsTab()
m_ui.settingsTab->setLayout(layout);
}
-
-
void MainWindow::setupCutSelectors()
{
QVBoxLayout* layout = new QVBoxLayout;

0 comments on commit 95e423e

Please sign in to comment.
Something went wrong with that request. Please try again.