ATLAS Offline Software
jFEXNtupleWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***************************************************************************
6 // jFEXNtupleWriter.cxx - copied from eFEXNtupleWrite by Tong Qiu
7 // -------------------
8 // begin : 12 12 2020
9 // email : varsiha.sothilingam@cern.ch
10 // **************************************************************************
11 
13 #include "StoreGate/StoreGateSvc.h"
16 #include <vector>
17 #include "TTree.h"
18 #include "GaudiKernel/ITHistSvc.h"
19 #include "GaudiKernel/ServiceHandle.h"
20 #include <memory>
23 #include "xAODTruth/TruthVertex.h"
25 #include "xAODJet/JetContainer.h"
26 
27 
28 LVL1::jFEXNtupleWriter::jFEXNtupleWriter(const std::string& name, ISvcLocator* pSvcLocator): AthAlgorithm(name, pSvcLocator) { }
29 
31 
32 }
33 
36  CHECK( histSvc.retrieve() );
37  m_myTree = new TTree("data","data");
38  CHECK( histSvc->regTree("/ANALYSIS/data",m_myTree) );
39  ATH_CHECK( m_jFEXOutputCollectionSGKey.initialize() );
40 
41  m_myTree->Branch ("smallRJet_eta", &m_smallRJet_eta);
42  m_myTree->Branch ("smallRJet_phi", &m_smallRJet_phi);
43  m_myTree->Branch ("smallRJet_ET", &m_smallRJet_ET);
44  m_myTree->Branch ("smallRJet_clusterET", &m_smallRJet_clusterET);
45  m_myTree->Branch ("smallRJet_nTOBs", &m_smallRJet_nTOBs, "nTOBs");
46  m_myTree->Branch ("smallRJet_isCentralTowerSeed", &m_smallRJet_isCentralTowerSeed);
47 
48  m_myTree->Branch ("smallRJetTOB_eta", &m_smallRJetTOB_eta);
49  m_myTree->Branch ("smallRJetTOB_phi", &m_smallRJetTOB_phi);
50  m_myTree->Branch ("smallRJetTOB_ET", &m_smallRJetTOB_ET);
51  m_myTree->Branch ("smallRJetTOB_sat", &m_smallRJetTOB_sat);
52  m_myTree->Branch ("smallRJetTOB_word", &m_smallRJetTOB_word);
53  m_myTree->Branch ("smallRJetTOB_jfexID", &m_smallRJetTOB_jfexID);
54  m_myTree->Branch ("smallRJetTOB_fpgaID", &m_smallRJetTOB_fpgaID);
55 
56 
57  m_myTree->Branch ("largeRJet_eta", &m_largeRJet_eta);
58  m_myTree->Branch ("largeRJet_phi", &m_largeRJet_phi);
59  m_myTree->Branch ("largeRJet_ET", &m_largeRJet_ET);
60  m_myTree->Branch ("largeRJet_nTOBs", &m_largeRJet_nTOBs);
61 
62  m_myTree->Branch ("largeRJetTOB_ET", &m_largeRJetTOB_ET);
63  m_myTree->Branch ("largeRJetTOB_eta", &m_largeRJetTOB_eta);
64  m_myTree->Branch ("largeRJetTOB_phi", &m_largeRJetTOB_phi);
65  m_myTree->Branch ("largeRJetTOB_sat", &m_largeRJetTOB_sat);
66 
67  m_myTree->Branch ("largeRJetTOB_word", &m_largeRJetTOB_word);
68  m_myTree->Branch ("largeRJetTOB_jfexID", &m_largeRJetTOB_jfexID);
69  m_myTree->Branch ("largeRJetTOB_fpgaID", &m_largeRJetTOB_fpgaID);
70 
71  m_myTree->Branch ("tau_TT_ID", &m_tau_TT_ID);
72  m_myTree->Branch ("tau_isLocalMax", &m_tau_isLocalMax);
73  m_myTree->Branch ("tau_ET", &m_tau_ET);
74  m_myTree->Branch ("tau_clusterET", &m_tau_clusterET);
75  m_myTree->Branch ("tau_eta", &m_tau_eta);
76  m_myTree->Branch ("tau_phi", &m_tau_phi);
77  m_myTree->Branch ("tau_realeta", &m_tau_realeta);
78  m_myTree->Branch ("tau_ISO", &m_tau_ISO);
79  m_myTree->Branch ("tau_jFEXid", &m_tau_jFEXid);
80  m_myTree->Branch ("tau_FPGAid", &m_tau_FPGAid);
81 
82  m_myTree->Branch ("tau_TOB_word", &m_tau_TOB_word);
83  m_myTree->Branch ("tau_TOB_ET", &m_tau_TOB_ET);
84  m_myTree->Branch ("tau_TOB_eta", &m_tau_TOB_eta);
85  m_myTree->Branch ("tau_TOB_phi", &m_tau_TOB_phi);
86  m_myTree->Branch ("tau_TOB_ISO", &m_tau_TOB_ISO);
87  m_myTree->Branch ("tau_TOB_Sat", &m_tau_TOB_Sat);
88 
89  //Pileup
90  m_myTree->Branch ("pileup_FPGAid", &m_pileup_FPGAid);
91  m_myTree->Branch ("pileup_jFEXid", &m_pileup_jFEXid);
92  m_myTree->Branch ("pileup_rho_EM", &m_pileup_rho_EM);
93  m_myTree->Branch ("pileup_rho_HAD1", &m_pileup_rho_HAD1);
94  m_myTree->Branch ("pileup_rho_HAD2", &m_pileup_rho_HAD2);
95  m_myTree->Branch ("pileup_rho_HAD3", &m_pileup_rho_HAD3);
96  m_myTree->Branch ("pileup_rho_FCAL", &m_pileup_rho_FCAL);
97 
98  m_myTree->Branch ("pileup_map_ID", &m_pileup_map_ID);
99  m_myTree->Branch ("pileup_map_Et_values_HAD_jet", &m_pileup_map_Et_values_HAD_jet);
100  m_myTree->Branch ("pileup_map_Et_values_EM_jet", &m_pileup_map_Et_values_EM_jet);
101  m_myTree->Branch ("pileup_map_Et_values_Total_jet", &m_pileup_map_Et_values_Total_jet);
102  m_myTree->Branch ("pileup_map_Et_values_HAD_met", &m_pileup_map_Et_values_HAD_met);
103  m_myTree->Branch ("pileup_map_Et_values_EM_met", &m_pileup_map_Et_values_EM_met);
104  m_myTree->Branch ("pileup_map_Et_values_Total_met", &m_pileup_map_Et_values_Total_met);
105 
106  return StatusCode::SUCCESS;
107 }
108 
110  SG::ReadHandle<LVL1::jFEXOutputCollection> jFEXOutputCollectionobj = SG::ReadHandle<LVL1::jFEXOutputCollection>(m_jFEXOutputCollectionSGKey/*,ctx*/);
111  if(!jFEXOutputCollectionobj.isValid()) {
112  ATH_MSG_ERROR("Could not retrieve jFEXOutputCollection " << m_jFEXOutputCollectionSGKey.key());
113  return StatusCode::FAILURE;
114  }
115  if (!jFEXOutputCollectionobj->getdooutput()) {
116  return StatusCode::SUCCESS;
117  }
118  CHECK(loadsmallRJetAlgoVariables(jFEXOutputCollectionobj));
119  CHECK(loadlargeRJetAlgoVariables(jFEXOutputCollectionobj));
120  CHECK(loadtauAlgoVariables(jFEXOutputCollectionobj));
121  CHECK(loadPileupVariables(jFEXOutputCollectionobj));
122  CHECK(loadPileupEt(jFEXOutputCollectionobj));
123  m_myTree->Fill();
124 
125  return StatusCode::SUCCESS;
126 }
127 
129  ATH_MSG_DEBUG("Finalizing " << name() << "...");
130  return StatusCode::SUCCESS;
131 }
132 
134 
135  m_smallRJet_eta.clear();
136  m_smallRJet_phi.clear();
137  m_smallRJet_isCentralTowerSeed.clear();
138  m_smallRJet_ET.clear();
139  m_smallRJet_clusterET.clear();
140  m_smallRJetTOB_eta.clear();
141  m_smallRJetTOB_phi.clear();
142  m_smallRJetTOB_ET.clear();
143  m_smallRJetTOB_sat.clear();
144  m_smallRJetTOB_word.clear();
145  m_smallRJetTOB_jfexID.clear();
146  m_smallRJetTOB_fpgaID.clear();
147 
148  for (int i = 0; i < jFEXOutputCollectionobj->SRJetSize(); i++)
149  {
150  m_smallRJet_isCentralTowerSeed.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJet_isCentralTowerSeed"));
151  m_smallRJet_phi.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJet_phi"));
152  m_smallRJet_eta.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJet_eta"));
153  m_smallRJet_ET.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJet_ET"));
154  m_smallRJet_clusterET.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJet_clusterET"));
155  m_smallRJetTOB_eta.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_eta"));
156  m_smallRJetTOB_phi.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_phi"));
157  m_smallRJetTOB_ET.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_ET"));
158  m_smallRJetTOB_sat.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_sat"));
159  m_smallRJetTOB_word.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_word"));
160  m_smallRJetTOB_jfexID.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_jfexID"));
161  m_smallRJetTOB_fpgaID.push_back( jFEXOutputCollectionobj->get_smallRJet(i,"smallRJetTOB_fpgaID"));
162  }
163  return StatusCode::SUCCESS;
164 }
165 
167 
168  m_largeRJet_ET.clear();
169  m_largeRJet_nTOBs.clear();
170  m_largeRJet_eta.clear();
171  m_largeRJet_phi.clear();
172  m_largeRJetTOB_ET.clear();
173  m_largeRJetTOB_eta.clear();
174  m_largeRJetTOB_phi.clear();
175  m_largeRJetTOB_sat.clear();
176  m_largeRJetTOB_word.clear();
177  m_largeRJetTOB_fpgaID.clear();
178  m_largeRJetTOB_jfexID.clear();
179 
180  for (int i = 0; i < jFEXOutputCollectionobj->LRJetSize(); i++)
181  {
182  m_largeRJet_ET.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJet_ET"));
183  m_largeRJet_nTOBs.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJet_nTOBs"));
184  m_largeRJet_eta.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJet_eta"));
185  m_largeRJet_phi.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJet_phi"));
186  m_largeRJetTOB_ET.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_ET"));
187  m_largeRJetTOB_eta.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_eta"));
188  m_largeRJetTOB_phi.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_phi"));
189  m_largeRJetTOB_sat.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_sat"));
190  m_largeRJetTOB_word.push_back( jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_word"));
191  m_largeRJetTOB_fpgaID.push_back(jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_fpgaID"));
192  m_largeRJetTOB_jfexID.push_back(jFEXOutputCollectionobj->get_largeRJet(i,"largeRJetTOB_jfexID"));
193 
194  }
195  return StatusCode::SUCCESS;
196 }
197 
199 
200  m_tau_TT_ID.clear();
201  m_tau_jFEXid.clear();
202  m_tau_FPGAid.clear();
203  m_tau_isLocalMax.clear();
204  m_tau_ET.clear();
205  m_tau_clusterET.clear();
206  m_tau_eta.clear();
207  m_tau_phi.clear();
208  m_tau_realeta.clear();
209  m_tau_ISO.clear();
210 
211  m_tau_TOB_word.clear();
212  m_tau_TOB_ET.clear();
213  m_tau_TOB_eta.clear();
214  m_tau_TOB_phi.clear();
215  m_tau_TOB_ISO.clear();
216  m_tau_TOB_Sat.clear();
217 
218  for (int i = 0; i < jFEXOutputCollectionobj->TauSize(); i++)
219  {
220  m_tau_isLocalMax.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_isLocalMax"));
221  m_tau_TT_ID.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TT_ID"));
222  m_tau_jFEXid.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_jFEXid"));
223  m_tau_FPGAid.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_FPGAid"));
224  m_tau_ET.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_ET"));
225  m_tau_clusterET.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_clusterET"));
226  m_tau_eta.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_eta"));
227  m_tau_phi.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_phi"));
228  m_tau_realeta.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_realeta"));
229  m_tau_ISO.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_ISO"));
230 
231  m_tau_TOB_word.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_word"));
232  m_tau_TOB_ET.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_ET"));
233  m_tau_TOB_eta.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_eta"));
234  m_tau_TOB_phi.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_phi"));
235  m_tau_TOB_ISO.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_ISO"));
236  m_tau_TOB_Sat.push_back( jFEXOutputCollectionobj->get_tau(i,"tau_TOB_Sat"));
237 
238  }
239  return StatusCode::SUCCESS;
240 }
241 
243 
244  m_pileup_FPGAid.clear();
245  m_pileup_jFEXid.clear();
246  m_pileup_rho_EM.clear();
247  m_pileup_rho_HAD1.clear();
248  m_pileup_rho_HAD2.clear();
249  m_pileup_rho_HAD3.clear();
250  m_pileup_rho_FCAL.clear();
251 
252  for (int i = 0; i < jFEXOutputCollectionobj->PileupSize(); i++)
253  {
254 
255  m_pileup_FPGAid.push_back( jFEXOutputCollectionobj->get_pileup(i,"pileup_FPGAid"));
256  m_pileup_jFEXid.push_back( jFEXOutputCollectionobj->get_pileup(i,"pileup_jFEXid"));
257  m_pileup_rho_EM.push_back( jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_EM"));
258  m_pileup_rho_HAD1.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD1"));
259  m_pileup_rho_HAD2.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD2"));
260  m_pileup_rho_HAD3.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_HAD3"));
261  m_pileup_rho_FCAL.push_back(jFEXOutputCollectionobj->get_pileup(i,"pileup_rho_FCAL"));
262  }
263  return StatusCode::SUCCESS;
264 }
265 
267 
268  m_pileup_map_ID.clear();
269  m_pileup_map_Et_values_HAD_jet.clear();
270  m_pileup_map_Et_values_EM_jet.clear();
271  m_pileup_map_Et_values_Total_jet.clear();
272  m_pileup_map_Et_values_HAD_met.clear();
273  m_pileup_map_Et_values_EM_met.clear();
274  m_pileup_map_Et_values_Total_met.clear();
275 
276  for (int i = 0; i < jFEXOutputCollectionobj->PileupEtSize(); i++)
277  {
278  m_pileup_map_ID.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_ID"));
279  m_pileup_map_Et_values_HAD_jet.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_HAD_jet"));
280  m_pileup_map_Et_values_EM_jet.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_EM_jet"));
281  m_pileup_map_Et_values_Total_jet.push_back(jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_Total_jet"));
282  m_pileup_map_Et_values_HAD_met.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_HAD_met"));
283  m_pileup_map_Et_values_EM_met.push_back( jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_EM_met"));
284  m_pileup_map_Et_values_Total_met.push_back(jFEXOutputCollectionobj->get_pileup_map(i,"pileup_map_Et_values_Total_met"));
285 
286  }
287 
288 
289  return StatusCode::SUCCESS;
290 }
jFEXSmallRJetAlgo.h
LVL1::jFEXOutputCollection::PileupSize
int PileupSize() const
Definition: jFEXOutputCollection.cxx:165
LVL1::jFEXOutputCollection::get_pileup_map
std::vector< int > get_pileup_map(int, std::string) const
Definition: jFEXOutputCollection.cxx:195
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TruthParticleContainer.h
LVL1::jFEXNtupleWriter::finalize
StatusCode finalize()
Definition: jFEXNtupleWriter.cxx:128
LVL1::jFEXOutputCollection::get_tau
int get_tau(int, std::string) const
Definition: jFEXOutputCollection.cxx:182
LVL1::jFEXNtupleWriter::loadPileupEt
StatusCode loadPileupEt(SG::ReadHandle< LVL1::jFEXOutputCollection >)
Definition: jFEXNtupleWriter.cxx:266
LVL1::jFEXOutputCollection::getdooutput
bool getdooutput() const
Definition: jFEXOutputCollection.cxx:204
LVL1::jFEXNtupleWriter::loadPileupVariables
StatusCode loadPileupVariables(SG::ReadHandle< LVL1::jFEXOutputCollection >)
Definition: jFEXNtupleWriter.cxx:242
jFEXOutputCollection.h
LVL1::jFEXOutputCollection::SRJetSize
int SRJetSize() const
Definition: jFEXOutputCollection.cxx:148
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
LVL1::jFEXNtupleWriter::loadtauAlgoVariables
StatusCode loadtauAlgoVariables(SG::ReadHandle< LVL1::jFEXOutputCollection >)
Definition: jFEXNtupleWriter.cxx:198
jFEXNtupleWriter.h
LVL1::jFEXNtupleWriter::initialize
StatusCode initialize()
Definition: jFEXNtupleWriter.cxx:34
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::jFEXOutputCollection::get_pileup
int get_pileup(int, std::string) const
Definition: jFEXOutputCollection.cxx:191
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LVL1::jFEXOutputCollection::LRJetSize
int LRJetSize() const
Definition: jFEXOutputCollection.cxx:153
LVL1::jFEXOutputCollection::PileupEtSize
int PileupEtSize() const
Definition: jFEXOutputCollection.cxx:169
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LVL1::jFEXNtupleWriter::execute
StatusCode execute()
Definition: jFEXNtupleWriter.cxx:109
TrigConf::name
Definition: HLTChainList.h:35
LVL1::jFEXOutputCollection::get_largeRJet
int get_largeRJet(int, std::string) const
Definition: jFEXOutputCollection.cxx:178
LVL1::jFEXNtupleWriter::loadlargeRJetAlgoVariables
StatusCode loadlargeRJetAlgoVariables(SG::ReadHandle< LVL1::jFEXOutputCollection >)
Definition: jFEXNtupleWriter.cxx:166
TruthVertex.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LVL1::jFEXNtupleWriter::~jFEXNtupleWriter
~jFEXNtupleWriter()
Definition: jFEXNtupleWriter.cxx:30
LVL1::jFEXNtupleWriter::loadsmallRJetAlgoVariables
StatusCode loadsmallRJetAlgoVariables(SG::ReadHandle< LVL1::jFEXOutputCollection >)
Definition: jFEXNtupleWriter.cxx:133
LVL1::jFEXOutputCollection::TauSize
int TauSize() const
Definition: jFEXOutputCollection.cxx:157
JetContainer.h
LVL1::jFEXNtupleWriter::jFEXNtupleWriter
jFEXNtupleWriter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: jFEXNtupleWriter.cxx:28
LVL1::jFEXOutputCollection::get_smallRJet
int get_smallRJet(int, std::string) const
Definition: jFEXOutputCollection.cxx:174
TruthParticle.h
TruthEventContainer.h
StoreGateSvc.h
ServiceHandle< ITHistSvc >