Skip to content
Snippets Groups Projects
Commit 40f66c6e authored by Carl Gwilliam's avatar Carl Gwilliam
Browse files

Speed up scint/calo digi by factorising e and time loops

parent 53fcd3e6
No related branches found
No related tags found
No related merge requests found
......@@ -99,12 +99,24 @@ CaloWaveformDigiAlg::execute(const EventContext& ctx) const {
// Create structure to store pulse for each channel
std::map<Identifier, std::vector<uint16_t>> waveforms = m_digiTool->create_waveform_map(m_ecalID);
// Sum energy for each channel (i.e. identifier)
std::map<unsigned int, float> esum;
for (const auto& hit : *caloHitHandle) {
esum[hit.identify()] += hit.energyLoss();
}
// Loop over time samples
for (const auto& tk : m_timekernel) {
std::map<unsigned int, float> counts;
// Convolve hit energy with evaluated kernel and sum for each hit id (i.e. channel)
for (const auto& hit : *caloHitHandle) {
counts[hit.identify()] += tk * hit.energyLoss();
//for (const auto& hit : *caloHitHandle) {
// counts[hit.identify()] += tk * hit.energyLoss();
//}
// Convolve summed energy with evaluated kernel for each hit id (i.e. channel)
for (const auto& e : esum) {
counts[e.first] = tk * e.second;
}
// Subtract count from basleine and add result to correct waveform vector
......
......@@ -110,35 +110,61 @@ ScintWaveformDigiAlg::execute(const EventContext& ctx) const {
waveforms = m_digiTool->create_waveform_map(m_preshowerID);
}
// Sum energy for each channel (i.e. identifier)
std::map<Identifier, float> esum;
Identifier id;
for (const auto& hit : *scintHitHandle) {
if (first.isTrigger()) {
Identifier plate_id = m_triggerID->plate_id(hit.getIdentifier());
// Need to do something better here, but for now just fill both
id = m_triggerID->pmt_id(plate_id, 0); // ID for PMT 0
esum[id] += hit.energyLoss();
id = m_triggerID->pmt_id(plate_id, 1); // ID for PMT 1
esum[id] += hit.energyLoss();
} else {
// All others have only 1 PMT
// Use detector id (not hit id) throughout
id = hit.getIdentifier();
esum[id] += hit.energyLoss();
}
}
// Loop over time samples
// Should really do sums first, as repeating these in the loop is a waste
for (const auto& tk : m_timekernel) {
std::map<Identifier, float> counts;
// Convolve hit energy with evaluated kernel and sum for each hit id (i.e. channel)
Identifier id;
for (const auto& hit : *scintHitHandle) {
// Special handling for trigger scintillator
if (first.isTrigger()) {
// Hits are created per plate
// Need to split between 2 PMTs
// Identifier from hit is plate ID
Identifier plate_id = m_triggerID->plate_id(hit.getIdentifier());
// Need to do something better here, but for now just fill both
id = m_triggerID->pmt_id(plate_id, 0); // ID for PMT 0
counts[id] += tk * hit.energyLoss();
id = m_triggerID->pmt_id(plate_id, 1); // ID for PMT 1
counts[id] += tk * hit.energyLoss();
} else {
// All others have only 1 PMT
// Use detector id (not hit id) throughout
id = hit.getIdentifier();
counts[id] += tk * hit.energyLoss();
}
// // Convolve hit energy with evaluated kernel and sum for each hit id (i.e. channel)
// Identifier id;
// for (const auto& hit : *scintHitHandle) {
//
// // Special handling for trigger scintillator
// if (first.isTrigger()) {
// // Hits are created per plate
// // Need to split between 2 PMTs
//
// // Identifier from hit is plate ID
// Identifier plate_id = m_triggerID->plate_id(hit.getIdentifier());
//
// // Need to do something better here, but for now just fill both
// id = m_triggerID->pmt_id(plate_id, 0); // ID for PMT 0
// counts[id] += tk * hit.energyLoss();
// id = m_triggerID->pmt_id(plate_id, 1); // ID for PMT 1
// counts[id] += tk * hit.energyLoss();
//
// } else {
// // All others have only 1 PMT
// // Use detector id (not hit id) throughout
// id = hit.getIdentifier();
// counts[id] += tk * hit.energyLoss();
// }
// }
// Convolve summed energy with evaluated kernel for each hit id (i.e. channel)
for (const auto& e : esum) {
// Convert hit id to Identifier and store
id = e.first;
counts[id] = tk * e.second;
}
// Subtract count from basleine and add result to correct waveform vector
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment