CMS 3D CMS Logo

SignCaloSpecificAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METAlgorithms
4 // Class: SigInputObj
5 //
6 // Original Author: Kyle Story, Freya Blekman (Cornell University)
7 // Created: Fri Apr 18 11:58:33 CEST 2008
8 //
9 //
10 
11 //____________________________________________________________________________||
18 
19 #include <string>
20 
21 using namespace reco;
22 using namespace std;
23 
24 //____________________________________________________________________________||
26  matrix_(0, 0) = matrix_(1, 0) = matrix_(0, 1) = matrix_(1, 1) = 0.;
27 }
29 
30 void SignCaloSpecificAlgo::usePreviousSignif(const std::vector<double>& values) {
31  if (values.size() != 4)
32  return;
33  matrix_(0, 0) = values[0];
34  matrix_(0, 1) = values[1];
35  matrix_(1, 0) = values[2];
36  matrix_(1, 1) = values[3];
37  return;
38 }
40 //
41 // Convert a list of calo towers to objects that can be passed to the significance algo:
42 
43 std::vector<metsig::SigInputObj> SignCaloSpecificAlgo::makeVectorOutOfCaloTowers(
45  const ::metsig::SignAlgoResolutions& resolutions,
46  bool noHF,
47  double globalThreshold) {
48  edm::View<Candidate>::const_iterator towerCand = towers->begin();
49  std::vector<metsig::SigInputObj> signInputVec;
50  //iterate over all CaloTowers and record information
51  for (; towerCand != towers->end(); towerCand++) {
52  const Candidate* candidate = &(*towerCand);
53  if (candidate) {
54  const CaloTower* calotower = dynamic_cast<const CaloTower*>(candidate);
55  if (calotower) {
56  double sign_tower_et = calotower->et();
57  if (sign_tower_et < globalThreshold)
58  continue;
59  bool wasused = false;
60  double sign_tower_phi = calotower->phi();
61  double sign_tower_sigma_et = 0;
62  double sign_tower_sigma_phi = 0;
63  std::string sign_tower_type = "";
64 
65  bool hadIsDone = false;
66  bool emIsDone = false;
67  int cell = calotower->constituentsSize();
68 
69  while (--cell >= 0 && (!hadIsDone || !emIsDone)) {
70  DetId id = calotower->constituent(cell);
71  if (!hadIsDone && id.det() == DetId::Hcal) {
72  HcalSubdetector subdet = HcalDetId(id).subdet();
73  if (subdet == HcalBarrel) {
74  sign_tower_type = "hadcalotower";
75  sign_tower_et = calotower->hadEt();
76  sign_tower_sigma_et =
77  resolutions.eval(metsig::caloHB, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
78  sign_tower_sigma_phi =
79  resolutions.eval(metsig::caloHB, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
80  } else if (subdet == HcalOuter) {
81  sign_tower_type = "hadcalotower";
82  sign_tower_et = calotower->outerEt();
83  sign_tower_sigma_et =
84  resolutions.eval(metsig::caloHO, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
85  sign_tower_sigma_phi =
86  resolutions.eval(metsig::caloHO, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
87  } else if (subdet == HcalEndcap) {
88  sign_tower_type = "hadcalotower";
89  sign_tower_et = calotower->hadEt();
90  sign_tower_sigma_et =
91  resolutions.eval(metsig::caloHE, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
92  sign_tower_sigma_phi =
93  resolutions.eval(metsig::caloHE, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
94  } else if (subdet == HcalForward) {
95  sign_tower_type = "hadcalotower";
96  sign_tower_et = calotower->et();
97  sign_tower_sigma_et =
98  resolutions.eval(metsig::caloHF, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
99  sign_tower_sigma_phi =
100  resolutions.eval(metsig::caloHF, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
101  } else {
102  edm::LogWarning("SignCaloSpecificAlgo")
103  << " HCAL tower cell not assigned to an HCAL subdetector!!!" << std::endl;
104  }
105  // and book!
107  sign_tower_type, sign_tower_et, sign_tower_phi, sign_tower_sigma_et, sign_tower_sigma_phi);
108  if (!noHF || subdet != HcalForward)
109  signInputVec.push_back(temp);
110 
111  wasused = true;
112  hadIsDone = true;
113  } else if (!emIsDone && id.det() == DetId::Ecal) {
114  EcalSubdetector subdet = EcalSubdetector(id.subdetId());
115 
116  if (subdet == EcalBarrel) {
117  sign_tower_type = "emcalotower";
118  sign_tower_et = calotower->emEt();
119  sign_tower_sigma_et =
120  resolutions.eval(metsig::caloEB, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
121  sign_tower_sigma_phi =
122  resolutions.eval(metsig::caloEB, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
123  } else if (subdet == EcalEndcap) {
124  sign_tower_type = "emcalotower";
125  sign_tower_et = calotower->emEt();
126  sign_tower_sigma_et =
127  resolutions.eval(metsig::caloEE, metsig::ET, sign_tower_et, calotower->phi(), calotower->eta());
128  sign_tower_sigma_phi =
129  resolutions.eval(metsig::caloEE, metsig::PHI, sign_tower_et, calotower->phi(), calotower->eta());
130 
131  } else {
132  edm::LogWarning("SignCaloSpecificAlgo")
133  << " ECAL tower cell not assigned to an ECAL subdetector!!!" << std::endl;
134  }
136  sign_tower_type, sign_tower_et, sign_tower_phi, sign_tower_sigma_et, sign_tower_sigma_phi);
137  signInputVec.push_back(temp);
138  wasused = true;
139  emIsDone = true;
140  }
141  }
142  if (wasused == 0)
143  edm::LogWarning("SignCaloSpecificAlgo") << "found non-assigned cell, " << std::endl;
144  }
145  }
146  }
147  return signInputVec;
148 }
150 //
151 // Basic MET algorithm. gets towers, does sum. Very similar to standard MET.
153  const CommonMETData& met,
155  bool noHF,
156  double globalThreshold) {
157  //retreive calo tower information from candidates
158  //start with the first element of the candidate list
159 
160  // use this container to calculate the significance. SigInputObj are objects that contain both directional and uncertainty information and are used as input to the significance calculation
161 
162  std::vector<metsig::SigInputObj> signInputVec = makeVectorOutOfCaloTowers(towers, resolutions, noHF, globalThreshold);
163 
164  // now run the significance algorithm.
165 
166  double sign_calo_met_total = 0;
167  double sign_calo_met_phi = 0;
168  double sign_calo_met_set = 0;
169  metsig::significanceAlgo signifalgo;
170  // check the caloMET, if significance was already run continue with the matrix that is stored..
171  signifalgo.addSignifMatrix(matrix_);
172  signifalgo.addObjects(signInputVec);
173  matrix_ = signifalgo.getSignifMatrix();
174  significance_ = signifalgo.significance(sign_calo_met_total, sign_calo_met_phi, sign_calo_met_set);
175  // cleanup everything:
176  signInputVec.clear();
177  // and return
178 }
179 
180 //-------------------------------------------------------------------------
metsig::caloHB
Definition: SignAlgoResolutions.h:46
metsig::caloHE
Definition: SignAlgoResolutions.h:43
significanceAlgo.h
MessageLogger.h
metsig::ET
Definition: SignAlgoResolutions.h:59
SignCaloSpecificAlgo::calculateBaseCaloMET
void calculateBaseCaloMET(edm::Handle< edm::View< reco::Candidate > > towers, const CommonMETData &met, const metsig::SignAlgoResolutions &resolutions, bool noHF, double globalthreshold)
Definition: SignCaloSpecificAlgo.cc:152
SignCaloSpecificAlgo::usePreviousSignif
void usePreviousSignif(const std::vector< double > &values)
Definition: SignCaloSpecificAlgo.cc:30
SignCaloSpecificAlgo::makeVectorOutOfCaloTowers
std::vector< metsig::SigInputObj > makeVectorOutOfCaloTowers(edm::Handle< edm::View< reco::Candidate > > towers, const metsig::SignAlgoResolutions &resolutions, bool noHF, double globalthreshold)
Definition: SignCaloSpecificAlgo.cc:43
DetId::Hcal
Definition: DetId.h:28
ewkMuLumiMonitorDQM_cfi.calotower
calotower
Definition: ewkMuLumiMonitorDQM_cfi.py:36
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
CommonMETData
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HcalBarrel
Definition: HcalAssistant.h:33
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
EcalBarrel
Definition: EcalSubdetector.h:10
SignCaloSpecificAlgo::~SignCaloSpecificAlgo
~SignCaloSpecificAlgo()
Definition: SignCaloSpecificAlgo.cc:28
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
SignAlgoResolutions.h
DetId
Definition: DetId.h:17
metsig::significanceAlgo::addObjects
const void addObjects(const std::vector< metsig::SigInputObj > &EventVec)
Definition: significanceAlgo.cc:109
metsig::caloEB
Definition: SignAlgoResolutions.h:42
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
HcalOuter
Definition: HcalAssistant.h:35
metsig::caloHO
Definition: SignAlgoResolutions.h:44
HLT_2018_cff.noHF
noHF
Definition: HLT_2018_cff.py:48522
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
edm::LogWarning
Definition: MessageLogger.h:141
edm::View
Definition: CaloClusterFwd.h:14
metsig::caloEE
Definition: SignAlgoResolutions.h:41
HcalDetId.h
SignCaloSpecificAlgo::significance_
double significance_
Definition: SignCaloSpecificAlgo.h:56
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
distPFMET_cfi.globalThreshold
globalThreshold
Definition: distPFMET_cfi.py:16
HcalDetId
Definition: HcalDetId.h:12
CaloTower
Definition: CaloTower.h:26
metsig::significanceAlgo::significance
const double significance(double &met_r, double &met_phi, double &met_set)
Definition: significanceAlgo.cc:139
DetId::Ecal
Definition: DetId.h:27
reco::Candidate
Definition: Candidate.h:27
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
electronProducer_cfi.resolutions
resolutions
Definition: electronProducer_cfi.py:80
HLT_2018_cff.towers
towers
Definition: HLT_2018_cff.py:35030
metsig::PHI
Definition: SignAlgoResolutions.h:59
std
Definition: JetResolutionObject.h:76
metsig::significanceAlgo
Definition: significanceAlgo.h:86
HcalEndcap
Definition: HcalAssistant.h:34
metsig::SignAlgoResolutions
Definition: SignAlgoResolutions.h:61
metsig::significanceAlgo::getSignifMatrix
reco::METCovMatrix getSignifMatrix() const
Definition: significanceAlgo.h:99
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
SignCaloSpecificAlgo::SignCaloSpecificAlgo
SignCaloSpecificAlgo()
Definition: SignCaloSpecificAlgo.cc:25
metsig::SigInputObj
Definition: SigInputObj.h:29
SignCaloSpecificAlgo.h
metsig::caloHF
Definition: SignAlgoResolutions.h:45
metsig::significanceAlgo::addSignifMatrix
const void addSignifMatrix(const reco::METCovMatrix &input)
Definition: significanceAlgo.cc:39
SignCaloSpecificAlgo::matrix_
reco::METCovMatrix matrix_
Definition: SignCaloSpecificAlgo.h:57