ATLAS Offline Software
Loading...
Searching...
No Matches
LArCellBinning.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ***********************************************************
6//
7// LArCellBinning - class to hold granularity info
8// for layers of the LAr-Calorimeter. To be used with
9// LArCellMonTools class
10//
11// ***********************************************************
12#include "LArCellBinning.h"
13#include <iostream>
14#include "TMath.h"
15
16
17static const double Pi = TMath::Pi();
18
19using namespace CaloMonitoring;
20
21void LArCellBinning::doEtaBinning(const int nEtaRegions, const double* etaBreakPts, const int * nEtaBins) {
22
23 unsigned nBins=0;
24 for(int i=0; i<nEtaRegions; i++) {
25 nBins += nEtaBins[i];
26 }
27
28 //m_etaBinArray = new double[nBins+1]; // to account for the high edge of the last bin
29 m_etaBinArray.resize(nBins+1,0.0);
30
31
32 // Loop over regions and figure out size of bins in each region
33 int bin=0;
34 for(int iReg=0; iReg<nEtaRegions; iReg++) {
35 double startEta = etaBreakPts[iReg];
36 double endEta = etaBreakPts[iReg+1];
37 double regSize = endEta - startEta; // will be negative on C side
38 double dEta = regSize/nEtaBins[iReg]; // this will also be <= 0 on C
39
40 // Fill eta bin array
41 for(int iBin=0; iBin<nEtaBins[iReg]; iBin++) {
42 m_etaBinArray[bin] = startEta+iBin*dEta;
43 bin++;
44 }
45 }
46
47 // Add last bin for this layer
48 m_etaBinArray[bin] = etaBreakPts[nEtaRegions];
49
50 // check that in ascending order
51 for(int j=0; j<getNTotEtaBins(); j++) {
52 if(m_etaBinArray[j] >= m_etaBinArray[j+1]) {
53 std::cerr << "ERROR: Bin array not in correct order. Make sure breakPoints array\n"
54 << "is in ascending order" << std::endl;
55 }
56 }
57}
58
59// Allows for the case for multiple granularity regions in phi (only really happens
60// for the FCAL)
61void LArCellBinning::doPhiBinning(const int nPhiRegions, const double* phiBreakPts, const int * nPhiBins) {
62
63
64 unsigned nBins=0;
65 for(int i=0; i<nPhiRegions; i++) {
66 nBins += nPhiBins[i];
67 }
68
69 m_phiBinArray.resize(nBins+1,0.0);
70
71 // Loop over regions and figure out size of bins in each region
72 int bin=0;
73 for(int iReg=0; iReg<nPhiRegions; iReg++) {
74 double startPhi = phiBreakPts[iReg];
75 double endPhi = phiBreakPts[iReg+1];
76 double regSize = endPhi - startPhi; // will be negative on C side
77 double dPhi = regSize/nPhiBins[iReg]; // this will also be <= 0 on C
78
79 // Fill phi bin array
80 for(int iBin=0; iBin<nPhiBins[iReg]; iBin++) {
81 m_phiBinArray[bin] = startPhi+iBin*dPhi;
82 bin++;
83 }
84 }
85
86 // Add last bin for this layer
87 m_phiBinArray[bin] = phiBreakPts[nPhiRegions];
88
89 // check that in ascending order
90 for(int j=0; j<getNTotPhiBins(); j++) {
91 if(m_phiBinArray[j] >= m_phiBinArray[j+1]) {
92 std::cerr << "ERROR: Bin array not in correct order. Make sure breakPoints array\n"
93 << "is in ascending order" << std::endl;
94 }
95 }
96}
97
98// Does phi binning using the common case with only one phi granularity region
99void LArCellBinning::doPhiBinning(int nPhiBins) {
100
101 int nPhiBinArray[1] = {nPhiBins};
102 double phiBreakPtsArray[2] = {-Pi,Pi};
103
104 doPhiBinning(1, phiBreakPtsArray, nPhiBinArray);
105}
106
108 LArCellBinning mirrored;
109
110 //copy phi-binning:
111 mirrored.m_phiBinArray=this->m_phiBinArray;
112
113 //fill eta-binning
114 const size_t etaSize=this->m_etaBinArray.size();
115 mirrored.m_etaBinArray.resize(etaSize);
116 for (size_t i=0;i<etaSize;++i) {
117 mirrored.m_etaBinArray[i]=-1.0*m_etaBinArray[etaSize-i-1];
118 }
119
120 // check that in ascending order
121 for(int j=0; j<mirrored.getNTotEtaBins(); j++) {
122 if(mirrored.m_etaBinArray[j] >= mirrored.m_etaBinArray[j+1]) {
123 std::cerr << "ERROR: Bin array not in correct order. Make sure breakPoints array\n"
124 << "is in ascending order" << std::endl;
125 }
126 }
127 return mirrored;
128}
static const double Pi
void doEtaBinning(const int nEtaRegions, const double *etaBreakPts, const int *nEtaBins)
std::vector< double > m_etaBinArray
void doPhiBinning(const int nPhiRegions, const double *phiBreakPts, const int *nPhiBins)
std::vector< double > m_phiBinArray
LArCellBinning etaMirror() const
constexpr std::size_t nPhiBins
constexpr unsigned nEtaBins
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)