/usr/include/ThePEG/Utilities/Direction.h is in libthepeg-dev 1.8.0-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | // -*- C++ -*-
//
// Direction.h 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.
//
#ifndef ThePEG_Direction_H
#define ThePEG_Direction_H
// This is the declaration of the Direction class.
#include "ThePEG/Config/ThePEG.h"
#include "Direction.xh"
namespace ThePEG {
template <int I>
/**
* A <code>Direction</code> object can be used to specify that some
* following operations should be assumed to be performed with the
* z-direction of the momenta reversed. As an example, if
* <code>Direction<0>::pos()</code> is true, the method
* <code>Lorentz5Momentum::dirPlus()</code> will return the positive,
* light-cone component, and <code>Lorentz5Momentum::dirMinus()</code>
* the negative, while if <code>Direction<0>::pos()</code> is false
* the behavior of the methods are reversed.
*
* <code>Direction</code> is templated with an integer template argument
* (default = 0), and only one object per class can be instatiated at
* the time. Attempts to instatiate a second object of a
* <code>Direction</code> class will result in an exception being
* thrown. To have several different directions classes with different
* template arguments must be instantiated. <code>Direction<0></code> is
* reserved for <code>Lorentz5Momentum</code>. Attempts to use the
* static methods of a <code>Direction</code> class when no object has
* been instatiated will result in an exception being thrown.
*
* @see Lorentz5Momentum
*/
class Direction {
public:
/** The enum defining the directions. */
enum Dir { Neg = -1, /**< Reversed direction. */
Negative = -1, /**< Reversed direction. */
Undefined = 0, /**< No direction has been defined. */
Pos = 1, /**< Standard (positive) direction. */
Positive = 1 /**< Standard (positive) direction. */
};
public:
/**
* Create an object with a given direction.
*/
Direction(Dir newDirection)
{
if ( theDirection != Undefined ) throw MultipleDirectionException(I);
if ( newDirection == Positive ) theDirection = Positive;
else if ( newDirection == Negative ) theDirection = Negative;
else throw UndefinedDirectionException(I);
}
/**
* Create an object with a positive direction if rnd > 0.5,
* otherwise set the negative direction.
*/
Direction(double rnd)
{
if ( theDirection != Undefined ) throw MultipleDirectionException(I);
theDirection = rnd > 0 ? Positive : Negative;
}
/**
* Create an object with a positive direction if p is true,
* otherwise set the negative direction.
*/
Direction(bool p)
{
if ( theDirection != Undefined ) throw MultipleDirectionException(I);
theDirection = p ? Positive : Negative;
}
/**
* Destructure makeing the static variable undefined.
*/
~Direction() { theDirection = Undefined; }
public:
/**
* Set the direction.
*/
static void set(Dir newDirection) {
if ( newDirection == Positive ) theDirection = Positive;
else if ( newDirection == Negative ) theDirection = Negative;
else throw UndefinedDirectionException(I);
}
/**
* Reverse the direction.
*/
static void reverse() {
theDirection = pos() ? Negative : Positive;
}
/**
* Return true if the direction is positive.
*/
static bool pos() {
return dir() == Positive;
}
/**
* Return true if the direction is negative (reversed).
*/
static bool neg() {
return dir() == Negative;
}
/**
* Return the direction.
*/
static Dir dir() {
if ( theDirection == Undefined ) throw UndefinedDirectionException(I);
return theDirection;
}
private:
/**
* The direction.
*/
static Dir theDirection;
private:
/**
* Default ctors and assignment is private and not implemented.
*/
Direction();
/**
* Default ctors and assignment is private and not implemented.
*/
Direction(const Direction &);
/**
* Default ctors and assignment is private and not implemented.
*/
Direction & operator=(const Direction &);
};
template<int I>
typename Direction<I>::Dir Direction<I>::theDirection = Direction<I>::Undefined;
}
#endif /* ThePEG_Direction_H */
|