3 July 2008 BW mass is limited by "PYTHIA method", by I. Lokhtin and L. Malinina
6 Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
7 amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
21 #include "DatabasePDG.h"
24 #include "ParticlePDG.h"
27 #include "DecayChannel.h"
29 #ifndef HADRONDECAYER_INCLUDED
30 #include "HadronDecayer.h"
32 #ifndef UKUTILITY_INCLUDED
33 #include "UKUtility.h"
35 #ifndef PARTICLE_INCLUDED
38 #include "HYJET_COMMONS.h"
40 //calculates decay time in fm/c
41 //calculates 1,2 and 3 body decays
46 Double_t GetDecayTime(const Particle &parent, Double_t weakDecayLimit) {
47 ParticlePDG *pDef = parent.Def();
48 Double_t width = pDef->GetWidth(); //GeV
49 if(width > weakDecayLimit) {
50 const Double_t slope = parent.E() * 0.1973 / (pDef->GetMass() * width);
51 // cout<<"get decay time"<<pDef->GetPDG()<<" "<<slope<<endl;
52 return -slope * TMath::Log(gRandom->Rndm());//in fm/c
59 extern "C" void mydelta_();
60 extern SERVICEEVCommon SERVICEEV;
62 void Decay(List_t &output, Particle &parent, ParticleAllocator &allocator, DatabasePDG* database) {
63 // check if the parent particle has been decayed already
65 Int_t daughters = parent.GetNDaughters();
67 //cout<<"in Decay pdg"<< parent.Def()->GetPDG()<<"daughters "<<daughters<<endl;
69 if(daughters>0) // particle decayed already
72 // Get the PDG properties of the particle
73 ParticlePDG *pDef = parent.Def();
75 // Get the number of posible decay channels
76 Int_t nDecayChannel = pDef->GetNDecayChannels();
78 // check the full branching of this specie
79 Double_t fullBranching = pDef->GetFullBranching(); // Only 3 or less body decays
81 // return if particle has no branching
82 if(fullBranching < 0.00001)
85 // get the PDG mass of the specie
86 Double_t PDGmass = pDef->GetMass();
90 Bool_t success = kFALSE;
92 // Try to decay the particle
94 // get a random mass using the Breit Wigner distribution
95 Double_t BWmass = gRandom->BreitWigner(PDGmass, pDef->GetWidth());
98 // Try to cut the Breit Wigner tail of the particle using the cuts from pythia
99 // The Delta variable is obtained from pythia based on the specie
100 int encoding =pDef->GetPDG();
101 SERVICEEV.ipdg = encoding;
103 ComprCodePyth=SERVICEEV.KC;
104 Delta = SERVICEEV.delta;// PYDAT2.PMAS[KC][3];
106 //if there are no such particle in PYTHIA particle table, we take Delta=0.4
107 if(ComprCodePyth==0){
112 //bad delta - an exception
113 if(ComprCodePyth==254){
118 //for particles from PYTHIA table only, if the BW mass is outside the cut range then quit this iteration and generate another BW mass
119 if(ComprCodePyth!=0 && Delta>0 && (BWmass<PDGmass-Delta || BWmass>PDGmass+Delta)){
120 // std::cout<<"encoding"<<encoding<<"delta"<<Delta<<"width "<<pDef->GetWidth()<<"mass"<<BWmass<<std::endl;
126 std::cout<<" > 5 encoding"<<encoding<<" pdgmass "<<PDGmass<<" delta "<<Delta<<"width "<<pDef->GetWidth()<<" mass "<<BWmass<<"CC"<<ComprCodePyth<<std::endl;
128 // check how many decay channels are allowed with the generated mass
129 Int_t nAllowedChannels = database->GetNAllowedChannels(pDef, BWmass);
130 // if no decay channels are posible with this mass, then generate another BW mass
131 if(nAllowedChannels==0) {
136 std::vector<Particle> apDaughter;
137 std::vector<Double_t> dMass; //daughters'mass
138 std::vector<Double_t> dMom;
139 std::vector<Double_t> sm;
140 std::vector<Double_t> rd;
142 // we need to choose an allowed decay channel
143 Double_t randValue = gRandom->Rndm() * fullBranching;
144 Int_t chosenChannel = 1000;
145 Bool_t found = kFALSE;
146 Int_t channelIterations = 0;
148 for(Int_t nChannel = 0; nChannel < nDecayChannel; ++nChannel) {
149 randValue -= pDef->GetDecayChannel(nChannel)->GetBranching();
150 if(randValue <= 0. && database->IsChannelAllowed(pDef->GetDecayChannel(nChannel), BWmass)) {
151 chosenChannel = nChannel;
159 // get the PDG information for the chosen decay channel
160 DecayChannel *dc = pDef->GetDecayChannel(chosenChannel);
161 Int_t nSec = dc->GetNDaughters();
163 // Adjust the parent momentum four-vector for the MC generated Breit-Wigner mass
164 Particle parentBW(database->GetPDGParticle(parent.Encoding()));
165 parentBW.Pos(parent.Pos());
166 Double_t BWenergy = TMath::Sqrt(parent.Mom().X()*parent.Mom().X() +
167 parent.Mom().Y()*parent.Mom().Y() +
168 parent.Mom().Z()*parent.Mom().Z() +
171 Int_t NB = (Int_t)parent.GetType(); //particle from jets
173 TLorentzVector MomparentBW(parent.Mom().X(), parent.Mom().Y(), parent.Mom().Z(), BWenergy);
174 parentBW.Mom(MomparentBW);
175 // take into account BW when calculating boost velocity (for wide resonances it matters)
176 TVector3 velocityBW(parentBW.Mom().BoostVector());
178 // now we have an allowed decay
179 // first case: one daughter particle
181 // initialize the daughter particle
182 Particle p1(database->GetPDGParticle(dc->GetDaughterPDG(0)));
183 p1.SetLastMotherPdg(parentBW.Encoding());
184 p1.SetLastMotherDecayCoor(parentBW.Pos());
185 p1.SetLastMotherDecayMom(parentBW.Mom());
187 // link the parent and daughters trough their indexes in the list
188 Int_t parentIndex = -1;
189 if(parent.GetMother()==-1) parentIndex = parent.SetIndex(); // parents which are primaries don't have yet an index
190 else parentIndex = parent.GetIndex(); // parents which are secondaries have an index
191 Int_t p1Index = p1.SetIndex(); // set the daughter index
192 p1.SetMother(parentIndex); // set the mother index for this daughter
193 parent.SetDaughter(p1Index); // set p1 as daughter to the parent
194 if(parent.GetMother()==-1) allocator.AddParticle(parent, output); // add it only if its a primary particle
195 allocator.AddParticle(p1, output);
198 // second case: two daughter particles
200 // initialize the daughter particles
201 Particle p1(database->GetPDGParticle(dc->GetDaughterPDG(0)));
202 p1.Pos(parentBW.Pos());
203 Particle p2(database->GetPDGParticle(dc->GetDaughterPDG(1)));
204 p2.Pos(parentBW.Pos());
206 // calculate the momenta in rest frame of mother for the two particles (theta and phi are isotropic)
207 MomAntiMom(p1.Mom(), p1.TableMass(), p2.Mom(), p2.TableMass(), BWmass);
209 // boost to the laboratory system (to the mother velocity)
210 p1.Mom().Boost(velocityBW);
211 p2.Mom().Boost(velocityBW);
213 //store information about mother
214 p1.SetLastMotherPdg(parentBW.Encoding());
215 p1.SetLastMotherDecayCoor(parentBW.Pos());
216 p1.SetLastMotherDecayMom(parentBW.Mom());
217 p2.SetLastMotherPdg(parentBW.Encoding());
218 p2.SetLastMotherDecayCoor(parentBW.Pos());
219 p2.SetLastMotherDecayMom(parentBW.Mom());
220 // std::cout<<"2d NB="<<NB<<std::endl;
221 //set to daughters the same type as has mother
226 // check the kinematics in the lab system
227 Double_t deltaS = TMath::Sqrt((parentBW.Mom().X()-p1.Mom().X()-p2.Mom().X())*(parentBW.Mom().X()-p1.Mom().X()-p2.Mom().X())+
228 (parentBW.Mom().Y()-p1.Mom().Y()-p2.Mom().Y())*(parentBW.Mom().Y()-p1.Mom().Y()-p2.Mom().Y())+
229 (parentBW.Mom().Z()-p1.Mom().Z()-p2.Mom().Z())*(parentBW.Mom().Z()-p1.Mom().Z()-p2.Mom().Z())+
230 (parentBW.Mom().E()-p1.Mom().E()-p2.Mom().E())*(parentBW.Mom().E()-p1.Mom().E()-p2.Mom().E()));
231 // if deltaS is too big then repeat the kinematic procedure
236 cout << "2-body decay kinematic check in lab system: " << pDef->GetPDG() << " --> " << p1.Encoding() << " + " << p2.Encoding() << endl;
237 cout << "Mother (e,px,py,pz): " << parentBW.Mom().E() << "\t" << parentBW.Mom().X() << "\t" << parentBW.Mom().Y() << "\t" << parentBW.Mom().Z() << endl;
238 cout << "Mother (x,y,z,t): " << parentBW.Pos().X() << "\t" << parentBW.Pos().Y() << "\t" << parentBW.Pos().Z() << "\t" << parentBW.Pos().T() << endl;
240 cout << "Daughter1 (e,px,py,pz): " << p1.Mom().E() << "\t" << p1.Mom().X() << "\t" << p1.Mom().Y() << "\t" << p1.Mom().Z() << endl;
241 cout << "Daughter2 (e,px,py,pz): " << p2.Mom().E() << "\t" << p2.Mom().X() << "\t" << p2.Mom().Y() << "\t" << p2.Mom().Z() << endl;
242 cout << "2-body decay delta(sqrtS) = " << deltaS << endl;
243 cout << "Repeating the decay algorithm ..." << endl;
248 // push particles to the list of secondaries
249 Int_t parentIndex = -1;
250 if(parent.GetMother()==-1) parentIndex = parent.SetIndex(); // parents which are primaries don't have yet an index
251 else parentIndex = parent.GetIndex(); // parents which are secondaries have an index
254 p1.SetMother(parentIndex);
255 p2.SetMother(parentIndex);
256 parent.SetDaughter(p1.GetIndex());
257 parent.SetDaughter(p2.GetIndex());
258 if(parent.GetMother()==-1) allocator.AddParticle(parent, output); // add it only if its a primary
259 allocator.AddParticle(p1, output);
260 allocator.AddParticle(p2, output);
264 // third case: three daughter particle
266 // initialize the daughter particle
267 Particle p1(database->GetPDGParticle(dc->GetDaughterPDG(0)));
268 p1.Pos(parentBW.Pos());
269 Particle p2(database->GetPDGParticle(dc->GetDaughterPDG(1)));
270 p2.Pos(parentBW.Pos());
271 Particle p3(database->GetPDGParticle(dc->GetDaughterPDG(2)));
272 p3.Pos(parentBW.Pos());
273 // calculate the momenta in the rest frame of the mother particle
274 Double_t pAbs1 = 0., pAbs2 = 0., pAbs3 = 0., sumPabs = 0., maxPabs = 0.;
275 Double_t mass1 = p1.TableMass(), mass2 = p2.TableMass(), mass3 = p3.TableMass();
276 TLorentzVector &mom1 = p1.Mom(), &mom2 = p2.Mom(), &mom3 = p3.Mom();
277 Double_t deltaMass = BWmass - mass1 - mass2 - mass3;
280 Double_t rd1 = gRandom->Rndm();
281 Double_t rd2 = gRandom->Rndm();
285 Double_t e = rd2*deltaMass;
286 pAbs1 = TMath::Sqrt(e*e + 2*e*mass1);
290 e = (1-rd1)*deltaMass;
291 pAbs2 = TMath::Sqrt(e*e + 2*e*mass2);
298 e = (rd1-rd2)*deltaMass;
299 pAbs3 = TMath::Sqrt(e*e + 2*e*mass3);
304 } while(maxPabs > sumPabs - maxPabs);
306 // isotropic sample first particle 3-momentum
307 Double_t cosTheta = 2*(gRandom->Rndm()) - 1;
308 Double_t sinTheta = TMath::Sqrt(1 - cosTheta*cosTheta);
309 Double_t phi = TMath::TwoPi()*(gRandom->Rndm());
310 Double_t sinPhi = TMath::Sin(phi);
311 Double_t cosPhi = TMath::Cos(phi);
313 mom1.SetPxPyPzE(sinTheta*cosPhi, sinTheta*sinPhi, cosTheta, 0);
315 // sample rest particle 3-momentum
316 Double_t cosThetaN = (pAbs2*pAbs2 - pAbs3*pAbs3 - pAbs1*pAbs1)/(2*pAbs1*pAbs3);
317 Double_t sinThetaN = TMath::Sqrt(1 - cosThetaN*cosThetaN);
318 Double_t phiN = TMath::TwoPi()*(gRandom->Rndm());
319 Double_t sinPhiN = TMath::Sin(phiN);
320 Double_t cosPhiN = TMath::Cos(phiN);
322 mom3.SetPxPyPzE(sinThetaN*cosPhiN*cosTheta*cosPhi - sinThetaN*sinPhiN*sinPhi + cosThetaN*sinTheta*cosPhi,
323 sinThetaN*cosPhiN*cosTheta*sinPhi + sinThetaN*sinPhiN*cosPhi + cosThetaN*sinTheta*sinPhi,
324 -sinThetaN*cosPhiN*sinTheta + cosThetaN*cosTheta,
327 mom3 *= pAbs3*mom3.P();
332 mom1.SetE(TMath::Sqrt(mom1.P()*mom1.P() + mass1*mass1));
333 mom2.SetE(TMath::Sqrt(mom2.P()*mom2.P() + mass2*mass2));
334 mom3.SetE(TMath::Sqrt(mom3.P()*mom3.P() + mass3*mass3));
336 // boost to Lab system
337 mom1.Boost(velocityBW);
338 mom2.Boost(velocityBW);
339 mom3.Boost(velocityBW);
341 p1.SetLastMotherPdg(parentBW.Encoding());
342 p1.SetLastMotherDecayCoor(parentBW.Pos());
343 p1.SetLastMotherDecayMom(parentBW.Mom());
344 p2.SetLastMotherPdg(parentBW.Encoding());
345 p2.SetLastMotherDecayCoor(parentBW.Pos());
346 p2.SetLastMotherDecayMom(parentBW.Mom());
347 p3.SetLastMotherPdg(parentBW.Encoding());
348 p3.SetLastMotherDecayCoor(parentBW.Pos());
349 p3.SetLastMotherDecayMom(parentBW.Mom());
351 //set to daughters the same type as has mother
355 // std::cout<<"3d NB="<<NB<<std::endl;
359 // energy conservation check in the lab system
360 Double_t deltaS = TMath::Sqrt((parentBW.Mom().X()-p1.Mom().X()-p2.Mom().X()-p3.Mom().X())*(parentBW.Mom().X()-p1.Mom().X()-p2.Mom().X()-p3.Mom().X()) +
361 (parentBW.Mom().Y()-p1.Mom().Y()-p2.Mom().Y()-p3.Mom().Y())*(parentBW.Mom().Y()-p1.Mom().Y()-p2.Mom().Y()-p3.Mom().Y()) +
362 (parentBW.Mom().Z()-p1.Mom().Z()-p2.Mom().Z()-p3.Mom().Z())*(parentBW.Mom().Z()-p1.Mom().Z()-p2.Mom().Z()-p3.Mom().Z()) +
363 (parentBW.Mom().E()-p1.Mom().E()-p2.Mom().E()-p3.Mom().E())*(parentBW.Mom().E()-p1.Mom().E()-p2.Mom().E()-p3.Mom().E()));
364 // if deltaS is too big then repeat the kinematic procedure
367 cout << "3-body decay kinematic check in lab system: " << pDef->GetPDG() << " --> " << p1.Encoding() << " + " << p2.Encoding() << " + " << p3.Encoding() << endl;
368 cout << "Mother (e,px,py,pz): " << parentBW.Mom().E() << "\t" << parentBW.Mom().X() << "\t" << parentBW.Mom().Y() << "\t" << parentBW.Mom().Z() << endl;
369 cout << "Daughter1 (e,px,py,pz): " << p1.Mom().E() << "\t" << p1.Mom().X() << "\t" << p1.Mom().Y() << "\t" << p1.Mom().Z() << endl;
370 cout << "Daughter2 (e,px,py,pz): " << p2.Mom().E() << "\t" << p2.Mom().X() << "\t" << p2.Mom().Y() << "\t" << p2.Mom().Z() << endl;
371 cout << "Daughter3 (e,px,py,pz): " << p3.Mom().E() << "\t" << p3.Mom().X() << "\t" << p3.Mom().Y() << "\t" << p3.Mom().Z() << endl;
372 cout << "3-body decay delta(sqrtS) = " << deltaS << endl;
373 cout << "Repeating the decay algorithm..." << endl;
379 Int_t parentIndex = -1;
380 if(parent.GetMother()==-1) parentIndex = parent.SetIndex(); // parents which are primaries don't have yet an index
381 else parentIndex = parent.GetIndex(); // parents which are secondaries have an index
385 p1.SetMother(parentIndex);
386 p2.SetMother(parentIndex);
387 p3.SetMother(parentIndex);
388 parent.SetDaughter(p1.GetIndex());
389 parent.SetDaughter(p2.GetIndex());
390 parent.SetDaughter(p3.GetIndex());
391 if(parent.GetMother()==-1) allocator.AddParticle(parent, output); // add it only if its a primary
392 allocator.AddParticle(p1, output);
393 allocator.AddParticle(p2, output);
394 allocator.AddParticle(p3, output);