CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  significance_(0.)
27 {
28  matrix_(0,0)=matrix_(1,0)=matrix_(0,1)=matrix_(1,1)=0.;
29 }
31 {
32 }
33 
34 void SignCaloSpecificAlgo::usePreviousSignif(const std::vector<double> &values)
35 {
36  if(values.size()!=4)
37  return;
38  matrix_(0,0)=values[0];
39  matrix_(0,1)=values[1];
40  matrix_(1,0)=values[2];
41  matrix_(1,1)=values[3];
42  return;
43 }
45 //
46 // Convert a list of calo towers to objects that can be passed to the significance algo:
47 
48 std::vector<metsig::SigInputObj>
50 {
51 
52  edm::View<Candidate>::const_iterator towerCand = towers->begin();
53  std::vector<metsig::SigInputObj> signInputVec;
54  //iterate over all CaloTowers and record information
55  for( ; towerCand != towers->end(); towerCand++ ) {
56  const Candidate *candidate = &(*towerCand);
57  if(candidate){
58  const CaloTower * calotower = dynamic_cast<const CaloTower*> (candidate);
59  if(calotower){
60  double sign_tower_et = calotower->et();
61  if(sign_tower_et<globalThreshold)
62  continue;
63  bool wasused=false;
64  double sign_tower_phi = calotower->phi();
65  double sign_tower_sigma_et = 0;
66  double sign_tower_sigma_phi = 0;
67  std::string sign_tower_type = "";
68 
69  bool hadIsDone = false;
70  bool emIsDone = false;
71  int cell = calotower->constituentsSize();
72 
73  while ( --cell >= 0 && (!hadIsDone || !emIsDone) )
74  {
75  DetId id = calotower->constituent( cell );
76  if( !hadIsDone && id.det() == DetId::Hcal )
77  {
78  HcalSubdetector subdet = HcalDetId(id).subdet();
79  if(subdet == HcalBarrel){
80  sign_tower_type = "hadcalotower";
81  sign_tower_et = calotower->hadEt();
82  sign_tower_sigma_et = resolutions.eval(metsig::caloHB,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
83  sign_tower_sigma_phi = resolutions.eval(metsig::caloHB,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
84  }
85  else if(subdet==HcalOuter){
86  sign_tower_type = "hadcalotower";
87  sign_tower_et = calotower->outerEt();
88  sign_tower_sigma_et = resolutions.eval(metsig::caloHO,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
89  sign_tower_sigma_phi = resolutions.eval(metsig::caloHO,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
90  }
91  else if(subdet==HcalEndcap){
92  sign_tower_type = "hadcalotower";
93  sign_tower_et = calotower->hadEt();
94  sign_tower_sigma_et = resolutions.eval(metsig::caloHE,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
95  sign_tower_sigma_phi = resolutions.eval(metsig::caloHE,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
96  }
97  else if(subdet == HcalForward){
98  sign_tower_type = "hadcalotower";
99  sign_tower_et = calotower->et();
100  sign_tower_sigma_et = resolutions.eval(metsig::caloHF,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
101  sign_tower_sigma_phi = resolutions.eval(metsig::caloHF,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
102  }
103  else{
104  edm::LogWarning("SignCaloSpecificAlgo") << " HCAL tower cell not assigned to an HCAL subdetector!!!" << std::endl;
105  }
106  // and book!
107  metsig::SigInputObj temp(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=1;
112  hadIsDone = true;
113  }
114  else if( !emIsDone && id.det() == DetId::Ecal )
115  {
116  EcalSubdetector subdet = EcalSubdetector( id.subdetId() );
117 
118  if(subdet == EcalBarrel){
119  sign_tower_type = "emcalotower";
120  sign_tower_et = calotower->emEt();
121  sign_tower_sigma_et = resolutions.eval(metsig::caloEB,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
122  sign_tower_sigma_phi = resolutions.eval(metsig::caloEB,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
123  }
124  else if(subdet == EcalEndcap ){
125  sign_tower_type = "emcalotower";
126  sign_tower_et = calotower->emEt();
127  sign_tower_sigma_et = resolutions.eval(metsig::caloEE,metsig::ET,sign_tower_et,calotower->phi(),calotower->eta());
128  sign_tower_sigma_phi = resolutions.eval(metsig::caloEE,metsig::PHI,sign_tower_et,calotower->phi(),calotower->eta());
129 
130  }
131  else{
132  edm::LogWarning("SignCaloSpecificAlgo") << " ECAL tower cell not assigned to an ECAL subdetector!!!" << std::endl;
133  }
134  metsig::SigInputObj temp(sign_tower_type,sign_tower_et,sign_tower_phi,sign_tower_sigma_et,sign_tower_sigma_phi);
135  signInputVec.push_back(temp);
136  wasused=1;
137  emIsDone = true;
138  }
139  }
140  if(wasused==0)
141  edm::LogWarning("SignCaloSpecificAlgo") << "found non-assigned cell, " << std::endl;
142  }
143  }
144  }
145  return signInputVec;
146 }
148 //
149 // Basic MET algorithm. gets towers, does sum. Very similar to standard MET.
151 {
152 
153  //retreive calo tower information from candidates
154  //start with the first element of the candidate list
155 
156 
157 
158  // 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
159 
160  std::vector<metsig::SigInputObj> signInputVec = makeVectorOutOfCaloTowers(towers, resolutions, noHF, globalThreshold);
161 
162  // now run the significance algorithm.
163 
164  double sign_calo_met_total=0;
165  double sign_calo_met_phi=0;
166  double sign_calo_met_set=0;
167  metsig::significanceAlgo signifalgo;
168  // check the caloMET, if significance was already run continue with the matrix that is stored..
169  signifalgo.addSignifMatrix(matrix_);
170  signifalgo.addObjects(signInputVec);
171  matrix_=signifalgo.getSignifMatrix();
172  significance_ = signifalgo.significance( sign_calo_met_total, sign_calo_met_phi, sign_calo_met_set);
173  // cleanup everything:
174  signInputVec.clear();
175  // and return
176 }
177 
178 //-------------------------------------------------------------------------
const void addObjects(const std::vector< metsig::SigInputObj > &EventVec)
std::vector< metsig::SigInputObj > makeVectorOutOfCaloTowers(edm::Handle< edm::View< reco::Candidate > > towers, const metsig::SignAlgoResolutions &resolutions, bool noHF, double globalthreshold)
size_t constituentsSize() const
Definition: CaloTower.h:102
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
DetId constituent(size_t i) const
Definition: CaloTower.h:103
double hadEt() const
Definition: CaloTower.h:113
const double significance(double &met_r, double &met_phi, double &met_set)
double outerEt() const
Definition: CaloTower.h:114
virtual double phi() const final
momentum azimuthal angle
reco::METCovMatrix matrix_
void usePreviousSignif(const std::vector< double > &values)
HcalSubdetector
Definition: HcalAssistant.h:31
tuple globalThreshold
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
const void addSignifMatrix(const reco::METCovMatrix &input)
Definition: DetId.h:18
void calculateBaseCaloMET(edm::Handle< edm::View< reco::Candidate > > towers, const CommonMETData &met, const metsig::SignAlgoResolutions &resolutions, bool noHF, double globalthreshold)
reco::METCovMatrix getSignifMatrix() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
double et(double vtxZ) const
Definition: CaloTower.h:129
virtual double eta() const final
momentum pseudorapidity
EcalSubdetector
double emEt() const
Definition: CaloTower.h:112