File: DecayHandler.cc

package info (click to toggle)
thepeg 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 9,312 kB
  • ctags: 11,509
  • sloc: cpp: 57,129; sh: 11,315; java: 3,212; lisp: 1,402; makefile: 830; ansic: 58; perl: 3
file content (118 lines) | stat: -rw-r--r-- 3,898 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// -*- C++ -*-
//
// DecayHandler.cc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined, non-templated member
// functions of the DecayHandler class.
//

#include "DecayHandler.h"
#include "Hint.h"
#include "ThePEG/PDT/ParticleData.h"
#include "ThePEG/PDT/DecayMode.h"
#include "ThePEG/PDT/Decayer.h"
#include "ThePEG/EventRecord/Particle.h"
#include "ThePEG/EventRecord/Step.h"
#include "ThePEG/EventRecord/Collision.h"
#include "ThePEG/Interface/Switch.h"
#include "ThePEG/Interface/Parameter.h"
#include "ThePEG/Interface/ClassDocumentation.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"

using namespace ThePEG;

DecayHandler::~DecayHandler() {}

IBPtr DecayHandler::clone() const {
  return new_ptr(*this);
}

IBPtr DecayHandler::fullclone() const {
  return new_ptr(*this);
}

void DecayHandler::
handle(EventHandler &, const tPVector & tagged,
       const Hint &) {
  // First go through to see which of the tagged particles should be
  // decayed: Exit if none are found.
  tPVector parents;
  for ( int i = 0, N = tagged.size(); i < N; ++i )
    if ( tagged[i] && !tagged[i]->data().stable() )
      parents.push_back(tagged[i]);

  if ( parents.empty() ) return;

  // Create a new step, decay all particles and add their children in
  // the new step.
  for ( int i = 0, N = parents.size(); i < N; ++i )
    performDecay(newStep()->find(parents[i]->final()), *newStep());
}

void DecayHandler::
performDecay(tPPtr parent, Step & s) const {
  if ( maxLifeTime() >= ZERO ) {
    if( ( lifeTimeOption() && parent->lifeLength().tau() > maxLifeTime())||
	(!lifeTimeOption() && parent->data().cTau()      > maxLifeTime()) ) {
      parent->setLifeLength(Distance());
      return;
    }
  }
  ParticleVector children = Decayer::DecayParticle(parent, s, maxLoop());
  for ( int i = 0, N = children.size(); i < N; ++i )
    if ( !children[i]->data().stable() ) performDecay(children[i], s);
}

void DecayHandler::persistentOutput(PersistentOStream & os) const {
  os << theMaxLoop << ounit(theMaxLifeTime, mm) << theLifeTimeOption;
}

void DecayHandler::persistentInput(PersistentIStream & is, int) {
  is >> theMaxLoop >> iunit(theMaxLifeTime, mm) >> theLifeTimeOption;
}

ClassDescription<DecayHandler> DecayHandler::initDecayHandler;

void DecayHandler::Init() {

  static ClassDocumentation<DecayHandler> documentation
    ("This is the main class handling the decay of unstable particles. Note "
     "that the actual decays will be performed by objects of the "
     "ThePEG::Decayer class.");

  static Parameter<DecayHandler,long> interfaceMaxLoop
    ("MaxLoop",
     "The maximum number of attempts per event when selecting a decay channel.",
     &DecayHandler::theMaxLoop, 100000, 100, 100000000, true, false, true);

  static Parameter<DecayHandler,Length> interfaceMaxLifeTime
    ("MaxLifeTime",
     "The maximum lifetime (c*tau) in units of mm. Particles with longer "
     "lifetimes than this will not be decayed.",
     &DecayHandler::theMaxLifeTime, mm, -1.0*mm, -1.0*mm, ZERO,
     true, false, Interface::lowerlim);


  static Switch<DecayHandler,bool> interfaceLifeTimeOption
    ("LifeTimeOption",
     "Option for how the maximum life time is interpreted",
     &DecayHandler::theLifeTimeOption, false, false, false);
  static SwitchOption interfaceLifeTimeOptionAverage
    (interfaceLifeTimeOption,
     "Average",
     "Cut on the average lifetime of the particle type",
     false);
  static SwitchOption interfaceLifeTimeOptionReal
    (interfaceLifeTimeOption,
     "Real",
     "Cut on the lifetime generated for the given instance",
     true);

}