Message: Re: how to get the RMS error of cellFlux scoring by mesh_box? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: how to get the RMS error of cellFlux scoring by mesh_box? 

Forum: Biasing and Scoring
Re: Question how to get the RMS error of cellFlux scoring by mesh_box? (lcl)
Date: 27 May, 2014
From: lcl <lcl>

I have found how to calcule error for scoring mesh.

error=

x=1.96

void EventAction::EndOfEventAction(const G4Event* evt)
{
  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
  if(!HCE) return;
  G4SDManager* SDMan = G4SDManager::GetSDMpointer();
  G4int colID = SDMan->GetCollectionID("boxMesh_1/trackLengthGamma");
  G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(colID));
  std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin();
  for(; itr != evtMap->GetMap()->end(); itr++)
    {
      sum[itr->first] += *(itr->second);
      sum2[itr->first] += (*(itr->second))*(*(itr->second));
    }    
}  
void RunAction::EndOfRunAction(const G4Run* aRun)
{
  G4int nofEvents = aRun->GetNumberOfEvent();
  if (nofEvents == 0) return;
  G4double sqrt_n = std::sqrt(nofEvents);   
  
  std::map<G4int,G4double> Rsum  = EventAction::Instance()->sum;// sum in RunAction
  std::map<G4int,G4double> Rsum2 = EventAction::Instance()->sum2;
  std::map<G4int,G4double> sigma,error;
  std::map<G4int,G4double>::iterator itr = Rsum.begin();
  std::ofstream ofile("error.txt");
  if(!ofile) return;
  for(; itr != Rsum.end(); itr++)
    {
      G4int i = itr->first;
      sigma[i] = Rsum2[i]/nofEvents-(Rsum[i]/nofEvents)*(Rsum[i]/nofEvents);
      if (sigma[i] > 0.) sigma[i] = std::sqrt(sigma[i]);else sigma[i] = 0.;
      error[i] = 1.96*sigma[i]/sqrt_n;
      ofile << itr->first << " " << error[i]/Rsum[i]*nofEvents << G4endl;
    }
  ofile.close(); 
} 

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

1 None: Re: how to get the RMS error of cellFlux scoring by mesh_box?   (Sarah - 31 May, 2014)
1 None: Re: how to get the RMS error of cellFlux scoring by mesh_box?   (lcl - 31 May, 2014)
1 None: Re: how to get the RMS error of cellFlux scoring by mesh_box?   (Sarah - 31 May, 2014)
... 2 Message(s)
2 None: Re: how to get the RMS error of cellFlux scoring by mesh_box?   (Sarah - 08 Jun, 2014)
... 1 Message(s)
2 Question: Re: how to get the RMS error of cellFlux scoring by mesh_box?   (Jessica Garczarczyk - 15 Nov, 2017)
 Add Message Add Message
to: "Re: how to get the RMS error of cellFlux scoring by mesh_box?"

 Subscribe Subscribe

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