// --------------------------------------------------------------------------
//
// Macro for STS QA
//
// V. Friese 13/01/2006
//
// --------------------------------------------------------------------------
void run_qa(Int_t nEvents = 1, const char* setupName = "sis100_electron")
{
// ========================================================================
// Adjust this part according to your requirements
// Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
Int_t iVerbose = 1;
TString outDir = "data/";
// MC file
TString simFile = outDir + setupName + "_test.mc.root"; // Input file (MC events)
// Reco file
TString recFile = outDir + setupName + "_test.eds.root"; // Output file
// Parameter file
TString parFile = outDir + setupName + "_params.root"; // Parameter file
// Output file
TString outFile = outDir + setupName + "_test.qa.root"; // Output file
TString srcDir = gSystem->Getenv("VMCWORKDIR");
TString paramDir = srcDir + "/parameters/";
// ----- Load the geometry setup -------------------------------------
std::cout << std::endl;
TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C";
TString setupFunct = "setup_";
setupFunct = setupFunct + setupName + "()";
std::cout << "-I- " << "run_qa" << ": Loading macro " << setupFile << std::endl;
gROOT->LoadMacro(setupFile);
gROOT->ProcessLine(setupFunct);
// In general, the following parts need not be touched
// ========================================================================
// ----- Timer --------------------------------------------------------
TStopwatch timer;
timer.Start();
// ------------------------------------------------------------------------
// ----- Analysis run --------------------------------------------------
FairRunAna *fRun= new FairRunAna();
FairFileSource* inputSource = new FairFileSource(recFile);
fRun->SetSource(inputSource);
// fRun->SetInputFile(simFile);
// fRun->AddFriend(recFile);
// fRun->SetInputFile(recFile);
// fRun->AddFriend(simFile);
fRun->SetOutputFile(outFile);
// Define output file for FairMonitor histograms
TString monitorFile{outFile};
monitorFile.ReplaceAll("qa","qa.monitor");
FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile);
// ------------------------------------------------------------------------
// ----- Parameter database --------------------------------------------
FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
FairParRootFileIo* parIo1 = new FairParRootFileIo();
parIo1->open(parFile.Data(),"UPDATE");
rtdb->setFirstInput(parIo1);
// ------------------------------------------------------------------------
// ----- Intialise and run --------------------------------------------
fRun->Init();
rtdb->setOutput(parIo1);
rtdb->saveOutput();
rtdb->print();
cout << "Starting run" << endl;
fRun->Run(0,nEvents);
// ------------------------------------------------------------------------
// ----- Finish -------------------------------------------------------
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
cout << endl << endl;
cout << "Macro finished succesfully." << endl;
cout << "Output file is " << outFile << endl;
cout << "Parameter file is " << parFile << endl;
cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
cout << endl;
// ------------------------------------------------------------------------
// Extract the maximal used memory an add is as Dart measurement
// This line is filtered by CTest and the value send to CDash
FairSystemInfo sysInfo;
Float_t maxMemory=sysInfo.GetMaxMemory();
cout << "";
cout << maxMemory;
cout << "" << endl;
Float_t cpuUsage=ctime/rtime;
cout << "";
cout << cpuUsage;
cout << "" << endl;
FairMonitor* tempMon = FairMonitor::GetMonitor();
tempMon->Print();
RemoveGeoManager();
cout << " Test passed" << endl;
cout << " All ok " << endl;
}