/** @file mSTS DATA unpacking for binning FW ** @author P.-A. Loizeau ** @date 17.04.2020 ** 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_sts_binning(TString inFile = "", UInt_t uRunId = 0, UInt_t nrEvents=0, TString outDir="data", TString inDir="") { 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 runId = TString::Format("%u", uRunId); TString outFile = outDir + "/unp_sts_" + runId + ".root"; TString parFile = outDir + "/unp_sts_params_" + runId + ".root"; // --- Set log output levels FairLogger::GetLogger(); gLogger->SetLogScreenLevel("INFO"); //gLogger->SetLogScreenLevel("DEBUG4"); gLogger->SetLogVerbosityLevel("MEDIUM"); //gLogger->SetLogVerbosityLevel("LOW"); // --- Define parameter files TList *parFileList = new TList(); TString paramDir = srcDir + "/macro/beamtime/mcbm2020/"; TString paramFileSts = paramDir + "mStsPar.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; CbmMcbm2018UnpackerTaskSts * unpacker_sts = new CbmMcbm2018UnpackerTaskSts(); unpacker_sts ->SetMonitorMode(); unpacker_sts ->SetIgnoreOverlapMs(); unpacker_sts ->SetBinningFwFlag( kTRUE ); // ------------------------------ // // Enable Asic type for MUCH data. // fFlag = 0 ==> Asic type 2.0 (20) ---> December 2018 and March 2019 Data // fFlag = 1 ==> Asic type 2.1 (21) ---> December 2019 Data // This is to correct the channel fliping problem in smx 2.1 chip //Int_t fFlag = 1; //unpacker_much->EnableAsicType(fFlag); // ------------------------------ // // --- Source task CbmMcbm2018Source* source = new CbmMcbm2018Source(); source->SetFileName(inFile); // source->SetInputDir(inDir); source->AddUnpacker(unpacker_sts, 0x10, ECbmModuleId::kSts );//STS xyter // --- Event header FairEventHeader* event = new CbmTbEvent(); event->SetRunId(uRunId); // --- RootFileSink // --- Open next outputfile after 4GB FairRootFileSink* sink = new FairRootFileSink(outFile); // sink->GetOutTree()->SetMaxTreeSize(4294967295LL); // --- Run run = new FairRunOnline(source); run->SetSink(sink); 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_mcbm: Starting run..." << std::endl; if ( 0 == nrEvents) { run->Run(nEvents, 0); // run until end of input file } else { run->Run(0, nrEvents); // process N Events } 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_mcbm: Macro finished successfully." << std::endl; std::cout << ">>> unpack_tsa_mcbm: Output file is " << outFile << std::endl; std::cout << ">>> unpack_tsa_mcbm: 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; }