StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
THijing.cxx
1 /**********************************************************************
2  *
3  * Author: Chunhui Han
4  *
5  **********************************************************************/
6 #include "THijing.h"
7 #include <iostream>
8 #include <fstream>
9 #include <string.h>
10 
11 using namespace std;
12 THijing::THijing( const char *paramFile ) {
13  if (strlen(paramFile) > 255) {
14  cout << "Input parameter fileName is " << paramFile << endl;
15  cout << "This is longer than 255 characters. Need to increase buffer size." << endl;
16  }
17  hfilename_.length = strlen(paramFile);
18  strcpy(hfilename_.fileName,paramFile);
19  init();
20 }
21 
22 void THijing::init() {
23  mNevent = 0;
24  hijev_();
25 }
26 
27 THijing::~THijing() {
28 }
29 
30 void THijing::SetRandomSeed(int iseed, int k1, int k2) {
31  int lux = 2;
32  rluxgo_(&lux,&iseed,&k1,&k2);
33 }
34 void THijing::GetRandomSeed(int *lux, int *iseed, int *k1, int *k2) {
35  rluxat_(lux,iseed,k1,k2);
36 }
37 void THijing::SaveRandomSeeds(int *ivec) {
38  rluxut_(ivec);
39 }
40 void THijing::RestoreRandomSeeds(int *ivec) {
41  rluxin_(ivec);
42 }
43 void THijing::GenerateEvent() {
44  // Comment out the following line, so that THijing always
45  // generate an event when called by this method.
46  // The number of events in the cardfile thus has no effect.
47  // if(mNevent == headpss_.vsshep[3]) return;
48  hijev_();
49  mNevent++;
50 }
51 
52 void THijing::writeOut() const {
53  if(mNevent == 0) {
54  cout <<"No event generated."<<endl;
55  return;
56  }
57  ofstream fout("particles.dat",ios::app);
58  fout << "Event " << mNevent << '\t' << himain1_.natt << endl;
59  // loop over all produced, stable particles
60  for(int ip = 0; ip < himain1_.natt; ip++) {
61  int istat = (himain2_.katt[3][ip] == 11) ? 2 : himain2_.katt[3][ip];
62  fout << ip << '\t' << istat << '\t' << himain2_.katt[0][ip] << '\t'
63  << himain2_.patt[0][ip] << '\t' << himain2_.patt[1][ip] << '\t'
64  << himain2_.patt[2][ip] << '\t' << himain2_.patt[3][ip] << '\t'
65  << endl;
66  }
67 }