source: trunk/modules/MadGraphParticleClassifier.cc@ 3

Last change on this file since 3 was 2, checked in by Pavel Demin, 16 years ago

first commit

File size: 3.0 KB
RevLine 
[2]1
2#include "modules/MadGraphParticleClassifier.h"
3
4#include "ExRootAnalysis/ExRootClasses.h"
5
6#include "TClass.h"
7
8#include <iostream>
9
10using namespace std;
11
12//------------------------------------------------------------------------------
13
14MadGraphParticleClassifier::MadGraphParticleClassifier() :
15 fMaxCategories(0), fIsExtendable(kFALSE)
16{
17}
18
19//------------------------------------------------------------------------------
20
21void MadGraphParticleClassifier::InsertParticleStatus(Int_t status)
22{
23 fParticleStatusSet.insert(status);
24}
25
26//------------------------------------------------------------------------------
27
28void MadGraphParticleClassifier::InsertClassPID(const TString &className, Int_t pid)
29{
30 Int_t category;
31 map< TString, Int_t >::const_iterator itClassNameMap;
32
33 itClassNameMap = fClassNameMap.find(className);
34
35 if(itClassNameMap == fClassNameMap.end())
36 {
37 category = fMaxCategories;
38 fClassNameMap[className] = category;
39 fClassNameArray.push_back(className);
40 ++fMaxCategories;
41 }
42 else
43 {
44 category = itClassNameMap->second;
45 }
46 fParticleIDMap[pid] = category;
47}
48
49//------------------------------------------------------------------------------
50
51Int_t MadGraphParticleClassifier::GetCategory(TObject *object)
52{
53 Int_t pidAbs, pid, status;
54 Int_t result = -1;
55
56 if(object->IsA()->InheritsFrom(ExRootLHEFParticle::Class()))
57 {
58 ExRootLHEFParticle *particle = static_cast<ExRootLHEFParticle*>(object);
59 pid = particle->PID;
60 status = particle->Status;
61 }
62 else if(object->IsA()->InheritsFrom(ExRootGenParticle::Class()))
63 {
64 ExRootGenParticle *particle = static_cast<ExRootGenParticle*>(object);
65 pid = particle->PID;
66 status = particle->Status;
67 }
68 else
69 {
70 return -1;
71 }
72
73 map< Int_t, Int_t >::const_iterator itParticleIDMap;
74
75 TString className;
76
77 if(fParticleStatusSet.find(status) == fParticleStatusSet.end()) return -1;
78
79 itParticleIDMap = fParticleIDMap.find(pid);
80
81 if(itParticleIDMap != fParticleIDMap.end())
82 {
83 result = itParticleIDMap->second;
84 }
85 else if(fIsExtendable)
86 {
87 pidAbs = TMath::Abs(pid);
88 className = Form("%d", pidAbs);
89 result = fMaxCategories;
90 InsertClassPID(className, pidAbs);
91 InsertClassPID(className, -pidAbs);
92 }
93
94 return result;
95}
96
97//------------------------------------------------------------------------------
98
99void MadGraphParticleClassifier::SetExtendable(Bool_t extendable)
100{
101 fIsExtendable = extendable;
102}
103
104//------------------------------------------------------------------------------
105
106Int_t MadGraphParticleClassifier::GetMaxCategories() const
107{
108 return fMaxCategories;
109}
110
111//------------------------------------------------------------------------------
112
113TString MadGraphParticleClassifier::GetCategoryClassName(Int_t category) const
114{
115 return fClassNameArray[category];
116}
117
118//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.