// -----------------------------------------------------------------------------
// ----- create_calib.C -----
// ----- -----
// ----- adapted by C. Simon on 2019-03-04 -----
// ----- -----
// -----------------------------------------------------------------------------
void create_calib(Long64_t iNEvents, const TString& tFileId, Bool_t bTimeBasedData)
{
// ---------------------------------------------------------------------------
TString tLogLevel = "NOLOG";// "ERROR";
TString tLogVerbosity = "LOW";
gErrorIgnoreLevel = kWarning;
gDebug = 0;
TTree::SetMaxTreeSize(1000000000000LL); // [B] here: 1 TB
// ---------------------------------------------------------------------------
TStopwatch tTimer;
tTimer.Start();
// ---------------------------------------------------------------------------
FairLogger::GetLogger()->SetLogScreenLevel(tLogLevel.Data());
FairLogger::GetLogger()->SetLogVerbosityLevel(tLogVerbosity.Data());
// ---------------------------------------------------------------------------
TString tSrcDir = gSystem->Getenv("VMCWORKDIR");
TString tParamDir = tSrcDir + "/macro/tof/beamtime/sim/nov15";
// ---------------------------------------------------------------------------
TList* tParFileList = new TList();
TObjString* tUnpackParFile = new TObjString(tParamDir + "/unpack.par");
TObjString* tCalibParFile = new TObjString(tParamDir + "/calib.par");
tParFileList->Add(tUnpackParFile);
tParFileList->Add(tCalibParFile);
// ---------------------------------------------------------------------------
CbmHldSource* tFileSource = new CbmHldSource();
tFileSource->AddPath("/lustre/nyx/cbm/prod/beamtime/2015/11/cern/data/production/", Form("CbmTofSps_%s*.hld", tFileId.Data()));
// ---------------------------------------------------------------------------
FairRunOnline* tRun = new FairRunOnline();
tRun->SetAutoFinish(kFALSE);
tRun->SetSource(tFileSource);
if(!bTimeBasedData)
{
tRun->SetOutputFile("data/unpack.calib.root");
}
else
{
tRun->SetOutputFile("data/raw.calib.root");
}
/*
FairMonitor::GetMonitor()->EnableMonitor(kTRUE);
*/
// ---------------------------------------------------------------------------
FairRuntimeDb* tRuntimeDb = tRun->GetRuntimeDb();
FairParAsciiFileIo* tParIo1 = new FairParAsciiFileIo();
tParIo1->open(tParFileList, "in");
tRuntimeDb->setFirstInput(tParIo1);
// ---------------------------------------------------------------------------
TTrbUnpackTof* tTofTrbDataUnpacker = new TTrbUnpackTof(10, 1, 31, 0, 0);
tTofTrbDataUnpacker->SetInspection(kTRUE);
tTofTrbDataUnpacker->SetSaveRawData(kFALSE);
// ---------------------------------------------------------------------------
tFileSource->AddUnpacker(tTofTrbDataUnpacker);
// ---------------------------------------------------------------------------
TMbsUnpTofMonitor* tTofUnpMonitor = new TMbsUnpTofMonitor("Tof Unp Moni");
// ---------------------------------------------------------------------------
TTofTrbTdcCalib* tTofCalibTrb = new TTofTrbTdcCalib();
tTofCalibTrb->CreateCalibration(kTRUE);
tTofCalibTrb->SaveCalibData(kFALSE);
tTofCalibTrb->SetFineTimeMethod(0);
tTofCalibTrb->SetToTMethod(0);
tTofCalibTrb->SetMinEntriesBinByBin(100000);
tTofCalibTrb->SetMinEntriesLocalFineLimits(10000);
tTofCalibTrb->SetTimeContinuum(kTRUE);
tTofCalibTrb->SetTrailingOffsetCycles(2);
tTofCalibTrb->SetLowerLinearFineLimit(16);
tTofCalibTrb->SetUpperLinearFineLimit(490);
tTofCalibTrb->SetReferenceBoard(0);
tTofCalibTrb->SetToTSingleLeading(-100.);
// ---------------------------------------------------------------------------
CbmTofOnlineDisplay* tTofOnlineDisplay = new CbmTofOnlineDisplay();
tTofOnlineDisplay->MonitorTdcOccupancy(kTRUE);
tTofOnlineDisplay->MonitorCts(kTRUE);
tTofOnlineDisplay->MonitorSebStatus(kTRUE);
tTofOnlineDisplay->MonitorTdcStatus(kTRUE);
tTofOnlineDisplay->MonitorFSMockup(kTRUE);
tTofOnlineDisplay->MonitorInspection(kTRUE);
tTofOnlineDisplay->MonitorCalibration(kTRUE);
// tTofOnlineDisplay->SetUpdateInterval(10000);
tTofOnlineDisplay->SetUpdateInterval(100000000); // disables live updates (speed-up)
// ---------------------------------------------------------------------------
tRun->AddTask(tTofUnpMonitor);
tRun->AddTask(tTofCalibTrb);
tRun->AddTask(tTofOnlineDisplay);
// ---------------------------------------------------------------------------
std::cout << "-I- create_calib: initializing run..." << std::endl;
tRun->Init();
std::cout << "-I- create_calib: starting run..." << std::endl;
tRun->Run(0, iNEvents);
// ---------------------------------------------------------------------------
if(tTofTrbDataUnpacker->IsGoodEventInBuffer())
{
FairRootManager::Instance()->SetLastFill(kTRUE);
}
// ---------------------------------------------------------------------------
std::cout << "-I- create_calib: finishing run..." << std::endl;
tRun->Finish();
// ---------------------------------------------------------------------------
tTofTrbDataUnpacker->WriteHistograms();
// ---------------------------------------------------------------------------
tTimer.Stop();
Double_t dRealTime = tTimer.RealTime();
Double_t dCPUTime = tTimer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << "Macro finished successfully." << std::endl;
std::cout << "Real time " << dRealTime << " s, CPU time " << dCPUTime << " s" << std::endl;
std::cout << std::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 tSysInfo;
Float_t fMaxMemory = tSysInfo.GetMaxMemory();
std::cout << "";
std::cout << fMaxMemory;
std::cout << "" << endl;
Float_t fCPUUsage = dCPUTime/dRealTime;
std::cout << "";
std::cout << fCPUUsage;
std::cout << "" << endl;
/*
FairMonitor::GetMonitor()->Print();
*/
// ---------------------------------------------------------------------------
}