Skip to content

Commit

Permalink
changes core code review
Browse files Browse the repository at this point in the history
  • Loading branch information
agrubercms committed Jan 12, 2024
1 parent 0a4c347 commit d9eb42d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,35 @@ void SimTauProducer::buildSimTau(SimTauCPLink& t,
const auto& caloPartVec = *calo_particle_h;
auto& daughters = gen_particle.daughterRefVector();
bool is_leaf = (daughters.empty());

if (is_leaf) {
LogDebug("SimTauProducer").format(" TO BE SAVED {} ", resonance_idx);
auto const& gen_particle_barcode = gen_particle_barcodes[gen_particle_key];
auto const& found_in_caloparticles = std::find_if(caloPartVec.begin(), caloPartVec.end(), [&](const auto& p) {
return p.g4Tracks()[0].genpartIndex() == gen_particle_barcode;
return p.g4Tracks()[0].genpartIndex() == gen_particle_barcode;
});
if (found_in_caloparticles != caloPartVec.end()) {
auto calo_particle_idx = (found_in_caloparticles - caloPartVec.begin());
t.calo_particle_leaves.push_back(CaloParticleRef(calo_particle_h, calo_particle_idx));
t.leaves.push_back(
{gen_particle.pdgId(), resonance_idx, (int)t.calo_particle_leaves.size() - 1, gen_particle_key});
{gen_particle.pdgId(), resonance_idx, (int)t.calo_particle_leaves.size() - 1, gen_particle_key});
LogDebug("SimTauProducer").format(" CP {} {}", calo_particle_idx, caloPartVec[calo_particle_idx]);
} else {
t.leaves.push_back({gen_particle.pdgId(), resonance_idx, -1, gen_particle_key});
}
return;
} else if (generation != 0) {
t.resonances.push_back({gen_particle.pdgId(), resonance_idx});
resonance_idx = t.resonances.size() - 1;
LogDebug("SimTauProducer").format(" RESONANCE/INTERMEDIATE {} ", resonance_idx);
}
} else if (generation != 0) {
t.resonances.push_back({gen_particle.pdgId(), resonance_idx});
resonance_idx = t.resonances.size() - 1;
LogDebug("SimTauProducer").format(" RESONANCE/INTERMEDIATE {} ", resonance_idx);
}

++generation;
for (auto daughter = daughters.begin(); daughter != daughters.end(); ++daughter) {
int gen_particle_key = (*daughter).key();
LogDebug("SimTauProducer").format(" gen {} {} {} ", generation, gen_particle_key, (*daughter)->pdgId());
buildSimTau(t, generation, resonance_idx, *(*daughter), gen_particle_key, calo_particle_h, gen_particle_barcodes);
}

++generation;
for (auto daughter = daughters.begin(); daughter != daughters.end(); ++daughter) {
int gen_particle_key = (*daughter).key();
LogDebug("SimTauProducer").format(" gen {} {} {} ", generation, gen_particle_key, (*daughter)->pdgId());
buildSimTau(t, generation, resonance_idx, *(*daughter), gen_particle_key, calo_particle_h, gen_particle_barcodes);
}
}

void SimTauProducer::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const {
Expand All @@ -105,7 +104,7 @@ void SimTauProducer::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup
auto caloParticles_h = iEvent.getHandle(caloParticles_token_);
const auto& genParticles = iEvent.get(genParticles_token_);
const auto& genBarcodes = iEvent.get(genBarcodes_token_);

auto tauDecayVec = std::make_unique<std::vector<SimTauCPLink>>();
for (auto const& g : genParticles) {
auto const& flags = g.statusFlags();
Expand Down
7 changes: 5 additions & 2 deletions SimDataFormats/CaloAnalysis/interface/SimTauCPLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class SimTauCPLink {
int resonance_idx() const { return resonance_idx_; }
int calo_particle_idx() const { return calo_particle_idx_; }
int gen_particle_idx() const { return gen_particle_idx_; }
private:

private:
};

std::vector<std::pair<int, int>> resonances;
Expand Down Expand Up @@ -52,7 +53,9 @@ class SimTauCPLink {

void dump(void) const {
for (auto const &l : leaves) {
LogDebug("SimTauProducer").format("L {} {} CP: {} GenP idx: {}", l.pdgId(), l.resonance_idx(), l.calo_particle_idx(), l.gen_particle_idx());
LogDebug("SimTauProducer")
.format(
"L {} {} CP: {} GenP idx: {}", l.pdgId(), l.resonance_idx(), l.calo_particle_idx(), l.gen_particle_idx());
}
for (auto const &r : resonances) {
LogDebug("SimTauProducer").format("R {} {}", r.first, r.second);
Expand Down

0 comments on commit d9eb42d

Please sign in to comment.