test
CMS 3D CMS Logo

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