/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 | Private Attributes
DsG4GdCaptureGammas Class Reference

#include <DsG4GdCaptureGammas.h>

List of all members.

Public Member Functions

 DsG4GdCaptureGammas ()
 ~DsG4GdCaptureGammas ()
G4ReactionProductVector * GetGammas ()
std::vector< double > GetEnergy ()

Private Attributes

TFile * specfile
TH1F * capspec

Detailed Description

Definition at line 18 of file DsG4GdCaptureGammas.h.


Constructor & Destructor Documentation

DsG4GdCaptureGammas::DsG4GdCaptureGammas ( )

Definition at line 25 of file DsG4GdCaptureGammas.cc.

{
    //First back up the current TDirectory. This is hard-wired, but at 
    //this point we assume that an output root file has been opened at the
    //very beginning of the run. I will try to find a prettier fix  
    //later. jianglai 05/09/2006
    TDirectory *dirKeep = gDirectory;

    // The experimental spectrum is saved in gdcap_spec.root.
    // This file should be placed in the data/ directory.
    // It will get copied to the InstallArea/${tag}/data directory when
    // the package is 'make'd.
    // The InstallArea/${tag}/data which should be linked to with the $DAYA_DATA_DIR
    // environment variable.

    std::string specfilename = "gdcap_spec.root";
    const char* prefix = getenv("DAYA_DATA_DIR");
    if(prefix) {
        if(strlen(prefix)>0) { 
            std::string newname = prefix;
            newname += "/";
            newname += specfilename;
            specfilename = newname;
        }
    }

    specfile = TFile::Open(specfilename.c_str());

    if(!specfile)
        G4cout << "Can not open gdcap_spec.root. "
               << "Make sure DAYA_DATA_DIR is set to it's location." << G4endl;
    if(!(specfile->IsOpen()))
        G4cout << "Can not open gdcap_spec.root. "
               << "Make sure DAYA_DATA_DIR is set to it's location." << G4endl;

    capspec = (TH1F*)(specfile->Get("h1"));

    // return to the TDirectory used before opening TFile
    if (dirKeep) {
        dirKeep->cd();
    }  
}
DsG4GdCaptureGammas::~DsG4GdCaptureGammas ( )

Definition at line 68 of file DsG4GdCaptureGammas.cc.

{
  /*
    if(specfile && specfile->IsOpen()) {
        specfile->Close();
        G4cout <<"gdcap_spec.root closed"<<G4endl;
    }
    else 
        G4cout <<"gdcap_spec.root is not closed."<<G4endl;
  */
}

Member Function Documentation

G4ReactionProductVector * DsG4GdCaptureGammas::GetGammas ( )

Definition at line 80 of file DsG4GdCaptureGammas.cc.

{
    G4ReactionProductVector* theGammas = new G4ReactionProductVector;
    vector<double> energy = GetEnergy();
    for(unsigned int i=0; i<energy.size(); i++) {

        G4ReactionProduct* theOne = new G4ReactionProduct;
        theOne->SetDefinition( G4Gamma::Gamma() );

        // Get the gammas direction. 
        // Isotropic emission.
        G4double costheta = 2.*G4UniformRand()-1;
        G4double theta = acos(costheta);
        G4double phi = twopi*G4UniformRand();
        G4double sinth = sin(theta);
        theOne->SetTotalEnergy( energy[i] );
        G4ThreeVector temp(energy[i]*sinth*cos(phi), 
                           energy[i]*sinth*sin(phi),
                           energy[i]*cos(theta) );
        theOne->SetMomentum( temp ) ;
        theGammas->push_back(theOne);
    }
    return theGammas;
}
vector< double > DsG4GdCaptureGammas::GetEnergy ( )

Definition at line 157 of file DsG4GdCaptureGammas.cc.

{
    vector<double> Energy;
    G4double TotalEnergy;
    if (G4UniformRand()<0.815)
        TotalEnergy = 7.93; // captured by Gd157
    else
        TotalEnergy = 8.53; // captured by Gd155
    G4double energy_sum = 0.0;
    G4int    gamma_num = 0;
    G4double gamma_energy[100]={0};
    G4double energy_tmp;
  
  sample:
  

    //Use the CLHEP random engine to sample the distribution instead
    //Jianglai 10/01/2006
    //G4double energy=capspec->GetRandom();// sample from the experimental spectrum.
    G4double energy = getRandomCLHEP(capspec);
  
    energy_sum = energy_sum+energy;
    gamma_num = gamma_num+1;
    gamma_energy[gamma_num] = energy;

    if(energy_sum>TotalEnergy) {
        if((energy_sum-TotalEnergy)<0.8) {
            energy_tmp = gamma_energy[gamma_num-1]+energy-(energy_sum-TotalEnergy);
            if(energy_tmp>7.4) {
                energy_sum = energy_sum-energy;
                gamma_num = gamma_num-1;
                goto sample;
            }
            gamma_num = gamma_num-1;
            gamma_energy[gamma_num]=energy_tmp;
            goto goon;
        }
        energy_sum = energy_sum-energy;
        gamma_num = gamma_num-1;
        goto sample;
    }
    goto sample;

  goon:
  
    // set the sequence
    for(int i=gamma_num;i>1;i--) {
        for(int j=1;j<i;j++) {
            if(gamma_energy[j]<gamma_energy[j+1]) {
                energy_tmp = gamma_energy[j+1];
                gamma_energy[j+1] = gamma_energy[j];
                gamma_energy[j] = energy_tmp;
            }
        }
    }
    if(gamma_num<=3)
        goto  ok;
  
    if(gamma_energy[gamma_num]<0.8) {
        energy_tmp = gamma_energy[gamma_num]+gamma_energy[gamma_num-1];
        if(energy_tmp>7.4)
            goto ok;
        gamma_energy[gamma_num-1]=energy_tmp;
        gamma_num=gamma_num-1;
    }
   
  ok:
  
    for(int k=1;k<=gamma_num;k++)
        Energy.push_back(gamma_energy[k]); 
   
    return Energy;
}

Member Data Documentation

Definition at line 29 of file DsG4GdCaptureGammas.h.

Definition at line 30 of file DsG4GdCaptureGammas.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:17:58 for DetSim by doxygen 1.7.4