CMS 3D CMS Logo

FixedGridEnergyDensity.cc
Go to the documentation of this file.
2 
5 #include "TMath.h"
6 
7 using namespace reco;
8 using namespace edm;
9 using namespace std;
10 
12  //define the phi bins
13  vector<float> phibins;
14  for (int i=0;i<10;i++) phibins.push_back(-TMath::Pi()+(2*i+1)*TMath::TwoPi()/20.);
15  //define the eta bins
16  vector<float> etabins;
17  if (etaRegion==Central) {
18  for (int i=0;i<8;++i) etabins.push_back(-2.1+0.6*i);
19  } else if (etaRegion==Forward) {
20  for (int i=0;i<10;++i) {
21  if (i<5) etabins.push_back(-5.1+0.6*i);
22  else etabins.push_back(2.7+0.6*(i-5));
23  }
24  } else if (etaRegion==All) {
25  for (int i=0;i<18;++i) etabins.push_back(-5.1+0.6*i);
26  }
27  return fixedGridRho(etabins,phibins);
28 }
29 
30 
31 float FixedGridEnergyDensity::fixedGridRho(std::vector<float>& etabins,std::vector<float>& phibins) {
32  float etadist = etabins[1]-etabins[0];
33  float phidist = phibins[1]-phibins[0];
34  float etahalfdist = (etabins[1]-etabins[0])/2.;
35  float phihalfdist = (phibins[1]-phibins[0])/2.;
36  vector<float> sumPFNallSMDQ;
37  sumPFNallSMDQ.reserve(etabins.size()*phibins.size());
38  for (unsigned int ieta=0;ieta<etabins.size();++ieta) {
39  for (unsigned int iphi=0;iphi<phibins.size();++iphi) {
40  float pfniso_ieta_iphi = 0;
41  for(PFCandidateCollection::const_iterator pf_it = pfCandidates->begin(); pf_it != pfCandidates->end(); pf_it++) {
42  if (fabs(etabins[ieta]-pf_it->eta())>etahalfdist) continue;
43  if (fabs(reco::deltaPhi(phibins[iphi],pf_it->phi()))>phihalfdist) continue;
44  pfniso_ieta_iphi+=pf_it->pt();
45  }
46  sumPFNallSMDQ.push_back(pfniso_ieta_iphi);
47  }
48  }
49  float evt_smdq = 0;
50  sort(sumPFNallSMDQ.begin(),sumPFNallSMDQ.end());
51  if (sumPFNallSMDQ.size()%2) evt_smdq = sumPFNallSMDQ[(sumPFNallSMDQ.size()-1)/2];
52  else evt_smdq = (sumPFNallSMDQ[sumPFNallSMDQ.size()/2]+sumPFNallSMDQ[(sumPFNallSMDQ.size()-2)/2])/2.;
53  return evt_smdq/(etadist*phidist);
54 }
const double TwoPi
const double Pi
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
float fixedGridRho(EtaRegion etaRegion=Central)
fixed size matrix
HLT enums.