diff --git a/RecCalorimeter/src/components/CreateCaloCells.cpp b/RecCalorimeter/src/components/CreateCaloCells.cpp index 0072fbe6..4b254956 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.cpp +++ b/RecCalorimeter/src/components/CreateCaloCells.cpp @@ -36,12 +36,15 @@ StatusCode CreateCaloCells::initialize() { info() << "add cell noise : " << m_addCellNoise << endmsg; info() << "remove cells below threshold : " << m_filterCellNoise << endmsg; info() << "add position information to the cell : " << m_addPosition << endmsg; + info() << "emulate crosstalk : " << m_addCrosstalk << endmsg; // Initialization of tools // Cell crosstalk tool - if (!m_crosstalksTool.retrieve()) { - error() << "Unable to retrieve the cell crosstalk tool!!!" << endmsg; - return StatusCode::FAILURE; + if (m_addCrosstalk) { + if (!m_crosstalksTool.retrieve()) { + error() << "Unable to retrieve the cell crosstalk tool!!!" << endmsg; + return StatusCode::FAILURE; + } } // Calibrate Geant4 energy to EM scale tool if (m_doCellCalibration) { @@ -95,59 +98,60 @@ StatusCode CreateCaloCells::execute() { m_cellsMap.clear(); } - std::unordered_map HitCellsMap; // 1. Merge energy deposits into cells // If running with noise map already was prepared. Otherwise it is being // created below for (const auto& hit : *hits) { verbose() << "CellID : " << hit.getCellID() << endmsg; - if(m_addCrosstalk) { // Crosstalk only applies to energy deposits caused by EM shower hits. Therefore, cell noise needs to be excluded. - HitCellsMap[hit.getCellID()] += hit.getEnergy(); - } m_cellsMap[hit.getCellID()] += hit.getEnergy(); } + debug() << "Number of calorimeter cells after merging of hits: " << m_cellsMap.size() << endmsg; + + // 2. Emulate cross-talk (if asked) if(m_addCrosstalk) { - m_CrosstalkCellsMap.clear(); - // loop over cells that get actual EM shower hits - for (const auto& this_cell : HitCellsMap) { - uint64_t this_cellId=this_cell.first; + // Derive the cross-talk contributions without affecting yet the nominal energy + // (one has to emulate crosstalk based on cells free from any cross-talk contributions) + m_CrosstalkCellsMap.clear(); // this is a temporary map to hold energy exchange due to cross-talk, without affecting yet the nominal energy + // loop over cells with nominal energies + for (const auto& this_cell : m_cellsMap) { + uint64_t this_cellId = this_cell.first; auto vec_neighbours = m_crosstalksTool->getNeighbours(this_cellId); // a vector of neighbour IDs auto vec_crosstalks = m_crosstalksTool->getCrosstalks(this_cellId); // a vector of crosstalk coefficients - // loop over crosstalk neighbrous of the cell under study + // loop over crosstalk neighbours of the cell under study for (unsigned int i_cell=0; i_cellcalibrate(m_cellsMap); } - // 3. Add noise to all cells + // 4. Add noise to all cells if (m_addCellNoise) { m_noiseTool->addRandomCellNoise(m_cellsMap); } - // 4. Filter cells + // 5. Filter cells if (m_filterCellNoise) { m_noiseTool->filterCellNoise(m_cellsMap); } - // 5. Copy information to CaloHitCollection + // 6. Copy information to CaloHitCollection edm4hep::CalorimeterHitCollection* edmCellsCollection = new edm4hep::CalorimeterHitCollection(); for (const auto& cell : m_cellsMap) { if (m_addCellNoise || (!m_addCellNoise && cell.second != 0)) { diff --git a/RecCalorimeter/src/components/CreateCaloCells.h b/RecCalorimeter/src/components/CreateCaloCells.h index 0aaa2d76..5c3a2724 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.h +++ b/RecCalorimeter/src/components/CreateCaloCells.h @@ -32,14 +32,17 @@ class IGeoSvc; * * Flow of the program: * 1/ Merge Geant4 energy deposits with same cellID - * 2/ Calibrate to electromagnetic scale (if calibration switched on) - * 3/ Add random noise to each cell (if noise switched on) - * 4/ Filter cells and remove those with energy below threshold (if noise + + * 2/ Emulate cross-talk (if switched on) + * 3/ Calibrate to electromagnetic scale (if calibration switched on) + * 4/ Add random noise to each cell (if noise switched on) + * 5/ Filter cells and remove those with energy below threshold (if noise + * filtering switched on) * * Tools called: * - CalibrateCaloHitsTool * - NoiseCaloCellsTool + * - CaloReadCrosstalkMap + * - CalorimeterTool (for geometry) * * @author Jana Faltova * @author Anna Zaborowska @@ -70,7 +73,7 @@ class CreateCaloCells : public GaudiAlgorithm { ToolHandle m_geoTool{"TubeLayerPhiEtaCaloTool", this}; /// Add crosstalk to cells? - Gaudi::Property m_addCrosstalk{this, "addCrosstalk", true, "Add crosstalk effect?"}; + Gaudi::Property m_addCrosstalk{this, "addCrosstalk", false, "Add crosstalk effect?"}; /// Calibrate to EM scale? Gaudi::Property m_doCellCalibration{this, "doCellCalibration", true, "Calibrate to EM scale?"}; /// Add noise to cells? @@ -119,8 +122,9 @@ class CreateCaloCells : public GaudiAlgorithm { /// Pointer to the geometry service ServiceHandle m_geoSvc; dd4hep::VolumeManager m_volman; - /// Maps of cell IDs (corresponding to DD4hep IDs) on (1) final energies to be used for clustering, (2) transfer of signals due to crosstalk + /// Maps of cell IDs (corresponding to DD4hep IDs) on final energies to be used for clustering std::unordered_map m_cellsMap; + /// Maps of cell IDs (corresponding to DD4hep IDs) on transfer of signals due to crosstalk std::unordered_map m_CrosstalkCellsMap; };