Message: Re: CSV overwriting/interrupting lines in multithreaded operation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: CSV overwriting/interrupting lines in multithreaded operation 

Forum: Analysis
Re: Question CSV overwriting/interrupting lines in multithreaded operation (Nicole Ackerman)
Re: None Re: CSV overwriting/interrupting lines in multithreaded operation (Ivana Hrivnacova)
Date: 20 Jan, 2017
From: Nicole Ackerman <Nicole Ackerman>

Guy, thank you for the suggestion. I am fairly sure that there should be no special characters, since I am just printing out the particle name and creation process from Geant4. I don't believe that these lines are happening at the end of the file, I think they have happened somewhere in the middle.

Ivana, I have copied below what my colleague told me she has submitted to her cluster. It has been a long time since I worked on a a batch system, and it was before multithreading (so I apologize if this does not answer your question). I have run the program locally on a single computer with multithreading, and I didn't see any issues. However, that was only 4 threads and not as many events as she is running.

> qsub - I -q comp16 -l nodes=1:ppn=16 
> export G4FORCENUMBEROFTHREADS=16
> mpirun -np 16 ~/path/executable < input file

For the code itself, I think I have followed example code fairly closely to use the CSV analysis manager. I've copied below the two snippets of code that I think are most relevant for writing out these data. We are using version 4.10.2.p02

=====
void EventAction::EndOfEventAction(const G4Event* event)
 {

  G4HCofThisEvent* hce = event->GetHCofThisEvent();
  if (!hce)
  {
    G4ExceptionDescription msg;
    msg << "No hits collection of this event found.\n";
    G4Exception("EventAction::EndOfEventAction()","Code001", JustWarning, msg);
    return;
  }

  // Get hits collections
  BMHitsCollection* hHC1 = static_cast<BMHitsCollection*>(hce->GetHC(fHHC1ID));

  if (!hHC1)
  {
    G4ExceptionDescription msg;
    msg << "Some of hits collections of this event not found.\n";
    G4Exception("EventAction::EndOfEventAction()","Code001", JustWarning, msg);
    return;
  }

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

  for (G4int i=0;i<hHC1->entries();i++)
  {
    analysisManager->FillNtupleIColumn(0,(*hHC1)[i]->GetEventID());
    analysisManager->FillNtupleIColumn(1,(*hHC1)[i]->GetTrackID());
    analysisManager->FillNtupleSColumn(2,(*hHC1)[i]->GetParticleName());
    analysisManager->FillNtupleDColumn(3,(*hHC1)[i]->GetEkin());
    analysisManager->FillNtupleDColumn(4,(*hHC1)[i]->GetEdep());
    analysisManager->FillNtupleDColumn(5,(*hHC1)[i]->GetEtr());
    analysisManager->FillNtupleSColumn(6,(*hHC1)[i]->GetProcessName());
    analysisManager->FillNtupleDColumn(7,(*hHC1)[i]->GetRho());
    analysisManager->FillNtupleDColumn(8,(*hHC1)[i]->GetPhi());
    analysisManager->FillNtupleDColumn(9,(*hHC1)[i]->GetZ());
    analysisManager->FillNtupleDColumn(10,(*hHC1)[i]->GetGlobalTime());
    analysisManager->FillNtupleDColumn(11,(*hHC1)[i]->GetBoxX());
    analysisManager->FillNtupleDColumn(12,(*hHC1)[i]->GetBoxY());
    analysisManager->FillNtupleDColumn(13,(*hHC1)[i]->GetBoxZ());
    analysisManager->FillNtupleIColumn(14,(*hHC1)[i]->GetCoNo());
    analysisManager->FillNtupleSColumn(15,(*hHC1)[i]->GetIso());
    analysisManager->FillNtupleSColumn(16,(*hHC1)[i]->GetDaughter());
    analysisManager->FillNtupleSColumn(17,(*hHC1)[i]->GetDaughterProcess());
    analysisManager->FillNtupleDColumn(18,(*hHC1)[i]->GetDaughterEnergy());
    //G4cout<<"Track"<< i  <<G4endl;

    analysisManager->AddNtupleRow();
  }
 }

=====

void RunAction::EndOfRunAction(const G4Run* /*run*/){
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();

  analysisManager->Write();
  analysisManager->CloseFile();
}

=====

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

1 None: Re: CSV overwriting/interrupting lines in multithreaded operation   (Ivana Hrivnacova - 20 Jan, 2017)
(_ None: Re: CSV overwriting/interrupting lines in multithreaded operation   (Nicole Ackerman - 20 Jan, 2017)
(_ None: Re: CSV overwriting/interrupting lines in multithreaded operation   (Ivana Hrivnacova - 23 Jan, 2017)
(_ None: Re: CSV overwriting/interrupting lines in multithreaded operation   (Nicole Ackerman - 27 Jan, 2017)
 Add Message Add Message
to: "Re: CSV overwriting/interrupting lines in multithreaded operation"

 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 ]