source: trunk/modules/PythiaFix.cc@ 5

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

first commit

File size: 3.5 KB
RevLine 
[2]1
2#include "modules/PythiaFix.h"
3
4
5#include "ExRootAnalysis/ExRootResult.h"
6#include "ExRootAnalysis/ExRootClasses.h"
7
8#include "ExRootAnalysis/ExRootFilter.h"
9#include "ExRootAnalysis/ExRootClassifier.h"
10
11#include "ExRootAnalysis/ExRootFactory.h"
12#include "ExRootAnalysis/ExRootCandidate.h"
13
14#include "TMath.h"
15#include "TString.h"
16#include "TLorentzVector.h"
17#include "TDatabasePDG.h"
18#include "TClonesArray.h"
19
20#include <iostream>
21#include <set>
22
23using namespace std;
24
25//------------------------------------------------------------------------------
26
27PythiaFix::PythiaFix() :
28 fItBranchParticle(0)
29{
30}
31
32//------------------------------------------------------------------------------
33
34PythiaFix::~PythiaFix()
35{
36}
37
38//------------------------------------------------------------------------------
39
40void PythiaFix::Init()
41{
42 // import ROOT tree branch
43
44 fBranchParticle = UseBranch("GenParticle");
45 fItBranchParticle = fBranchParticle->MakeIterator();
46
47}
48
49//------------------------------------------------------------------------------
50
51void PythiaFix::Finish()
52{
53 if(fItBranchParticle) delete fItBranchParticle;
54}
55
56//------------------------------------------------------------------------------
57
58void PythiaFix::FixDaughters(Int_t indexParticle, Int_t indexMother)
59{
60 ExRootGenParticle *mother = 0;
61 mother = static_cast<ExRootGenParticle*>(fBranchParticle->At(indexMother));
62
63 if(!mother) return;
64
65 // skip beam particles
66 if(mother->M1 < 0 && mother->M2 < 0) return;
67
68 if(mother->D1 < 0 && mother->D2 < 0)
69 {
70 mother->D1 = indexParticle;
71 mother->D2 = indexParticle;
72 }
73 else if(mother->D1 < indexParticle && mother->D2 + 1 == indexParticle)
74 {
75 mother->D2 = indexParticle;
76 }
77 else if(mother->D1 < indexParticle)
78 {
79 mother->D1 = indexParticle;
80 mother->D2 = indexParticle;
81 }
82}
83
84//------------------------------------------------------------------------------
85
86void PythiaFix::Process()
87{
88 ExRootGenParticle *particle = 0;
89 Int_t indexParticle, indexMother;
90
91/*
92 TDatabasePDG *pdg = TDatabasePDG::Instance();
93
94 indexParticle = -1;
95 fItBranchParticle->Reset();
96 while(particle = static_cast<ExRootGenParticle*>(fItBranchParticle->Next()))
97 {
98 ++indexParticle;
99 cout << indexParticle << "\t" << pdg->GetParticle(particle->PID)->GetName() << "\t";
100 cout << particle->Status << "\t" << particle->M1 << "\t" << particle->M2 << "\t";
101 cout << particle->D1 << "\t" << particle->D2 << endl;
102 }
103*/
104
105 indexParticle = -1;
106 fItBranchParticle->Reset();
107 while(particle = static_cast<ExRootGenParticle*>(fItBranchParticle->Next()))
108 {
109 ++indexParticle;
110
111 if(particle->M1 < 0) continue;
112
113 if(particle->M2 < 0)
114 {
115 FixDaughters(indexParticle, particle->M1);
116 }
117 else
118 {
119 for(indexMother = particle->M1; indexMother <= particle->M2; ++indexMother)
120 {
121 FixDaughters(indexParticle, indexMother);
122 }
123 }
124 }
125
126/*
127 cout << "==============================" << endl;
128 indexParticle = -1;
129 fItBranchParticle->Reset();
130 while(particle = static_cast<ExRootGenParticle*>(fItBranchParticle->Next()))
131 {
132 ++indexParticle;
133 cout << indexParticle << "\t" << pdg->GetParticle(particle->PID)->GetName() << "\t";
134 cout << particle->Status << "\t" << particle->M1 << "\t" << particle->M2 << "\t";
135 cout << particle->D1 << "\t" << particle->D2 << endl;
136 }
137*/
138}
139
140//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.