FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndPidTestTask Class Reference

#include <PndPidTestTask.h>

Inheritance diagram for PndPidTestTask:

Public Member Functions

 PndPidTestTask ()
 
 ~PndPidTestTask ()
 
virtual InitStatus Init ()
 
virtual void Exec (Option_t *opt)
 
virtual void Finish ()
 
void SetClassifier (TString val)
 
void SetSelector (TString val)
 
void PrintConfusionMatrix (bool relative=false)
 
std::vector< std::vector< int > > GetConfusionMatrix () const
 

Private Member Functions

virtual void SetParContainers ()
 
 ClassDef (PndPidTestTask, 1)
 

Private Attributes

int fEvtCount
 
std::vector< std::vector< int > > fConfusionMatrix
 
std::map< int, int > fPdgIndex
 
std::vector< std::string > fParticleNames
 
PndAnalysisfAnalysis
 
TString fClassifier
 
TString fSelector
 
std::vector< RhoCandList * > fCandLists
 

Detailed Description

Definition at line 21 of file PndPidTestTask.h.

Constructor & Destructor Documentation

PndPidTestTask::PndPidTestTask ( )

Definition at line 49 of file PndPidTestTask.cxx.

References fCandLists, fConfusionMatrix, fParticleNames, fPdgIndex, i, and vec.

49  :
50  FairTask("Panda Pid Test Task") {
51 
52  fPdgIndex[11] = 0;
53  fPdgIndex[13] = 1;
54  fPdgIndex[211] = 2;
55  fPdgIndex[321] = 3;
56  fPdgIndex[2212] = 4;
57  fPdgIndex[-11] = 5;
58  fPdgIndex[-13] = 6;
59  fPdgIndex[-211] = 7;
60  fPdgIndex[-321] = 8;
61  fPdgIndex[-2212] = 9;
62 
63  fParticleNames.push_back("Electron");
64  fParticleNames.push_back("Muon");
65  fParticleNames.push_back("Pion");
66  fParticleNames.push_back("Kaon");
67  fParticleNames.push_back("Proton");
68 
69 
70  std::cout << "fPdgIndex.size()1 = " << fPdgIndex.size() << std::endl;
71 
72  for (int i = 0; i < fPdgIndex.size(); i++){
73  std::vector<int> vec(fPdgIndex.size(), 0);
74  fConfusionMatrix.push_back(vec);
75  }
76 
77  // *** RhoCandLists for the analysis
78  for (int i = 0; i < fPdgIndex.size(); i++){
79  fCandLists.push_back(new RhoCandList());
80  }
81 }
Int_t i
Definition: run_full.C:25
std::vector< RhoCandList * > fCandLists
std::map< int, int > fPdgIndex
std::vector< std::string > fParticleNames
dble_vec_t vec[12]
Definition: ranlxd.cxx:380
std::vector< std::vector< int > > fConfusionMatrix
PndPidTestTask::~PndPidTestTask ( )

Definition at line 86 of file PndPidTestTask.cxx.

86 { }

Member Function Documentation

PndPidTestTask::ClassDef ( PndPidTestTask  ,
 
)
private
void PndPidTestTask::Exec ( Option_t *  opt)
virtual

Definition at line 117 of file PndPidTestTask.cxx.

References fAnalysis, fCandLists, fClassifier, fConfusionMatrix, fEvtCount, PndAnalysis::FillList(), fParticleNames, fPdgIndex, fSelector, fVerbose, PndAnalysis::GetEventInTask(), RhoCandidate::GetMcTruth(), RhoCandidate::PdgCode(), and RhoCandidate::PrintOn().

118 {
119  // *** some variables
120  int j=0;
121 
122  // necessary to read the next event
124 
125  if (!(++fEvtCount%100)) cout << "evt "<<fEvtCount<<endl;
126 
127 
128 
129 
140 
141  int candListIndex = 0;
142  for (auto candidates : fCandLists){
143  if (fVerbose > 1) std::cout << "CandList " << candListIndex++ << " Entries: " << candidates->GetLength() << std::endl;
144  for (int candInd = 0; candInd < candidates->GetLength(); candInd++){
145  RhoCandidate* cand = (*candidates)[candInd];
146  if (fVerbose > 1) cand->PrintOn(std::cout);
147  if (fVerbose > 1) std::cout << std::endl;
148  RhoCandidate* mccand = cand->GetMcTruth();
149  if (fVerbose > 1) std::cout << candInd << " Cand: " << cand->PdgCode() << " MCCand " << mccand->PdgCode() << std::endl;
150  if (fVerbose > 1) std::cout << *(FairMultiLinkedData_Interface*)mccand << std::endl;
151  if (fPdgIndex.count(cand->PdgCode()) > 0 && fPdgIndex.count(mccand->PdgCode()) > 0){
152  fConfusionMatrix[fPdgIndex[mccand->PdgCode()]][fPdgIndex[cand->PdgCode()]]++;
153  } else {
154  std::cout << "-W- PndPidTestTask::Exec Wrong PDG Codes: Cand: " << cand->PdgCode() << " MCCand: " << mccand->PdgCode() << std::endl;
155  }
156  }
157  }
158 
159 }
int fVerbose
Definition: poormantracks.C:24
PndAnalysis * fAnalysis
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
std::vector< RhoCandList * > fCandLists
void GetEventInTask()
std::map< int, int > fPdgIndex
void PrintOn(std::ostream &o=std::cout) const
std::vector< std::string > fParticleNames
RhoCandidate * GetMcTruth() const
Definition: RhoCandidate.h:437
TString fClassifier
std::vector< std::vector< int > > fConfusionMatrix
void PndPidTestTask::Finish ( )
virtual

Definition at line 181 of file PndPidTestTask.cxx.

References PrintConfusionMatrix().

182 {
183  PrintConfusionMatrix(false);
184  PrintConfusionMatrix(true);
185 
186 }
void PrintConfusionMatrix(bool relative=false)
std::vector<std::vector <int> > PndPidTestTask::GetConfusionMatrix ( ) const
inline

Definition at line 50 of file PndPidTestTask.h.

References fConfusionMatrix.

50 {return fConfusionMatrix;}
std::vector< std::vector< int > > fConfusionMatrix
InitStatus PndPidTestTask::Init ( )
virtual

Definition at line 93 of file PndPidTestTask.cxx.

References fAnalysis, and fEvtCount.

94 {
95  // initialize analysis object
96  fAnalysis = new PndAnalysis();
97 
98  // reset the event counter
99  fEvtCount = 0;
100 
101  return kSUCCESS;
102 }
PndAnalysis * fAnalysis
void PndPidTestTask::PrintConfusionMatrix ( bool  relative = false)

Definition at line 161 of file PndPidTestTask.cxx.

References fConfusionMatrix, fParticleNames, fPdgIndex, and i.

Referenced by Finish().

161  {
162  for (int i = 0; i < fPdgIndex.size(); i++){
163  std::cout << i << " : " << std::setw(15) << fParticleNames[i%fParticleNames.size()] + ((i < fParticleNames.size()) ? "Plus" : "Minus") << " : ";
164  for (int j = 0; j < fPdgIndex.size(); j++){
165  if (relative == false)
166  std::cout << std::setw(5) << fConfusionMatrix[i][j] << " ";
167  else {
168  std::cout << std::setw(5);
169  int entryCount = std::accumulate(fConfusionMatrix[i].begin(), fConfusionMatrix[i].end(), 0);
170  if (entryCount > 0)
171  std::cout << std::fixed << std::setprecision(2) << fConfusionMatrix[i][j] / (double)entryCount << " ";
172  else
173  std::cout << std::fixed << std::setprecision(2) << 0.0 << " ";
174  }
175  }
176  std::cout << std::endl;
177  }
178 }
Int_t i
Definition: run_full.C:25
std::map< int, int > fPdgIndex
std::vector< std::string > fParticleNames
std::vector< std::vector< int > > fConfusionMatrix
void PndPidTestTask::SetClassifier ( TString  val)
inline

Definition at line 40 of file PndPidTestTask.h.

References fClassifier, and val.

Referenced by pidTest_complete().

40  {
41  fClassifier = val;
42  }
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
TString fClassifier
void PndPidTestTask::SetParContainers ( )
privatevirtual

Definition at line 106 of file PndPidTestTask.cxx.

References run.

107 {
108  // Get run and runtime database
109  FairRun* run = FairRun::Instance();
110  if ( ! run ) Fatal("SetParContainers", "No analysis run");
111 }
Int_t run
Definition: autocutx.C:47
void PndPidTestTask::SetSelector ( TString  val)
inline

Definition at line 44 of file PndPidTestTask.h.

References fSelector, and val.

Referenced by pidTest_complete().

44  {
45  fSelector = val;
46  }
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11

Member Data Documentation

PndAnalysis* PndPidTestTask::fAnalysis
private

Definition at line 66 of file PndPidTestTask.h.

Referenced by Exec(), and Init().

std::vector<RhoCandList*> PndPidTestTask::fCandLists
private

Definition at line 74 of file PndPidTestTask.h.

Referenced by Exec(), and PndPidTestTask().

TString PndPidTestTask::fClassifier
private

Definition at line 72 of file PndPidTestTask.h.

Referenced by Exec(), and SetClassifier().

std::vector<std::vector <int> > PndPidTestTask::fConfusionMatrix
private

Definition at line 59 of file PndPidTestTask.h.

Referenced by Exec(), GetConfusionMatrix(), PndPidTestTask(), and PrintConfusionMatrix().

int PndPidTestTask::fEvtCount
private

Definition at line 57 of file PndPidTestTask.h.

Referenced by Exec(), and Init().

std::vector<std::string> PndPidTestTask::fParticleNames
private

Definition at line 61 of file PndPidTestTask.h.

Referenced by Exec(), PndPidTestTask(), and PrintConfusionMatrix().

std::map<int, int> PndPidTestTask::fPdgIndex
private

Definition at line 60 of file PndPidTestTask.h.

Referenced by Exec(), PndPidTestTask(), and PrintConfusionMatrix().

TString PndPidTestTask::fSelector
private

Definition at line 73 of file PndPidTestTask.h.

Referenced by Exec(), and SetSelector().


The documentation for this class was generated from the following files: