Skip to content

Commit 6a462f7

Browse files
Use mc flag to be able to run with data
clang-format
1 parent a8504a4 commit 6a462f7

2 files changed

Lines changed: 67 additions & 60 deletions

File tree

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ typedef boost::unordered_map<Triplet_t, int, TripletHash, TripletEqualTo> Triple
191191
class AODProducerWorkflowDPL : public Task
192192
{
193193
public:
194-
AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr<DataRequest> dataRequest) : mInputSources(src), mDataRequest(dataRequest) {}
194+
AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr<DataRequest> dataRequest, bool useMC = true) : mInputSources(src), mDataRequest(dataRequest), mUseMC(useMC) {}
195195
~AODProducerWorkflowDPL() override = default;
196196
void init(InitContext& ic) final;
197197
void run(ProcessingContext& pc) final;
198198
void endOfStream(framework::EndOfStreamContext& ec) final;
199199

200200
private:
201+
bool mUseMC = true;
202+
201203
const float cSpeed = 0.029979246f; // speed of light in TOF units
202204

203205
GID::mask_t mInputSources;

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,40 +1067,42 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
10671067
// correct ordering when iterating over container elements
10681068
std::map<std::pair<int, int>, int> mcColToEvSrc;
10691069

1070-
// TODO: figure out collision weight
1071-
float mcColWeight = 1.;
1072-
// filling mcCollision table
1073-
int nMCCollisions = mcContext->getNCollisions();
1074-
for (int iCol = 0; iCol < nMCCollisions; iCol++) {
1075-
auto time = mcRecords[iCol].getTimeNS();
1076-
auto globalBC = mcRecords[iCol].toLong();
1077-
auto item = bcsMap.find(globalBC);
1078-
int bcID = -1;
1079-
if (item != bcsMap.end()) {
1080-
bcID = item->second;
1081-
} else {
1082-
LOG(FATAL) << "Error: could not find a corresponding BC ID for MC collision; BC = " << globalBC << ", mc collision = " << iCol;
1083-
}
1084-
auto& colParts = mcParts[iCol];
1085-
for (auto colPart : colParts) {
1086-
auto eventID = colPart.entryID;
1087-
auto sourceID = colPart.sourceID;
1088-
if (sourceID == 0) { // embedding: using background event info
1089-
// FIXME:
1090-
// use generators' names for generatorIDs (?)
1091-
short generatorID = sourceID;
1092-
auto& header = mcReader.getMCEventHeader(sourceID, eventID);
1093-
mcCollisionsCursor(0,
1094-
bcID,
1095-
generatorID,
1096-
truncateFloatFraction(header.GetX(), mCollisionPosition),
1097-
truncateFloatFraction(header.GetY(), mCollisionPosition),
1098-
truncateFloatFraction(header.GetZ(), mCollisionPosition),
1099-
truncateFloatFraction(time, mCollisionPosition),
1100-
truncateFloatFraction(mcColWeight, mCollisionPosition),
1101-
header.GetB());
1070+
if (mUseMC) {
1071+
// TODO: figure out collision weight
1072+
float mcColWeight = 1.;
1073+
// filling mcCollision table
1074+
int nMCCollisions = mcContext->getNCollisions();
1075+
for (int iCol = 0; iCol < nMCCollisions; iCol++) {
1076+
auto time = mcRecords[iCol].getTimeNS();
1077+
auto globalBC = mcRecords[iCol].toLong();
1078+
auto item = bcsMap.find(globalBC);
1079+
int bcID = -1;
1080+
if (item != bcsMap.end()) {
1081+
bcID = item->second;
1082+
} else {
1083+
LOG(FATAL) << "Error: could not find a corresponding BC ID for MC collision; BC = " << globalBC << ", mc collision = " << iCol;
1084+
}
1085+
auto& colParts = mcParts[iCol];
1086+
for (auto colPart : colParts) {
1087+
auto eventID = colPart.entryID;
1088+
auto sourceID = colPart.sourceID;
1089+
if (sourceID == 0) { // embedding: using background event info
1090+
// FIXME:
1091+
// use generators' names for generatorIDs (?)
1092+
short generatorID = sourceID;
1093+
auto& header = mcReader.getMCEventHeader(sourceID, eventID);
1094+
mcCollisionsCursor(0,
1095+
bcID,
1096+
generatorID,
1097+
truncateFloatFraction(header.GetX(), mCollisionPosition),
1098+
truncateFloatFraction(header.GetY(), mCollisionPosition),
1099+
truncateFloatFraction(header.GetZ(), mCollisionPosition),
1100+
truncateFloatFraction(time, mCollisionPosition),
1101+
truncateFloatFraction(mcColWeight, mCollisionPosition),
1102+
header.GetB());
1103+
}
1104+
mcColToEvSrc.emplace(std::pair<int, int>(eventID, sourceID), iCol); // point background and injected signal events to one collision
11021105
}
1103-
mcColToEvSrc.emplace(std::pair<int, int>(eventID, sourceID), iCol); // point background and injected signal events to one collision
11041106
}
11051107
}
11061108

@@ -1179,12 +1181,14 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
11791181
ft0RecPoint.getTrigger().triggersignals);
11801182
}
11811183

1182-
// filling MC collision labels
1183-
for (auto& label : primVerLabels) {
1184-
auto it = mcColToEvSrc.find(std::pair<int, int>(label.getEventID(), label.getSourceID()));
1185-
int32_t mcCollisionID = it != mcColToEvSrc.end() ? it->second : -1;
1186-
uint16_t mcMask = 0; // todo: set mask using normalized weights?
1187-
mcColLabelsCursor(0, mcCollisionID, mcMask);
1184+
if (mUseMC) {
1185+
// filling MC collision labels
1186+
for (auto& label : primVerLabels) {
1187+
auto it = mcColToEvSrc.find(std::pair<int, int>(label.getEventID(), label.getSourceID()));
1188+
int32_t mcCollisionID = it != mcColToEvSrc.end() ? it->second : -1;
1189+
uint16_t mcMask = 0; // todo: set mask using normalized weights?
1190+
mcColLabelsCursor(0, mcCollisionID, mcMask);
1191+
}
11881192
}
11891193

11901194
// hash map for track indices of secondary vertices
@@ -1288,26 +1292,27 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
12881292

12891293
bcsMap.clear();
12901294

1291-
// filling mc particles table
1292-
fillMCParticlesTable(mcReader,
1293-
mcParticlesCursor,
1294-
primVer2TRefs,
1295-
primVerGIs,
1296-
recoData,
1297-
mcColToEvSrc);
1298-
1299-
mcColToEvSrc.clear();
1300-
1301-
// ------------------------------------------------------
1302-
// filling track labels
1303-
1304-
// need to go through labels in the same order as for tracks
1305-
fillMCTrackLabelsTable(mcTrackLabelCursor, mcMFTTrackLabelCursor, mcFwdTrackLabelCursor, primVer2TRefs.back(), primVerGIs, recoData);
1306-
for (int iref = 0; iref < primVer2TRefs.size() - 1; iref++) {
1307-
auto& trackRef = primVer2TRefs[iref];
1308-
fillMCTrackLabelsTable(mcTrackLabelCursor, mcMFTTrackLabelCursor, mcFwdTrackLabelCursor, trackRef, primVerGIs, recoData);
1295+
if (mUseMC) {
1296+
// filling mc particles table
1297+
fillMCParticlesTable(mcReader,
1298+
mcParticlesCursor,
1299+
primVer2TRefs,
1300+
primVerGIs,
1301+
recoData,
1302+
mcColToEvSrc);
1303+
1304+
mcColToEvSrc.clear();
1305+
1306+
// ------------------------------------------------------
1307+
// filling track labels
1308+
1309+
// need to go through labels in the same order as for tracks
1310+
fillMCTrackLabelsTable(mcTrackLabelCursor, mcMFTTrackLabelCursor, mcFwdTrackLabelCursor, primVer2TRefs.back(), primVerGIs, recoData);
1311+
for (int iref = 0; iref < primVer2TRefs.size() - 1; iref++) {
1312+
auto& trackRef = primVer2TRefs[iref];
1313+
fillMCTrackLabelsTable(mcTrackLabelCursor, mcMFTTrackLabelCursor, mcFwdTrackLabelCursor, trackRef, primVerGIs, recoData);
1314+
}
13091315
}
1310-
13111316
mToStore.clear();
13121317

13131318
pc.outputs().snapshot(Output{"TFN", "TFNumber", 0, Lifetime::Timeframe}, tfNumber);
@@ -1360,7 +1365,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool useMC)
13601365
"aod-producer-workflow",
13611366
dataRequest->inputs,
13621367
outputs,
1363-
AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest)},
1368+
AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest, useMC)},
13641369
Options{
13651370
ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}},
13661371
ConfigParamSpec{"enable-truncation", VariantType::Int, 1, {"Truncation parameter: 1 -- on, != 1 -- off"}},

0 commit comments

Comments
 (0)