Skip to content

Commit 03f8f2e

Browse files
authored
Merge f22bacf into sapling-pr-archive-ktf
2 parents 58f270e + f22bacf commit 03f8f2e

File tree

27 files changed

+1007
-649
lines changed

27 files changed

+1007
-649
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct SimConfigData {
8383
bool mNoGeant = false; // if Geant transport should be turned off (when one is only interested in the generated events)
8484
bool mIsUpgrade = false; // true if the simulation is for Run 5
8585
std::string mFromCollisionContext = ""; // string denoting a collision context file; If given, this file will be used to determine number of events
86+
//
8687
bool mForwardKine = false; // true if tracks and event headers are to be published on a FairMQ channel (for reading by other consumers)
8788
bool mWriteToDisc = true; // whether we write simulation products (kine, hits) to disc
8889
VertexMode mVertexMode = VertexMode::kDiamondParam; // by default we should use die InteractionDiamond parameter
@@ -177,6 +178,10 @@ class SimConfig
177178
bool writeToDisc() const { return mConfigData.mWriteToDisc; }
178179
VertexMode getVertexMode() const { return mConfigData.mVertexMode; }
179180

181+
// returns the pair of collision context filename as well as event prefix encoded
182+
// in the mFromCollisionContext string. Returns empty string if information is not available or set.
183+
std::pair<std::string, std::string> getCollContextFilenameAndEventPrefix() const;
184+
180185
private:
181186
SimConfigData mConfigData; //!
182187

Common/SimConfig/src/SimConfig.cxx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void SimConfig::initOptions(boost::program_options::options_description& options
7676
"noGeant", bpo::bool_switch(), "prohibits any Geant transport/physics (by using tight cuts)")(
7777
"forwardKine", bpo::bool_switch(), "forward kinematics on a FairMQ channel")(
7878
"noDiscOutput", bpo::bool_switch(), "switch off writing sim results to disc (useful in combination with forwardKine)");
79-
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\".");
79+
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.");
8080
}
8181

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

273+
std::pair<std::string, std::string> SimConfig::getCollContextFilenameAndEventPrefix() const
274+
{
275+
// we decompose the argument to fetch
276+
// (a) collision contextfilename
277+
// (b) sim prefix to use from the context
278+
auto pos = mConfigData.mFromCollisionContext.find(':');
279+
std::string collcontextfile{mConfigData.mFromCollisionContext};
280+
std::string simprefix{mConfigData.mOutputPrefix};
281+
if (pos != std::string::npos) {
282+
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
283+
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
284+
}
285+
return std::make_pair(collcontextfile, simprefix);
286+
}
287+
273288
bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const& vm)
274289
{
275290
using o2::detectors::DetID;
@@ -333,17 +348,8 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
333348
mConfigData.mFilterNoHitEvents = true;
334349
}
335350
mConfigData.mFromCollisionContext = vm["fromCollContext"].as<std::string>();
336-
// we decompose the argument to fetch
337-
// (a) collision contextfilename
338-
// (b) sim prefix to use from the context
339-
auto pos = mConfigData.mFromCollisionContext.find(':');
340-
std::string collcontextfile{mConfigData.mFromCollisionContext};
341-
std::string simprefix{mConfigData.mOutputPrefix};
342-
if (pos != std::string::npos) {
343-
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
344-
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
345-
}
346-
adjustFromCollContext(collcontextfile, simprefix);
351+
auto collcontext_simprefix = getCollContextFilenameAndEventPrefix();
352+
adjustFromCollContext(collcontext_simprefix.first, collcontext_simprefix.second);
347353

348354
// analyse vertex options
349355
if (!parseVertexModeString(vm["vertexMode"].as<std::string>(), mConfigData.mVertexMode)) {

DataFormats/simulation/src/DigitizationContext.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,5 +578,7 @@ DigitizationContext DigitizationContext::extractSingleTimeframe(int timeframeid,
578578
} catch (std::exception) {
579579
LOG(warn) << "No such timeframe id in collision context. Returing empty object";
580580
}
581+
// fix number of collisions
582+
r.setNCollisions(r.mEventRecords.size());
581583
return r;
582584
}

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/V0Ext.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include "ReconstructionDataFormats/V0.h"
1818
#include "SimulationDataFormat/MCCompLabel.h"
1919

20-
namespace o2
21-
{
22-
namespace dataformats
20+
namespace o2::dataformats
2321
{
2422

2523
struct ProngInfoExt {
@@ -40,10 +38,10 @@ struct V0Ext {
4038
V0Index v0ID;
4139
std::array<ProngInfoExt, 2> prInfo{};
4240
const ProngInfoExt& getPrInfo(int i) const { return prInfo[i]; }
43-
ClassDefNV(V0Ext, 1);
41+
int mcPID = -1;
42+
ClassDefNV(V0Ext, 2);
4443
};
4544

46-
} // namespace dataformats
47-
} // namespace o2
45+
} // namespace o2::dataformats
4846

4947
#endif

Detectors/GlobalTrackingWorkflow/study/src/SVStudy.cxx

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "DetectorsBase/GeometryManager.h"
2323
#include "SimulationDataFormat/MCEventLabel.h"
2424
#include "SimulationDataFormat/MCUtils.h"
25+
#include "SimulationDataFormat/MCTrack.h"
2526
#include "CommonDataFormat/BunchFilling.h"
2627
#include "CommonUtils/NameConf.h"
2728
#include "DataFormatsFT0/RecPoints.h"
@@ -86,7 +87,7 @@ class SVStudySpec : public Task
8687
float mBz = 0;
8788
GTrackID::mask_t mTracksSrc{};
8889
o2::vertexing::DCAFitterN<2> mFitterV0;
89-
o2::steer::MCKinematicsReader mcReader; // reader of MC information
90+
std::unique_ptr<o2::steer::MCKinematicsReader> mcReader; // reader of MC information
9091
};
9192

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

101105
void SVStudySpec::run(ProcessingContext& pc)
@@ -161,23 +165,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
161165
v0ext.v0 = v0sel;
162166
}
163167
v0ext.v0ID = v0id;
164-
o2::MCCompLabel lb;
168+
o2::MCCompLabel lb[2];
169+
const o2::MCTrack* mcTrks[2];
165170
for (int ip = 0; ip < 2; ip++) {
166171
auto& prInfo = v0ext.prInfo[ip];
167172
auto gid = v0ext.v0ID.getProngID(ip);
168173
auto gidset = recoData.getSingleDetectorRefs(gid);
169-
lb = recoData.getTrackMCLabel(gid);
170-
if (lb.isValid()) {
171-
prInfo.corrGlo = !lb.isFake();
174+
lb[ip] = recoData.getTrackMCLabel(gid);
175+
if (lb[ip].isValid()) {
176+
prInfo.corrGlo = !lb[ip].isFake();
172177
}
173178
// get TPC tracks, if any
174179
if (gidset[GTrackID::TPC].isSourceSet()) {
175180
const auto& tpcTr = recoData.getTPCTrack(gidset[GTrackID::TPC]);
176181
prInfo.trackTPC = tpcTr;
177182
prInfo.nClTPC = tpcTr.getNClusters();
178-
lb = recoData.getTrackMCLabel(gidset[GTrackID::TPC]);
179-
if (lb.isValid()) {
180-
prInfo.corrTPC = !lb.isFake();
183+
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::TPC]);
184+
if (lb[ip].isValid()) {
185+
prInfo.corrTPC = !lb[ip].isFake();
181186
}
182187
}
183188
// get ITS tracks, if any
@@ -186,9 +191,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
186191
if (gidset[GTrackID::ITS].isSourceSet()) {
187192
const auto& itsTr = recoData.getITSTrack(gidset[GTrackID::ITS]);
188193
prInfo.nClITS = itsTr.getNClusters();
189-
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITS]);
190-
if (lb.isValid()) {
191-
prInfo.corrITS = !lb.isFake();
194+
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITS]);
195+
if (lb[ip].isValid()) {
196+
prInfo.corrITS = !lb[ip].isFake();
192197
}
193198
for (int il = 0; il < 7; il++) {
194199
if (itsTr.hasHitOnLayer(il)) {
@@ -198,9 +203,9 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
198203
} else {
199204
const auto& itsTrf = recoData.getITSABRefs()[gidset[GTrackID::ITSAB]];
200205
prInfo.nClITS = itsTrf.getNClusters();
201-
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITSAB]);
202-
if (lb.isValid()) {
203-
prInfo.corrITS = !lb.isFake();
206+
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITSAB]);
207+
if (lb[ip].isValid()) {
208+
prInfo.corrITS = !lb[ip].isFake();
204209
}
205210
for (int il = 0; il < 7; il++) {
206211
if (itsTrf.hasHitOnLayer(il)) {
@@ -211,13 +216,24 @@ o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoCo
211216
}
212217
if (gidset[GTrackID::ITSTPC].isSourceSet()) {
213218
auto mtc = recoData.getTPCITSTrack(gidset[GTrackID::ITSTPC]);
214-
lb = recoData.getTrackMCLabel(gidset[GTrackID::ITSTPC]);
219+
lb[ip] = recoData.getTrackMCLabel(gidset[GTrackID::ITSTPC]);
215220
prInfo.chi2ITSTPC = mtc.getChi2Match();
216-
if (lb.isValid()) {
217-
prInfo.corrITSTPC = !lb.isFake();
221+
if (lb[ip].isValid()) {
222+
prInfo.corrITSTPC = !lb[ip].isFake();
218223
}
219224
}
220225
}
226+
if (mUseMC && lb[ip].isValid()) { // temp store of mctrks
227+
mcTrks[ip] = mcReader->getTrack(lb[ip]);
228+
}
229+
}
230+
if (mUseMC && (mcTrks[0] != nullptr) && (mcTrks[1] != nullptr)) {
231+
// check majority vote on mother particle otherwise leave pdg -1
232+
if (lb[0].getSourceID() == lb[1].getSourceID() && lb[0].getEventID() == lb[1].getEventID() &&
233+
mcTrks[0]->getMotherTrackId() == mcTrks[1]->getMotherTrackId() && mcTrks[0]->getMotherTrackId() >= 0) {
234+
const auto mother = mcReader->getTrack(lb[0].getSourceID(), lb[0].getEventID(), mcTrks[0]->getMotherTrackId());
235+
v0ext.mcPID = mother->GetPdgCode();
236+
}
221237
}
222238
return v0ext;
223239
}

Detectors/MUON/MID/Calibration/macros/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,53 @@ root -l
6060
.x build_rejectlist.C+(1716436103391,1721272208000,"localhost:8083")
6161
```
6262

63+
### Add custom bad channels
64+
65+
The macro `build_rejectlist.C` scans the QCDB and the CCDB in search of issues.
66+
However, the QCDB flag is based on local boards with empty signals.
67+
It can happen that a local board is problematic, but not completely dead and, therefore, it is not correctly spotted by the macro.
68+
It is therefore important to have a way to add the issues by hand.
69+
This can be done with a json file in the form:
70+
71+
```json
72+
{
73+
"startRun": 557251,
74+
"endRun": 557926,
75+
"rejectList": [
76+
{
77+
"deId": 4,
78+
"columnId": 2,
79+
"patterns": [
80+
"0x0",
81+
"0xFFFF",
82+
"0x0",
83+
"0x0",
84+
"0x0"
85+
]
86+
},
87+
{
88+
"deId": 13,
89+
"columnId": 2,
90+
"patterns": [
91+
"0x0",
92+
"0xFFFF",
93+
"0x0",
94+
"0x0",
95+
"0x0"
96+
]
97+
}
98+
]
99+
}
100+
```
101+
102+
The path to the file is then given to the macro with:
103+
104+
```shell
105+
.x build_rejectlist.C+(1726299038000,1727386238000,"http://localhost:8083","http://alice-ccdb.cern.ch","http://localhost:8080","rejectlist.json")
106+
```
107+
108+
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.
109+
63110
## Running the local CCDB
64111

65112
The local CCDB server can be easily built through alibuild.

0 commit comments

Comments
 (0)