Message: Re: how to write my output data in root? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: how to write my output data in root? 

Forum: Analysis
Re: None how to write my output data in root? (Medoo Saudi)
Date: 21 Nov, 2015
From: Medoo Saudi <Medoo Saudi>

I have tried to print data in root as following

first : in myRunAction.cc

#include "Analysis.hh"

myRunAction::myRunAction() : G4UserRunAction() {

  AnalysisManager->SetVerboseLevel(1);
  AnalysisManager->SetFirstHistoId(1);

  // Creating histograms
  AnalysisManager->CreateH1("1","step number", 100, 0., 10);
  AnalysisManager->CreateH1("2","X-Position", 100, 0., 1*CLHEP::cm);
  AnalysisManager->CreateH1("3","Y-Position", 100, 0., 1*CLHEP::cm);
  AnalysisManager->CreateH1("4","Z-Position", 100, 0., 1*CLHEP::cm);
  AnalysisManager->CreateH1("5","Kin-Energy ", 100, 0., 50*CLHEP::keV);
  AnalysisManager->CreateH1("6","particle name ", 100, 0., 0.);
}

myRunAction::~myRunAction()
{
  delete G4AnalysisManager::Instance();  
}

void myRunAction::BeginOfRunAction(const G4Run*)
{ 
  G4RunManager::GetRunManager()->SetRandomNumberStore(false);

  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();

  AnalysisManager->OpenFile("M1");

void myRunAction::EndOfRunAction(const G4Run* run)
 // save histograms
  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
  //
  AnalysisManager->Write();
  AnalysisManager->CloseFile();

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Second in SteppingAction.cc

#include "Analysis.hh"

G4Track* track = step->GetTrack();

G4double kinEnergy = track->GetKineticEnergy();

G4double nustep = track->GetCurrentStepNumber();

G4String pname =track->GetParticleDefinition()->GetParticleName();

G4double posit1 = track->GetPosition().x();

G4double posit2 = track->GetPosition().y();

G4double posit3 = track->GetPosition().z();

  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();

	AnalysisManager ->FillH1(1,nustep);
	AnalysisManager ->FillH1(2,posit1);
	AnalysisManager ->FillH1(3,posit2);
	AnalysisManager ->FillH1(4,posit3);
	AnalysisManager ->FillH1(5,kinEnergy);
	AnalysisManager ->FillH1(6,pname);

. .

I am getting errors , any help on this please .

Thanks

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: how to write my output data in root?   (Ivana Hrivnacova - 25 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Medoo Saudi - 25 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Ivana Hrivnacova - 25 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Medoo Saudi - 25 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Ivana Hrivnacova - 26 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Medoo Saudi - 26 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Ivana Hrivnacova - 26 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Medoo Saudi - 26 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Medoo Saudi - 26 Nov, 2015)
(_ None: Re: how to write my output data in root?   (Ivana Hrivnacova - 27 Nov, 2015)
(_ Ok: Re: how to write my output data in root?   (Medoo Saudi - 27 Nov, 2015)
 Add Message Add Message
to: "Re: how to write my output data in root?"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]