CMS 3D CMS Logo

JetVertexMain.cc
Go to the documentation of this file.
1 
7 #include <cmath>
8 #include <string>
9 using namespace reco;
10 using namespace edm;
11 
13 
14  cutSigmaZ = parameters.getParameter<double>("JV_sigmaZ");
15  cutDeltaZ = parameters.getParameter<double>("JV_deltaZ");
16  threshold = parameters.getParameter<double>("JV_alpha_threshold");
17  cone_size = parameters.getParameter<double>("JV_cone_size");
18  Algo = parameters.getParameter<int>("JV_type_Algo");
19  cutType = parameters.getParameter<std::string>("JV_cutType");
20 
21 }
22 
23 
25  double signal_vert_Z, double signal_vert_z_error){
26 
27  std::pair<double, bool> parameter;
28 
29  double jet_et = jet.et();
30  double jet_phi = jet.phi();
31  double jet_eta = jet.eta();
32 
33  // cout<<"JET: "<<jet_et<<endl;
34  double Pt_jets_X = 0. ;
35  double Pt_jets_Y = 0. ;
36  double Pt_jets_X_tot = 0. ;
37  double Pt_jets_Y_tot = 0. ;
38 
39  TrackCollection::const_iterator track = tracks->begin ();
40 
41  if (tracks->size() > 0 ) {
42  for (; track != tracks->end (); track++) {
43  double Vertex_Z = track->vz();
44  double Vertex_Z_Error = track->dzError();
45  double track_eta = track->eta();
46  double track_phi = track->phi();
47 
48  if (DeltaR(track_eta,jet_eta, track_phi, jet_phi) < cone_size) {
49 
50  double DeltaZ = Vertex_Z-signal_vert_Z;
51  double DeltaZ_Error = sqrt((Vertex_Z_Error*Vertex_Z_Error)+(signal_vert_z_error*signal_vert_z_error));
52  Pt_jets_X_tot += track->px();
53  Pt_jets_Y_tot += track->py();
54  if (cutType == "sig") discriminator = (fabs(DeltaZ)/DeltaZ_Error) <= cutSigmaZ;
55  else discriminator = fabs(DeltaZ) < cutDeltaZ;
56 
57  if (discriminator){
58 
59  Pt_jets_X += track->px();
60  Pt_jets_Y += track->py();
61 
62  }
63 
64  }
65  }
66 }
67  double Var = -1;
68 
69  if (Algo == 1) Var = Track_Pt(Pt_jets_X, Pt_jets_Y)/jet_et;
70  else if (Algo == 2) {
71  if (Track_Pt(Pt_jets_X_tot, Pt_jets_Y_tot)!=0) Var = Track_Pt(Pt_jets_X, Pt_jets_Y)/Track_Pt(Pt_jets_X_tot, Pt_jets_Y_tot);
72  else std::cout << "[Jets] JetVertexAssociation: Warning! problems for Algo = 2: possible division by zero .." << std::endl;
73  }
74  else {
75 
76  Var = Track_Pt(Pt_jets_X, Pt_jets_Y)/jet_et;
77  std::cout << "[Jets] JetVertexAssociation: Warning! Algo = " << Algo << " not found; using Algo = 1" << std::endl;
78  }
79 
80  // cout<<"Var = "<<Var<<endl;
81 
82  if (Var >= threshold) parameter = std::pair<double, bool>(Var, true);
83  else parameter = std::pair<double, bool>(Var, false);
84 
85  return parameter;
86 
87 }
88 
89 double JetVertexMain::DeltaR(double eta1, double eta2, double phi1, double phi2){
90 
91  double dphi = fabs(phi1-phi2);
92  if(dphi > M_PI) dphi = 2*M_PI - dphi;
93  double deta = fabs(eta1-eta2);
94  return sqrt(dphi*dphi + deta*deta);
95 
96 }
97 
98 double JetVertexMain::Track_Pt(double px, double py){
99 
100  return sqrt(px*px+py*py);
101 
102 }
T getParameter(std::string const &) const
std::pair< double, bool > Main(const reco::CaloJet &jet, edm::Handle< reco::TrackCollection > tracks, double SIGNAL_V_Z, double SIGNAL_V_Z_Error)
double eta() const final
momentum pseudorapidity
Jets made from CaloTowers.
Definition: CaloJet.h:29
double DeltaR(double eta1, double eta2, double phi1, double phi2)
double Track_Pt(double px, double py)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
double et() const final
transverse energy
T sqrt(T t)
Definition: SSEVec.h:18
JetVertexMain(const edm::ParameterSet &parameters)
#define M_PI
fixed size matrix
HLT enums.
double phi() const final
momentum azimuthal angle
Definition: fakeMenu.h:6