Nowy plik MyAnalysis.hh

#ifndef MYANALYSIS_HH
#define MYANALYSIS_HH

#include "g4root.hh"
//#include "g4xml.hh"
//#include "g4csv.hh"

#endif


Zmiana formatu z ROOT na CSV realizowana poprzez zakomentowanie i odkomentowanie odpowiedniego pliku nagłówkowego.


ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

W pliku MyRunAction  (zmiany kolorem czerwonym)


....................................................................................................................................
#include "MyAnalysis.hh"
.....................................................................................................................................


void MyRunAction::BeginOfRunAction(const G4Run* aRun)
{
 G4cout << "MyLog:   Begin of run" << G4endl;

// Create analysis manager
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  analysisManager->SetVerboseLevel(1);
  analysisManager->SetFirstHistoId(1);
 
// Open an output file
  analysisManager->OpenFile("hist.root");

// Creating histograms
 G4int idPhotonFlux = analysisManager->CreateH1("PhotonFlux","photon flow",15,0.,90.);


}


void MyRunAction::EndOfRunAction(const G4Run* aRun)

{
 
// Get analysis manager
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();

// Get histogram id not efficient in event loop

  G4int idPhotonFlux = analysisManager->GetH1Id("PhotonFlux");
 
  MyRun* theRun = (MyRun*) aRun;
  G4cout << "MyLog: number of map entries in run: " << theRun->frunHitsMap.entries() << G4endl;
 
  std::map<int,double*>::iterator iter;
  iter = theRun->frunHitsMap.GetMap()->begin();
  while( iter != theRun->frunHitsMap.GetMap()->end() ) {

// Fill histagrams as weighted events
  analysisManager->FillH1(idPhotonFlux, (iter->first+0.5)*90./15. , *iter->second);

 
  G4cout<< "MyLog:      value of HitsMap for run: "<< *iter->second << " index of value: "<< iter->first << G4endl;
  iter++;
  }
 
// Save histograms and close file
  analysisManager->Write();
  analysisManager->CloseFile();


....................................................................................................................