Skip to content

Commit

Permalink
fix for theta readout
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannimarchiori committed Sep 27, 2023
1 parent e633941 commit b491630
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
61 changes: 43 additions & 18 deletions RecCalorimeter/src/components/ReadNoiseFromFileTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ StatusCode ReadNoiseFromFileTool::initialize() {

// Check if cell position tool available if m_useSeg==false; if tool not
// available, try using segmentation instead
if (!m_cellPositionsTool.retrieve() and !m_useSeg) {
info() << "Unable to retrieve cell positions tool, try eta-phi segmentation." << endmsg;
m_useSeg = true;
if (!m_useSeg){
if (!m_cellPositionsTool.retrieve()) {
info() << "Unable to retrieve cell positions tool, try eta-phi segmentation." << endmsg;
m_useSeg = true;
}
}

// Get PhiEta segmentation
Expand Down Expand Up @@ -151,13 +153,13 @@ double ReadNoiseFromFileTool::getNoiseConstantPerCell(uint64_t aCellId) {
double elecNoise = 0.;
double pileupNoise = 0.;

// Get cell coordinates: eta and radial layer
// Get cell coordinates: eta/theta and radial layer
dd4hep::DDSegmentation::CellID cID = aCellId;
double cellEta;
double cellEta, cellTheta;
if (m_useSeg)
cellEta = m_segmentation->eta(aCellId);
else
cellEta = m_cellPositionsTool->xyzPosition(aCellId).Eta();
cellTheta = m_cellPositionsTool->xyzPosition(aCellId).Theta();
unsigned cellLayer = m_decoder->get(cID, m_activeFieldName);

// All histograms have same binning, all bins with same size
Expand All @@ -174,11 +176,22 @@ double ReadNoiseFromFileTool::getNoiseConstantPerCell(uint64_t aCellId) {
// find the eta bin for the cell
int ibin = floor(fabs(cellEta) / deltaEtaBin) + 1;
*/
int ibin = m_histoElecNoiseConst.at(index).FindBin(fabs(cellEta));
if (ibin > Nbins) {
error() << "eta outside range of the histograms! Cell eta: " << cellEta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
int ibin;
if (m_useSeg) {
ibin = m_histoElecNoiseConst.at(index).FindBin(fabs(cellEta));
if (ibin > Nbins) {
error() << "eta outside range of the histograms! Cell eta: " << cellEta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
}
}
else {
ibin = m_histoElecNoiseConst.at(index).FindBin(cellTheta);
if (ibin > Nbins) {
error() << "theta outside range of the histograms! Cell theta: " << cellTheta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
}
}
// Check that there are not more layers than the constants are provided for
if (cellLayer < m_histoElecNoiseConst.size()) {
Expand Down Expand Up @@ -215,11 +228,11 @@ double ReadNoiseFromFileTool::getNoiseOffsetPerCell(uint64_t aCellId) {

// Get cell coordinates: eta and radial layer
dd4hep::DDSegmentation::CellID cID = aCellId;
double cellEta;
double cellEta, cellTheta;
if (m_useSeg)
cellEta = m_segmentation->eta(aCellId);
else
cellEta = m_cellPositionsTool->xyzPosition(aCellId).Eta();
cellTheta = m_cellPositionsTool->xyzPosition(aCellId).Theta();
unsigned cellLayer = m_decoder->get(cID, m_activeFieldName);

// All histograms have same binning, all bins with same size
Expand All @@ -236,12 +249,24 @@ double ReadNoiseFromFileTool::getNoiseOffsetPerCell(uint64_t aCellId) {
Nbins;
int ibin = floor(fabs(cellEta) / deltaEtaBin) + 1;
*/
int ibin = m_histoElecNoiseOffset.at(index).FindBin(fabs(cellEta));
if (ibin > Nbins) {
error() << "eta outside range of the histograms! Cell eta: " << cellEta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
int ibin;
if (m_useSeg) {
ibin = m_histoElecNoiseOffset.at(index).FindBin(fabs(cellEta));
if (ibin > Nbins) {
error() << "eta outside range of the histograms! Cell eta: " << cellEta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
}
}
else {
ibin = m_histoElecNoiseOffset.at(index).FindBin(cellTheta);
if (ibin > Nbins) {
error() << "theta outside range of the histograms! Cell theta: " << cellTheta << " Nbins in histogram: " << Nbins
<< endmsg;
ibin = Nbins;
}
}

// Check that there are not more layers than the constants are provided for
if (cellLayer < m_histoElecNoiseOffset.size()) {
elecNoise = m_histoElecNoiseOffset.at(cellLayer).GetBinContent(ibin);
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/ReadNoiseFromFileTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TH1F;
/** @class ReadNoiseFromFileTool
*
* Tool to read the stored noise constant per cell in the calorimeters
* Access noise constants from TH1F histogram (noise vs. |eta|)
* Access noise constants from TH1F histogram (noise vs. |eta| or theta)
*
* @author Jana Faltova, Coralie Neubueser
* @date 2018-01
Expand Down

0 comments on commit b491630

Please sign in to comment.