-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of crosstalk for ALLEGRO ECAL Barrel (#82)
* Add crosstalk neighbour class * Use c++ static_cast * Attempt to add automatic test * Adapt to the new headfile name of the k4geo update * revert neighbours to ExtSvc in the test * change function name: xtalk_get_cell_indices * Adapt to new k4geo function names for the crosstalk neighbours * Add reading crosstalk neighbours * Add the crosstalk effect to calo cells * Remove unused header * Implementation of crosstalk * ÂMake HitCellsMap a local variable * Add crosstalk computation test in CMakeLists.txt * Update the test of cross-talk map for ALLEGRO v03 * Update test macros for crosstalk calculation --------- Co-authored-by: Zhibo Wu <[email protected]> Co-authored-by: Zhibo Wu <[email protected]>
- Loading branch information
1 parent
34ae82e
commit 0341395
Showing
9 changed files
with
590 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "ReadCaloCrosstalkMap.h" | ||
|
||
#include "TFile.h" | ||
#include "TTree.h" | ||
#include "TBranch.h" | ||
|
||
DECLARE_COMPONENT(ReadCaloCrosstalkMap) | ||
|
||
ReadCaloCrosstalkMap::ReadCaloCrosstalkMap(const std::string& type, const std::string& name, | ||
const IInterface* parent) | ||
: GaudiTool(type, name, parent) { | ||
declareInterface<ICaloReadCrosstalkMap>(this); | ||
} | ||
|
||
StatusCode ReadCaloCrosstalkMap::initialize() { | ||
StatusCode sc = GaudiTool::initialize(); | ||
info() <<"Loading crosstalk map..." << endmsg; | ||
if (sc.isFailure()) return sc; | ||
std::unique_ptr<TFile> file(TFile::Open(m_fileName.value().c_str(),"READ")); | ||
TTree* tree = nullptr; | ||
file->GetObject("crosstalk_neighbours",tree); | ||
ULong64_t read_cellId; | ||
std::vector<uint64_t> *read_neighbours=0; | ||
std::vector<double> *read_crosstalks=0; | ||
|
||
tree->SetBranchAddress("cellId",&read_cellId); | ||
tree->SetBranchAddress("list_crosstalk_neighbours", &read_neighbours); | ||
tree->SetBranchAddress("list_crosstalks", &read_crosstalks); | ||
for (uint i = 0; i < tree->GetEntries(); i++) { | ||
tree->GetEntry(i); | ||
m_mapNeighbours.insert(std::pair<uint64_t, std::vector<uint64_t>>(read_cellId, *read_neighbours)); | ||
m_mapCrosstalks.insert(std::pair<uint64_t, std::vector<double>>(read_cellId, *read_crosstalks)); | ||
} | ||
|
||
info() <<"Crosstalk input: " << m_fileName.value().c_str() << endmsg; | ||
info() << "Total number of cells = " << tree->GetEntries() << ", Size of crosstalk neighbours = " << m_mapNeighbours.size() << ", Size of coefficients = " << m_mapCrosstalks.size() << endmsg; | ||
delete tree; | ||
delete read_neighbours; | ||
delete read_crosstalks; | ||
file->Close(); | ||
return sc; | ||
} | ||
|
||
StatusCode ReadCaloCrosstalkMap::finalize() { return GaudiTool::finalize(); } | ||
|
||
std::vector<uint64_t>& ReadCaloCrosstalkMap::getNeighbours(uint64_t aCellId) { | ||
return m_mapNeighbours[aCellId]; | ||
} | ||
|
||
std::vector<double>& ReadCaloCrosstalkMap::getCrosstalks(uint64_t aCellId) { | ||
return m_mapCrosstalks[aCellId]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef RECCALORIMETER_READCALOXTALKMAP_H | ||
#define RECCALORIMETER_READCALOXTALKMAP_H | ||
|
||
// from Gaudi | ||
#include "GaudiAlg/GaudiTool.h" | ||
|
||
// k4FWCore | ||
#include "k4Interface/ICaloReadCrosstalkMap.h" | ||
|
||
class IGeoSvc; | ||
|
||
/** @class ReadCaloCrosstalkMap Reconstruction/RecCalorimeter/src/components/ReadCaloCrosstalkMap.h | ||
*TopoCaloNeighbours.h | ||
* | ||
* Tool that reads a ROOT file containing the TTree with branches "cellId", "list_crosstalk_neighbours" and "list_crosstalks". | ||
* This tools reads the tree, creates two maps, and allows a lookup of all crosstalk neighbours as well as the corresponding crosstalk coefficients for a given cell. | ||
* | ||
* @author Zhibo Wu | ||
*/ | ||
|
||
class ReadCaloCrosstalkMap : public GaudiTool, virtual public ICaloReadCrosstalkMap { | ||
public: | ||
ReadCaloCrosstalkMap(const std::string& type, const std::string& name, const IInterface* parent); | ||
virtual ~ReadCaloCrosstalkMap() = default; | ||
|
||
virtual StatusCode initialize() final; | ||
virtual StatusCode finalize() final; | ||
|
||
/** Function to be called for the crosstalk neighbours of a cell. | ||
* @param[in] aCellId, cellid of the cell of interest. | ||
* @return vector of cellIDs, corresponding to the crosstalk neighbours. | ||
*/ | ||
virtual std::vector<uint64_t>& getNeighbours(uint64_t aCellId) final; | ||
|
||
/** Function to be called for the crosstalk coefficients between the input cell and its neighbouring cells. | ||
* @param[in] aCellId, cellid of the cell of interest. | ||
* @return vector of crosstalk coefficients. | ||
*/ | ||
virtual std::vector<double>& getCrosstalks(uint64_t aCellId) final; | ||
|
||
private: | ||
/// Name of input root file that contains the TTree with cellID->vec<list_crosstalk_neighboursCellID> and cellId->vec<list_crosstalksCellID> | ||
Gaudi::Property<std::string> m_fileName{this, "fileName", "xtalk_neighbours_map_ecalB_thetamodulemerged.root", "Name of the file that contains the crosstalk map"}; | ||
/// Output maps to be used for the fast lookup in the creating calo-cells algorithm | ||
std::unordered_map<uint64_t, std::vector<uint64_t>> m_mapNeighbours; | ||
std::unordered_map<uint64_t, std::vector<double>> m_mapCrosstalks; | ||
}; | ||
|
||
#endif /* RECCALORIMETER_READCALOXTALKMAP_H */ |
Oops, something went wrong.