/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
GtRockGammaTool Class Reference

#include <GtRockGammaTool.h>

Inheritance diagram for GtRockGammaTool:
Inheritance graph
[legend]
Collaboration diagram for GtRockGammaTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GtRockGammaTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~GtRockGammaTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode mutate (HepMC::GenEvent &event)
 Modify the event.

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Member Functions

StatusCode oneVertex (HepMC::GenEvent &event)
double ConvertCdfRand (const double &rand, const std::vector< double > &cdf, const std::vector< double > &edges)
unsigned int GetRandomWall ()

Private Attributes

Rndm::Numbers m_uni
double m_totalSurfaceArea
std::vector< GtSourceRect * > m_walls
std::vector< double > m_pdfGammas
std::vector< double > m_edgesGammas
std::vector< double > m_cdfGammas

Detailed Description

Definition at line 65 of file GtRockGammaTool.h.


Constructor & Destructor Documentation

GtRockGammaTool::GtRockGammaTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 101 of file GtRockGammaTool.cc.

  :GaudiTool(type,name,parent),
   m_totalSurfaceArea(0),
   m_walls()
{
  // Initialization
  m_pdfGammas.clear();   
  m_pdfGammas.push_back(1);
  m_edgesGammas.clear(); 
  m_edgesGammas.push_back(0.5*MeV); 
  m_edgesGammas.push_back(10*MeV);

  declareInterface<IHepMCEventMutator>(this);
  declareProperty("GammaSpectrum",m_pdfGammas,"User-Defined PDF for Gamma Spectrum");
  declareProperty("GammaBinEdges",m_edgesGammas,"Bin Edges of Gamma Spectrum");

}
GtRockGammaTool::~GtRockGammaTool ( ) [virtual]

Definition at line 121 of file GtRockGammaTool.cc.

{
  for(unsigned int wallIdx=0;wallIdx<m_walls.size();wallIdx++){
    delete m_walls[wallIdx];
    m_walls[wallIdx] = 0;
  }
  m_walls.clear();
}

Member Function Documentation

virtual StatusCode GtRockGammaTool::initialize ( ) [virtual]
virtual StatusCode GtRockGammaTool::finalize ( ) [virtual]
virtual StatusCode GtRockGammaTool::mutate ( HepMC::GenEvent event) [virtual]

Modify the event.

Implements IHepMCEventMutator.

StatusCode GtRockGammaTool::oneVertex ( HepMC::GenEvent event) [private]

Definition at line 137 of file GtGunGenTool.cc.

{
    CLHEP::Hep3Vector dir;

    if (m_directionMode == "Fixed") {
        dir.set(m_direction[0],m_direction[1],m_direction[2]);
    }
    else {
        // cos(angle) from mean direction
        double costh=0;
        do {
            costh = generateNumber(m_directionMode,1,m_directionSpread);
        } while (costh < -1.0||costh > 1.0);
        
        double sinth = sqrt(1-costh*costh);

        // azimuth angle around mean direction
        double phi = generateNumber("Uniform",0.0,360*CLHEP::degree);
        double cosphi = cos(phi);
        double sinphi = sin(phi);
        
        dir.set(sinth*cosphi,sinth*sinphi,costh);

        // rotate along Y-axis by the mean direction's theta
        dir.rotateY(acos(m_direction[2]));
        // rotate along Z-axis by the mean direction's phi
        dir.rotateZ(atan2(m_direction[1],m_direction[0]));

    }

    dir = dir.unit();

    double momentum;
    do{
      momentum = generateNumber(m_momentumMode,m_momentum,m_momentumSpread);
    } while (momentum < 0.0);

    // What is the interpretation of momentum?
    double energy = sqrt(momentum*momentum + m_mass*m_mass); 
    if (m_momentumInterpretation == "TotalEnergy") {
      energy = momentum ; 
      if ( energy < m_mass ) {
        fatal() << "Cannot set total energy(MeV) = " << energy/CLHEP::MeV 
                << " of " << m_particleName 
                << " to be less than particle mass(MeV) = " << m_mass/CLHEP::MeV << endreq;
        return StatusCode::FAILURE;
      }
      momentum = sqrt( (energy+m_mass) * (energy-m_mass) );
    }

    if (m_momentumInterpretation == "KineticEnergy") {
      energy = momentum + m_mass;
      momentum = sqrt( (energy+m_mass) * (energy-m_mass) );
    }
    
    HepMC::ThreeVector p(momentum*dir);
    HepMC::FourVector fourmom(p.x(),p.y(),p.z(),energy);

    debug() << m_particleName << " (" << m_pid << ") generated with 4momentum = " 
            << momentum
            << " dir = " << dir
            << " momentum(MeV) = " << momentum/CLHEP::MeV
            << " energy(MeV) = " << energy/CLHEP::MeV
            << " kinetic energy(MeV) = " << (energy-m_mass)/CLHEP::MeV
            << endreq;

    HepMC::GenParticle* particle = new HepMC::GenParticle(fourmom,m_pid,1/*=status*/);

    if (m_polarizeMode == "Random") {
        double phi = generateNumber("Uniform",0.0,360*CLHEP::degree);
        particle->set_polarization(HepMC::Polarization(0.5*HepMC::HepMC_pi,phi));
    }

    HepMC::GenVertex* vertex = event.signal_process_vertex();
    if (!vertex) {
        vertex = new HepMC::GenVertex(HepMC::FourVector(0,0,0,0));
        event.set_signal_process_vertex(vertex);
    }

    vertex->add_particle_out(particle);

    return StatusCode::SUCCESS;
}
double GtRockGammaTool::ConvertCdfRand ( const double &  rand,
const std::vector< double > &  cdf,
const std::vector< double > &  edges 
) [private]

Definition at line 403 of file GtRockGammaTool.cc.

                                                                       {
  // Convert a uniform random number in [0,1] to a random sample from
  // the given cumulative distribution function.
  int left = 0;
  int right = cdf.size();
  const double* cdfStart = &cdf[0];
  const double* edgesStart = &edges[0];

  while( right-left > 1 ){
    int mid = (right+left)/2;
    if( rand < *(cdfStart+mid) ) right = mid;
    else left = mid;
  }
  double value = *(edgesStart + left);
  double slope = (*(edgesStart+right) - *(edgesStart+left))
                /(*(cdfStart+right) - *(cdfStart+left));
  value += slope * (rand - *(cdfStart+left));
  return value;
}
unsigned int GtRockGammaTool::GetRandomWall ( ) [private]

Definition at line 425 of file GtRockGammaTool.cc.

                                            {
  // Choose a random wall, based on surface area
  double rand = m_uni();
  double randArea = rand*m_totalSurfaceArea;
  unsigned int wallIdx = 0;
  while(wallIdx<m_walls.size()){
    if( randArea < m_walls[wallIdx]->area() ){
      // Found the correct wall
      break;
    }
    randArea -= m_walls[wallIdx]->area();
    wallIdx++;
  }
  return wallIdx;
}
const InterfaceID & IHepMCEventMutator::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file IHepMCEventMutator.cc.

{ 
    return IID_IHepMCEventMutator; 
}

Member Data Documentation

Rndm::Numbers GtRockGammaTool::m_uni [private]

Definition at line 83 of file GtRockGammaTool.h.

Definition at line 84 of file GtRockGammaTool.h.

std::vector<GtSourceRect*> GtRockGammaTool::m_walls [private]

Definition at line 85 of file GtRockGammaTool.h.

std::vector<double> GtRockGammaTool::m_pdfGammas [private]

Definition at line 88 of file GtRockGammaTool.h.

std::vector<double> GtRockGammaTool::m_edgesGammas [private]

Definition at line 89 of file GtRockGammaTool.h.

std::vector<double> GtRockGammaTool::m_cdfGammas [private]

Definition at line 90 of file GtRockGammaTool.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:18:51 for GenTools by doxygen 1.7.4