Message: Resetting Analysis Manager Between Runs (Seg Fault Troubles) Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Resetting Analysis Manager Between Runs (Seg Fault Troubles) 

Forum: Analysis
Date: 23 Oct, 2015
From: William Donahue <William Donahue>


I want to export a CSV file of final results at the end of every run. I currently am merging all my results into a run and then writing to file using analysis manager. Initially i forgot to open and close files when performing this operation so all of my data was being dumped into a single file. After adding the file open and close commands I now get a segfault during my second run. I believe i need to reset the analysis manager between runs. What is the way to do this?



Code snippet from EndOfRunAction:

if (IsMaster()) {

     << "\n--------------------End of Global Run-----------------------"<<G4endl;

     //Get Logical Volume Store
     G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();

     //Get Analysis Manger and Create Ntuple
     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();

     //Open File
     //create Output Ntuple
     analysisManager->CreateNtuple("Doses", "Organ Doses");
    	analysisManager->CreateNtupleIColumn("OrganID");  // column Id = 0
	     analysisManager->CreateNtupleSColumn("Logical Volume Name");  // column Id = 1
	   analysisManager->CreateNtupleDColumn("Energy MeV"); // column Id = 2
	   analysisManager->CreateNtupleDColumn("Mass kg"); // column Id = 3
     analysisManager->CreateNtupleDColumn("Dose Gy"); // column Id = 4

     //Process Data

     const Run* localRun = static_cast<const Run*>(run);
  const Map localMap = localRun->GetRunMap();

  Map::const_iterator i= localMap.begin();
  Map::const_iterator end= localMap.end();

  G4double totalEnergyDepositInPhantom =0.;
  G4double totalMass =0.;
  G4int k=0;
  //Loop through data struct
      G4String bodypart = i->first;
      G4double energyDep = i->second;
      //  if(energyDep != 0.)
      //	{

       //find mass of Organ
       G4double mass = lvs->GetVolume(bodypart)->GetMass(false,false);

      G4cout << "Energy Total in Run:" << bodypart << ", ID: "  << k 
             << ", Energy Deposition (MeV): "  
	     << energyDep/MeV
	     << G4endl;

          analysisManager->FillNtupleIColumn(0, k); //ID
					analysisManager->FillNtupleSColumn(1, bodypart); //Name
					analysisManager->FillNtupleDColumn(2, energyDep/MeV); //Energy Deposited
					analysisManager->FillNtupleDColumn(3, mass/kg );
          analysisManager->FillNtupleDColumn(4, (energyDep/joule)/(mass/kg) );



     totalEnergyDepositInPhantom += energyDep;
     totalMass +=mass;

 G4cout << "Total Energy deposit in the body is: " 
	<< totalEnergyDepositInPhantom/MeV << " MeV" <<G4endl;

          analysisManager->FillNtupleIColumn(0, k); //ID
					analysisManager->FillNtupleSColumn(1, "body"); //Name
					analysisManager->FillNtupleDColumn(2, totalEnergyDepositInPhantom/MeV); //Energy Deposited
					analysisManager->FillNtupleDColumn(3, totalMass/kg );
          analysisManager->FillNtupleDColumn(4, (totalEnergyDepositInPhantom/joule)/(totalMass/kg) );

          //write to disk

          //close file


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

1 None: Re: Resetting Analysis Manager Between Runs (Seg Fault Troubles)   (Ivana Hrivnacova - 28 Oct, 2015)
(_ None: Re: Resetting Analysis Manager Between Runs (Seg Fault Troubles)   (Ivana Hrivnacova - 03 Nov, 2015)
 Add Message Add Message
to: "Resetting Analysis Manager Between Runs (Seg Fault Troubles)"

 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 ]