33 #include "tools/wroot/file"
34 #include "tools/wroot/mpi_ntuple_row_wise"
35 #include "tools/wroot/mpi_ntuple_column_wise"
43 tools::impi* impi,
G4int mpiRank,
G4int destinationRank)
48 fDestinationRank(destinationRank)
56 delete ntupleDescription;
72 G4String inFunction =
"G4RootMpiPNtupleManager::";
73 inFunction += functionName;
75 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
89 if ( ! ntupleDescription )
return nullptr;
91 if ( ! ntupleDescription->fBasePNtuple ) {
93 G4String inFunction =
"G4RootMpiPNtupleManager::";
94 inFunction += functionName;
96 description <<
" " <<
"ntupleId " <<
id <<
" does not exist.";
101 return ntupleDescription->fBasePNtuple;
125 G4cerr <<
"G4RootMpiPNtupleManager::CreateNtuple: wait_buffer() failed."<<
G4endl;
130 tools::uint32 mainNtupleId;
133 unsigned int compression;
134 tools::wroot::seek seekDirectory;
135 tools::uint32 basketSize;
137 std::vector<tools::uint32> basketSizes;
138 unsigned int basketEntries;
140 if ( !
fImpi->unpack(mainNtupleId) ) {
146 if ( !
fImpi->bunpack(rowWise) ) {
152 if ( !
fImpi->bunpack(byteSwap) ) {
158 if ( !
fImpi->unpack(compression) ) {
164 if ( !
fImpi->unpack(seekDirectory) ) {
171 if ( !
fImpi->unpack(basketSize) ) {
176 if ( !
fImpi->bunpack(rowMode) ) {
180 if ( !
fImpi->vunpack(basketSizes) ) {
184 if( !
fImpi->unpack(basketEntries) ) {
202 tools::wroot::mpi_ntuple_row_wise*
ntuple
203 =
new tools::wroot::mpi_ntuple_row_wise(
204 mainNtupleId,
G4cout, byteSwap, compression, seekDirectory,
209 tools::wroot::mpi_ntuple_column_wise*
ntuple
210 =
new tools::wroot::mpi_ntuple_column_wise(
211 mainNtupleId,
G4cout, byteSwap, compression, seekDirectory,
213 rowMode, basketEntries, verbose);
247 if ( ntupleDescription->fNtuple )
continue;
252 ->
Message(
"create from booking",
"mpi pntuple",
253 ntupleDescription->fNtupleBooking.name());
266 ->
Message(
"create from booking",
"mpi pntuple",
267 ntupleDescription->fNtupleBooking.name());
292 ntupleDescription->fNtupleBooking.set_name(name);
293 ntupleDescription->fNtupleBooking.set_title(title);
300 description << name <<
" ntupleId " << index +
fFirstId;
312 return CreateNtupleTColumn<int>(ntupleId,
name, vector);
319 return CreateNtupleTColumn<float>(ntupleId,
name, vector);
326 return CreateNtupleTColumn<double>(ntupleId,
name, vector);
333 return CreateNtupleTColumn<std::string>(ntupleId,
name,
nullptr);
344 return FillNtupleTColumn<int>(ntupleId, columnId,
value);
351 return FillNtupleTColumn<float>(ntupleId, columnId,
value);
358 return FillNtupleTColumn<double>(ntupleId, columnId,
value);
365 return FillNtupleTColumn<std::string>(ntupleId, columnId,
value);
379 description <<
" ntupleId " << ntupleId;
385 if ( ! ntupleDescription )
return false;
389 = ntupleDescription->fNtuple
394 description <<
" " <<
" ntupleId " << ntupleId
395 <<
"adding row has failed.";
396 G4Exception(
"G4RootMpiPNtupleManager::AddNtupleRow()",
403 description <<
" ntupleId " << ntupleId;
417 auto finalResult =
true;
422 if ( ! ntupleDescription->fActivation )
continue;
426 if ( ! ntupleDescription->fNtuple )
continue;
431 ->
Message(
"end_fill",
"pntuple", ntupleDescription->fNtupleBooking.name());
437 <<
" to rank " << ntupleDescription->fMainNtupleRank
438 <<
" pntuple: " << ntupleDescription->fNtuple <<
G4endl;
440 = ntupleDescription->fNtuple
445 description <<
" " <<
" ntuple " << ntupleDescription->fNtupleBooking.name()
446 <<
"end fill has failed.";
451 delete ntupleDescription->fNtuple;
452 ntupleDescription->fNtuple =
nullptr;
457 ->
Message(
"end_fill",
"pntuple", ntupleDescription->fNtupleBooking.name());
469 if ( deleteNtuple ) {
470 delete ntupleDescription->fNtuple;
472 ntupleDescription->fNtuple =
nullptr;
486 ntupleDescription->fActivation = activation;
496 if ( ! ntupleDescription )
return;
498 ntupleDescription->fActivation = activation;
503 G4int ntupleId)
const
506 if ( ! ntupleDescription )
return false;
508 return ntupleDescription->fActivation;
533 G4String inFunction =
"G4RootMpiPNtupleManager::::GetBasketSize";
535 description <<
" " <<
"File manager must be defined first.";