Skip to content
Snippets Groups Projects
Commit 64567da6 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

[mCBM] Generalize macro to use algo TOF clusterizer as task and gen. YAML files + HowTo

HowTo for now placed close to the macro, may be moved to docs later
parent 466f3e21
No related branches found
No related tags found
1 merge request!1526[mCBM] Generalize macro to use algo TOF clusterizer as task and gen. YAML files + HowTo
Pipeline #26113 passed
# Generation of TOF parameter YAML files for the algo version of the TOF HitFinder/Clusterizer
**!!! WORKING ONLY FOR mCBM RUNS !!!**
1. Pick a run (`<RUN ID>` in later parts), check in `core/base/utils/CbmMcbmUtils.cxx` to which setup it corresponds and check in `geometry/setup` that this would load the geometries you expect (if not modify te setup file)
1. Locate where you have your custom TOF calibration file (`.....tofClust.hst.root`)
1. Locate where you have your custom geometry alignment file (typ. `AlignmentMatrices_<setup_name>.root`) and make sure it fit you (eventually custom) setup
1. Create the geo root file in `macro/run` by running
```
root -l -b -q 'create_mcbm_geo_setup.C(<RUN ID>)'
```
1. Create an unpacked file with at least 1 TS for this run (with `macro/run/run_unpack_tsa.C`) or locate an existing unpacked file and make a symlink for it called `<RUN ID>.digi.root` in `macro/run/data`
1. Go to `macro/tools`
1. Run the following command (replacing the `<....>` parts with the corresponding info)
```
root -l -b -q 'tof_hitfinder_run.C(<RUN ID>, 1, "../run/data/", "../run/data/", -1, "", <FULL PATH TO TOF CALIB FILE>, <FULL PATH TO ALIGNMENT FILE>, true)'
```
1. You should now find in the folder you are two new YAML files called `TofCalibratePar.yaml` and `TofHitfinderPar.yaml`
- If you want you can try to compare them with `diff` or `meld` to the ones in `parameters/online`
1. To test the new YAML param files
1. Copy the files to `parameters/online`
1. Run (using the dummy/example file made for the yaml generation)
```
root -l -b -q 'tof_hitfinder_run.C(<RUN ID>, 1, "./data/", "./data/", -1)'
```
......@@ -7,13 +7,34 @@
#include <stdio.h>
#include <string.h>
template<typename TofTaskType>
void CreateTask(TofTaskType* tofCluster, FairRunAna* run, TString& myName, TString& cFname, Int_t& calMode,
Double_t& dDeadtime)
{
tofCluster->SetCalParFileName(cFname);
tofCluster->SetCalMode(calMode);
tofCluster->SetTotMax(20.); // Tot upper limit for walk corection
tofCluster->SetTotMin(0.); //(12000.); // Tot lower limit for walk correction
tofCluster->SetTotMean(5.); // Tot calibration target value in ns
tofCluster->SetMaxTimeDist(1.0); // default cluster range in ns
tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns
tofCluster->PosYMaxScal(0.75); //in % of length
run->AddTask(tofCluster);
std::cout << "-I- " << myName << ": Added task " << tofCluster->GetName() << std::endl;
}
/// FIXME: Disable clang formatting to keep easy parameters overview
/* clang-format off */
Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
Int_t nTimeslices = 1,
TString sInpDir = "/home/dsmith/cbmroot/macro/beamtime/mcbm2022/data/",
TString sOutDir = "rec/",
Int_t iUnpFileIndex = -1)
Int_t nTimeslices = 1,
TString sInpDir = "../beamtime/mcbm2022/data/",
TString sOutDir = "rec/",
Int_t iUnpFileIndex = -1,
TString TofFileFolder = "", // Your folder with the Tof Calibration files;
TString calibFile = "",
TString alignmentMatrixFileName = "",
bool bGenerateYamlFiles = false)
{
/// FIXME: Re-enable clang formatting after parameters initial values setting
/* clang-format on */
......@@ -40,9 +61,6 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
TString parFileOut = sOutDir + "/reco_event_mcbm_params_" + sRunId;
TString outFile = sOutDir + "/reco_event_mcbm_" + sRunId;
// Your folder with the Tof Calibration files;
TString TofFileFolder = "/home/dsmith/cbmroot/macro/run/data/";
/// Add index of splitting at unpacking level if needed
if (0 <= iUnpFileIndex) {
inFile += TString::Format("_%02u", iUnpFileIndex);
......@@ -82,6 +100,16 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
if (uRunId >= 2391) iCalSet = 22002500;
const Int_t iTofCluMode = 1;
if (TofFileFolder.Length() != 0) {
// Use user provided path
TofFileFolder = Form("%s/%s", TofFileFolder.Data(), cCalId.Data());
}
else {
// use default path
TofFileFolder = srcDir + "parameter/mcbm/";
// TofFileFolder = "../run/data/" + cCalId;
}
// ------------------------------------------------------------------------
// --- Load the geometry setup ----
......@@ -96,7 +124,7 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
return kFALSE;
}
TString geoFile = srcDir + "/macro/mcbm/data/" + geoSetupTag + ".geo.root";
TString geoFile = sInpDir + "/" + geoSetupTag + ".geo.root";
CbmSetup* geoSetup = CbmSetup::Instance();
geoSetup->LoadSetup(geoSetupTag);
......@@ -105,7 +133,6 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
//----- Load Parameters --------------------------------------------------
TList* parFileList = new TList();
TofFileFolder = Form("%s/%s", TofFileFolder.Data(), cCalId.Data());
// ----- TOF digitisation parameters -------------------------------------
TString geoTag;
......@@ -138,6 +165,39 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile);
// ------------------------------------------------------------------------
// =========================================================================
// === GEO Alignment ===
// =========================================================================
if (alignmentMatrixFileName.Length() != 0) {
std::cout << "-I- " << myName << ": Applying alignment for file " << alignmentMatrixFileName << std::endl;
// Define the basic structure which needs to be filled with information
// This structure is stored in the output file and later passed to the
// FairRoot framework to do the (miss)alignment
std::map<std::string, TGeoHMatrix>* matrices{nullptr};
// read matrices from disk
LOG(info) << "Filename: " << alignmentMatrixFileName;
TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
if (misalignmentMatrixRootfile->IsOpen()) {
gDirectory->GetObject("MisalignMatrices", matrices);
misalignmentMatrixRootfile->Close();
}
else {
LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
return kFALSE;
}
if (matrices) {
run->AddAlignmentMatrices(*matrices);
}
else {
LOG(error) << "Alignment required but no matrices found."
<< "\n Exiting";
return kFALSE;
}
}
// -------------------------------------------------------------------------
// ----- Logger settings ----------------------------------------------
FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
......@@ -151,15 +211,25 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
TString cFname;
switch (iTofCluMode) {
case 1: {
// For production of YAML files
//CbmTaskTofClusterizerParWrite* tofCluster = new CbmTaskTofClusterizerParWrite("Task TOF Clusterizer", 0, 1);
// For actual processing
CbmTaskTofClusterizer* tofCluster = new CbmTaskTofClusterizer("Task TOF Clusterizer", 0, 1);
cFname = Form("/%s_set%09d_%02d_%01dtofClust.hst.root", cCalId.Data(), iCalSet, calMode, calSel);
tofCluster->SetCalParFileName(TofFileFolder + cFname);
cFname = Form("%s/%s_set%09d_%02d_%01dtofClust.hst.root", TofFileFolder.Data(), cCalId.Data(), iCalSet, calMode,
calSel);
if (calibFile.Length() != 0) {
// Use user provided calib file, overriding the automatic determination based on run ID
cFname = calibFile;
}
if (bGenerateYamlFiles) {
// For production of YAML files
CbmTaskTofClusterizerParWrite* tofCluster = new CbmTaskTofClusterizerParWrite("Task TOF Clusterizer", 0, 1);
CreateTask<CbmTaskTofClusterizerParWrite>(tofCluster, run, myName, cFname, calMode, dDeadtime);
}
else {
// For actual processing
CbmTaskTofClusterizer* tofCluster = new CbmTaskTofClusterizer("Task TOF Clusterizer", 0, 1);
CreateTask<CbmTaskTofClusterizer>(tofCluster, run, myName, cFname, calMode, dDeadtime);
}
/*
tofCluster->SetCalParFileName(cFname);
tofCluster->SetCalMode(calMode);
tofCluster->SetTotMax(20.); // Tot upper limit for walk corection
tofCluster->SetTotMin(0.); //(12000.); // Tot lower limit for walk correction
......@@ -170,6 +240,7 @@ Bool_t tof_hitfinder_run(UInt_t uRunId = 2391,
run->AddTask(tofCluster);
std::cout << "-I- " << myName << ": Added task " << tofCluster->GetName() << std::endl;
*/
} break;
default: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment