EventHeaderSvc Class Reference

#include <EventHeaderSvc.hh>

List of all members.

Public Member Functions

 EventHeaderSvc ()
 ~EventHeaderSvc ()
void SetBranch ()
void ReadOutputCard (G4String filename)
void SetValue (const G4Event *evt, int runNb=0, double w=1)
void SetSeedsValue ()
void SetInitialMomentum (double, double, double)
void SetInitialPosition (double x, double y, double z)
void SetInitialParticle (const std::string &name)
void set_run_num (int val)
void set_evt_num (int val)
void set_R0 (double val)
void set_R1 (double val)
void set_weight (double val)
int get_R0 ()
int get_R1 ()

Static Public Member Functions

static EventHeaderSvcGetEventHeaderSvc ()

Private Member Functions

void ReSet ()
void ShowOutCard ()

Private Attributes

int run_num
int evt_num
int R0
int R1
double ipx
double ipy
double ipz
double ix
double iy
double iz
double weight
std::string i_particleName
bool flag_run_num
bool flag_evt_num
bool flag_R0
bool flag_R1
bool flag_ipx
bool flag_ipy
bool flag_ipz
bool flag_position
bool flag_pid
bool flag_weight
PrimaryGeneratorActionpPrimaryGeneratorAction

Static Private Attributes

static EventHeaderSvcfEventHeaderSvc = 0

Detailed Description

Definition at line 17 of file EventHeaderSvc.hh.


Constructor & Destructor Documentation

EventHeaderSvc::EventHeaderSvc (  ) 

Definition at line 23 of file EventHeaderSvc.cc.

References fEventHeaderSvc, ipx, ipy, ipz, ix, iy, iz, R0, and R1.

00024 {
00025         if (fEventHeaderSvc){
00026                 G4Exception("EventHeaderSvc::EventHeaderSvc()","Run0031",
00027                                 FatalException, "EventHeaderSvc constructed twice.");
00028         }
00029         fEventHeaderSvc = this;
00030         R0 = 0;
00031         R1 = 0;
00032         ipx = 0;
00033         ipy = 0;
00034         ipz = 0;
00035         ix=iy=iz=0;
00036 }

EventHeaderSvc::~EventHeaderSvc (  ) 

Definition at line 38 of file EventHeaderSvc.cc.

00039 {
00040         printf("~EventHeaderSvc\n");
00041 }


Member Function Documentation

int EventHeaderSvc::get_R0 (  )  [inline]

Definition at line 44 of file EventHeaderSvc.hh.

References R0.

Referenced by MyAnalysisSvc::EndOfEventAction().

00044 {return R0;};

int EventHeaderSvc::get_R1 (  )  [inline]

Definition at line 45 of file EventHeaderSvc.hh.

References R1.

Referenced by MyAnalysisSvc::EndOfEventAction().

00045 {return R1;};

EventHeaderSvc * EventHeaderSvc::GetEventHeaderSvc (  )  [static]

Definition at line 43 of file EventHeaderSvc.cc.

References fEventHeaderSvc.

Referenced by PrimaryGeneratorAction::InformEventHeaderHeader(), and MyAnalysisSvc::MyAnalysisSvc().

00043                                                  {
00044         if ( !fEventHeaderSvc ){
00045                 fEventHeaderSvc = new EventHeaderSvc;
00046         }
00047         return fEventHeaderSvc;
00048 }

void EventHeaderSvc::ReadOutputCard ( G4String  filename  ) 

Definition at line 65 of file EventHeaderSvc.cc.

References flag_evt_num, flag_ipx, flag_ipy, flag_ipz, flag_pid, flag_position, flag_R0, flag_R1, flag_run_num, flag_weight, ReSet(), and ShowOutCard().

Referenced by MyAnalysisSvc::set_out_card().

00065                                                     {
00066         ReSet();
00067         std::ifstream fin_card(filename);
00068         if(!fin_card){
00069                 std::cout<<"In EventHeaderSvc::ReadOutputCard, cannot open "<<filename<<"!!!"<<std::endl;
00070                 G4Exception("EventHeaderSvc::ReadOutputCard()",
00071                                 "InvalidSetup", FatalException,
00072                                 "cannot find output card");
00073         }
00074         std::stringstream buf_card;
00075         std::string s_card;
00076         int n_output_section_symbol = 0;
00077         while(getline(fin_card,s_card)){
00078                 buf_card.str("");
00079                 buf_card.clear();
00080                 buf_card<<s_card;
00081 
00082                 //eleminate useless lines
00083                 const char* c_card = s_card.c_str();
00084                 int length = strlen(c_card);
00085                 int offset = 0;
00086                 for ( ; offset < length; offset++ ){
00087                         if ( c_card[offset] != ' ' ) break;
00088                 }
00089                 if ( c_card[offset] == '#' || (c_card[offset] == '/' && c_card[offset+1] == '/') || length - offset == 0 ){
00090                         continue;
00091                 }
00092 
00093                 std::string name;
00094                 buf_card>>name;
00095                 if ( n_output_section_symbol == 0 ){
00096                         if ( name == "EVENTHEADER_SECTION" ){
00097                                 n_output_section_symbol++;
00098                         }
00099                 }
00100                 else if ( n_output_section_symbol == 1 ){
00101                         if ( name == "EVENTHEADER_SECTION" ){
00102                                 n_output_section_symbol++;
00103                         }
00104                         else if( name == "evt_num" ) flag_evt_num = true;
00105                         else if( name == "run_num" ) flag_run_num = true;
00106                         else if( name == "R0" ) flag_R0 = true;
00107                         else if( name == "R1" ) flag_R1 = true;
00108                         else if( name == "ipx" ) flag_ipx = true;
00109                         else if( name == "ipy" ) flag_ipy = true;
00110                         else if( name == "ipz" ) flag_ipz = true;
00111                         else if( name == "weight" ) flag_weight = true;
00112                         else if( name == "position" ) flag_position = true;
00113                         else if( name == "pid" ) flag_pid = true;
00114                         else{
00115                                 std::cout<<"In EventHeaderSvc::ReadOutputCard, unknown name: "<<name<<" in file "<<filename<<std::endl;
00116                                 std::cout<<"Will ignore this line!"<<std::endl;
00117                         }
00118                 }
00119 
00120                 if ( n_output_section_symbol > 1 ){
00121                         break;
00122                 }
00123         }
00124         buf_card.str("");
00125         buf_card.clear();
00126         if ( n_output_section_symbol <= 1 ){
00127                 std::cout<<"*****************WARNING********************"<<std::endl;
00128                 std::cout<<"In EventHeaderSvc::ReadOutputCard, failed to find enough section seperators for output in file "<<filename<<std::endl;
00129                 std::cout<<"Will use default settings."<<std::endl;
00130                 std::cout<<"********************************************"<<std::endl;
00131         }
00132         fin_card.close();
00133         ShowOutCard();
00134 }

void EventHeaderSvc::ReSet (  )  [private]

Definition at line 136 of file EventHeaderSvc.cc.

References flag_evt_num, flag_ipx, flag_ipy, flag_ipz, flag_pid, flag_position, flag_R0, flag_R1, and flag_run_num.

Referenced by ReadOutputCard().

00136                           {
00137         flag_evt_num = false;
00138         flag_run_num = false;
00139         flag_R0 = false;
00140         flag_R1 = false;
00141         flag_R1 = false;
00142         flag_ipx = false;
00143         flag_ipy = false;
00144         flag_ipz = false;
00145         flag_position = false;
00146         flag_pid = false;
00147 }

void EventHeaderSvc::set_evt_num ( int  val  )  [inline]

Definition at line 39 of file EventHeaderSvc.hh.

References evt_num.

00039 {evt_num = val;};

void EventHeaderSvc::set_R0 ( double  val  )  [inline]

Definition at line 40 of file EventHeaderSvc.hh.

References R0.

00040 {R0 = val;};

void EventHeaderSvc::set_R1 ( double  val  )  [inline]

Definition at line 41 of file EventHeaderSvc.hh.

References R1.

00041 {R1 = val;};

void EventHeaderSvc::set_run_num ( int  val  )  [inline]

Definition at line 38 of file EventHeaderSvc.hh.

References run_num.

00038 {run_num = val;};

void EventHeaderSvc::set_weight ( double  val  )  [inline]

Definition at line 42 of file EventHeaderSvc.hh.

References weight.

00042 {weight = val;};

void EventHeaderSvc::SetBranch (  ) 

Definition at line 50 of file EventHeaderSvc.cc.

References evt_num, flag_evt_num, flag_ipx, flag_ipy, flag_ipz, flag_pid, flag_position, flag_R0, flag_R1, flag_run_num, flag_weight, MyRoot::GetMyRoot(), i_particleName, ipx, ipy, ipz, ix, iy, iz, R0, R1, run_num, MyRoot::SetBranch(), and weight.

Referenced by MyAnalysisSvc::BeginOfRunAction().

00050                               {
00051         if(flag_run_num)  MyRoot::GetMyRoot()->SetBranch("run_num"       , &run_num);
00052         if(flag_evt_num)  MyRoot::GetMyRoot()->SetBranch("evt_num"       , &evt_num);
00053         if(flag_R0)       MyRoot::GetMyRoot()->SetBranch("R0"            , &R0);
00054         if(flag_R1)       MyRoot::GetMyRoot()->SetBranch("R1"            , &R1);
00055         if(flag_ipx)      MyRoot::GetMyRoot()->SetBranch("i_px"          , &ipx);
00056         if(flag_ipy)      MyRoot::GetMyRoot()->SetBranch("i_py"          , &ipy);
00057         if(flag_ipz)      MyRoot::GetMyRoot()->SetBranch("i_pz"          , &ipz);
00058         if(flag_position) MyRoot::GetMyRoot()->SetBranch("i_x"           , &ix);
00059         if(flag_position) MyRoot::GetMyRoot()->SetBranch("i_y"           , &iy);
00060         if(flag_position) MyRoot::GetMyRoot()->SetBranch("i_z"           , &iz);
00061         if(flag_weight)   MyRoot::GetMyRoot()->SetBranch("weight"        , &weight);
00062         if(flag_pid)      MyRoot::GetMyRoot()->SetBranch("i_particleName", &i_particleName);
00063 }

void EventHeaderSvc::SetInitialMomentum ( double  tipx,
double  tipy,
double  tipz 
)

Definition at line 172 of file EventHeaderSvc.cc.

References ipx, ipy, and ipz.

Referenced by PrimaryGeneratorAction::InformEventHeaderHeader().

00172                                                                             {
00173         ipx = tipx;
00174         ipy = tipy;
00175         ipz = tipz;
00176 }

void EventHeaderSvc::SetInitialParticle ( const std::string &  name  )  [inline]

Definition at line 35 of file EventHeaderSvc.hh.

References i_particleName.

Referenced by PrimaryGeneratorAction::InformEventHeaderHeader().

00035 {i_particleName=name;}

void EventHeaderSvc::SetInitialPosition ( double  x,
double  y,
double  z 
) [inline]

Definition at line 34 of file EventHeaderSvc.hh.

References ix, iy, and iz.

Referenced by PrimaryGeneratorAction::InformEventHeaderHeader().

00034 {ix=x;iy=y;iz=z;}

void EventHeaderSvc::SetSeedsValue (  ) 

Definition at line 168 of file EventHeaderSvc.cc.

References R0, and R1.

Referenced by PrimaryGeneratorAction::InformEventHeaderHeader().

00168                                   {
00169     R0 = CLHEP::HepRandom::getTheSeeds()[0];
00170     R1 = CLHEP::HepRandom::getTheSeeds()[1];
00171 }

void EventHeaderSvc::SetValue ( const G4Event *  evt,
int  runNb = 0,
double  w = 1 
)

Definition at line 163 of file EventHeaderSvc.cc.

References evt_num, run_num, and weight.

Referenced by MyAnalysisSvc::EndOfEventAction().

00163                                                                     {
00164         run_num = runNb;
00165         evt_num = evt->GetEventID();
00166         weight = w;
00167 }

void EventHeaderSvc::ShowOutCard (  )  [private]

Definition at line 149 of file EventHeaderSvc.cc.

References flag_evt_num, flag_ipx, flag_ipy, flag_ipz, flag_pid, flag_position, flag_R0, flag_R1, flag_run_num, and flag_weight.

Referenced by ReadOutputCard().

00149                                 {
00150         std::cout<<"*************************Output settings for EventHeaderSvc***************************"<<std::endl;
00151         std::cout<<"output evt_num?"<<(flag_evt_num?" yes":" no")<<std::endl;
00152         std::cout<<"output run_num?"<<(flag_run_num?" yes":" no")<<std::endl;
00153         std::cout<<"output R0?"<<(flag_R0?" yes":" no")<<std::endl;
00154         std::cout<<"output R1?"<<(flag_R1?" yes":" no")<<std::endl;
00155         std::cout<<"output ipx?"<<(flag_ipx?" yes":" no")<<std::endl;
00156         std::cout<<"output ipy?"<<(flag_ipy?" yes":" no")<<std::endl;
00157         std::cout<<"output ipz?"<<(flag_ipz?" yes":" no")<<std::endl;
00158         std::cout<<"output initial position?"<<(flag_position?" yes":" no")<<std::endl;
00159         std::cout<<"output weight?"<<(flag_weight?" yes":" no")<<std::endl;
00160         std::cout<<"output particle type?"<<(flag_pid?" yes":" no")<<std::endl;
00161 }


Member Data Documentation

int EventHeaderSvc::evt_num [private]

Definition at line 56 of file EventHeaderSvc.hh.

Referenced by set_evt_num(), SetBranch(), and SetValue().

Definition at line 53 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), and GetEventHeaderSvc().

Definition at line 65 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_ipx [private]

Definition at line 68 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_ipy [private]

Definition at line 69 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_ipz [private]

Definition at line 70 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_pid [private]

Definition at line 72 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

Definition at line 71 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_R0 [private]

Definition at line 66 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

bool EventHeaderSvc::flag_R1 [private]

Definition at line 67 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

Definition at line 64 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), ReSet(), SetBranch(), and ShowOutCard().

Definition at line 73 of file EventHeaderSvc.hh.

Referenced by ReadOutputCard(), SetBranch(), and ShowOutCard().

std::string EventHeaderSvc::i_particleName [private]

Definition at line 62 of file EventHeaderSvc.hh.

Referenced by SetBranch(), and SetInitialParticle().

double EventHeaderSvc::ipx [private]

Definition at line 59 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialMomentum().

double EventHeaderSvc::ipy [private]

Definition at line 59 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialMomentum().

double EventHeaderSvc::ipz [private]

Definition at line 59 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialMomentum().

double EventHeaderSvc::ix [private]

Definition at line 60 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialPosition().

double EventHeaderSvc::iy [private]

Definition at line 60 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialPosition().

double EventHeaderSvc::iz [private]

Definition at line 60 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), SetBranch(), and SetInitialPosition().

Definition at line 75 of file EventHeaderSvc.hh.

int EventHeaderSvc::R0 [private]

Definition at line 57 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), get_R0(), set_R0(), SetBranch(), and SetSeedsValue().

int EventHeaderSvc::R1 [private]

Definition at line 58 of file EventHeaderSvc.hh.

Referenced by EventHeaderSvc(), get_R1(), set_R1(), SetBranch(), and SetSeedsValue().

int EventHeaderSvc::run_num [private]

Definition at line 55 of file EventHeaderSvc.hh.

Referenced by set_run_num(), SetBranch(), and SetValue().

double EventHeaderSvc::weight [private]

Definition at line 61 of file EventHeaderSvc.hh.

Referenced by set_weight(), SetBranch(), and SetValue().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1