Skip to content

Commit

Permalink
Add cell filtering functionalities (#39)
Browse files Browse the repository at this point in the history
* Add the possibility to filter cells based on energy absolute value

* Add the possibility to filter cells without adding noise
  • Loading branch information
BrieucF authored Mar 17, 2023
1 parent fb5ea10 commit b5b0d2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions RecCalorimeter/src/components/CreateCaloCells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ StatusCode CreateCaloCells::initialize() {
info() << "CreateCaloCells initialized" << endmsg;
info() << "do calibration : " << m_doCellCalibration << endmsg;
info() << "add cell noise : " << m_addCellNoise << endmsg;
info() << "remove noise cells below threshold : " << m_filterCellNoise << endmsg;
info() << "remove cells below threshold : " << m_filterCellNoise << endmsg;
info() << "add position information to the cell : " << m_addPosition << endmsg;

// Initialization of tools
Expand All @@ -43,7 +43,7 @@ StatusCode CreateCaloCells::initialize() {
}
}
// Cell noise tool
if (m_addCellNoise) {
if (m_addCellNoise || m_filterCellNoise) {
if (!m_noiseTool.retrieve()) {
error() << "Unable to retrieve the calo cells noise tool!!!" << endmsg;
return StatusCode::FAILURE;
Expand Down Expand Up @@ -102,12 +102,14 @@ StatusCode CreateCaloCells::execute() {
// 3. Add noise to all cells
if (m_addCellNoise) {
m_noiseTool->addRandomCellNoise(m_cellsMap);
if (m_filterCellNoise) {
m_noiseTool->filterCellNoise(m_cellsMap);
}
}

// 4. Copy information to CaloHitCollection
// 4. Filter cells
if (m_filterCellNoise) {
m_noiseTool->filterCellNoise(m_cellsMap);
}

// 5. Copy information to CaloHitCollection
edm4hep::CalorimeterHitCollection* edmCellsCollection = new edm4hep::CalorimeterHitCollection();
for (const auto& cell : m_cellsMap) {
if (m_addCellNoise || (!m_addCellNoise && cell.second != 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void NoiseCaloCellsFromFileTool::filterCellNoise(std::unordered_map<uint64_t, do
// Erase a cell if it has energy bellow a threshold from the vector
auto it = aCells.begin();
while ((it = std::find_if(it, aCells.end(), [this](std::pair<const uint64_t, double>& p) {
return bool(p.second < m_filterThreshold * getNoiseConstantPerCell(p.first));
return m_useAbsInFilter ? bool(std::abs(p.second) < m_filterThreshold * getNoiseConstantPerCell(p.first)) : bool(p.second < m_filterThreshold * getNoiseConstantPerCell(p.first));
})) != aCells.end()) {
aCells.erase(it++);
}
Expand Down
6 changes: 5 additions & 1 deletion RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ class NoiseCaloCellsFromFileTool : public GaudiTool, virtual public INoiseCaloCe
"Name of electronics noise histogram"};
/// Energy threshold (cells with Ecell < filterThreshold*m_cellNoise removed)
Gaudi::Property<double> m_filterThreshold{
this, "filterNoiseThreshold", 3, " Energy threshold (cells with Ecell < filterThreshold*m_cellNoise removed)"};
this, "filterNoiseThreshold", 3, "Energy threshold (cells with Ecell < filterThreshold*m_cellNoise removed)"};
/// Change the cell filter condition to remove only cells with abs(Ecell) < filterThreshold*m_cellNoise removed)
/// This avoids to keep only 'one side' of the noise fluctuations and prevents biasing cluster energy towards higher energies
Gaudi::Property<bool> m_useAbsInFilter{
this, "useAbsInFilter", false, "Cell filtering condition becomes: drop cell if abs(Ecell) < filterThreshold*m_cellNoise"};
/// Number of radial layers
Gaudi::Property<uint> m_numRadialLayers{this, "numRadialLayers", 3, "Number of radial layers"};
/// Histograms with pileup constants (index in array - radial layer)
Expand Down

0 comments on commit b5b0d2b

Please sign in to comment.