Skip to content

Commit 1cb28ba

Browse files
committed
o2-sim: Summary of process/cut configuration used
* print summary of processes/cuts per medium into a dedicated file * warn if application of special cuts fails due to indexing problem
1 parent bbc79bd commit 1cb28ba

6 files changed

Lines changed: 45 additions & 22 deletions

File tree

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class NameConf
6767
// Filename to for decoding dictionaries
6868
static std::string getDictionaryFileName(DId det, const std::string_view prefix = "", const std::string_view ext = "");
6969

70+
// Filename to store summary about simulation processes and cut values
71+
static std::string getCutProcFileName(const std::string_view prefix = "");
72+
7073
// TGeometry object name
7174
static constexpr std::string_view GEOMOBJECTNAME = "FAIRGeom"; // hardcoded
7275

@@ -95,6 +98,7 @@ class NameConf
9598
static constexpr std::string_view GRP_STRING = "grp"; // hardcoded
9699
static constexpr std::string_view KINE_STRING = "Kine"; // hardcoded
97100
static constexpr std::string_view GEOM_FILE_STRING = "geometry";
101+
static constexpr std::string_view CUT_FILE_STRING = "proc-cut";
98102

99103
static constexpr std::string_view DICTFILENAME = "dictionary";
100104
};

DataFormats/Detectors/Common/src/NameConf.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ std::string NameConf::getGeomFileName(const std::string_view prefix)
4949
return o2::utils::concat_string(prefix.empty() ? STANDARDSIMPREFIX : prefix, "_", GEOM_FILE_STRING, ".root");
5050
}
5151

52+
// Filename to store simulation cuts/process summary
53+
std::string NameConf::getCutProcFileName(std::string_view prefix)
54+
{
55+
// check if the prefix is an existing path
56+
if (pathIsDirectory(prefix)) {
57+
return o2::utils::concat_string(prefix, "/", STANDARDSIMPREFIX, "_", CUT_FILE_STRING, ".dat");
58+
} else if (pathExists(prefix)) {
59+
return std::string(prefix); // it is a full file
60+
}
61+
return o2::utils::concat_string(prefix.empty() ? STANDARDSIMPREFIX : prefix, "_", CUT_FILE_STRING, ".dat");
62+
}
63+
5264
// Filename to store geometry file
5365
std::string NameConf::getDictionaryFileName(DId det, const std::string_view prefix, const std::string_view ext)
5466
{

Detectors/Base/include/DetectorsBase/MaterialManager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <map>
1919
#include <unordered_map>
2020
#include <initializer_list>
21+
#include <iosfwd>
2122

2223
class TGeoMedium;
2324

@@ -190,9 +191,9 @@ class MaterialManager
190191
void getSpecialCuts(const char* modname, int localindex, std::vector<std::pair<ECut, Float_t>>& cutVector);
191192

192193
/// Print all processes for all media as well as defaults.
193-
void printProcesses() const;
194+
void printProcesses(std::ostream& stream) const;
194195
/// Print all cuts for all media as well as defaults.
195-
void printCuts() const;
196+
void printCuts(std::ostream& stream) const;
196197

197198
// print out all registered materials
198199
void printMaterials() const;
@@ -232,7 +233,7 @@ class MaterialManager
232233
// a map allowing to lookup TGeoMedia from detector name and local medium index
233234
std::map<std::pair<std::string, int>, TGeoMedium*> mTGeoMediumMap;
234235

235-
// finally, I would like to keep track of tracking parameters and processes activated per medium
236+
// finally, we'd like to keep track of tracking parameters and processes activated per medium
236237

237238
std::map<std::string, int> mMaterialNameToGlobalIndexMap; // map of unique material name to global index
238239
std::map<std::string, int> mMediumNameToGlobalIndexMap; // map of unique material name to global index
@@ -247,7 +248,7 @@ class MaterialManager
247248
/// to care about the engine in use but only needs to set cuts according to ONE naming scheme.
248249
// \note Currently, the naming convention of GEANT4 v10.3.3 is used.
249250
// \note This might be overhead so far but makes the MaterialManager and therefore O2 finally capable of
250-
// forwarding cuts/processe to arbitrary engines.
251+
// forwarding cuts/processes to arbitrary engines.
251252
// \todo Is there a more elegant implementation?
252253
/// fixed names of cuts
253254
const static std::unordered_map<ECut, const char*> mCutIDToName;

Detectors/Base/src/MaterialManager.cxx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,50 +231,50 @@ void MaterialManager::printMedia() const
231231
}
232232
}
233233

234-
void MaterialManager::printProcesses() const
234+
void MaterialManager::printProcesses(std::ostream& stream) const
235235
{
236-
LOG(INFO) << "Print process settings of media.";
237-
std::cout << "Default process settings:\n";
236+
stream << "Summary of process settings per media.\n";
237+
stream << "-- Default process settings:\n";
238238
for (auto& p : mDefaultProcessMap) {
239239
auto it = mProcessIDToName.find(p.first);
240240
if (it != mProcessIDToName.end()) {
241-
std::cout << "\t" << it->second << " = " << p.second << "\n";
241+
stream << "\t" << it->second << " = " << p.second << "\n";
242242
}
243243
}
244244
if (mApplySpecialProcesses && mMediumProcessMap.size() > 0) {
245-
std::cout << "Settings for single media:\n";
245+
stream << "-- Custom process settings for single media:\n";
246246
for (auto& m : mMediumProcessMap) {
247-
std::cout << "Global medium ID " << m.first << " (module = " << getModuleFromMediumID(m.first)
248-
<< ", medium name = " << getMediumNameFromMediumID(m.first) << "):\n";
247+
stream << "Global medium ID " << m.first << " (module = " << getModuleFromMediumID(m.first)
248+
<< ", medium name = " << getMediumNameFromMediumID(m.first) << "):\n";
249249
for (auto& p : m.second) {
250250
auto it = mProcessIDToName.find(p.first);
251251
if (it != mProcessIDToName.end()) {
252-
std::cout << "\t" << it->second << " = " << p.second << "\n";
252+
stream << "\t" << it->second << " = " << p.second << "\n";
253253
}
254254
}
255255
}
256256
}
257257
}
258258

259-
void MaterialManager::printCuts() const
259+
void MaterialManager::printCuts(std::ostream& stream) const
260260
{
261-
LOG(INFO) << "Print cut settings of media.";
262-
std::cout << "Default cut settings:\n";
261+
stream << "Summary of cut settings per media.\n";
262+
stream << "-- Default cut settings:\n";
263263
for (auto& c : mDefaultCutMap) {
264264
auto it = mCutIDToName.find(c.first);
265265
if (it != mCutIDToName.end()) {
266-
std::cout << "\t" << it->second << " = " << c.second << "\n";
266+
stream << "\t" << it->second << " = " << c.second << "\n";
267267
}
268268
}
269269
if (mApplySpecialCuts && mMediumCutMap.size() > 0) {
270-
std::cout << "Settings for single media:\n";
270+
stream << "-- Custom cut settings for single media:\n";
271271
for (auto& m : mMediumCutMap) {
272-
std::cout << "Global medium ID " << m.first << " (module = " << getModuleFromMediumID(m.first)
273-
<< ", medium name = " << getMediumNameFromMediumID(m.first) << "):\n";
272+
stream << "Global medium ID " << m.first << " (module = " << getModuleFromMediumID(m.first)
273+
<< ", medium name = " << getMediumNameFromMediumID(m.first) << "):\n";
274274
for (auto& c : m.second) {
275275
auto it = mCutIDToName.find(c.first);
276276
if (it != mCutIDToName.end()) {
277-
std::cout << "\t" << it->second << " = " << c.second << "\n";
277+
stream << "\t" << it->second << " = " << c.second << "\n";
278278
}
279279
}
280280
}
@@ -435,6 +435,8 @@ void MaterialManager::SpecialCut(const char* modname, int localindex, ECut parID
435435
int globalindex = getMediumID(modname, localindex);
436436
if (globalindex != -1) {
437437
Cut(ESpecial::kTRUE, globalindex, parID, val);
438+
} else {
439+
LOG(WARN) << "SpecialCut: NO GLOBALINDEX FOUND FOR " << modname << " " << localindex;
438440
}
439441
}
440442

Detectors/gconfig/SetCuts.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,4 @@ void SetCuts()
7272
const char* settingCut = mgr.specialCutsEnabled() ? "enabled" : "disabled";
7373
LOG(INFO) << "Special process settings are " << settingProc << ".";
7474
LOG(INFO) << "Special cut settings are " << settingCut << ".";
75-
mgr.printProcesses();
76-
mgr.printCuts();
7775
}

macro/o2sim.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ FairRunSim* o2sim_init(bool asservice)
167167
}
168168
// todo: save beam information in the grp
169169

170+
// print summary about cuts and processes used
171+
std::ofstream cutfile(o2::base::NameConf::getCutProcFileName(confref.getOutPrefix()));
172+
auto& matmgr = o2::base::MaterialManager::Instance();
173+
matmgr.printCuts(cutfile);
174+
matmgr.printProcesses(cutfile);
175+
170176
timer.Stop();
171177
Double_t rtime = timer.RealTime();
172178
Double_t ctime = timer.CpuTime();

0 commit comments

Comments
 (0)