Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-04 09:11:23

0001 #include "Confusion.h"
0002 Confusion::Confusion(){
0003   constexpr int N = 5;
0004   m_ConfusionMatrix = std::make_unique<TH2D>("Confusion",
0005                          "RICH PID Confusion Matrix;Reco PID;True PID",
0006                          N, 0, N,
0007                          N, 0, N
0008                          );
0009 
0010 }
0011 Confusion::~Confusion(){
0012   std::cout<<"Confusion Destructed"<<std::endl;
0013 }
0014 void Confusion::BookConfusionMatrix(){ 
0015   constexpr int N = 5;
0016   const char* labels[] = {"e", "#pi", "K", "p", "#mu"};
0017 
0018   for (int i = 0; i < N; ++i) {
0019     m_ConfusionMatrix->GetXaxis()->SetBinLabel(i + 1, labels[i]);
0020     m_ConfusionMatrix->GetYaxis()->SetBinLabel(i + 1, labels[i]);
0021   }
0022   m_ConfusionMatrix->Write();
0023 }
0024 
0025 void Confusion::FillConfusion(int reco, int truth) {
0026   m_ConfusionMatrix->Fill(reco,truth);
0027 }
0028 int Confusion::PDGToBin(int pdg) {
0029   switch (std::abs(pdg)) { 
0030   case 11:   return 0;
0031   case 211:  return 1;
0032   case 321:  return 2;
0033   case 2212: return 3;
0034   case 13:   return 4;
0035   default:   return -1;
0036   }
0037 }