jFEXNtupleWriter.cxx 20.2 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4
5
*/

//***************************************************************************
6
//                           jFEXNtupleWriter.cxx  - copied from eFEXNtupleWrite by Tong Qiu
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//                              -------------------
//     begin                : 12 12 2020
//     email                : varsiha.sothilingam@cern.ch
//  **************************************************************************

#include <L1CaloFEXSim/jFEXNtupleWriter.h>
#include "StoreGate/StoreGateSvc.h"
#include "L1CaloFEXSim/jFEXSmallRJetAlgo.h"
#include "L1CaloFEXSim/jFEXSmallRJetTOB.h"
//#include "L1CaloFEXSim/jFEXtauAlgo.h"
//#include "L1CaloFEXSim/jFEXtauTOB.h"
#include "L1CaloFEXSim/jFEXOutputCollection.h"
#include <vector>
#include "TTree.h"
#include "GaudiKernel/ITHistSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include <memory>
#include "xAODTruth/TruthEventContainer.h"
#include "xAODTruth/TruthParticle.h"
#include "xAODTruth/TruthVertex.h"
#include "xAODTruth/TruthParticleContainer.h"
#include "xAODJet/JetContainer.h"


LVL1::jFEXNtupleWriter::jFEXNtupleWriter(const std::string& name, ISvcLocator* pSvcLocator): AthAlgorithm(name, pSvcLocator) { }

LVL1::jFEXNtupleWriter::~jFEXNtupleWriter() {

}

StatusCode LVL1::jFEXNtupleWriter::initialize () {
  ServiceHandle<ITHistSvc> histSvc("THistSvc",name()); 
  CHECK( histSvc.retrieve() );
  m_myTree = new TTree("data","data");
  CHECK( histSvc->regTree("/ANALYSIS/data",m_myTree) );
42
  ATH_CHECK( m_jFEXOutputCollectionSGKey.initialize() );
43
 /* 
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  m_load_truth_jet = false;

  m_myTree->Branch ("truth_smallRJet_eta",  &m_truth_smallRJet_eta);
  m_myTree->Branch ("truth_smallRJet_phi",  &m_truth_smallRJet_phi);
  m_myTree->Branch ("truth_smallRJet_ET",  &m_truth_smallRJet_ET);

  if (m_load_truth_jet){
    m_myTree->Branch ("truth_jet_eta",  &m_truth_jet_eta);
    m_myTree->Branch ("truth_jet_phi",  &m_truth_jet_phi);
    m_myTree->Branch ("truth_jet_ET",  &m_truth_jet_ET);
  }

  m_myTree->Branch ("em",  &m_em);
  m_myTree->Branch ("had",  &m_had);
  m_myTree->Branch ("TT Et", &m_TT_Et);    
59
*/
60
61
62
  m_myTree->Branch ("smallRJet_eta",  &m_smallRJet_eta);
  m_myTree->Branch ("smallRJet_phi",  &m_smallRJet_phi);
  m_myTree->Branch ("smallRJet_ET",  &m_smallRJet_ET);
63
  m_myTree->Branch ("smallRJet_clusterET", &m_smallRJet_clusterET);
64
65
66
  m_myTree->Branch ("smallRJet_nTOBs",  &m_smallRJet_nTOBs, "nTOBs");
  m_myTree->Branch ("smallRJet_isCentralTowerSeed",  &m_smallRJet_isCentralTowerSeed);
  
67
68
69
70
  m_myTree->Branch ("smallRJetTOB_eta", &m_smallRJetTOB_eta);
  m_myTree->Branch ("smallRJetTOB_phi", &m_smallRJetTOB_phi);
  m_myTree->Branch ("smallRJetTOB_ET", &m_smallRJetTOB_ET);
  m_myTree->Branch ("smallRJetTOB_sat", &m_smallRJetTOB_sat);
71
72
73
74
  m_myTree->Branch ("smallRJetTOB_word", &m_smallRJetTOB_word);
  m_myTree->Branch ("smallRJetTOB_jfexID", &m_smallRJetTOB_jfexID);
  m_myTree->Branch ("smallRJetTOB_fpgaID", &m_smallRJetTOB_fpgaID);

75

76
77
  m_myTree->Branch ("largeRJet_eta", &m_largeRJet_eta);
  m_myTree->Branch ("largeRJet_phi", &m_largeRJet_phi); 
78
79
80
  m_myTree->Branch ("largeRJet_ET",  &m_largeRJet_ET);
  m_myTree->Branch ("largeRJet_nTOBs",  &m_largeRJet_nTOBs);

81
82
  m_myTree->Branch ("largeRJetTOB_ET",  &m_largeRJetTOB_ET);
  m_myTree->Branch ("largeRJetTOB_eta", &m_largeRJetTOB_eta);
83
  m_myTree->Branch ("largeRJetTOB_phi", &m_largeRJetTOB_phi);
84
  m_myTree->Branch ("largeRJetTOB_sat", &m_largeRJetTOB_sat);
85

86
87
88
89
  m_myTree->Branch ("largeRJetTOB_word",   &m_largeRJetTOB_word);
  m_myTree->Branch ("largeRJetTOB_jfexID", &m_largeRJetTOB_jfexID);
  m_myTree->Branch ("largeRJetTOB_fpgaID", &m_largeRJetTOB_fpgaID);

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  m_myTree->Branch ("tau_TT_ID" ,  &m_tau_TT_ID);
  m_myTree->Branch ("tau_isLocalMax" ,  &m_tau_isLocalMax);
  m_myTree->Branch ("tau_ET" ,  &m_tau_ET);
  m_myTree->Branch ("tau_clusterET" ,  &m_tau_clusterET);
  m_myTree->Branch ("tau_eta",  &m_tau_eta);
  m_myTree->Branch ("tau_phi",  &m_tau_phi);
  m_myTree->Branch ("tau_realeta",  &m_tau_realeta);
  m_myTree->Branch ("tau_ISO",  &m_tau_ISO);
  m_myTree->Branch ("tau_jFEXid",  &m_tau_jFEXid);
  m_myTree->Branch ("tau_FPGAid",  &m_tau_FPGAid);

  m_myTree->Branch ("tau_TOB_word",  &m_tau_TOB_word);
  m_myTree->Branch ("tau_TOB_ET",  &m_tau_TOB_ET);
  m_myTree->Branch ("tau_TOB_eta",  &m_tau_TOB_eta);
  m_myTree->Branch ("tau_TOB_phi",  &m_tau_TOB_phi);
  m_myTree->Branch ("tau_TOB_ISO",  &m_tau_TOB_ISO);
  m_myTree->Branch ("tau_TOB_Sat",  &m_tau_TOB_Sat);
107

108
  //Pileup
109
110
111
112
113
114
115
  m_myTree->Branch ("pileup_FPGAid",    &m_pileup_FPGAid);
  m_myTree->Branch ("pileup_jFEXid",    &m_pileup_jFEXid);
  m_myTree->Branch ("pileup_rho_EM",    &m_pileup_rho_EM);
  m_myTree->Branch ("pileup_rho_HAD1",  &m_pileup_rho_HAD1);
  m_myTree->Branch ("pileup_rho_HAD2",  &m_pileup_rho_HAD2);
  m_myTree->Branch ("pileup_rho_HAD3",  &m_pileup_rho_HAD3);
  m_myTree->Branch ("pileup_rho_FCAL",  &m_pileup_rho_FCAL);
116
  
117
118
119
120
121
122
123
  m_myTree->Branch ("pileup_map_ID"  ,  &m_pileup_map_ID);
  m_myTree->Branch ("pileup_map_Et_values_HAD_jet"  ,  &m_pileup_map_Et_values_HAD_jet);
  m_myTree->Branch ("pileup_map_Et_values_EM_jet"   ,  &m_pileup_map_Et_values_EM_jet);
  m_myTree->Branch ("pileup_map_Et_values_Total_jet",  &m_pileup_map_Et_values_Total_jet);
  m_myTree->Branch ("pileup_map_Et_values_HAD_met"  ,  &m_pileup_map_Et_values_HAD_met);
  m_myTree->Branch ("pileup_map_Et_values_EM_met"   ,  &m_pileup_map_Et_values_EM_met);
  m_myTree->Branch ("pileup_map_Et_values_Total_met",  &m_pileup_map_Et_values_Total_met);
124

125
126
127
128
  return StatusCode::SUCCESS;
}

StatusCode LVL1::jFEXNtupleWriter::execute () {
129
130
131
132
133
134
135
136
  SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj = SG::ReadHandle<LVL1::jFEXOutputCollection>(m_jFEXOutputCollectionSGKey/*,ctx*/);
  if(!jFEXOutputCollectionobj.isValid()){
    ATH_MSG_FATAL("Could not retrieve jFEXOutputCollection " << m_jFEXOutputCollectionSGKey.key());
    return StatusCode::FAILURE;
  }
  if (!jFEXOutputCollectionobj->getdooutput()) {
    return StatusCode::SUCCESS; 
  }
137
138
  //ATH_MSG_DEBUG("==== jFEXNtupleWriter ============ execute()");

139
140
141
142
  CHECK(loadsmallRJetAlgoVariables(jFEXOutputCollectionobj));
  CHECK(loadlargeRJetAlgoVariables(jFEXOutputCollectionobj));
  CHECK(loadtauAlgoVariables(jFEXOutputCollectionobj));
  CHECK(loadPileupVariables(jFEXOutputCollectionobj));
143
  CHECK(loadPileupEt(jFEXOutputCollectionobj));
144
  m_myTree->Fill();
145

146
147
148
149
150
151
152
153
  return StatusCode::SUCCESS;
}

StatusCode LVL1::jFEXNtupleWriter::finalize () {
  ATH_MSG_DEBUG("Finalizing " << name() << "...");
  return StatusCode::SUCCESS;
}

154
StatusCode LVL1::jFEXNtupleWriter::loadsmallRJetAlgoVariables(SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj) {
155
156
157
158
  m_smallRJet_eta.clear();
  m_smallRJet_phi.clear();
  m_smallRJet_isCentralTowerSeed.clear();
  m_smallRJet_ET.clear();
159
  m_smallRJet_clusterET.clear();
160
161
162
  m_smallRJetTOB_eta.clear();
  m_smallRJetTOB_phi.clear();
  m_smallRJetTOB_ET.clear();
Varsiha Sothilingam's avatar
Varsiha Sothilingam committed
163
  m_smallRJetTOB_sat.clear();
164
165
166
167
  m_smallRJetTOB_word.clear();
  m_smallRJetTOB_jfexID.clear();  
  m_smallRJetTOB_fpgaID.clear();

168
  for (int i = 0; i < jFEXOutputCollectionobj->SRsize(); i++)
169
  {
170
171
172
173
174
175
176
177
178
179
180
181
    m_smallRJet_isCentralTowerSeed.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJet_isCentralTowerSeed"]);
    m_smallRJet_phi.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJet_phi"]);
    m_smallRJet_eta.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJet_eta"]);
    m_smallRJet_ET.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJet_ET"]);
    m_smallRJet_clusterET.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJet_clusterET"]);
    m_smallRJetTOB_eta.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_eta"]);
    m_smallRJetTOB_phi.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_phi"]);
    m_smallRJetTOB_ET.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_ET"]);
    m_smallRJetTOB_sat.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_sat"]);
    m_smallRJetTOB_word.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_word"]);
    m_smallRJetTOB_jfexID.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_jfexID"]);
    m_smallRJetTOB_fpgaID.push_back((*(jFEXOutputCollectionobj->get_smallRJet(i)))["smallRJetTOB_fpgaID"]);
182
183
184
185
  }
  return StatusCode::SUCCESS;
}

186
StatusCode LVL1::jFEXNtupleWriter::loadlargeRJetAlgoVariables(SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj) {
187
188
  m_largeRJet_ET.clear();
  m_largeRJet_nTOBs.clear();
189
190
  m_largeRJet_eta.clear();
  m_largeRJet_phi.clear();
191
  m_largeRJetTOB_ET.clear();
192
193
194
195
196
197
  m_largeRJetTOB_eta.clear();
  m_largeRJetTOB_phi.clear();
  m_largeRJetTOB_sat.clear();
  m_largeRJetTOB_word.clear();
  m_largeRJetTOB_fpgaID.clear();
  m_largeRJetTOB_jfexID.clear();
198

199
  for (int i = 0; i < jFEXOutputCollectionobj->LRsize(); i++)
200
  {
201
202
203
204
205
206
207
208
209
210
211
    m_largeRJet_ET.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJet_ET"]);
    m_largeRJet_nTOBs.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJet_nTOBs"]); 
    m_largeRJet_eta.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJet_eta"]);
    m_largeRJet_phi.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJet_phi"]);
    m_largeRJetTOB_ET.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_ET"]);
    m_largeRJetTOB_eta.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_eta"]);
    m_largeRJetTOB_phi.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_phi"]);
    m_largeRJetTOB_sat.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_sat"]);
    m_largeRJetTOB_word.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_word"]);
    m_largeRJetTOB_fpgaID.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_fpgaID"]);
    m_largeRJetTOB_jfexID.push_back((*(jFEXOutputCollectionobj->get_largeRJet(i)))["largeRJetTOB_jfexID"]);
212

213
214
215
  }
  return StatusCode::SUCCESS;
}
216

217
StatusCode LVL1::jFEXNtupleWriter::loadtauAlgoVariables(SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj) {
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

  m_tau_TT_ID.clear();
  m_tau_jFEXid.clear();
  m_tau_FPGAid.clear();
  m_tau_isLocalMax.clear();
  m_tau_ET.clear();
  m_tau_clusterET.clear();
  m_tau_eta.clear();
  m_tau_phi.clear();
  m_tau_realeta.clear();
  m_tau_ISO.clear();

  m_tau_TOB_word.clear();
  m_tau_TOB_ET.clear();
  m_tau_TOB_eta.clear();
  m_tau_TOB_phi.clear();
  m_tau_TOB_ISO.clear();
  m_tau_TOB_Sat.clear();

  
238
  for (int i = 0; i < jFEXOutputCollectionobj->tausize(); i++)
239
  {
240
241
242
243
244
245
246
247
248
249
    m_tau_isLocalMax.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_isLocalMax"]);
    m_tau_TT_ID.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TT_ID"]);
    m_tau_jFEXid.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_jFEXid"]);
    m_tau_FPGAid.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_FPGAid"]);
    m_tau_ET.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_ET"]);
    m_tau_clusterET.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_clusterET"]);
    m_tau_eta.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_eta"]); 
    m_tau_phi.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_phi"]);
    m_tau_realeta.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_realeta"]);
    m_tau_ISO.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_ISO"]);
250
    
251
252
253
254
255
256
    m_tau_TOB_word.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_word"]);
    m_tau_TOB_ET.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_ET"]);
    m_tau_TOB_eta.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_eta"]);
    m_tau_TOB_phi.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_phi"]);
    m_tau_TOB_ISO.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_ISO"]);
    m_tau_TOB_Sat.push_back((*(jFEXOutputCollectionobj->get_tau(i)))["tau_TOB_Sat"]);
257
258
259
260
261

  }
  return StatusCode::SUCCESS;
}

262
StatusCode LVL1::jFEXNtupleWriter::loadPileupVariables(SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj) {
263
264
265
266
267
268
269
270
271
272
273


  m_pileup_FPGAid.clear();
  m_pileup_jFEXid.clear();
  m_pileup_rho_EM.clear();
  m_pileup_rho_HAD1.clear();
  m_pileup_rho_HAD2.clear();
  m_pileup_rho_HAD3.clear();
  m_pileup_rho_FCAL.clear();

  
274
  for (int i = 0; i < jFEXOutputCollectionobj->pileupsize(); i++)
275
276
  {

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
    m_pileup_FPGAid.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_FPGAid"));
    m_pileup_jFEXid.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_jFEXid"));
    m_pileup_rho_EM.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_EM"));
    m_pileup_rho_HAD1.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD1"));
    m_pileup_rho_HAD2.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD2"));
    m_pileup_rho_HAD3.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD3"));
    m_pileup_rho_FCAL.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_FCAL"));
  }
  return StatusCode::SUCCESS;
}

StatusCode LVL1::jFEXNtupleWriter::loadPileupEt(SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj) {


  m_pileup_map_ID.clear();
  m_pileup_map_Et_values_HAD_jet.clear();
  m_pileup_map_Et_values_EM_jet.clear();
  m_pileup_map_Et_values_Total_jet.clear();
  m_pileup_map_Et_values_HAD_met.clear();
  m_pileup_map_Et_values_EM_met.clear();
  m_pileup_map_Et_values_Total_met.clear();
298

299
300
301
302
303
304
305
306
307
308
309
  
  for (int i = 0; i < jFEXOutputCollectionobj->pileuEtSize(); i++)
  {
    m_pileup_map_ID.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_ID"));
    m_pileup_map_Et_values_HAD_jet.push_back(  jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_HAD_jet"));
    m_pileup_map_Et_values_EM_jet.push_back(   jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_EM_jet"));
    m_pileup_map_Et_values_Total_jet.push_back(jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_Total_jet"));
    m_pileup_map_Et_values_HAD_met.push_back(  jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_HAD_met"));
    m_pileup_map_Et_values_EM_met.push_back(   jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_EM_met"));
    m_pileup_map_Et_values_Total_met.push_back(jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_Total_met"));
    
310
  }
311
312
  
  
313
314
315
  return StatusCode::SUCCESS;
}

316
317
318



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*
StatusCode LVL1::jFEXNtupleWriter::loadTruthElectron() {
  m_truth_e_eta.clear();
  m_truth_e_phi.clear();
  m_truth_e_ET.clear();
  const xAOD::TruthEventContainer* truthEvents;
  CHECK(evtStore()->retrieve( truthEvents, "TruthEvents"));
  for(auto ite : *truthEvents) {
    int nParticle = ite->nTruthParticles();
    for(int i = 0; i < nParticle; i++){
      const xAOD::TruthParticle* each_particle = ite->truthParticle(i);

      // ignore geant4
      if(each_particle->barcode() > 200000) continue;
      // select particles that is not decayed further by the generator
      if(each_particle->status() != 1) continue;
      // select electrons
      if(fabs(each_particle->pdgId()) != 11) continue;
      // select particles from Z
      if(!getMother(each_particle, 23)) continue;

      m_truth_e_ET.push_back(each_particle->p4().Pt());
      m_truth_e_eta.push_back(each_particle->p4().Eta());
      m_truth_e_phi.push_back(each_particle->p4().Phi());
    }
  }
  return StatusCode::SUCCESS;
}
*/
/*
StatusCode LVL1::jFEXNtupleWriter::loadTruthJets() {
  m_truth_jet_eta.clear();
  m_truth_jet_phi.clear();
  m_truth_jet_ET.clear();
  const xAOD::JetContainer* truth_jets;
  StatusCode sc = evtStore()->retrieve( truth_jets, m_jet_container_name);
  if (sc ==  StatusCode::FAILURE){
    m_jet_container_name = "InTimeAntiKt4TruthJets";
    StatusCode sc2 = evtStore()->retrieve( truth_jets, m_jet_container_name);
    if (sc2 ==  StatusCode::FAILURE){
      ATH_MSG_DEBUG("jFEXNtupleWriter::loadTruthJets() Unable to determine truth jet container");
      m_load_truth_jet = false;
      return StatusCode::SUCCESS;
    }
  }
  for (unsigned i=0; i!=truth_jets->size(); i++) {
    const xAOD::Jet* each_jet = (*truth_jets)[i];
    if(each_jet->pt()<10000) continue;
    m_truth_jet_eta.push_back(each_jet->p4().Eta());
    m_truth_jet_phi.push_back(each_jet->p4().Phi());
    m_truth_jet_ET.push_back(each_jet->p4().Et());
  }
  return StatusCode::SUCCESS;
}
*/
/*StatusCode LVL1::jFEXNtupleWriter::loadTruthTau() {
  m_truth_tauvisible_eta.clear();
  m_truth_tauvisible_phi.clear();
  m_truth_tauvisible_ET.clear();
  const xAOD::TruthEventContainer* truthEvents;
  CHECK( evtStore()->retrieve( truthEvents, "TruthEvents"));
  for (auto ite : *truthEvents) {
    int nParticle = ite->nTruthParticles();
    for(int i = 0; i < nParticle; i++) {
      const xAOD::TruthParticle* each_particle = ite->truthParticle(i);
      // ignore geant4
      if (each_particle->barcode() > 200000) continue;
      // select final state particles and decaying hadrons, muons or taus
      if (each_particle->status() != 1 && each_particle->status() != 2) continue;
      // select tau
      if (fabs(each_particle->pdgId()) != 15) continue;
      std::unique_ptr<TLorentzVector> p4_visible = visibleTauP4(each_particle);

      if (!p4_visible) break;
      m_truth_tauvisible_eta.push_back(p4_visible->Eta());
      m_truth_tauvisible_phi.push_back(p4_visible->Phi());
      m_truth_tauvisible_ET.push_back(p4_visible->Et());
    }
  }
  return StatusCode::SUCCESS;
}
*/
/*
std::unique_ptr<TLorentzVector> LVL1::jFEXNtupleWriter::visibleTauP4(const xAOD::TruthParticle* particle) {
  std::unique_ptr<TLorentzVector> psum(new TLorentzVector(0,0,0,0));
  // ignore documentation particles. Attempt to find the nOutgoingParticles() of a documentation particle 
  // causes crash.
  // It still gives the correct result, but I don't know why I have to do this.
  if (particle->status() == 3) {
    return psum;
  }
  const xAOD::TruthVertex* decay_vertex = particle->decayVtx();
  decay_vertex->nOutgoingParticles();
  for(uint i=0; i < decay_vertex->nOutgoingParticles(); i++) {
    const xAOD::TruthParticle* each_particle = decay_vertex->outgoingParticle(i);
    int pid = fabs(each_particle->pdgId());
    // particle that is not decayed further by the generator
    if (each_particle->status() == 1) {
      // ignore neutrinos
      if (pid ==  12 || pid ==  14 || pid ==  16) continue;
      // ignore leptonic decay events
      if (pid ==  11 || pid ==  13) return std::unique_ptr<TLorentzVector>(nullptr);
      (*psum) += each_particle->p4();
    }
    else{
      std::unique_ptr<TLorentzVector> p4_tem = visibleTauP4(each_particle);
      if (!p4_tem) return std::unique_ptr<TLorentzVector>(nullptr);
      (*psum) += (*p4_tem);
    }
  }
  return psum;
}
*/
/*
std::unique_ptr<TLorentzVector> LVL1::jFEXNtupleWriter::invisibleTauP4(const xAOD::TruthParticle* particle) {
  std::unique_ptr<TLorentzVector> psum(new TLorentzVector(0,0,0,0));
  // ignore documentation particles. Attempt to find the nOutgoingParticles() of a documentation particle 
  // causes crash.
  // It still gives the correct result, but I don't know why I have to do this.
  if (particle->status() == 3) {
    return psum;
  }
  const xAOD::TruthVertex* decay_vertex = particle->decayVtx();
  for (uint i=0; i < decay_vertex->nOutgoingParticles(); i++) {
    const xAOD::TruthParticle* each_particle = decay_vertex->outgoingParticle(i);
    int pid = fabs(each_particle->pdgId());
    // particle that is not decayed further by the generator
    if (each_particle->status() == 1) {
      // ignore leptonic decay events
      if (pid ==  11 || pid ==  13) return std::unique_ptr<TLorentzVector>(nullptr);
      // select neutrinos
      if (pid ==  12 || pid ==  14 || pid ==  16) (*psum) += each_particle->p4();
    }
    else {
      std::unique_ptr<TLorentzVector> p4_tem = invisibleTauP4(each_particle);
      if (!p4_tem) return std::unique_ptr<TLorentzVector>(nullptr);
      (*psum) += (*p4_tem);
    }
  }
  return psum;
}
*/
/*
const xAOD::TruthParticle* LVL1::jFEXNtupleWriter::getMother(const xAOD::TruthParticle* particle, int motherPid) {
   const xAOD::TruthVertex* productionVector = particle->prodVtx();
   if (!productionVector) return NULL;
   for (long unsigned int i = 0; i < productionVector->nIncomingParticles(); i++) {
      const xAOD::TruthParticle* mother = productionVector->incomingParticle(i);
      if (mother->pdgId()==motherPid) return mother;
      const xAOD::TruthParticle* grandmother = getMother(mother, motherPid);
      if (grandmother) return grandmother;
   }
   return NULL;
}
*/