ATLAS Offline Software
PMGSherpaVjetsSysTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: PMGSherpaVjetsSysTool.cxx.cxx 2016-07-12 tripiana $
6 
7 // ROOT include(s):
8 #include "TKey.h"
9 #include "TIterator.h"
10 #include "TH2F.h"
11 
12 // EDM include(s):
14 #include "xAODJet/JetContainer.h"
17 
18 // Tool include(s):
20 
21 // Local include(s):
24 
25 namespace PMGTools {
26 
27  using namespace std;
28 
30  : asg::AsgTool( name ),
31  m_current_njets(-1),
32  m_use_cache(false),
33  m_cache_ptype(SysParType::None),
34  m_cache_ptidx(-1),
35  m_weightsFile(""),
36  m_truthJetContainer(""),
37  m_truthParticleContainer("")
38  {
39 
40  // Declare the properties of the tool:
41  declareProperty( "WeightsFile",
43  "dev/SUSYTools/Vjets_SysParameterization/AllVariationWeights.root" );
44 
45  declareProperty( "TruthJetContainer",
46  m_truthJetContainer = "AntiKt4TruthWZJets" );
47  declareProperty( "TruthParticleContainer",
48  m_truthParticleContainer = "TruthParticles" );
49  }
50 
52 
53  // Tell the user what's happening:
54  ATH_MSG_INFO( "Initializing " << name() << "..." );
55  ATH_MSG_DEBUG( "Will be using:" );
56  ATH_MSG_DEBUG( " WeightsFile = " << m_weightsFile );
57  ATH_MSG_DEBUG( " TruthJetContainer = " << m_truthJetContainer );
58  ATH_MSG_DEBUG( " TruthParticleContainer = " << m_truthParticleContainer );
59 
60  //load parametrization maps
61  m_map_w = {};
62  m_map_zll = {};
63  m_map_znunu = {};
64  m_map_gamma = {};
65 
66  //open the rootfiles
67  const std::string fileName = PathResolverFindCalibFile( m_weightsFile );
68  m_file.reset( TFile::Open( fileName.c_str(), "READ" ) );
69  if( ( ! m_file ) || m_file->IsZombie() ) {
70  ATH_MSG_ERROR( "Couldn't open file: " << m_weightsFile );
71  return StatusCode::FAILURE;
72  }
73 
74  TKey *key;
75  std::string hname="";
76  std::string keyname="";
77  TIter next( m_file->GetListOfKeys());
78  while ((key = (TKey *) next())) {
79 
80  keyname = std::string(key->GetName());
81 
82  //load Zee histograms
83  if( keyname.find("Zee_") != std::string::npos ){
84  keyname.erase(0,4);
85  hname = "PMGSherpaVjetsSysTool::ZllJets_"+keyname;
86 
87  m_map_zll[keyname] = (TH2F*)m_file->Get(key->GetName())->Clone(hname.c_str());
88  m_supported_zll.push_back(key->GetName());
89  }
90 
91  //load Znunu histograms
92  if( keyname.find("Znunu_") != std::string::npos ){
93  keyname.erase(0,6);
94  hname = "PMGSherpaVjetsSysTool::ZnunuJets_"+keyname;
95 
96  m_map_znunu[keyname] = (TH2F*)m_file->Get(key->GetName())->Clone(hname.c_str());
97  m_supported_znunu.push_back(keyname);
98  }
99 
100  //load Wlnu histograms
101  if( keyname.find("Wenu_") != std::string::npos ){
102  keyname.erase(0,5);
103  hname = "PMGSherpaVjetsSysTool::WlnuJets_"+keyname;
104 
105  m_map_w[keyname] = (TH2F*)m_file->Get(key->GetName())->Clone(hname.c_str());
106  m_supported_w.push_back(keyname);
107  }
108 
109  //load gammaJets histograms
110  if( keyname.find("Gamma_") != std::string::npos ){
111  keyname.erase(0,6);
112  hname = "PMGSherpaVjetsSysTool::GammaJets_"+keyname;
113 
114  m_map_gamma[keyname] = (TH2F*)m_file->Get(key->GetName())->Clone(hname.c_str());
115  m_supported_gamma.push_back(keyname);
116  }
117 
118  }
119 
120  // Return gracefully:
121  return StatusCode::SUCCESS;
122  }
123 
124 
126 
127  m_use_cache = do_it;
128  if(do_it){
131  }
132  }
133 
134 
135  double PMGSherpaVjetsSysTool::getWeight( const std::string& sysVariation ) {
136 
138  int ptIdx(0);
139 
140  //look for DSID type and pt-bin unless previously fixed by user
141  if(!m_use_cache){
142  ptIdx = getPtMapping(pType);
143  }
144  else{
145  pType = m_cache_ptype;
146  ptIdx = m_cache_ptidx;
147  }
148 
149  //if not found in mapped samples, then return 1.
150  if(pType == SysParType::None) return 1.;
151 
152  // get number of truth jets
153  unsigned int njets = (m_current_njets >=0 ? m_current_njets : this->getNtruthJets());
154 
155  // re-define last bin for n_jets >= 11
156  if(njets>11)
157  njets = 11;
158 
159 
160  // retrieve weight
161  if(pType == SysParType::Zll) return m_map_zll[sysVariation]->GetBinContent(ptIdx, njets+1);
162  if(pType == SysParType::Znunu) return m_map_znunu[sysVariation]->GetBinContent(ptIdx, njets+1);
163  if(pType == SysParType::Wlnu) return m_map_w[sysVariation]->GetBinContent(ptIdx, njets+1);
164  if(pType == SysParType::GammaJets) return m_map_gamma[sysVariation]->GetBinContent(ptIdx, njets+1);
165  //...
166 
167  return 1.;
168  }
169 
170 
172  //get MCID --> PT-BIN mapping
173 
174  const xAOD::EventInfo* ei = 0;
175  if(! evtStore()->retrieve( ei, "EventInfo").isSuccess() ){
176  ATH_MSG_ERROR("No EventInfo found in TStore(). Not able to get the sample ID. Dummy null weight retrieved.");
177  return 0;
178  }
179 
180  unsigned int MCID = ei->mcChannelNumber();
181 
182  //Check Znunu 2.1 samples
183  if( MCID>=361444 && MCID<361447 ){ pType=SysParType::Znunu; return 1; }
184  if( MCID>=361447 && MCID<361450 ){ pType=SysParType::Znunu; return 2; }
185  if( MCID>=361450 && MCID<361453 ){ pType=SysParType::Znunu; return 3; }
186  if( MCID>=361453 && MCID<361456 ){ pType=SysParType::Znunu; return 4; }
187  if( MCID>=361456 && MCID<361459 ){ pType=SysParType::Znunu; return 5; }
188  if( MCID>=361459 && MCID<361462 ){ pType=SysParType::Znunu; return 6; }
189  if( MCID>=361462 && MCID<361465 ){ pType=SysParType::Znunu; return 7; }
190  if( MCID>=361465 && MCID<361468 ){ pType=SysParType::Znunu; return 8; }
191 
192  //Check Zee 2.1 samples
193  if( MCID>=361372 && MCID<361375 ){ pType=SysParType::Zll; return 1; }
194  if( MCID>=361375 && MCID<361378 ){ pType=SysParType::Zll; return 2; }
195  if( MCID>=361378 && MCID<361381 ){ pType=SysParType::Zll; return 3; }
196  if( MCID>=361381 && MCID<361384 ){ pType=SysParType::Zll; return 4; }
197  if( MCID>=361384 && MCID<361387 ){ pType=SysParType::Zll; return 5; }
198  if( MCID>=361387 && MCID<361390 ){ pType=SysParType::Zll; return 6; }
199  if( MCID>=361390 && MCID<361393 ){ pType=SysParType::Zll; return 7; }
200  if( MCID>=361393 && MCID<361396 ){ pType=SysParType::Zll; return 8; }
201 
202  //Check Zmumu 2.1 samples
203  if( MCID>=361396 && MCID<361399 ){ pType=SysParType::Zll; return 1; }
204  if( MCID>=361399 && MCID<361402 ){ pType=SysParType::Zll; return 2; }
205  if( MCID>=361402 && MCID<361405 ){ pType=SysParType::Zll; return 3; }
206  if( MCID>=361405 && MCID<361408 ){ pType=SysParType::Zll; return 4; }
207  if( MCID>=361408 && MCID<361411 ){ pType=SysParType::Zll; return 5; }
208  if( MCID>=361411 && MCID<361414 ){ pType=SysParType::Zll; return 6; }
209  if( MCID>=361414 && MCID<361417 ){ pType=SysParType::Zll; return 7; }
210  if( MCID>=361417 && MCID<361420 ){ pType=SysParType::Zll; return 8; }
211 
212  //Check Ztautau 2.1 samples
213  if( MCID>=361420 && MCID<361423 ){ pType=SysParType::Zll; return 1; }
214  if( MCID>=361423 && MCID<361426 ){ pType=SysParType::Zll; return 2; }
215  if( MCID>=361426 && MCID<361429 ){ pType=SysParType::Zll; return 3; }
216  if( MCID>=361429 && MCID<361432 ){ pType=SysParType::Zll; return 4; }
217  if( MCID>=361432 && MCID<361435 ){ pType=SysParType::Zll; return 5; }
218  if( MCID>=361435 && MCID<361438 ){ pType=SysParType::Zll; return 6; }
219  if( MCID>=361438 && MCID<361441 ){ pType=SysParType::Zll; return 7; }
220  if( MCID>=361441 && MCID<361444 ){ pType=SysParType::Zll; return 8; }
221 
222  //Check Wenu 2.1 samples
223  if( MCID>=361300 && MCID<361303 ){ pType=SysParType::Wlnu; return 1; }
224  if( MCID>=361303 && MCID<361306 ){ pType=SysParType::Wlnu; return 2; }
225  if( MCID>=361306 && MCID<361309 ){ pType=SysParType::Wlnu; return 3; }
226  if( MCID>=361309 && MCID<361312 ){ pType=SysParType::Wlnu; return 4; }
227  if( MCID>=361312 && MCID<361315 ){ pType=SysParType::Wlnu; return 5; }
228  if( MCID>=361315 && MCID<361318 ){ pType=SysParType::Wlnu; return 6; }
229  if( MCID>=361318 && MCID<361321 ){ pType=SysParType::Wlnu; return 7; }
230  if( MCID>=361321 && MCID<361324 ){ pType=SysParType::Wlnu; return 8; }
231 
232  //Check Wmunu 2.1 samples
233  if( MCID>=361324 && MCID<361327 ){ pType=SysParType::Wlnu; return 1; }
234  if( MCID>=361327 && MCID<361330 ){ pType=SysParType::Wlnu; return 2; }
235  if( MCID>=361330 && MCID<361333 ){ pType=SysParType::Wlnu; return 3; }
236  if( MCID>=361333 && MCID<361336 ){ pType=SysParType::Wlnu; return 4; }
237  if( MCID>=361336 && MCID<361339 ){ pType=SysParType::Wlnu; return 5; }
238  if( MCID>=361339 && MCID<361342 ){ pType=SysParType::Wlnu; return 6; }
239  if( MCID>=361342 && MCID<361345 ){ pType=SysParType::Wlnu; return 7; }
240  if( MCID>=361345 && MCID<361348 ){ pType=SysParType::Wlnu; return 8; }
241 
242  //Check Wtaunu 2.1 samples
243  if( MCID>=361348 && MCID<361351 ){ pType=SysParType::Wlnu; return 1; }
244  if( MCID>=361351 && MCID<361354 ){ pType=SysParType::Wlnu; return 2; }
245  if( MCID>=361354 && MCID<361357 ){ pType=SysParType::Wlnu; return 3; }
246  if( MCID>=361357 && MCID<361360 ){ pType=SysParType::Wlnu; return 4; }
247  if( MCID>=361360 && MCID<361363 ){ pType=SysParType::Wlnu; return 5; }
248  if( MCID>=361363 && MCID<361366 ){ pType=SysParType::Wlnu; return 6; }
249  if( MCID>=361366 && MCID<361369 ){ pType=SysParType::Wlnu; return 7; }
250  if( MCID>=361369 && MCID<361372 ){ pType=SysParType::Wlnu; return 8; }
251 
252  //Check Znunu 2.2 samples
253  if( MCID>=363412 && MCID<363415 ){ pType=SysParType::Znunu; return 1; }
254  if( MCID>=363415 && MCID<363418 ){ pType=SysParType::Znunu; return 2; }
255  if( MCID>=363418 && MCID<363421 ){ pType=SysParType::Znunu; return 3; }
256  if( MCID>=363421 && MCID<363424 ){ pType=SysParType::Znunu; return 4; }
257  if( MCID>=363424 && MCID<363427 ){ pType=SysParType::Znunu; return 5; }
258  if( MCID>=363427 && MCID<363430 ){ pType=SysParType::Znunu; return 6; }
259  if( MCID>=363430 && MCID<363433 ){ pType=SysParType::Znunu; return 7; }
260  if( MCID>=363433 && MCID<363436 ){ pType=SysParType::Znunu; return 8; }
261 
262  //Check Zee 2.2 samples
263  if( MCID>=363388 && MCID<363391 ){ pType=SysParType::Zll; return 1; }
264  if( MCID>=363391 && MCID<363394 ){ pType=SysParType::Zll; return 2; }
265  if( MCID>=363394 && MCID<363397 ){ pType=SysParType::Zll; return 3; }
266  if( MCID>=363397 && MCID<363400 ){ pType=SysParType::Zll; return 4; }
267  if( MCID>=363400 && MCID<363403 ){ pType=SysParType::Zll; return 5; }
268  if( MCID>=363403 && MCID<363406 ){ pType=SysParType::Zll; return 6; }
269  if( MCID>=363406 && MCID<363409 ){ pType=SysParType::Zll; return 7; }
270  if( MCID>=363409 && MCID<363412 ){ pType=SysParType::Zll; return 8; }
271 
272  //Check Zmumu 2.2 samples
273  if( MCID>=363364 && MCID<363367 ){ pType=SysParType::Zll; return 1; }
274  if( MCID>=363367 && MCID<363370 ){ pType=SysParType::Zll; return 2; }
275  if( MCID>=363370 && MCID<363373 ){ pType=SysParType::Zll; return 3; }
276  if( MCID>=363373 && MCID<363376 ){ pType=SysParType::Zll; return 4; }
277  if( MCID>=363376 && MCID<363379 ){ pType=SysParType::Zll; return 5; }
278  if( MCID>=363379 && MCID<363382 ){ pType=SysParType::Zll; return 6; }
279  if( MCID>=363382 && MCID<363385 ){ pType=SysParType::Zll; return 7; }
280  if( MCID>=363385 && MCID<363388 ){ pType=SysParType::Zll; return 8; }
281 
282  //Check Ztautau 2.2 samples
283  if( MCID>=363099 && MCID<363102 ){ pType=SysParType::Zll; return 1; }
284  if( MCID>=363102 && MCID<363105 ){ pType=SysParType::Zll; return 2; }
285  if( MCID>=363105 && MCID<363108 ){ pType=SysParType::Zll; return 3; }
286  if( MCID>=363108 && MCID<363111 ){ pType=SysParType::Zll; return 4; }
287  if( MCID>=363111 && MCID<363114 ){ pType=SysParType::Zll; return 5; }
288  if( MCID>=363114 && MCID<363117 ){ pType=SysParType::Zll; return 6; }
289  if( MCID>=363117 && MCID<363120 ){ pType=SysParType::Zll; return 7; }
290  if( MCID>=363120 && MCID<363123 ){ pType=SysParType::Zll; return 8; }
291 
292  //Check Wenu 2.2 samples
293  if( MCID>=363460 && MCID<363463 ){ pType=SysParType::Wlnu; return 1; }
294  if( MCID>=363463 && MCID<363466 ){ pType=SysParType::Wlnu; return 2; }
295  if( MCID>=363466 && MCID<363469 ){ pType=SysParType::Wlnu; return 3; }
296  if( MCID>=363469 && MCID<363472 ){ pType=SysParType::Wlnu; return 4; }
297  if( MCID>=363472 && MCID<363475 ){ pType=SysParType::Wlnu; return 5; }
298  if( MCID>=363475 && MCID<363478 ){ pType=SysParType::Wlnu; return 6; }
299  if( MCID>=363478 && MCID<363481 ){ pType=SysParType::Wlnu; return 7; }
300  if( MCID>=363481 && MCID<363484 ){ pType=SysParType::Wlnu; return 8; }
301 
302  //Check Wmunu 2.2 samples
303  if( MCID>=363436 && MCID<363439 ){ pType=SysParType::Wlnu; return 1; }
304  if( MCID>=363439 && MCID<363442 ){ pType=SysParType::Wlnu; return 2; }
305  if( MCID>=363442 && MCID<363445 ){ pType=SysParType::Wlnu; return 3; }
306  if( MCID>=363445 && MCID<363448 ){ pType=SysParType::Wlnu; return 4; }
307  if( MCID>=363448 && MCID<363451 ){ pType=SysParType::Wlnu; return 5; }
308  if( MCID>=363451 && MCID<363454 ){ pType=SysParType::Wlnu; return 6; }
309  if( MCID>=363454 && MCID<363457 ){ pType=SysParType::Wlnu; return 7; }
310  if( MCID>=363457 && MCID<363460 ){ pType=SysParType::Wlnu; return 8; }
311 
312  //Check Wtaunu 2.2 samples
313  if( MCID>=363331 && MCID<363334 ){ pType=SysParType::Wlnu; return 1; }
314  if( MCID>=363334 && MCID<363337 ){ pType=SysParType::Wlnu; return 2; }
315  if( MCID>=363337 && MCID<363340 ){ pType=SysParType::Wlnu; return 3; }
316  if( MCID>=363340 && MCID<363343 ){ pType=SysParType::Wlnu; return 4; }
317  if( MCID>=363343 && MCID<363346 ){ pType=SysParType::Wlnu; return 5; }
318  if( MCID>=363346 && MCID<363349 ){ pType=SysParType::Wlnu; return 6; }
319  if( MCID>=363349 && MCID<363352 ){ pType=SysParType::Wlnu; return 7; }
320  if( MCID>=363352 && MCID<363355 ){ pType=SysParType::Wlnu; return 8; }
321 
322  //Check gamma+Jets samples
323  if( MCID>=361039 && MCID<361042 ){ pType=SysParType::GammaJets; return 1; }
324  if( MCID>=361042 && MCID<361045 ){ pType=SysParType::GammaJets; return 2; }
325  if( MCID>=361045 && MCID<361048 ){ pType=SysParType::GammaJets; return 3; }
326  if( MCID>=361048 && MCID<361051 ){ pType=SysParType::GammaJets; return 4; }
327  if( MCID>=361051 && MCID<361054 ){ pType=SysParType::GammaJets; return 5; }
328  if( MCID>=361054 && MCID<361057 ){ pType=SysParType::GammaJets; return 6; }
329  if( MCID>=361057 && MCID<361061 ){ pType=SysParType::GammaJets; return 7; }
330 
331 
332  //Check Znunu 2.2.1 samples
333  if( MCID>=364142 && MCID<364145 ){ pType=SysParType::Znunu; return 1; }
334  if( MCID>=364145 && MCID<364148 ){ pType=SysParType::Znunu; return 2; }
335  if( MCID>=364148 && MCID<364151 ){ pType=SysParType::Znunu; return 3; }
336  if( MCID>=364151 && MCID<364154 ){ pType=SysParType::Znunu; return 4; }
337  if( MCID==364154 ){ pType=SysParType::Znunu; return 5; }
338  if( MCID==364155 ){ pType=SysParType::Znunu; return 7; }
339 
340  //Check Zee 2.2.1 samples
341  if( MCID>=364114 && MCID<364117 ){ pType=SysParType::Zll; return 1; }
342  if( MCID>=364117 && MCID<364120 ){ pType=SysParType::Zll; return 2; }
343  if( MCID>=364120 && MCID<364123 ){ pType=SysParType::Zll; return 3; }
344  if( MCID>=364123 && MCID<364126 ){ pType=SysParType::Zll; return 4; }
345  if( MCID==364126 ){ pType=SysParType::Zll; return 5; }
346  if( MCID==364127 ){ pType=SysParType::Zll; return 7; }
347 
348  //Check Zmumu 2.2.1 samples
349  if( MCID>=364100 && MCID<364103 ){ pType=SysParType::Zll; return 1; }
350  if( MCID>=364103 && MCID<364106 ){ pType=SysParType::Zll; return 2; }
351  if( MCID>=364106 && MCID<364109 ){ pType=SysParType::Zll; return 3; }
352  if( MCID>=364109 && MCID<364112 ){ pType=SysParType::Zll; return 4; }
353  if( MCID==364112 ){ pType=SysParType::Zll; return 5; }
354  if( MCID==364113 ){ pType=SysParType::Zll; return 7; }
355 
356  //Check Ztautau 2.2.1 samples
357  if( MCID>=364128 && MCID<364131 ){ pType=SysParType::Zll; return 1; }
358  if( MCID>=364131 && MCID<364134 ){ pType=SysParType::Zll; return 2; }
359  if( MCID>=364134 && MCID<364137 ){ pType=SysParType::Zll; return 3; }
360  if( MCID>=364137 && MCID<364140 ){ pType=SysParType::Zll; return 4; }
361  if( MCID==364140 ){ pType=SysParType::Zll; return 5; }
362  if( MCID==364141 ){ pType=SysParType::Zll; return 7; }
363 
364  //Check Wenu 2.2.1 samples
365  if( MCID>=364170 && MCID<364173 ){ pType=SysParType::Wlnu; return 1; }
366  if( MCID>=364173 && MCID<364176 ){ pType=SysParType::Wlnu; return 2; }
367  if( MCID>=364176 && MCID<364179 ){ pType=SysParType::Wlnu; return 3; }
368  if( MCID>=364179 && MCID<364182 ){ pType=SysParType::Wlnu; return 4; }
369  if( MCID==364182 ){ pType=SysParType::Wlnu; return 5; }
370  if( MCID==364183 ){ pType=SysParType::Wlnu; return 7; }
371 
372  //Check Wmunu 2.2.1 samples
373  if( MCID>=364156 && MCID<364159 ){ pType=SysParType::Wlnu; return 1; }
374  if( MCID>=364159 && MCID<364162 ){ pType=SysParType::Wlnu; return 2; }
375  if( MCID>=364162 && MCID<364165 ){ pType=SysParType::Wlnu; return 3; }
376  if( MCID>=364165 && MCID<364168 ){ pType=SysParType::Wlnu; return 4; }
377  if( MCID==364168 ){ pType=SysParType::Wlnu; return 5; }
378  if( MCID==364169 ){ pType=SysParType::Wlnu; return 7; }
379 
380  //Check Wtaunu 2.2.1 samples
381  if( MCID>=364184 && MCID<364187 ){ pType=SysParType::Wlnu; return 1; }
382  if( MCID>=364187 && MCID<364190 ){ pType=SysParType::Wlnu; return 2; }
383  if( MCID>=364190 && MCID<364193 ){ pType=SysParType::Wlnu; return 3; }
384  if( MCID>=364193 && MCID<364196 ){ pType=SysParType::Wlnu; return 4; }
385  if( MCID==364196 ){ pType=SysParType::Wlnu; return 5; }
386  if( MCID==364197 ){ pType=SysParType::Wlnu; return 7; }
387 
388 
389  return -1;
390  }
391 
392 
394  //
395  // Count number of truthjets compatible with evaluation of correction
396  //
397  // MT : ~same to what's done in PMGSherpa22VJetsWeightTool already. Might want to inherit/merge/move to PMGUtils-like common code?
398 
399  // Check whether to do overlap removal with truth leptons:
400  const bool doRemoval = ( m_truthJetContainer == "AntiKt4TruthJets" );
401 
402  // Retrieve the truth jets
403  const xAOD::JetContainer* truthJets( 0 );
404  if( evtStore()->retrieve( truthJets, m_truthJetContainer ).isFailure() ) {
405  ATH_MSG_ERROR( "No TruthJetContainer (\"" << m_truthJetContainer << "\") found! Dummy null weight retrieved." );
406  return 0;
407  }
408 
409  size_t nTruthJets = 0;
410 
411  // Retrieve the truth particles to get the leptons
412  const xAOD::TruthParticleContainer* truthParticles( 0 );
413  if( doRemoval ) {
414  if( evtStore()->retrieve( truthParticles,
415  m_truthParticleContainer ).isFailure() ) {
416  ATH_MSG_ERROR( "Couldn't retrieve truth particle container: " << m_truthParticleContainer );
417  return 0;
418  }
419  }
420 
421  // Loop over all truth jets passing basic cuts:
422  for( const xAOD::Jet* truthJet : *truthJets ) {
423 
424  // Start with a simple kinematic cut:
425  if( truthJet->pt() <= 20000. || std::abs( truthJet->eta() ) >= 2.8 ) { //MT : until John updates the parametrization with a 4.5 upper cut...
426  continue;
427  }
428 
429  // Remove hadronic taus e.g. from Ztautau, Wtaunu decays
431  acc( "HadronConeExclTruthLabelID" );
432  if( acc.isAvailable( *truthJet ) && ( acc( *truthJet ) == 15 ) ) {
433  continue;
434  }
435 
436  // If no overlap removal is to be made, we're done already:
437  if( ! doRemoval ) {
438  ++nTruthJets;
439  continue;
440  }
441 
442  // Loop over the truth particles, to veto some jets:
443  bool vetoJet = false;
444  for( const xAOD::TruthParticle* truthParticle : *truthParticles ) {
445 
446  // Only select final state electrons and muons:
447  if( !MC::isStable(truthParticle) ||
448  ( ( std::abs( truthParticle->pdgId() ) != 11 ) &&
449  ( std::abs( truthParticle->pdgId() ) != 13 ) ) ) {
450  continue;
451  }
452  // ...which also pass some basic kinematic cuts:
453  if( ( truthParticle->pt() <= 20000.0 ) ||
454  ( std::abs( truthParticle->eta() ) >= 2.8 ) ) { //MT : until John updates the parametrization with a 4.5 upper cut...
455  continue;
456  }
457 
458  // Veto the jet if it's close to this lepton:
459  static const double MIN_DISTANCE = 0.2 * 0.2;
460  const double dR2 =
461  xAOD::P4Helpers::deltaR2( truthJet, truthParticle, true );
462  if( dR2 < MIN_DISTANCE ) {
463  vetoJet = true;
464  break;
465  }
466  }
467 
468  // If the jet was not vetoed:
469  if( ! vetoJet ) {
470  ++nTruthJets;
471  }
472  }
473 
474  // Return the calculated value:
475  return nTruthJets;
476  }
477 
478 
480  m_current_njets = njets;
481  }
482 
483 
485 
486  if(ptype == SysParType::Zll) return m_supported_zll;
487  if(ptype == SysParType::Znunu) return m_supported_znunu;
488  if(ptype == SysParType::Wlnu) return m_supported_w;
489  if(ptype == SysParType::GammaJets) return m_supported_gamma;
490 
491  std::vector<std::string> vdummy={};
492  return vdummy;
493  }
494 
495 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PMGTools::PMGSherpaVjetsSysTool::PMGSherpaVjetsSysTool
PMGSherpaVjetsSysTool(const std::string &name)
Standard tool constructor, with name.
Definition: PMGSherpaVjetsSysTool.cxx:29
PMGTools::PMGSherpaVjetsSysTool::m_supported_w
std::vector< std::string > m_supported_w
Definition: PMGSherpaVjetsSysTool.h:86
PMGTools::None
@ None
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:20
PMGTools::PMGSherpaVjetsSysTool::m_current_njets
int m_current_njets
Current settings.
Definition: PMGSherpaVjetsSysTool.h:70
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PMGTools::PMGSherpaVjetsSysTool::initialize
StatusCode initialize() override
Initialize is required by AsgTool base class.
Definition: PMGSherpaVjetsSysTool.cxx:51
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:272
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TruthParticleContainer.h
PMGTools::Wlnu
@ Wlnu
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:23
asg
Definition: DataHandleTestTool.h:28
PMGTools::Znunu
@ Znunu
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:21
PMGTools::GammaJets
@ GammaJets
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:24
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
PMGTools::PMGSherpaVjetsSysTool::m_supported_zll
std::vector< std::string > m_supported_zll
Definition: PMGSherpaVjetsSysTool.h:87
PMGTools::PMGSherpaVjetsSysTool::cacheDSID
void cacheDSID(bool do_it=true) override
Definition: PMGSherpaVjetsSysTool.cxx:125
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition: xAODP4Helpers.h:111
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
PMGTools::PMGSherpaVjetsSysTool::m_map_zll
std::map< std::string, TH2F * > m_map_zll
Definition: PMGSherpaVjetsSysTool.h:82
PMGTools::PMGSherpaVjetsSysTool::getPtMapping
int getPtMapping(SysParType &pType)
Definition: PMGSherpaVjetsSysTool.cxx:171
xAOD::EventInfo_v1::mcChannelNumber
uint32_t mcChannelNumber() const
The MC generator's channel number.
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
PMGTools::PMGSherpaVjetsSysTool::m_truthParticleContainer
std::string m_truthParticleContainer
The truth particle container to use for the calculation.
Definition: PMGSherpaVjetsSysTool.h:99
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PMGTools::PMGSherpaVjetsSysTool::setNjets
void setNjets(int njets) override
Some setters to speed up the calculation for multiple variations/events.
Definition: PMGSherpaVjetsSysTool.cxx:479
PMGTools::PMGSherpaVjetsSysTool::getWeight
double getWeight(const std::string &sysVariation="nom") override
Return weight for a given systematic variation.
Definition: PMGSherpaVjetsSysTool.cxx:135
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
PMGTools
Tool providing sample cross-sections and k-factors etc.
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGCrossSectionTool.h:15
PMGTools::PMGSherpaVjetsSysTool::m_map_znunu
std::map< std::string, TH2F * > m_map_znunu
Definition: PMGSherpaVjetsSysTool.h:83
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
PMGTools::PMGSherpaVjetsSysTool::m_supported_gamma
std::vector< std::string > m_supported_gamma
Definition: PMGSherpaVjetsSysTool.h:89
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
PMGTools::PMGSherpaVjetsSysTool::m_supported_znunu
std::vector< std::string > m_supported_znunu
Definition: PMGSherpaVjetsSysTool.h:88
PMGTools::PMGSherpaVjetsSysTool::m_weightsFile
std::string m_weightsFile
Tool properties.
Definition: PMGSherpaVjetsSysTool.h:94
PathResolver.h
PMGTools::PMGSherpaVjetsSysTool::m_cache_ptype
SysParType m_cache_ptype
Definition: PMGSherpaVjetsSysTool.h:74
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
PMGTools::PMGSherpaVjetsSysTool::m_use_cache
bool m_use_cache
Cache MC DSID (to avoid checking it everytime)
Definition: PMGSherpaVjetsSysTool.h:73
PMGSherpaVjetsSysTool.h
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
PMGTools::SysParType
SysParType
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:19
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
PMGTools::PMGSherpaVjetsSysTool::m_truthJetContainer
std::string m_truthJetContainer
The truth jet container to use for the calculation.
Definition: PMGSherpaVjetsSysTool.h:97
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
JetContainer.h
PMGTools::PMGSherpaVjetsSysTool::getNtruthJets
unsigned int getNtruthJets() override
get number of truth jets as defined in the parametrization analysis
Definition: PMGSherpaVjetsSysTool.cxx:393
PMGTools::PMGSherpaVjetsSysTool::getSupportedVariations
std::vector< std::string > getSupportedVariations(SysParType ptype) override
Helpers to get the list of supported variations for Z/W+jets and gamma+jets.
Definition: PMGSherpaVjetsSysTool.cxx:484
PMGTools::PMGSherpaVjetsSysTool::m_file
std::unique_ptr< TFile > m_file
Parametrization files.
Definition: PMGSherpaVjetsSysTool.h:78
PMGTools::Zll
@ Zll
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGSherpaVjetsSysTool.h:22
PMGTools::PMGSherpaVjetsSysTool::m_map_w
std::map< std::string, TH2F * > m_map_w
Parametrization maps.
Definition: PMGSherpaVjetsSysTool.h:81
PMGTools::PMGSherpaVjetsSysTool::m_cache_ptidx
unsigned int m_cache_ptidx
Definition: PMGSherpaVjetsSysTool.h:75
HepMCHelpers.h
PMGTools::PMGSherpaVjetsSysTool::m_map_gamma
std::map< std::string, TH2F * > m_map_gamma
Definition: PMGSherpaVjetsSysTool.h:84
vetoJet
bool vetoJet(const xAOD::jFexSRJetRoI *j)
Definition: L1MonitorAdaptors.h:14
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37