-
Administrator authored
Apply code formatting to all source/header files and root macros.
Administrator authoredApply code formatting to all source/header files and root macros.
unpack_tsa_psd.C 3.35 KiB
/** @file MCBM PSD DATA unpacking
** @author Nikolay Karpushkin <karpushkin@inr.ru>
** @date 09.10.2019
** Based on unpack_tsa_tof by P.-A. Loizeau
** ROOT macro to read tsa files which have been produced with the new data transport
** Convert data into cbmroot format.
** Uses CbmMcbm2018Source as source task.
*/
// In order to call later Finish, we make this global
FairRunOnline* run = NULL;
void unpack_tsa_psd(TString inFile = "") {
TString srcDir = gSystem->Getenv("VMCWORKDIR");
// --- Specify number of events to be produced.
// --- -1 means run until the end of the input file.
Int_t nEvents = -1;
// --- Specify output file name (this is just an example)
TString outFile = "data/unp_psd.root";
TString parFile = "data/unp_psd_params.root";
// --- Set log output levels
FairLogger::GetLogger();
gLogger->SetLogScreenLevel("INFO");
//gLogger->SetLogScreenLevel("DEBUG");
gLogger->SetLogVerbosityLevel("MEDIUM");
// --- Define parameter files
TList* parFileList = new TList();
TString paramDir = "./";
TString paramFileSts = paramDir + "mPsdPar.par";
TObjString* parStsFileName = new TObjString(paramFileSts);
parFileList->Add(parStsFileName);
// --- Set debug level
gDebug = 0;
std::cout << std::endl;
std::cout << ">>> unpack_tsa: output file is " << outFile << std::endl;
// ------------------------------------------------------------------------
std::cout << std::endl;
std::cout << ">>> unpack_tsa: Initialising..." << std::endl;
CbmMcbm2018UnpackerTaskPsd* unpacker_psd = new CbmMcbm2018UnpackerTaskPsd();
unpacker_psd->SetIgnoreOverlapMs();
unpacker_psd->SetDiamondDpbIdx(2);
// --- Source task
CbmMcbm2018Source* source = new CbmMcbm2018Source();
source->SetFileName(inFile);
source->AddUnpacker(unpacker_psd, 0x80, kPsd);
// --- Event header
FairEventHeader* event = new CbmTbEvent();
event->SetRunId(1);
// --- Run
run = new FairRunOnline(source);
run->SetOutputFile(outFile);
run->SetEventHeader(event);
run->SetAutoFinish(kFALSE);
// ----- Runtime database ---------------------------------------------
FairRuntimeDb* rtdb = run->GetRuntimeDb();
Bool_t kParameterMerged = kTRUE;
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
FairParAsciiFileIo* parIn = new FairParAsciiFileIo();
parOut->open(parFile.Data());
parIn->open(parFileList, "in");
rtdb->setFirstInput(parIn);
rtdb->setOutput(parOut);
run->Init();
// --- Start run
TStopwatch timer;
timer.Start();
std::cout << ">>> unpack_tsa_psd: Starting run..." << std::endl;
run->Run(nEvents, 0); // run until end of input file
//run->Run(0, nEvents); // process nEvents
run->Finish();
timer.Stop();
std::cout << "Processed " << std::dec << source->GetTsCount() << " timeslices"
<< std::endl;
// --- End-of-run info
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << ">>> unpack_tsa_psd: Macro finished successfully." << std::endl;
std::cout << ">>> unpack_tsa_psd: Output file is " << outFile << std::endl;
std::cout << ">>> unpack_tsa_psd: Real time " << rtime << " s, CPU time "
<< ctime << " s" << std::endl;
std::cout << std::endl;
/// --- Screen output for automatic tests
std::cout << " Test passed" << std::endl;
std::cout << " All ok " << std::endl;
}