Skip to content

Commit

Permalink
Merge f22bacf into sapling-pr-archive-ktf
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf authored Nov 13, 2024
2 parents 58f270e + f22bacf commit 03f8f2e
Show file tree
Hide file tree
Showing 27 changed files with 1,007 additions and 649 deletions.
5 changes: 5 additions & 0 deletions Common/SimConfig/include/SimConfig/SimConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct SimConfigData {
bool mNoGeant = false; // if Geant transport should be turned off (when one is only interested in the generated events)
bool mIsUpgrade = false; // true if the simulation is for Run 5
std::string mFromCollisionContext = ""; // string denoting a collision context file; If given, this file will be used to determine number of events
//
bool mForwardKine = false; // true if tracks and event headers are to be published on a FairMQ channel (for reading by other consumers)
bool mWriteToDisc = true; // whether we write simulation products (kine, hits) to disc
VertexMode mVertexMode = VertexMode::kDiamondParam; // by default we should use die InteractionDiamond parameter
Expand Down Expand Up @@ -177,6 +178,10 @@ class SimConfig
bool writeToDisc() const { return mConfigData.mWriteToDisc; }
VertexMode getVertexMode() const { return mConfigData.mVertexMode; }

// returns the pair of collision context filename as well as event prefix encoded
// in the mFromCollisionContext string. Returns empty string if information is not available or set.
std::pair<std::string, std::string> getCollContextFilenameAndEventPrefix() const;

private:
SimConfigData mConfigData; //!

Expand Down
30 changes: 18 additions & 12 deletions Common/SimConfig/src/SimConfig.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void SimConfig::initOptions(boost::program_options::options_description& options
"noGeant", bpo::bool_switch(), "prohibits any Geant transport/physics (by using tight cuts)")(
"forwardKine", bpo::bool_switch(), "forward kinematics on a FairMQ channel")(
"noDiscOutput", bpo::bool_switch(), "switch off writing sim results to disc (useful in combination with forwardKine)");
options.add_options()("fromCollContext", bpo::value<std::string>()->default_value(""), "Use a pregenerated collision context to infer number of events to simulate, how to embedd them, the vertex position etc. Takes precedence of other options such as \"--nEvents\".");
options.add_options()("fromCollContext", bpo::value<std::string>()->default_value(""), "Use a pregenerated collision context to infer number of events to simulate, how to embedd them, the vertex position etc. Takes precedence of other options such as \"--nEvents\". The format is COLLISIONCONTEXTFILE.root[:SIGNALNAME] where SIGNALNAME is the event part in the context which is relevant.");
}

void SimConfig::determineActiveModules(std::vector<std::string> const& inputargs, std::vector<std::string> const& skippedModules, std::vector<std::string>& activeModules, bool isUpgrade)
Expand Down Expand Up @@ -270,6 +270,21 @@ void SimConfig::determineReadoutDetectors(std::vector<std::string> const& active
}
}

std::pair<std::string, std::string> SimConfig::getCollContextFilenameAndEventPrefix() const
{
// we decompose the argument to fetch
// (a) collision contextfilename
// (b) sim prefix to use from the context
auto pos = mConfigData.mFromCollisionContext.find(':');
std::string collcontextfile{mConfigData.mFromCollisionContext};
std::string simprefix{mConfigData.mOutputPrefix};
if (pos != std::string::npos) {
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
}
return std::make_pair(collcontextfile, simprefix);
}

bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const& vm)
{
using o2::detectors::DetID;
Expand Down Expand Up @@ -333,17 +348,8 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
mConfigData.mFilterNoHitEvents = true;
}
mConfigData.mFromCollisionContext = vm["fromCollContext"].as<std::string>();
// we decompose the argument to fetch
// (a) collision contextfilename
// (b) sim prefix to use from the context
auto pos = mConfigData.mFromCollisionContext.find(':');
std::string collcontextfile{mConfigData.mFromCollisionContext};
std::string simprefix{mConfigData.mOutputPrefix};
if (pos != std::string::npos) {
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
}
adjustFromCollContext(collcontextfile, simprefix);
auto collcontext_simprefix = getCollContextFilenameAndEventPrefix();
adjustFromCollContext(collcontext_simprefix.first, collcontext_simprefix.second);

// analyse vertex options
if (!parseVertexModeString(vm["vertexMode"].as<std::string>(), mConfigData.mVertexMode)) {
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/simulation/src/DigitizationContext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -578,5 +578,7 @@ DigitizationContext DigitizationContext::extractSingleTimeframe(int timeframeid,
} catch (std::exception) {
LOG(warn) << "No such timeframe id in collision context. Returing empty object";
}
// fix number of collisions
r.setNCollisions(r.mEventRecords.size());
return r;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include "ReconstructionDataFormats/V0.h"
#include "SimulationDataFormat/MCCompLabel.h"

namespace o2
{
namespace dataformats
namespace o2::dataformats
{

struct ProngInfoExt {
Expand All @@ -40,10 +38,10 @@ struct V0Ext {
V0Index v0ID;
std::array<ProngInfoExt, 2> prInfo{};
const ProngInfoExt& getPrInfo(int i) const { return prInfo[i]; }
ClassDefNV(V0Ext, 1);
int mcPID = -1;
ClassDefNV(V0Ext, 2);
};

} // namespace dataformats
} // namespace o2
} // namespace o2::dataformats

#endif
50 changes: 33 additions & 17 deletions Detectors/GlobalTrackingWorkflow/study/src/SVStudy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "DetectorsBase/GeometryManager.h"
#include "SimulationDataFormat/MCEventLabel.h"
#include "SimulationDataFormat/MCUtils.h"
#include "SimulationDataFormat/MCTrack.h"
#include "CommonDataFormat/BunchFilling.h"
#include "CommonUtils/NameConf.h"
#include "DataFormatsFT0/RecPoints.h"
Expand Down Expand Up @@ -86,7 +87,7 @@ class SVStudySpec : public Task
float mBz = 0;
GTrackID::mask_t mTracksSrc{};
o2::vertexing::DCAFitterN<2> mFitterV0;
o2::steer::MCKinematicsReader mcReader; // reader of MC information
std::unique_ptr<o2::steer::MCKinematicsReader> mcReader; // reader of MC information
};

void SVStudySpec::init(InitContext& ic)
Expand All @@ -96,6 +97,9 @@ void SVStudySpec::init(InitContext& ic)
mRefit = ic.options().get<bool>("refit");
mSelK0 = ic.options().get<float>("sel-k0");
mMaxEta = ic.options().get<float>("max-eta");
if (mUseMC) {
mcReader = std::make_unique<o2::steer::MCKinematicsReader>("collisioncontext.root");
}
}

void SVStudySpec::run(ProcessingContext& pc)
Expand Down Expand Up @@ -161,23 +165,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
v0ext.v0 = v0sel;
}
v0ext.v0ID = v0id;
o2::MCCompLabel lb;
o2::MCCompLabel lb[2];
const o2::MCTrack* mcTrks[2];
for (int ip = 0; ip < 2; ip++) {
auto& prInfo = v0ext.prInfo[ip];
auto gid = v0ext.v0ID.getProngID(ip);
auto gidset = recoData.getSingleDetectorRefs(gid);
lb = recoData.getTrackMCLabel(gid);
if (lb.isValid()) {
prInfo.corrGlo = !lb.isFake();
lb[ip] = recoData.getTrackMCLabel(gid);
if (lb[ip].isValid()) {
prInfo.corrGlo = !lb[ip].isFake();
}
// get TPC tracks, if any
if (gidset[GTrackID::TPC].isSourceSet()) {
const auto& tpcTr = recoData.getTPCTrack(gidset[GTrackID::TPC]);
prInfo.trackTPC = tpcTr;
prInfo.nClTPC = tpcTr.getNClusters();
lb = recoData.getTrackMCLabel(gidset[GTrackID::TPC]);
if (lb.isValid()) {
prInfo.corrTPC = !lb.isFake();
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::TPC]);
if (lb[ip].isValid()) {
prInfo.corrTPC = !lb[ip].isFake();
}
}
// get ITS tracks, if any
Expand All @@ -186,9 +191,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
if (gidset[GTrackID::ITS].isSourceSet()) {
const auto& itsTr = recoData.getITSTrack(gidset[GTrackID::ITS]);
prInfo.nClITS = itsTr.getNClusters();
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITS]);
if (lb.isValid()) {
prInfo.corrITS = !lb.isFake();
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITS]);
if (lb[ip].isValid()) {
prInfo.corrITS = !lb[ip].isFake();
}
for (int il = 0; il < 7; il++) {
if (itsTr.hasHitOnLayer(il)) {
Expand All @@ -198,9 +203,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
} else {
const auto& itsTrf = recoData.getITSABRefs()[gidset[GTrackID::ITSAB]];
prInfo.nClITS = itsTrf.getNClusters();
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITSAB]);
if (lb.isValid()) {
prInfo.corrITS = !lb.isFake();
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITSAB]);
if (lb[ip].isValid()) {
prInfo.corrITS = !lb[ip].isFake();
}
for (int il = 0; il < 7; il++) {
if (itsTrf.hasHitOnLayer(il)) {
Expand All @@ -211,13 +216,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
}
if (gidset[GTrackID::ITSTPC].isSourceSet()) {
auto mtc = recoData.getTPCITSTrack(gidset[GTrackID::ITSTPC]);
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITSTPC]);
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITSTPC]);
prInfo.chi2ITSTPC = mtc.getChi2Match();
if (lb.isValid()) {
prInfo.corrITSTPC = !lb.isFake();
if (lb[ip].isValid()) {
prInfo.corrITSTPC = !lb[ip].isFake();
}
}
}
if (mUseMC && lb[ip].isValid()) { // temp store of mctrks
mcTrks[ip] = mcReader->getTrack(lb[ip]);
}
}
if (mUseMC && (mcTrks[0] != nullptr) && (mcTrks[1] != nullptr)) {
// check majority vote on mother particle otherwise leave pdg -1
if (lb[0].getSourceID() == lb[1].getSourceID() && lb[0].getEventID() == lb[1].getEventID() &&
mcTrks[0]->getMotherTrackId() == mcTrks[1]->getMotherTrackId() && mcTrks[0]->getMotherTrackId() >= 0) {
const auto mother = mcReader->getTrack(lb[0].getSourceID(), lb[0].getEventID(), mcTrks[0]->getMotherTrackId());
v0ext.mcPID = mother->GetPdgCode();
}
}
return v0ext;
}
Expand Down
47 changes: 47 additions & 0 deletions Detectors/MUON/MID/Calibration/macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,53 @@ root -l
.x build_rejectlist.C+(1716436103391,1721272208000,"localhost:8083")
```

### Add custom bad channels

The macro `build_rejectlist.C` scans the QCDB and the CCDB in search of issues.
However, the QCDB flag is based on local boards with empty signals.
It can happen that a local board is problematic, but not completely dead and, therefore, it is not correctly spotted by the macro.
It is therefore important to have a way to add the issues by hand.
This can be done with a json file in the form:

```json
{
"startRun": 557251,
"endRun": 557926,
"rejectList": [
{
"deId": 4,
"columnId": 2,
"patterns": [
"0x0",
"0xFFFF",
"0x0",
"0x0",
"0x0"
]
},
{
"deId": 13,
"columnId": 2,
"patterns": [
"0x0",
"0xFFFF",
"0x0",
"0x0",
"0x0"
]
}
]
}
```

The path to the file is then given to the macro with:

```shell
.x build_rejectlist.C+(1726299038000,1727386238000,"http://localhost:8083","http://alice-ccdb.cern.ch","http://localhost:8080","rejectlist.json")
```

The macro will then merge the manual reject list from the file with the reject list that it finds by scanning the QCDB and CCDB.

## Running the local CCDB

The local CCDB server can be easily built through alibuild.
Expand Down
Loading

0 comments on commit 03f8f2e

Please sign in to comment.