Skip to content

Commit 785ff1c

Browse files
committed
Formatting - braces around single-statement conditionals - sigh, such an annoyingly unproductive rule
1 parent a2b651b commit 785ff1c

2 files changed

Lines changed: 42 additions & 144 deletions

File tree

Detectors/AOD/src/AODMcProducerHelpers.cxx

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ bool updateHepMCXSection(const XSectionCursor& cursor,
7070

7171
if (when == HepMCUpdate::never or
7272
(when != HepMCUpdate::always and
73-
not hasKeys(header, {Key::acceptedEvents, Key::attemptedEvents, Key::xSection, Key::xSectionError}, when == HepMCUpdate::anyKey)))
73+
not hasKeys(header, {Key::acceptedEvents, Key::attemptedEvents, Key::xSection, Key::xSectionError}, when == HepMCUpdate::anyKey))) {
7474
return false;
75-
75+
}
76+
7677
cursor(0,
7778
collisionID,
7879
generatorID,
@@ -95,9 +96,10 @@ bool updateHepMCPdfInfo(const PdfInfoCursor& cursor,
9596
using Key = o2::dataformats::MCInfoKeys;
9697

9798
if (when == HepMCUpdate::never or
98-
(when != HepMCUpdate::always and not hasKeys(header, {Key::pdfParton1Id, Key::pdfParton2Id, Key::pdfCode1, Key::pdfCode2, Key::pdfX1, Key::pdfX2, Key::pdfScale, Key::pdfXF1, Key::pdfXF2}, when == HepMCUpdate::anyKey)))
99+
(when != HepMCUpdate::always and not hasKeys(header, {Key::pdfParton1Id, Key::pdfParton2Id, Key::pdfCode1, Key::pdfCode2, Key::pdfX1, Key::pdfX2, Key::pdfScale, Key::pdfXF1, Key::pdfXF2}, when == HepMCUpdate::anyKey))) {
99100
return false;
100-
101+
}
102+
101103
cursor(0,
102104
collisionID,
103105
generatorID,
@@ -123,9 +125,10 @@ bool updateHepMCHeavyIon(const HeavyIonCursor& cursor,
123125
using Key = dataformats::MCInfoKeys;
124126

125127
if (when == HepMCUpdate::never or
126-
(when != HepMCUpdate::always and not hasKeys(header, {Key::nCollHard, Key::nPartProjectile, Key::nPartTarget, Key::nColl, Key::nCollNNWounded, Key::nCollNWoundedN, Key::nCollNWoundedNwounded, Key::nSpecProjectileNeutron, Key::nSpecTargetNeutron, Key::nSpecProjectileProton, Key::nSpecTargetProton, Key::planeAngle, "eccentricity", Key::sigmaInelNN, Key::centrality}, when == HepMCUpdate::anyKey)))
128+
(when != HepMCUpdate::always and not hasKeys(header, {Key::nCollHard, Key::nPartProjectile, Key::nPartTarget, Key::nColl, Key::nCollNNWounded, Key::nCollNWoundedN, Key::nCollNWoundedNwounded, Key::nSpecProjectileNeutron, Key::nSpecTargetNeutron, Key::nSpecProjectileProton, Key::nSpecTargetProton, Key::planeAngle, "eccentricity", Key::sigmaInelNN, Key::centrality}, when == HepMCUpdate::anyKey))) {
127129
return false;
128-
130+
}
131+
129132
int specNeutrons = (getEventInfo(header, Key::nSpecProjectileNeutron, -1) +
130133
getEventInfo(header, Key::nSpecTargetNeutron, -1));
131134
int specProtons = (getEventInfo(header, Key::nSpecProjectileProton, -1) +
@@ -168,8 +171,9 @@ void updateParticle(const ParticleCursor& cursor,
168171

169172
auto mapping = [&toStore](int trackNo) {
170173
auto iter = toStore.find(trackNo);
171-
if (iter == toStore.end())
174+
if (iter == toStore.end()) {
172175
return -1;
176+
}
173177
return iter->second;
174178
};
175179

@@ -179,30 +183,37 @@ void updateParticle(const ParticleCursor& cursor,
179183
flags = ProducedByTransport;
180184
statusCode = track.getProcess();
181185
}
182-
if (MCTrackNavigator::isPhysicalPrimary(track, tracks))
186+
if (MCTrackNavigator::isPhysicalPrimary(track, tracks)) {
183187
flags = PhysicalPrimary;
184-
188+
}
189+
185190
int daughters[2] = {-1, -1};
186191
std::vector<int> mothers;
187192
int id;
188-
if ((id = mapping(track.getMotherTrackId())) >= 0)
193+
if ((id = mapping(track.getMotherTrackId())) >= 0) {
189194
mothers.push_back(id);
190-
if ((id = mapping(track.getSecondMotherTrackId())) >= 0)
195+
}
196+
if ((id = mapping(track.getSecondMotherTrackId())) >= 0) {
191197
mothers.push_back(id);
192-
if ((id = mapping(track.getFirstDaughterTrackId())) >= 0)
198+
}
199+
if ((id = mapping(track.getFirstDaughterTrackId())) >= 0) {
193200
daughters[0] = id;
194-
if ((id = mapping(track.getFirstDaughterTrackId())) >= 0)
201+
}
202+
if ((id = mapping(track.getFirstDaughterTrackId())) >= 0) {
195203
daughters[1] = id;
196-
else
204+
}
205+
else {
197206
daughters[1] = daughters[0];
207+
}
198208
if (daughters[0] < 0 and daughters[1] >= 0) {
199209
LOG(error) << "Problematic daughters: " << daughters[0] << " and "
200210
<< daughters[1];
201211
daughters[0] = daughters[1];
202212
}
203-
if (daughters[0] > daughters[1])
213+
if (daughters[0] > daughters[1]) {
204214
std::swap(daughters[0], daughters[1]);
205-
215+
}
216+
206217
float weight = track.getWeight();
207218
float pX = float(track.Px());
208219
float pY = float(track.Py());
@@ -253,8 +264,9 @@ uint32_t updateParticles(const ParticleCursor& cursor,
253264
// the table exported.
254265
auto mapping = [&toStore](int trackNo) {
255266
auto iter = toStore.find(trackNo);
256-
if (iter == toStore.end())
267+
if (iter == toStore.end()) {
257268
return -1;
269+
}
258270
return iter->second;
259271
};
260272

@@ -281,14 +293,18 @@ uint32_t updateParticles(const ParticleCursor& cursor,
281293
// daughters(?) to be stored.
282294
if (filter) {
283295
int id;
284-
if ((id = track.getMotherTrackId()) >= 0)
296+
if ((id = track.getMotherTrackId()) >= 0) {
285297
toStore[id] = 1;
286-
if ((id = track.getSecondMotherTrackId()) >= 0)
298+
}
299+
if ((id = track.getSecondMotherTrackId()) >= 0) {
287300
toStore[id] = 1;
288-
if ((id = track.getFirstDaughterTrackId()) >= 0)
301+
}
302+
if ((id = track.getFirstDaughterTrackId()) >= 0) {
289303
toStore[id] = 1;
290-
if ((id = track.getLastDaughterTrackId()) >= 0)
304+
}
305+
if ((id = track.getLastDaughterTrackId()) >= 0) {
291306
toStore[id] = 1;
307+
}
292308
}
293309
}
294310

@@ -299,8 +315,9 @@ uint32_t updateParticles(const ParticleCursor& cursor,
299315
size_t index = 0;
300316
for (size_t trackNo = 0U; trackNo < tracks.size(); trackNo++) {
301317
auto storeIt = mapping(trackNo);
302-
if (storeIt < 0)
318+
if (storeIt < 0) {
303319
continue;
320+
}
304321

305322
toStore[trackNo] = offset + index;
306323
index++;
@@ -313,9 +330,10 @@ uint32_t updateParticles(const ParticleCursor& cursor,
313330
// Third loop to actually store the particles in the order given
314331
for (size_t trackNo = 0U; trackNo < tracks.size(); trackNo++) {
315332
auto storeIt = mapping(trackNo);
316-
if (storeIt < 0)
333+
if (storeIt < 0) {
317334
continue;
318-
335+
}
336+
319337
auto& track = tracks[trackNo];
320338
auto hepmc = getHepMCStatusCode(track.getStatusCode());
321339
uint8_t flags = (background ? FromBackgroundEvent : 0);

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -932,126 +932,6 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
932932
mMcParticleMom,
933933
mMcParticlePos);
934934

935-
#if 0
936-
// skip treatment if this particle has not been marked during reconstruction
937-
// or based on criteria just above
938-
if (mToStore[source][event].size() > 0 && mToStore[source][event].find(particle) == mToStore[source][event].end()) {
939-
continue;
940-
}
941-
942-
int mother0 = mcParticles[particle].getMotherTrackId();
943-
// we store mothers and daughters of particles that are reconstructed
944-
if (mother0 != -1) {
945-
keepMCParticle(mToStore, source, event, mother0);
946-
}
947-
int mother1 = mcParticles[particle].getSecondMotherTrackId();
948-
if (mother1 != -1) {
949-
keepMCParticle(mToStore, source, event, mother1);
950-
}
951-
int daughter0 = mcParticles[particle].getFirstDaughterTrackId();
952-
if (daughter0 != -1) {
953-
keepMCParticle(mToStore, source, event, daughter0);
954-
}
955-
int daughterL = mcParticles[particle].getLastDaughterTrackId();
956-
if (daughterL != -1) {
957-
keepMCParticle(mToStore, source, event, daughterL);
958-
}
959-
}
960-
particleIDsToKeep.clear();
961-
if (mToStore[source][event].size() > 0) {
962-
LOG(debug) << "The fraction of MC particles kept is " << mToStore[source][event].size() / (1. * mcParticles.size()) << " for source " << source << " and event " << event;
963-
964-
for (auto& p : mToStore[source][event]) {
965-
particleIDsToKeep.push_back(p.first);
966-
}
967-
std::sort(particleIDsToKeep.begin(), particleIDsToKeep.end());
968-
for (auto pid : particleIDsToKeep) {
969-
(mToStore[source][event])[pid] = tableIndex - 1;
970-
tableIndex++;
971-
}
972-
} else {
973-
LOG(warn) << "Empty MC event for event id " << event;
974-
}
975-
} else {
976-
// if all mc particles are stored, all mc particles will be enumerated
977-
particleIDsToKeep.clear();
978-
for (auto particle = 0U; particle < mcParticles.size(); particle++) {
979-
keepMCParticle(mToStore, source, event, particle, tableIndex - 1);
980-
tableIndex++;
981-
particleIDsToKeep.push_back(particle);
982-
}
983-
}
984-
985-
// second part: fill survived mc tracks into the AOD table
986-
mcParticlesCursor.reserve(particleIDsToKeep.size());
987-
for (auto particle : particleIDsToKeep) {
988-
int statusCode = 0;
989-
uint8_t flags = 0;
990-
if (!mcParticles[particle].isPrimary()) {
991-
flags |= o2::aod::mcparticle::enums::ProducedByTransport; // mark as produced by transport
992-
statusCode = mcParticles[particle].getProcess();
993-
} else {
994-
statusCode = mcParticles[particle].getStatusCode().fullEncoding;
995-
}
996-
if (source == 0) {
997-
flags |= o2::aod::mcparticle::enums::FromBackgroundEvent; // mark as particle from background event
998-
}
999-
if (o2::mcutils::MCTrackNavigator::isPhysicalPrimary(mcParticles[particle], mcParticles)) {
1000-
flags |= o2::aod::mcparticle::enums::PhysicalPrimary; // mark as physical primary
1001-
}
1002-
float weight = mcParticles[particle].getWeight();
1003-
std::vector<int> mothers;
1004-
int mcMother0 = mcParticles[particle].getMotherTrackId();
1005-
auto item = mToStore[source][event].find(mcMother0);
1006-
if (item != mToStore[source][event].end()) {
1007-
mothers.push_back(item->second);
1008-
}
1009-
int mcMother1 = mcParticles[particle].getSecondMotherTrackId();
1010-
item = mToStore[source][event].find(mcMother1);
1011-
if (item != mToStore[source][event].end()) {
1012-
mothers.push_back(item->second);
1013-
}
1014-
int daughters[2] = {-1, -1}; // slice
1015-
int mcDaughter0 = mcParticles[particle].getFirstDaughterTrackId();
1016-
item = mToStore[source][event].find(mcDaughter0);
1017-
if (item != mToStore[source][event].end()) {
1018-
daughters[0] = item->second;
1019-
}
1020-
int mcDaughterL = mcParticles[particle].getLastDaughterTrackId();
1021-
item = mToStore[source][event].find(mcDaughterL);
1022-
if (item != mToStore[source][event].end()) {
1023-
daughters[1] = item->second;
1024-
if (daughters[0] < 0) {
1025-
LOG(error) << "AOD problematic daughter case observed";
1026-
daughters[0] = daughters[1]; /// Treat the case of first negative label (pruned in the kinematics)
1027-
}
1028-
} else {
1029-
daughters[1] = daughters[0];
1030-
}
1031-
if (daughters[0] > daughters[1]) {
1032-
std::swap(daughters[0], daughters[1]);
1033-
}
1034-
auto pX = (float)mcParticles[particle].Px();
1035-
auto pY = (float)mcParticles[particle].Py();
1036-
auto pZ = (float)mcParticles[particle].Pz();
1037-
auto energy = (float)mcParticles[particle].GetEnergy();
1038-
mcParticlesCursor(mcColId,
1039-
mcParticles[particle].GetPdgCode(),
1040-
statusCode,
1041-
flags,
1042-
mothers,
1043-
daughters,
1044-
truncateFloatFraction(weight, mMcParticleW),
1045-
truncateFloatFraction(pX, mMcParticleMom),
1046-
truncateFloatFraction(pY, mMcParticleMom),
1047-
truncateFloatFraction(pZ, mMcParticleMom),
1048-
truncateFloatFraction(energy, mMcParticleMom),
1049-
truncateFloatFraction((float)mcParticles[particle].Vx(), mMcParticlePos),
1050-
truncateFloatFraction((float)mcParticles[particle].Vy(), mMcParticlePos),
1051-
truncateFloatFraction((float)mcParticles[particle].Vz(), mMcParticlePos),
1052-
truncateFloatFraction((float)mcParticles[particle].T(), mMcParticlePos));
1053-
}
1054-
#endif
1055935
mcReader.releaseTracksForSourceAndEvent(source, event);
1056936
}
1057937
}

0 commit comments

Comments
 (0)