This macro shows the usage of TMPIFile to simulate event reconstruction and merging them in parallel.
#include "TMPIFile.h"
#ifdef TMPI_SECOND_RUN
#include <chrono>
#include <sstream>
{
if (
newfile->GetMPIGlobalRank() == 0) {
Info(
"test_tmpi",
" running with parallel ranks: %d",
newfile->GetMPIGlobalSize());
}
Info(
"Collector",
"[%d]\troot output filename = %s",
newfile->GetMPIGlobalRank(),
smpifname.str().c_str());
}
} else {
auto sync_start = std::chrono::high_resolution_clock::now();
auto start = std::chrono::high_resolution_clock::now();
auto evt_built = std::chrono::high_resolution_clock::now();
double build_time = std::chrono::duration_cast<std::chrono::duration<double>>(
evt_built - start).count();
Info(
"Rank",
"[%d] [%d]\tevt = %d;\tbuild_time = %f",
newfile->GetMPIColor(),
newfile->GetMPILocalRank(), i,
std::this_thread::sleep_for(std::chrono::seconds(
int(
sleep)));
auto end = std::chrono::high_resolution_clock::now();
double sync_time = std::chrono::duration_cast<std::chrono::duration<double>>(end -
sync_start).count();
Info(
"Rank",
"[%d] [%d]\tevent collection time: %f",
newfile->GetMPIColor(),
newfile->GetMPILocalRank(),
sync_start = std::chrono::high_resolution_clock::now();
}
}
}
}
Info(
"Rank",
"[%d] [%d]\tclosing file",
newfile->GetMPIColor(),
newfile->GetMPILocalRank());
if (
newfile->GetMPILocalRank() == 0) {
if (file.IsOpen()) {
file.ls();
if (tree)
Info(
"Rank",
"[%d] [%d]\tfile should have %d events and has %lld",
newfile->GetMPIColor(),
}
}
}
{
auto start = std::chrono::high_resolution_clock::now();
auto end = std::chrono::high_resolution_clock::now();
double time = std::chrono::duration_cast<std::chrono::duration<double>>(end - start).count();
std::string
msg =
"Total elapsed time: ";
msg += std::to_string(time);
Info(
"testTMPIFile",
"%s",
msg.c_str());
Info(
"testTMPIFile",
"exiting");
}
#else
{
}
gROOT->ProcessLine(
".L JetEvent.cxx+");
}
gROOT->ProcessLine(
"#define TMPI_SECOND_RUN yes");
gROOT->ProcessLine(
"testTMPIFile(true)");
}
}
#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
R__EXTERN C unsigned int sleep(unsigned int seconds)
R__EXTERN TRandom * gRandom
R__EXTERN TSystem * gSystem
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual UInt_t GetSeed() const
Get the random generator seed.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
void Print(Option_t *option="") const override
Print a summary of the tree contents.
virtual Long64_t GetEntries() const
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
virtual void SetAutoFlush(Long64_t autof=-30000000)
This function may be called at the start of a program to change the default value for fAutoFlush.
RVec< PromoteType< T > > abs(const RVec< T > &v)