CMS 3D CMS Logo

RazorComputer.cc
Go to the documentation of this file.
2 #include "TLorentzVector.h"
3 
5  : CachingVariable("RazorBox", arg.n, arg.iConfig, iC) {}
6 
7 void RazorBox::compute(const edm::Event& iEvent) const {}
8 
10  : VariableComputer(arg, iC) {
11  jet_ = edm::Service<InputTagDistributorService>()->retrieve("jet", arg.iConfig);
12  met_ = edm::Service<InputTagDistributorService>()->retrieve("met", arg.iConfig);
13  jetToken_ = iC.consumes<std::vector<pat::Jet>>(jet_);
14  metToken_ = iC.consumes<std::vector<pat::MET>>(met_);
15  pt_ = 40.;
16  eta_ = 2.4;
17 
18  declare("MRT", iC);
19  declare("MR", iC);
20  declare("R2", iC);
21  declare("R", iC);
22 }
23 
24 namespace razor {
26 
27  double CalcMR(const LorentzVector& ja, const LorentzVector& jb) {
28  double A = ja.P();
29  double B = jb.P();
30  double az = ja.Pz();
31  double bz = jb.Pz();
32 
33  double temp = sqrt((A + B) * (A + B) - (az + bz) * (az + bz));
34 
35  return temp;
36  }
37  double CalcMTR(const LorentzVector& j1, const LorentzVector& j2, const pat::MET& met) {
38  double temp = met.et() * (j1.Pt() + j2.Pt()) - met.px() * (j1.X() + j2.X()) - met.py() * (j1.Y() + j2.Y());
39  temp /= 2.;
40 
41  temp = sqrt(temp);
42 
43  return temp;
44  }
45 }; // namespace razor
46 
48  //std::cout<<"getting into computation"<<std::endl;
49 
52  iEvent.getByToken(jetToken_, jetH);
53  iEvent.getByToken(metToken_, metH);
54 
56 
57  std::vector<LorentzVector> jets;
58  jets.reserve(jetH.product()->size());
59  for (std::vector<pat::Jet>::const_iterator jetit = jetH.product()->begin(); jetit != jetH.product()->end(); ++jetit) {
60  if (jetit->et() > pt_ && fabs(jetit->eta()) < eta_) {
61  jets.push_back(jetit->p4());
62  }
63  }
64 
65  reco::Candidate::LorentzVector HEM_1, HEM_2;
66 
67  HEM_1.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
68  HEM_2.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
69 
70  if (jets.size() < 2) {
71  } else {
72  unsigned int N_comb = 1;
73  for (unsigned int i = 0; i < jets.size(); i++) {
74  N_comb *= 2;
75  }
76 
77  double M_temp;
78 
79  double M_min = 9999999999.0;
80  int j_count;
81 
82  for (unsigned int i = 1; i < N_comb - 1; i++) {
83  LorentzVector j_temp1, j_temp2;
84  int itemp = i;
85  j_count = N_comb / 2;
86  int count = 0;
87  while (j_count > 0) {
88  if (itemp / j_count == 1) {
89  j_temp1 += jets[count];
90  } else {
91  j_temp2 += jets[count];
92  }
93  itemp -= j_count * (itemp / j_count);
94  j_count /= 2;
95  count++;
96  }
97 
98  M_temp = j_temp1.M2() + j_temp2.M2();
99 
100  if (M_temp < M_min) {
101  M_min = M_temp;
102  HEM_1 = j_temp1;
103  HEM_2 = j_temp2;
104  }
105  }
106 
107  if (HEM_2.Pt() > HEM_1.Pt()) {
108  LorentzVector temp = HEM_1;
109  HEM_1 = HEM_2;
110  HEM_2 = temp;
111  }
112  }
113 
114  double mrt = razor::CalcMTR(HEM_1, HEM_2, metH.product()->at(0));
115  double mr = razor::CalcMR(HEM_1, HEM_2);
116 
117  assign("MRT", mrt);
118  assign("MR", mr);
119  double r = -1, r2 = -1;
120  if (mr != 0) {
121  r = mrt / mr;
122  r2 = r * r;
123  }
124  assign("R", r);
125  assign("R2", r2);
126 
127  //std::cout<<"MR,R2 "<<mr<<" , "<<r2<<std::endl;
128 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Analysis-level MET class.
Definition: MET.h:40
edm::InputTag met_
Definition: RazorComputer.h:27
void compute(const edm::Event &iEvent) const
Definition: RazorComputer.cc:7
Definition: APVGainStruct.h:7
double CalcMTR(const LorentzVector &j1, const LorentzVector &j2, const pat::MET &met)
T const * product() const
Definition: Handle.h:70
edm::InputTag jet_
Definition: RazorComputer.h:26
RazorBox(const CachingVariable::CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
Definition: RazorComputer.cc:4
A arg
Definition: Factorize.h:31
void assign(std::string var, double &value) const
int iEvent
Definition: GenABIO.cc:224
RazorComputer(const CachingVariable::CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
Definition: RazorComputer.cc:9
edm::EDGetTokenT< std::vector< pat::MET > > metToken_
Definition: RazorComputer.h:29
T sqrt(T t)
Definition: SSEVec.h:23
math::XYZTLorentzVector LorentzVector
reco::Candidate::LorentzVector LorentzVector
void compute(const edm::Event &iEvent) const override
double CalcMR(const LorentzVector &ja, const LorentzVector &jb)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::EDGetTokenT< std::vector< pat::Jet > > jetToken_
Definition: RazorComputer.h:28
Definition: APVGainStruct.h:7
void declare(std::string var, edm::ConsumesCollector &iC)