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  cutSigmaZ = parameters.getParameter<double>("JV_sigmaZ");
14  cutDeltaZ = parameters.getParameter<double>("JV_deltaZ");
15  threshold = parameters.getParameter<double>("JV_alpha_threshold");
16  cone_size = parameters.getParameter<double>("JV_cone_size");
17  Algo = parameters.getParameter<int>("JV_type_Algo");
18  cutType = parameters.getParameter<std::string>("JV_cutType");
19 }
20 
21 std::pair<double, bool> JetVertexMain::Main(const reco::CaloJet& jet,
23  double signal_vert_Z,
24  double signal_vert_z_error) {
25  std::pair<double, bool> parameter;
26 
27  double jet_et = jet.et();
28  double jet_phi = jet.phi();
29  double jet_eta = jet.eta();
30 
31  // cout<<"JET: "<<jet_et<<endl;
32  double Pt_jets_X = 0.;
33  double Pt_jets_Y = 0.;
34  double Pt_jets_X_tot = 0.;
35  double Pt_jets_Y_tot = 0.;
36 
37  TrackCollection::const_iterator track = tracks->begin();
38 
39  if (!tracks->empty()) {
40  for (; track != tracks->end(); track++) {
41  double Vertex_Z = track->vz();
42  double Vertex_Z_Error = track->dzError();
43  double track_eta = track->eta();
44  double track_phi = track->phi();
45 
46  if (DeltaR(track_eta, jet_eta, track_phi, jet_phi) < cone_size) {
47  double DeltaZ = Vertex_Z - signal_vert_Z;
48  double DeltaZ_Error = sqrt((Vertex_Z_Error * Vertex_Z_Error) + (signal_vert_z_error * signal_vert_z_error));
49  Pt_jets_X_tot += track->px();
50  Pt_jets_Y_tot += track->py();
51  if (cutType == "sig")
52  discriminator = (fabs(DeltaZ) / DeltaZ_Error) <= cutSigmaZ;
53  else
54  discriminator = fabs(DeltaZ) < cutDeltaZ;
55 
56  if (discriminator) {
57  Pt_jets_X += track->px();
58  Pt_jets_Y += track->py();
59  }
60  }
61  }
62  }
63  double Var = -1;
64 
65  if (Algo == 1)
66  Var = Track_Pt(Pt_jets_X, Pt_jets_Y) / jet_et;
67  else if (Algo == 2) {
68  if (Track_Pt(Pt_jets_X_tot, Pt_jets_Y_tot) != 0)
69  Var = Track_Pt(Pt_jets_X, Pt_jets_Y) / Track_Pt(Pt_jets_X_tot, Pt_jets_Y_tot);
70  else
71  std::cout << "[Jets] JetVertexAssociation: Warning! problems for Algo = 2: possible division by zero .."
72  << std::endl;
73  } else {
74  Var = Track_Pt(Pt_jets_X, Pt_jets_Y) / jet_et;
75  std::cout << "[Jets] JetVertexAssociation: Warning! Algo = " << Algo << " not found; using Algo = 1" << std::endl;
76  }
77 
78  // cout<<"Var = "<<Var<<endl;
79 
80  if (Var >= threshold)
81  parameter = std::pair<double, bool>(Var, true);
82  else
83  parameter = std::pair<double, bool>(Var, false);
84 
85  return parameter;
86 }
87 
88 double JetVertexMain::DeltaR(double eta1, double eta2, double phi1, double phi2) {
89  double dphi = fabs(phi1 - phi2);
90  if (dphi > M_PI)
91  dphi = 2 * M_PI - dphi;
92  double deta = fabs(eta1 - eta2);
93  return sqrt(dphi * dphi + deta * deta);
94 }
95 
96 double JetVertexMain::Track_Pt(double px, double py) { return sqrt(px * px + py * py); }
reco::CaloJet
Jets made from CaloTowers.
Definition: CaloJet.h:27
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:29
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
CaloJet.h
JetVertexMain::JetVertexMain
JetVertexMain(const edm::ParameterSet &parameters)
Definition: JetVertexMain.cc:12
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
pfMETsysShiftCorrections_cfi.parameter
parameter
Definition: pfMETsysShiftCorrections_cfi.py:118
JetVertexMain::Main
std::pair< double, bool > Main(const reco::CaloJet &jet, edm::Handle< reco::TrackCollection > tracks, double SIGNAL_V_Z, double SIGNAL_V_Z_Error)
Definition: JetVertexMain.cc:21
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLT_FULL_cff.DeltaZ
DeltaZ
Definition: HLT_FULL_cff.py:446
edm::Handle
Definition: AssociativeIterator.h:50
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
Track.h
TrackFwd.h
PDWG_TauSkim_cff.discriminator
discriminator
Definition: PDWG_TauSkim_cff.py:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9608
JetVertexMain::DeltaR
double DeltaR(double eta1, double eta2, double phi1, double phi2)
Definition: JetVertexMain.cc:88
Algo
Definition: fakeMenu.h:6
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9607
edm::ParameterSet
Definition: ParameterSet.h:47
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
JetVertexMain::Track_Pt
double Track_Pt(double px, double py)
Definition: JetVertexMain.cc:96
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
metsig::jet
Definition: SignAlgoResolutions.h:47
JetVertexMain.h
ParameterSet.h
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426