Message: Re: AnalysisManager root performance for large numbers of ntuples Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: AnalysisManager root performance for large numbers of ntuples 

Forum: Analysis
Re: None AnalysisManager root performance for large numbers of ntuples (Sebastian Heil)
Re: None Re: AnalysisManager root performance for large numbers of ntuples (Ivana Hrivnacova)
Date: 02 Jan, 2014
From: Sebastian Heil <Sebastian Heil>

Hi Ivana,

there are no histograms in the current implementation and write() is called in G4UserRunAction::EndOfEvent(). It happens in sequential mode aswell. I will post the essential parts of code below


void MyActionInitialization::BuildForMaster() const {
}

void MyActionInitialization::Build() const {
// prop is a pointer to an object containing most of the simulation properties like number of detectors
  SetUserAction(new MyPrimaryGeneratorAction(prop));
  SetUserAction(new MyRunAction(prop));
  SetUserAction(new MyEventAction(prop));
}



MyRunAction::MyRunAction(Properties *prop) : G4UserRunAction() {
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();

  for (int i = 0; i < properties->getDetectorNumber(); i++) {
    analysisManager->CreateNtupleDColumn(*(properties->getDetectorID(i)));
  }
  analysisManager->FinishNtuple();
}

void CECRunAction::BeginOfRunAction(const G4Run* /*run*/) {
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  analysisManager->OpenFile("root.root");
}

void MyRunAction::EndOfRunAction(const G4Run* /*run*/) {
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  G4Timer *timer = new G4Timer();
  timer->Start();
  analysisManager->Write();
  timer->Stop();
  std::cout << "MyRunAction.EndOfRun: System time used: " << timer->GetSystemElapsed() << " s"
      << std::endl;
  std::cout << "MyRunAction.EndOfRun: Real time used: " << timer->GetRealElapsed() << " s"
      << std::endl;
  analysisManager->CloseFile();
}



void MyEventAction::EndOfEventAction(const G4Event* event) {
  if (fHCID == -1) {
    fHCID = G4SDManager::GetSDMpointer()->GetCollectionID("HitCollection");
  }
  CECCalorHitsCollection* detectorHC = GetHitsCollection(fHCID, event);
  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();

  for (int i = 0; i < numberOfDetectors; i++) {
    G4double eDep = ((*detectorHC)[i])->GetEdep();;
    analysisManager->FillNtupleDColumn(i, eDep);
  }
  analysisManager->AddNtupleRow(0);
}



G4bool MySensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
  G4double edep = step->GetTotalEnergyDeposit()/keV;
  G4int id = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetInstanceID()
      - fIDOffset;
  (*fHitsCollection)[id]->Add(edep);
  return true;
}


The produced output by EndOfRun for a single event with four threads is:
MyRunAction.EndOfRun: System time used: 54.86 s
MyRunAction.EndOfRun: Real time used: 28.66 s
(for every thread of course)


Thank you very much,
Sebastian

 Add Message Add Message
to: "Re: AnalysisManager root performance for large numbers of ntuples"

 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 ]