File indexing completed on 2023-03-17 11:20:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "RecoMET/METAlgorithms/interface/SignCaloSpecificAlgo.h"
0013 #include "RecoMET/METAlgorithms/interface/significanceAlgo.h"
0014 #include "RecoMET/METAlgorithms/interface/SignAlgoResolutions.h"
0015 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0016 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018
0019 #include <string>
0020
0021 using namespace reco;
0022 using namespace std;
0023
0024
0025 SignCaloSpecificAlgo::SignCaloSpecificAlgo() : significance_(0.) {
0026 matrix_(0, 0) = matrix_(1, 0) = matrix_(0, 1) = matrix_(1, 1) = 0.;
0027 }
0028 SignCaloSpecificAlgo::~SignCaloSpecificAlgo() {}
0029
0030 void SignCaloSpecificAlgo::usePreviousSignif(const std::vector<double>& values) {
0031 if (values.size() != 4)
0032 return;
0033 matrix_(0, 0) = values[0];
0034 matrix_(0, 1) = values[1];
0035 matrix_(1, 0) = values[2];
0036 matrix_(1, 1) = values[3];
0037 return;
0038 }
0039
0040
0041
0042
0043 std::vector<metsig::SigInputObj> SignCaloSpecificAlgo::makeVectorOutOfCaloTowers(
0044 edm::Handle<edm::View<reco::Candidate> > towers,
0045 const ::metsig::SignAlgoResolutions& resolutions,
0046 bool noHF,
0047 double globalThreshold) {
0048 edm::View<Candidate>::const_iterator towerCand = towers->begin();
0049 std::vector<metsig::SigInputObj> signInputVec;
0050
0051 for (; towerCand != towers->end(); towerCand++) {
0052 const Candidate* candidate = &(*towerCand);
0053 if (candidate) {
0054 const CaloTower* calotower = dynamic_cast<const CaloTower*>(candidate);
0055 if (calotower) {
0056 double sign_tower_et = calotower->et();
0057 if (sign_tower_et < globalThreshold)
0058 continue;
0059 bool wasused = false;
0060 double sign_tower_phi = calotower->phi();
0061 double sign_tower_sigma_et = 0;
0062 double sign_tower_sigma_phi = 0;
0063 std::string sign_tower_type = "";
0064
0065 bool hadIsDone = false;
0066 bool emIsDone = false;
0067 int cell = calotower->constituentsSize();
0068
0069 while (--cell >= 0 && (!hadIsDone || !emIsDone)) {
0070 DetId id = calotower->constituent(cell);
0071 if (!hadIsDone && id.det() == DetId::Hcal) {
0072 HcalSubdetector subdet = HcalDetId(id).subdet();
0073 if (subdet == HcalBarrel) {
0074 sign_tower_type = "hadcalotower";
0075 sign_tower_et = calotower->hadEt();
0076 sign_tower_sigma_et =
0077 resolutions.eval(metsig::caloHB, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0078 sign_tower_sigma_phi =
0079 resolutions.eval(metsig::caloHB, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0080 } else if (subdet == HcalOuter) {
0081 sign_tower_type = "hadcalotower";
0082 sign_tower_et = calotower->outerEt();
0083 sign_tower_sigma_et =
0084 resolutions.eval(metsig::caloHO, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0085 sign_tower_sigma_phi =
0086 resolutions.eval(metsig::caloHO, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0087 } else if (subdet == HcalEndcap) {
0088 sign_tower_type = "hadcalotower";
0089 sign_tower_et = calotower->hadEt();
0090 sign_tower_sigma_et =
0091 resolutions.eval(metsig::caloHE, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0092 sign_tower_sigma_phi =
0093 resolutions.eval(metsig::caloHE, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0094 } else if (subdet == HcalForward) {
0095 sign_tower_type = "hadcalotower";
0096 sign_tower_et = calotower->et();
0097 sign_tower_sigma_et =
0098 resolutions.eval(metsig::caloHF, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0099 sign_tower_sigma_phi =
0100 resolutions.eval(metsig::caloHF, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0101 } else {
0102 edm::LogWarning("SignCaloSpecificAlgo")
0103 << " HCAL tower cell not assigned to an HCAL subdetector!!!" << std::endl;
0104 }
0105
0106 metsig::SigInputObj temp(
0107 sign_tower_type, sign_tower_et, sign_tower_phi, sign_tower_sigma_et, sign_tower_sigma_phi);
0108 if (!noHF || subdet != HcalForward)
0109 signInputVec.push_back(temp);
0110
0111 wasused = true;
0112 hadIsDone = true;
0113 } else if (!emIsDone && id.det() == DetId::Ecal) {
0114 EcalSubdetector subdet = EcalSubdetector(id.subdetId());
0115
0116 if (subdet == EcalBarrel) {
0117 sign_tower_type = "emcalotower";
0118 sign_tower_et = calotower->emEt();
0119 sign_tower_sigma_et =
0120 resolutions.eval(metsig::caloEB, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0121 sign_tower_sigma_phi =
0122 resolutions.eval(metsig::caloEB, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0123 } else if (subdet == EcalEndcap) {
0124 sign_tower_type = "emcalotower";
0125 sign_tower_et = calotower->emEt();
0126 sign_tower_sigma_et =
0127 resolutions.eval(metsig::caloEE, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
0128 sign_tower_sigma_phi =
0129 resolutions.eval(metsig::caloEE, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
0130
0131 } else {
0132 edm::LogWarning("SignCaloSpecificAlgo")
0133 << " ECAL tower cell not assigned to an ECAL subdetector!!!" << std::endl;
0134 }
0135 metsig::SigInputObj temp(
0136 sign_tower_type, sign_tower_et, sign_tower_phi, sign_tower_sigma_et, sign_tower_sigma_phi);
0137 signInputVec.push_back(temp);
0138 wasused = true;
0139 emIsDone = true;
0140 }
0141 }
0142 if (wasused == 0)
0143 edm::LogWarning("SignCaloSpecificAlgo") << "found non-assigned cell, " << std::endl;
0144 }
0145 }
0146 }
0147 return signInputVec;
0148 }
0149
0150
0151
0152 void SignCaloSpecificAlgo::calculateBaseCaloMET(edm::Handle<edm::View<reco::Candidate> > towers,
0153 const CommonMETData& met,
0154 const metsig::SignAlgoResolutions& resolutions,
0155 bool noHF,
0156 double globalThreshold) {
0157
0158
0159
0160
0161
0162 std::vector<metsig::SigInputObj> signInputVec = makeVectorOutOfCaloTowers(towers, resolutions, noHF, globalThreshold);
0163
0164
0165
0166 double sign_calo_met_total = 0;
0167 double sign_calo_met_phi = 0;
0168 double sign_calo_met_set = 0;
0169 metsig::significanceAlgo signifalgo;
0170
0171 signifalgo.addSignifMatrix(matrix_);
0172 signifalgo.addObjects(signInputVec);
0173 matrix_ = signifalgo.getSignifMatrix();
0174 significance_ = signifalgo.significance(sign_calo_met_total, sign_calo_met_phi, sign_calo_met_set);
0175
0176 signInputVec.clear();
0177
0178 }
0179
0180