71 throw std::runtime_error{
"TRD not enabled in current geometry!"};
75 throw std::runtime_error{
"Failed to get TRD geo tag from CbmSetup!"};
78 TString paramFilesTrd(Form(
"%s/parameters/trd/trd_%s",
fSrcDir.Data(), geoTagTrd.Data()));
79 std::vector<TString> paramFilesVecTrd = {
"asic",
"digi",
"gas",
"gain"};
80 for (
auto parIt : paramFilesVecTrd) {
81 fParList->Add(
new TObjString(Form(
"%s.%s.par", paramFilesTrd.Data(), parIt.Data())));
84 for (
auto parFileVecIt : *
fParList) {
85 std::cout << Form(
"TrdParams - %s - added to parameter file list", parFileVecIt->GetName()) << std::endl;
91 fRun->AddTask(trdHitfinderPar);
94 .hitfinder =
"TrdHitfinderPar.yaml",
98 .hitfinder =
"TrdHitfinder2DPar.yaml",
136 TObjString* tofBdfFile =
new TObjString(
fSrcDir +
"/parameters/tof/tof_" + geoTag +
".digibdf.par");
138 std::cout <<
"-I- TOF: Using parameter file " << tofBdfFile->GetString() << std::endl;
144 Double_t dDeadtime = 50.;
146 TString TofFileFolder =
fSrcDir +
"/parameters/mcbm/";
147 bool doCalibration =
true;
148 TString cCalId =
"490.100.5.0";
149 Int_t iCalSet = 30040500;
161 cFname = Form(
"%s/%s1_TofCal.hst.root", TofFileFolder.Data(), tofCalTag.c_str());
163 if (cFname.IsNull() && doCalibration) {
165 Form(
"%s/%s_set%09d_%02d_%01dtofClust.hst.root", TofFileFolder.Data(), cCalId.Data(), iCalSet, calMode, calSel);
169 tofCluster->SetCalParFileName(cFname);
170 tofCluster->SetCalMode(calMode);
171 tofCluster->SetTotMax(20.);
172 tofCluster->SetTotMin(0.);
173 tofCluster->SetTotMean(5.);
174 tofCluster->SetMaxTimeDist(1.0);
175 tofCluster->SetChannelDeadtime(dDeadtime);
176 tofCluster->PosYMaxScal(0.75);
177 tofCluster->SetRunId(
fConfig.runId);
178 tofCluster->SetRecoParOutputDir(
fOutDirReco.string());
179 fRun->AddTask(tofCluster);
182 .calibrate =
"TofCalibratePar.yaml",
183 .hitfinder =
"TofHitfinderPar.yaml",
187 .calibrate =
"BmonCalibratePar.yaml",
188 .hitfinder =
"BmonHitfinderPar.yaml",
206 LOG(info) <<
"STS geo tag: " << geoTag;
210 sensor6cm.
SetPar(0, 6.2092);
212 sensor6cm.
SetPar(2, 0.03);
213 sensor6cm.
SetPar(3, 5.9692);
214 sensor6cm.
SetPar(4, 1024.);
215 sensor6cm.
SetPar(5, 1024.);
216 sensor6cm.
SetPar(6, 0.0058);
217 sensor6cm.
SetPar(7, 0.0058);
222 sensor12cm.
SetPar(1, 12.4);
223 sensor12cm.
SetPar(3, 12.1692);
231 auto sensorParSet =
new CbmStsParSetSensor(
"CbmStsParSetSensor",
"STS sensor parameters"
261 sensorParSet->SetParSensor(stsAddress01, sensor6cm);
262 sensorParSet->SetParSensor(stsAddress02, sensor6cm);
263 sensorParSet->SetParSensor(stsAddress03, sensor6cm);
264 sensorParSet->SetParSensor(stsAddress04, sensor6cm);
265 sensorParSet->SetParSensor(stsAddress05, sensor6cm);
266 sensorParSet->SetParSensor(stsAddress06, sensor12cm);
267 sensorParSet->SetParSensor(stsAddress07, sensor6cm);
268 sensorParSet->SetParSensor(stsAddress08, sensor12cm);
269 sensorParSet->SetParSensor(stsAddress09, sensor6cm);
270 sensorParSet->SetParSensor(stsAddress10, sensor6cm);
271 sensorParSet->SetParSensor(stsAddress11, sensor6cm);
274 uint32_t addr01 = 0x10008012;
275 uint32_t addr02 = 0x10018012;
276 uint32_t addr03 = 0x10008412;
277 uint32_t addr04 = 0x10018412;
278 uint32_t addr05 = 0x10008422;
279 uint32_t addr06 = 0x10018422;
280 uint32_t addr07 = 0x10008822;
281 uint32_t addr08 = 0x10018822;
282 uint32_t addr09 = 0x10028822;
283 uint32_t addr10 = 0x10008022;
284 uint32_t addr11 = 0x10018022;
285 uint32_t addr00 = 0x10000002;
300 sensorParSet->SetParSensor(addr01, sensor6cm);
301 sensorParSet->SetParSensor(addr02, sensor6cm);
302 sensorParSet->SetParSensor(addr03, sensor6cm);
303 sensorParSet->SetParSensor(addr04, sensor6cm);
304 sensorParSet->SetParSensor(addr05, sensor6cm);
305 sensorParSet->SetParSensor(addr06, sensor12cm);
306 sensorParSet->SetParSensor(addr07, sensor6cm);
307 sensorParSet->SetParSensor(addr08, sensor6cm);
308 sensorParSet->SetParSensor(addr09, sensor6cm);
309 sensorParSet->SetParSensor(addr10, sensor6cm);
310 sensorParSet->SetParSensor(addr11, sensor12cm);
311 sensorParSet->SetParSensor(addr00, sensor6cm);
317 recoSts->UseSensorParSet(sensorParSet);
321 auto parAsic =
new CbmStsParAsic(128, 31, 75000., 3000., 5., 800., 1000., 3.9789e-3);
325 parMod->SetAllAsics(*parAsic);
326 recoSts->UseModulePar(parMod);
331 recoSts->UseSensorCond(sensorCond);
332 recoSts->SetRecoParOutputDir(
fOutDirReco.string());
334 fRun->AddTask(recoSts);
337 .hitfinder =
"StsHitfinder.yaml",
354 Int_t muchFlag = (geoTag.Contains(
"mcbm") ? 1 : 0);
355 TString parFile = gSystem->Getenv(
"VMCWORKDIR");
356 parFile +=
"/parameters/much/much_" + geoTag(0, 4) +
"_digi_sector.root";
360 if (!muchGeoScheme->IsInitialized()) {
361 muchGeoScheme->Init(parFile, muchFlag);
366 std::string caParFilename = Form(
"%s.ca.par",
fGeoSetupTag.Data());
367 fs::path mainCfgPath = fs::absolute(fs::weakly_canonical(
fOutDirReco)) /
"MainConfig.yaml";
368 fs::path caParPath = fs::absolute(fs::weakly_canonical(
fOutDirReco)) / caParFilename;
369 if (!fs::exists(mainCfgPath)) {
370 throw std::runtime_error(
"Could not locate MainConfig.yaml");
375 pCaParHandler.SetIgnoreHitPresence(
true);
376 pCaParHandler.SetMainConfig(mainCfgPath.string());
377 pCaParHandler.StoreParameters(caParPath.string());
379 fRun->AddTask(&pCaParHandler);
390 std::string srcDirName = TString(gSystem->Getenv(
"VMCWORKDIR")).Data();
391 if (srcDirName.empty()) {
392 LOG(fatal) <<
"Cannot copy parameters: the VMCWORKDIR environmental variable is not specified";
396 fs::path srcDir = srcDirName +
"/" + cbmRunDb.GetRecoParDir();
397 if (!fs::exists(srcDir)) {
398 LOG(fatal) <<
"Source directory " << srcDir.string()
399 <<
" for the parameter files does not exist (runId=" <<
fConfig.runId <<
"). "
400 <<
"Maybe, the run ID was not defined in the CbmRunDatabase.yaml";
403 fs::path dstDir = fs::absolute(fs::weakly_canonical(
fOutDirReco));
404 if (!fs::exists(dstDir)) {
405 fs::create_directories(dstDir);
407 LOG(info) <<
"Copying parameters from " << srcDir.string() <<
" to " << dstDir.string();
408 for (fs::directory_iterator it(srcDir); it != fs::directory_iterator{}; ++it) {
409 fs::path srcFile = it->path();
410 fs::path dstFile = fs::absolute(fs::weakly_canonical(dstDir / srcFile.filename()));
411 if (fs::exists(dstFile)) {
414 fs::copy_file(srcFile, dstFile);
415 LOG(info) <<
" - copying " << srcFile.string() <<
" -> " << dstFile.string();
425 static bool callOnce =
true;
427 throw std::runtime_error(
"CbmOnlineParWrite::Run() can only be called once at the moment!");
434 fSrcDir = gSystem->Getenv(
"VMCWORKDIR");
439 cbmRunDb.LoadRun(
fConfig.runId);
442 if (config.
doAlignment && cbmRunDb.GetAlignmentTag().empty()) {
443 std::stringstream msg;
444 msg <<
"LOGIC ERROR: alignment application was required, but no alignment tag was defined in the "
445 <<
"data-base. Please, re-run the application with \"--no-alignment\" option";
446 throw std::logic_error(msg.str());
451 if (!
fConfig.experimental && !cbmRunDb.GetRecoParTag().empty()) {
455 else if (
fConfig.experimental) {
459 LOG(warn) <<
"A tag for reconstruction parameters was not defined in the CBM run database. The parameters "
460 <<
"will be stored in the output directory, but please provide a valid tag for this run ID";
466 LOG(info) <<
"Using geometry setup: " << geoSetupTag;
469 auto geoFilePath = fs::absolute(fs::weakly_canonical(
fConfig.geoFileDir)) / (geoSetupTag +
".geo.root").
Data();
470 if (!fs::exists(geoFilePath)) {
471 throw std::runtime_error{
"Geometry file " + geoFilePath.string() +
" does not exist"};
474 TString geoFile = geoFilePath.string();
475 LOG(info) <<
"Using geometry file: " << geoFile;
477 fSetup->LoadSetup(geoSetupTag);
483 fRun =
new FairRunAna();
495 TString alignmentMatrixFileName =
fSrcDir +
"/parameters/mcbm/AlignmentMatrices_" + alignmentTag +
".root";
496 if (alignmentMatrixFileName.Length() == 0) {
497 throw std::runtime_error{
"Alignment matrix file name is empty"};
500 LOG(info) <<
"Applying alignment for file '" << alignmentMatrixFileName <<
"'";
505 std::map<std::string, TGeoHMatrix>* matrices{
nullptr};
508 LOG(info) <<
"Filename: " << alignmentMatrixFileName;
509 TFile* misalignmentMatrixRootfile =
new TFile(alignmentMatrixFileName,
"READ");
510 if (misalignmentMatrixRootfile->IsOpen()) {
511 gDirectory->GetObject(
"MisalignMatrices", matrices);
512 misalignmentMatrixRootfile->Close();
515 throw std::runtime_error{
"Could not open alignment matrix file: " + alignmentMatrixFileName};
519 fRun->AddAlignmentMatrices(*matrices);
522 throw std::runtime_error{
"Could not read alignment matrices from file: " + alignmentMatrixFileName};
527 fParFiles.timesliceReco = std::make_optional<cbm::algo::RecoParFiles>();
543 fRun->AddTask(pRecoSetupManager);
552 FairRuntimeDb* rtdb =
fRun->GetRuntimeDb();
553 FairParAsciiFileIo* parIo2 =
new FairParAsciiFileIo();
554 parIo2->setAutoWritable(
false);
556 rtdb->setSecondInput(parIo2);
560 fRun->SetGeomFile(geoFile);
566 gGeoManager->GetListOfVolumes()->Delete();
567 gGeoManager->GetListOfShapes()->Delete();
571 gSystem->Exec(
"rm all_*.par *.mat.kf.bin");
579 namespace fs = boost::filesystem;
581 fs::path mainCfgPath = fs::absolute(fs::weakly_canonical(
fOutDirReco)) /
"MainConfig.yaml";
582 if (!fs::exists(mainCfgPath)) {
583 throw std::runtime_error(
"Cannot find the main config " + mainCfgPath.string() +
" in the output directory ");
591 std::array<std::stringstream, 3> content;
595 std::ifstream in(mainCfgPath.string());
596 for (std::string line; std::getline(in, line,
'\n');) {
597 bool bFound = line.find(
"parFiles:") != std::string::npos;
598 if (bFound) ++nFound;
600 throw std::runtime_error(
"CbmOnlineParWrite::UpdateParFiles(): found more than one lines with \"parFiles:\"");
602 if (iStream == 1 && line[0] !=
' ' && line[0] !=
'\t') iStream = 2;
603 if (iStream == 0 && bFound) iStream = 1;
604 content[iStream] << line <<
'\n';
609 auto parFilesNode = YAML::Load(content[1])[
"parFiles"];
610 auto parFiles = yaml::Read<ParFiles>(parFilesNode);
611 parFiles.timesliceReco =
fParFiles.timesliceReco;
612 parFiles.eventReco =
fParFiles.eventReco;
613 parFiles.recoSetupPath =
fParFiles.recoSetupPath;
616 std::ofstream out(mainCfgPath.string());
617 out << content[0].str() <<
'\n';
620 YAML::Emitter yamlEmitter;
621 yamlEmitter << YAML::BeginMap;
622 yamlEmitter << YAML::Key << std::string{
"parFiles"};
623 yamlEmitter << YAML::Value;
624 dump.
DoDump(parFiles, yamlEmitter);
625 yamlEmitter << YAML::EndMap;
626 out << yamlEmitter.c_str() <<
'\n';
628 out << content[2].str();
int32_t GetAddress(uint32_t unit=0, uint32_t ladder=0, uint32_t halfladder=0, uint32_t module=0, uint32_t sensor=0, uint32_t side=0, uint32_t version=kCurrentVersion)
Construct address.