ATLAS Offline Software
TtresdRmin.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 // //
7 // TTBarLeptonJetsBuilder_dRmin tool //
8 // //
9 // This tool provides functionality to calculated the ttbar mass using the //
10 // dRmin method //
11 // //
12 // (1) If the event contains a high mass jet above a given threshold, the //
13 // mass is calculated using the high mass jet, the closest jet to this //
14 // one, and the jet closest to the leptonic W-boson //
15 // //
16 // (2) If the event does not contain a high mass jet and at least four jets, //
17 // the dRmin method removes jets passing a specific cut requirement //
18 // correlated to its mass. This procedure is repeated as long as there //
19 // are at least 4 jets available. //
20 // //
21 // Note: This procedure also calculates the mass for cases with only 2 jets. //
22 // These events have to be filtered in the cutflow! //
23 // //
24 // Contact: lmasetti@cern.ch //
25 // theck@cern.ch //
26 // //
28 
29 
31 
32 //==========================================================================================================
33 // Class constructor
34 //
36  m_init = false;
38 
39  if (units == "MeV") {
40  m_Units = 1000.0;
41  } else if (units == "GeV") {
42  m_Units = 1.0;
43  } else {
44  cout << " ERROR in in TtresdRmin :: Unit setting '" << units << "' doest not match pattern of GeV or MeV" << endl;
45  }
46 }
47 
48 //==========================================================================================================
49 // Initialize parameters for tool
50 //
51 void TtresdRmin::Init(double highJetMass, double minJetPt, double dRCutOffset, double dRCutMassFactor) {
52  //Set parameters
53  m_highM = highJetMass;
54  m_minJetPt = minJetPt;
55  m_dRCutOffset = dRCutOffset;
56  m_dRCutMassFactor = dRCutMassFactor;
57 
58  //Reset
59  m_jet_indices.clear();
60  m_highMassJetIndex = -1;
61  m_highestJetMass = 0.0;
62 
63  //Initialization status
64  m_init = true;
65 }
66 
67 //==========================================================================================================
68 // Setup event with kinematic objects
69 //
70 bool TtresdRmin::SetupEvent(vector<TLorentzVector*>& jets, TLorentzVector& lepton, TLorentzVector& neutrino) {
71  if (!m_init) {
72  cout << " ERROR in TtresdRmin :: Tool not initialized! Initialize tool before usage!!!" << endl;
73  return false;
74  }
75 
76  //Set objects
77  m_jets = jets;
78  m_lepton = lepton;
79  m_neutrino = neutrino;
80  m_Wleptonic = lepton + neutrino;
81 
82  //Reset
83  m_jet_indices.clear();
84  m_highMassJetIndex = -1;
85  m_highestJetMass = 0.0;
86 
87 
88  //===== Search for high mass jet =====
89  int highMJetIdx = -1; //Index of jet with highest mass above threshold
90  double highM = m_highM * m_Units; //Threshold for high mass jet
91  double minJetPt = m_minJetPt * m_Units; //Threshold for jet pT
92 
93  //Loop jets
94  for (int ijet = 0; ijet < (int) jets.size(); ijet++) {
95  //pT requirmenet
96  if (jets.at(ijet)->Pt() <= minJetPt) continue; //next jet
97 
98  //high mass requirement
99  if (jets.at(ijet)->M() <= highM) continue; //next jet
100 
101  highMJetIdx = ijet;
102  highM = jets.at(ijet)->M();
103  }//end of jet loop
104 
105  if (highMJetIdx >= 0) {
106  m_highMassJetIndex = highMJetIdx;
107  m_highestJetMass = highM;
109  } else {
111  }
112 
113  return true;
114 }
115 
116 //==========================================================================================================
117 // Get invariant ttbar mass
118 //
120  double mtt_dRmin = 0.0;
121 
122  if (m_jet_indices.size() > 0) {
123  TLorentzVector dRsumJet(0, 0, 0, 0);
124  for (unsigned int ijet = 0; ijet < m_jet_indices.size(); ijet++) {
125  dRsumJet += *(m_jets.at(m_jet_indices.at(ijet)));
126  }
127  mtt_dRmin = (dRsumJet + m_Wleptonic).M();
128  }
129 
130  return mtt_dRmin;
131 }
132 
133 //==========================================================================================================
134 // Get ttbar system TLorentzVector
135 //
136 TLorentzVector TtresdRmin::GetTlvdRmin() {
137  TLorentzVector tt_dRmin(0, 0, 0, 0);
138 
139  if (m_jet_indices.size() > 0) {
140  TLorentzVector dRsumJet(0, 0, 0, 0);
141  for (unsigned int ijet = 0; ijet < (unsigned int) m_jet_indices.size(); ijet++) {
142  dRsumJet += *(m_jets.at(m_jet_indices.at(ijet)));
143  }
144  tt_dRmin = dRsumJet + m_Wleptonic;
145  }
146 
147  return tt_dRmin;
148 }
149 
150 //==========================================================================================================
151 // Find jet indices for reconstruction for events with a high mass jet
152 //
154  //===== Find closest jet to high mass jet =====
155  double dR_had = 999.9;
156  int closest_jetIdx_had = -1;
157 
158  //Loop m_jets
159  for (int ijet = 0; ijet < (int) m_jets.size(); ijet++) {
160  if (ijet == m_highMassJetIndex) continue; //next jet
161  double dR = m_jets.at(m_highMassJetIndex)->DeltaR(*(m_jets.at(ijet)));
162  if (dR < dR_had) {
163  closest_jetIdx_had = ijet;
164  dR_had = dR;
165  }
166  }//end of jet loop
167 
168 
169  //===== Find closest jet to leptonic W-boson =====
170  double dR_lep = 999.9;
171  int closest_jetIdx_lep = -1;
172 
173  //Loop jets
174  for (int ijet = 0; ijet < (int) m_jets.size(); ijet++) {
175  if (ijet == m_highMassJetIndex) continue; //next jet
176  if (ijet == closest_jetIdx_had) continue; //next jet
177  double dR = m_Wleptonic.DeltaR(*(m_jets.at(ijet)));
178  if (dR < dR_lep) {
179  closest_jetIdx_lep = ijet;
180  dR_lep = dR;
181  }
182  }//end of jet loop
183 
184  //===== Save jet indices used for reconstruction =====
186 
187  if (closest_jetIdx_had >= 0) {
188  m_jet_indices.push_back(closest_jetIdx_had);
189  } else {
190  if (m_verbose) cout << " WARNING in TtresdRmin :: Can not find jet close to high mass jet" << endl;
191  }
192 
193  if (closest_jetIdx_lep >= 0) {
194  m_jet_indices.push_back(closest_jetIdx_lep);
195  } else {
196  if (m_verbose) cout << " WARNING in TtresdRmin :: Can not find jet close to leptonic W-boson" << endl;
197  }
198 
199  return true;
200 }
201 
202 //==========================================================================================================
203 // Find jet indices for reconstruction for events without a high mass jet
204 //
206  //jetflag vector to flag jets rejected by dRmin method
207  vector<bool> jetflags(m_jets.size(), true);
208 
209  //do dRmin procedure if at least 4 jets are available
210  bool repeat_dRmin = ((int) m_jets.size() > 3);
211 
212  //Loop dRmin method
213  while (repeat_dRmin) {
214  repeat_dRmin = false;
215 
216  double dR_max = 0.0; //Maximum dR passing dRmin cut requirement
217  int index_max = -1; //Index of jet with dR_max
218 
219  //Number of goodflagged processed jets (outer loop)
220  int nijet = 0;
221 
222  //Outer jet loop
223  for (int ijet = 0; ijet < (int) m_jets.size(); ijet++) {
224  if (!jetflags.at(ijet)) continue; //next outer jet
225 
226  //Use maximum of 4 goodflagged jets
227  if (nijet > 3) break;
228  nijet++;
229 
230  double dR_min = 999.9;
231 
232  double dR_lep = m_jets.at(ijet)->DeltaR(m_lepton);
233  dR_min = dR_lep;
234 
235  //Number of goodflagged processed jets (inner loop)
236  int njjet = 0;
237 
238  //Inner jet loop
239  for (int jjet = 0; jjet < (int) m_jets.size(); jjet++) {
240  if (!jetflags.at(jjet)) continue; //next inner jet
241 
242  //Use maximum of 4 goodflagged jets
243  if (njjet > 3) break;
244  njjet++;
245 
246  if (jjet == ijet) continue; //next inner jet
247 
248  double dR_jet = m_jets.at(ijet)->DeltaR(*(m_jets.at(jjet)));
249  if (dR_jet < dR_min) {
250  dR_min = dR_jet;
251  }
252  } //end of inner jet loop
253 
254  if (dR_min > dR_max) {
255  //dRmin specific cut (defined for GeV, needs m_Units correction on mass)
256  double dR_cut = m_dRCutOffset - m_dRCutMassFactor * m_jets.at(ijet)->M() / m_Units;
257  if (dR_min > dR_cut) {
258  dR_max = dR_min;
259  index_max = ijet;
260  }
261  }
262  }//end of outer jet loop
263 
264  if (index_max >= 0) {
265  jetflags.at(index_max) = false;
266  if (count(jetflags.begin(), jetflags.end(), true) > 3) repeat_dRmin = true;
267  }
268  }//end of while(repeat)
269 
270  int nijet = 0;
271  //Save selected jet indices
272  for (int ijet = 0; ijet < (int) m_jets.size(); ijet++) {
273  if (!jetflags.at(ijet)) continue; //next jet
274 
275  //Use maximum of 4 goodflagged jets
276  if (nijet > 3) break;
277  nijet++;
278 
279  m_jet_indices.push_back(ijet);
280  }
281 
282  return true;
283 }
TtresdRmin::m_lepton
TLorentzVector m_lepton
Input lepton object.
Definition: TtresdRmin.h:128
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TtresdRmin::m_jets
vector< TLorentzVector * > m_jets
Input vector of jet objects.
Definition: TtresdRmin.h:127
TtresdRmin::m_init
bool m_init
Flag of initialization status of tool.
Definition: TtresdRmin.h:116
TtresdRmin::GetMttdRmin
double GetMttdRmin()
Get calculated invariant ttbar mass for dRmin method.
Definition: TtresdRmin.cxx:119
TtresdRmin::m_highMassJetIndex
int m_highMassJetIndex
Index of highest mass jet for current event.
Definition: TtresdRmin.h:124
TtresdRmin.h
TtresdRmin::FindJetIndices_HM
bool FindJetIndices_HM()
Find the jet indices used for mtt reconstruction for events containing a high mass jet.
Definition: TtresdRmin.cxx:153
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
TtresdRmin::m_verbose
bool m_verbose
Flag for verbosity level.
Definition: TtresdRmin.h:117
TtresdRmin::GetTlvdRmin
TLorentzVector GetTlvdRmin()
Get the TLorentzVector for the ttbar system.
Definition: TtresdRmin.cxx:136
TtresdRmin::m_dRCutOffset
double m_dRCutOffset
Offset of dRmin specific cut on jet_dR.
Definition: TtresdRmin.h:121
TtresdRmin::m_neutrino
TLorentzVector m_neutrino
Input neutrino object.
Definition: TtresdRmin.h:129
TtresdRmin::m_Units
double m_Units
Unit factor used, GeV = 1, MeV = 1000.
Definition: TtresdRmin.h:119
TtresdRmin::m_highestJetMass
double m_highestJetMass
Highest jet mass found for current event.
Definition: TtresdRmin.h:125
perfmonmt-refit.units
string units
Definition: perfmonmt-refit.py:77
TtresdRmin::Init
void Init(double highJetMass=60.0, double minJetPt=25.0, double dRCutOffset=2.5, double dRCutMassFactor=0.015)
Initialize the tool, giving specific parameters needed for dRmin cut Paramters are given in GeV scale...
Definition: TtresdRmin.cxx:51
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
TtresdRmin::m_minJetPt
double m_minJetPt
Minimum jet pT used for highM jet search.
Definition: TtresdRmin.h:120
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
TtresdRmin::m_highM
double m_highM
Jet mass threshold to identify it as a "high mass jet".
Definition: TtresdRmin.h:118
TtresdRmin::SetupEvent
bool SetupEvent(vector< TLorentzVector * > &jets, TLorentzVector &lepton, TLorentzVector &neutrino)
Set the objects needed to calculate the invariant ttbar mass.
Definition: TtresdRmin.cxx:70
TtresdRmin::FindJetIndices_LM
bool FindJetIndices_LM()
Find the jet indices used for mtt reconstruction for events NOT containing a high mass jet.
Definition: TtresdRmin.cxx:205
TtresdRmin::m_Wleptonic
TLorentzVector m_Wleptonic
leptonic W object reconstructed from lepton and neutrino
Definition: TtresdRmin.h:130
TtresdRmin::m_jet_indices
vector< int > m_jet_indices
Indices of jets used for reconstruction of invariant ttbar mass.
Definition: TtresdRmin.h:132
TtresdRmin::m_dRCutMassFactor
double m_dRCutMassFactor
Jet mass factor of dRmin specific cut on jet_dR.
Definition: TtresdRmin.h:122
TtresdRmin::TtresdRmin
TtresdRmin(TString units="GeV", bool verbose=false)
Class constructor.
Definition: TtresdRmin.cxx:35