13 #include "GaudiKernel/ITHistSvc.h"
14 #include "GaudiKernel/ServiceHandle.h"
36 m_myTree =
new TTree(
"data",
"data");
39 ATH_CHECK( m_eFEXOutputCollectionSGKey.initialize() );
41 m_load_truth_jet =
false;
43 m_myTree->Branch (
"truth_tauvisible_eta", &m_truth_tauvisible_eta);
44 m_myTree->Branch (
"truth_tauvisible_phi", &m_truth_tauvisible_phi);
45 m_myTree->Branch (
"truth_tauvisible_ET", &m_truth_tauvisible_ET);
47 m_myTree->Branch (
"truth_e_eta", &m_truth_e_eta);
48 m_myTree->Branch (
"truth_e_phi", &m_truth_e_phi);
49 m_myTree->Branch (
"truth_e_ET", &m_truth_e_ET);
50 if (m_load_truth_jet){
51 m_myTree->Branch (
"truth_jet_eta", &m_truth_jet_eta);
52 m_myTree->Branch (
"truth_jet_phi", &m_truth_jet_phi);
53 m_myTree->Branch (
"truth_jet_ET", &m_truth_jet_ET);
56 m_myTree->Branch (
"em", &m_em);
57 m_myTree->Branch (
"had", &m_had);
59 m_myTree->Branch (
"eg_eta", &m_eg_eta);
60 m_myTree->Branch (
"eg_phi", &m_eg_phi);
61 m_myTree->Branch (
"eg_ET", &m_eg_ET);
62 m_myTree->Branch (
"eg_wstotnum", &m_eg_WstotNum);
63 m_myTree->Branch (
"eg_wstotden", &m_eg_WstotDen);
64 m_myTree->Branch (
"eg_retanum", &m_eg_RetaNum);
65 m_myTree->Branch (
"eg_retaden", &m_eg_RetaDen);
66 m_myTree->Branch (
"eg_rhadnum", &m_eg_RhadNum);
67 m_myTree->Branch (
"eg_rhadden", &m_eg_RhadDen);
68 m_myTree->Branch (
"eg_haveSeed", &m_eg_haveseed);
69 m_myTree->Branch (
"tau_RealRCore", &m_tau_realRCore);
70 m_myTree->Branch (
"tau_RCoreCore", &m_tau_rCoreCore);
71 m_myTree->Branch (
"tau_RCoreEnv", &m_tau_rCoreEnv);
72 m_myTree->Branch (
"tau_RCoreWP", &m_tau_rCoreWP);
73 m_myTree->Branch (
"tau_RealRHad", &m_tau_realRHad);
74 m_myTree->Branch (
"tau_RHadCore", &m_tau_rHadCore);
75 m_myTree->Branch (
"tau_RHadEnv", &m_tau_rHadEnv);
76 m_myTree->Branch (
"tau_RHadWP", &m_tau_rHadWP);
77 m_myTree->Branch (
"tau_Seed", &m_tau_seed);
78 m_myTree->Branch (
"tau_UnD", &m_tau_und);
79 m_myTree->Branch (
"tau_Et", &m_tau_Et);
80 m_myTree->Branch (
"tau_Eta", &m_tau_Eta);
81 m_myTree->Branch (
"tau_Phi", &m_tau_Phi);
82 m_myTree->Branch (
"tau_floatEta", &m_tau_floatEta);
83 m_myTree->Branch (
"tau_floatPhi", &m_tau_floatPhi);
84 m_myTree->Branch (
"tau_isCentralTowerSeed", &m_tau_isCentralTowerSeed);
85 m_myTree->Branch (
"tau_CenterTowerEt", &m_tau_CenterTowerEt);
86 m_myTree->Branch (
"tau_OneOffEtaTowerEt", &m_tau_OneOffEtaTowerEt);
87 m_myTree->Branch (
"tau_OneBelowEtaTowerEt", &m_tau_OneBelowEtaTowerEt);
88 m_myTree->Branch (
"tau_eFEXID", &m_tau_eFEXID);
89 m_myTree->Branch (
"tau_FPGAID", &m_tau_FPGAID);
90 m_myTree->Branch (
"eFEXnumber", &m_eFex_number);
91 m_myTree->Branch (
"eg_nTOBs", &m_eg_nTOBs);
93 m_myTree->Branch (
"eg_TOB_FP", &m_eg_TOB_FP);
94 m_myTree->Branch (
"eg_TOB_Eta", &m_eg_TOB_Eta);
95 m_myTree->Branch (
"eg_TOB_Phi", &m_eg_TOB_Phi);
96 m_myTree->Branch (
"eg_TOB_ha", &m_eg_TOB_ha);
97 m_myTree->Branch (
"eg_TOB_f3", &m_eg_TOB_f3);
98 m_myTree->Branch (
"eg_TOB_Re", &m_eg_TOB_Re);
99 m_myTree->Branch (
"eg_TOB_Sd", &m_eg_TOB_Sd);
100 m_myTree->Branch (
"eg_TOB_UnD", &m_eg_TOB_UnD);
101 m_myTree->Branch (
"eg_TOB_Max", &m_eg_TOB_Max);
102 m_myTree->Branch (
"eg_TOB_zeros", &m_eg_TOB_zeros);
103 m_myTree->Branch (
"eg_TOB_energy", &m_eg_TOB_energy);
104 return StatusCode::SUCCESS;
109 if(!eFEXOutputCollectionobj.
isValid()){
110 ATH_MSG_FATAL(
"Could not retrieve eFEXOutputCollection " << m_eFEXOutputCollectionSGKey.key());
111 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
117 CHECK(loadegAlgoVariables(eFEXOutputCollectionobj));
118 CHECK(loadegAlgoTOBs(eFEXOutputCollectionobj));
119 CHECK(loadtauAlgoVariables(eFEXOutputCollectionobj));
120 CHECK(loadTruthElectron());
121 CHECK(loadTruthTau());
122 if (m_load_truth_jet){
123 CHECK(loadTruthJets());
128 return StatusCode::SUCCESS;
133 return StatusCode::SUCCESS;
137 m_tau_realRCore.clear();
138 m_tau_rCoreCore.clear();
139 m_tau_rCoreEnv.clear();
140 m_tau_rCoreWP.clear();
141 m_tau_realRHad.clear();
142 m_tau_rHadCore.clear();
143 m_tau_rHadEnv.clear();
144 m_tau_rHadWP.clear();
150 m_tau_floatEta.clear();
151 m_tau_floatPhi.clear();
152 m_tau_isCentralTowerSeed.clear();
153 m_tau_CenterTowerEt.clear();
154 m_tau_OneOffEtaTowerEt.clear();
155 m_tau_OneBelowEtaTowerEt.clear();
156 m_tau_eFEXID.clear();
157 m_tau_FPGAID.clear();
158 for (
int i = 0;
i < eFEXOutputCollectionobj->
tau_size();
i++)
160 m_tau_isCentralTowerSeed.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"isCentralTowerSeed"]);
161 m_tau_Et.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"Et"]);
162 m_tau_Eta.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"Eta"]);
163 m_tau_Phi.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"Phi"]);
164 m_tau_floatEta.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"FloatEta"]);
165 m_tau_floatPhi.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"FloatPhi"]);
166 m_tau_realRCore.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RealRCore"]);
167 m_tau_rCoreCore.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RCoreCore"]);
168 m_tau_rCoreEnv.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RCoreEnv"]);
169 m_tau_rCoreWP.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RCoreWP"]);
170 m_tau_realRHad.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RealRHad"]);
171 m_tau_rHadCore.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RHadCore"]);
172 m_tau_rHadEnv.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RHadEnv"]);
173 m_tau_rHadWP.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"RHadWP"]);
174 m_tau_seed.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"Seed"]);
175 m_tau_und.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"UnD"]);
176 m_tau_CenterTowerEt.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"CenterTowerEt"]);
177 m_tau_OneOffEtaTowerEt.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"OneOffEtaTowerEt"]);
178 m_tau_OneBelowEtaTowerEt.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"OneBelowEtaTowerEt"]);
179 m_tau_eFEXID.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"eFEXID"]);
180 m_tau_FPGAID.push_back((*(eFEXOutputCollectionobj->
get_tau(
i)))[
"FPGAID"]);
182 return StatusCode::SUCCESS;
187 m_eg_WstotNum.clear();
188 m_eg_WstotDen.clear();
191 m_eg_haveseed.clear();
192 m_eg_RetaNum.clear();
193 m_eg_RetaDen.clear();
194 m_eg_RhadNum.clear();
195 m_eg_RhadDen.clear();
196 m_eFex_number.clear();
200 m_eg_nTOBs = eFEXOutputCollectionobj->
size();
201 for (
int i = 0;
i < eFEXOutputCollectionobj->
size();
i++)
203 std::map<std::string, float> eFEXegvalue_tem = (*(eFEXOutputCollectionobj->
get_eg(
i)));
204 m_eg_WstotNum.push_back(eFEXegvalue_tem[
"WstotNum"]);
205 m_eg_WstotDen.push_back(eFEXegvalue_tem[
"WstotDen"]);
206 m_eg_RetaNum.push_back(eFEXegvalue_tem[
"RetaNum"]);
207 m_eg_RetaDen.push_back(eFEXegvalue_tem[
"RetaDen"]);
208 m_eg_RhadNum.push_back(eFEXegvalue_tem[
"RhadNum"]);
209 m_eg_RhadDen.push_back(eFEXegvalue_tem[
"RhadDen"]);
210 m_eg_haveseed.push_back(eFEXegvalue_tem[
"haveSeed"]);
211 m_eg_ET.push_back(eFEXegvalue_tem[
"ET"]);
212 m_eg_eta.push_back(eFEXegvalue_tem[
"eta"]);
213 m_eg_phi.push_back(eFEXegvalue_tem[
"phi"]);
214 m_em.push_back(eFEXegvalue_tem[
"em"]);
215 m_had.push_back(eFEXegvalue_tem[
"had"]);
217 return StatusCode::SUCCESS;
222 m_eg_TOB_Eta.clear();
223 m_eg_TOB_Phi.clear();
228 m_eg_TOB_UnD.clear();
229 m_eg_TOB_Max.clear();
230 m_eg_TOB_zeros.clear();
231 m_eg_TOB_energy.clear();
232 for (
int i = 0;
i < eFEXOutputCollectionobj->
size();
i++)
247 m_eg_TOB_FP.push_back(FP);
248 m_eg_TOB_Eta.push_back(
Eta);
249 m_eg_TOB_Phi.push_back(
Phi);
250 m_eg_TOB_ha.push_back(
ha);
251 m_eg_TOB_f3.push_back(
f3);
252 m_eg_TOB_Re.push_back(Re);
253 m_eg_TOB_Sd.push_back(Sd);
254 m_eg_TOB_UnD.push_back(UnD);
255 m_eg_TOB_Max.push_back(Max);
256 m_eg_TOB_zeros.push_back(
zeros);
257 m_eg_TOB_energy.push_back(
energy * 100);
260 return StatusCode::SUCCESS;
264 m_truth_e_eta.clear();
265 m_truth_e_phi.clear();
266 m_truth_e_ET.clear();
269 for(
auto ite : *truthEvents) {
270 int nParticle = ite->nTruthParticles();
271 for(
int i = 0;
i < nParticle;
i++){
279 if(std::abs(each_particle->
pdgId()) != 11)
continue;
281 if(!getMother(each_particle, 23))
continue;
283 m_truth_e_ET.push_back(each_particle->
p4().Pt());
284 m_truth_e_eta.push_back(each_particle->
p4().Eta());
285 m_truth_e_phi.push_back(each_particle->
p4().Phi());
288 return StatusCode::SUCCESS;
292 m_truth_jet_eta.clear();
293 m_truth_jet_phi.clear();
294 m_truth_jet_ET.clear();
296 StatusCode sc = evtStore()->retrieve( truth_jets, m_jet_container_name);
297 if (
sc == StatusCode::FAILURE){
298 m_jet_container_name =
"InTimeAntiKt4TruthJets";
299 StatusCode sc2 = evtStore()->retrieve( truth_jets, m_jet_container_name);
300 if (sc2 == StatusCode::FAILURE){
301 ATH_MSG_DEBUG(
"eFEXNtupleWriter::loadTruthJets() Unable to determine truth jet container");
302 m_load_truth_jet =
false;
303 return StatusCode::SUCCESS;
306 for (
unsigned i=0;
i!=truth_jets->
size();
i++) {
308 if(each_jet->
pt()<10000)
continue;
309 m_truth_jet_eta.push_back(each_jet->
p4().Eta());
310 m_truth_jet_phi.push_back(each_jet->
p4().Phi());
311 m_truth_jet_ET.push_back(each_jet->
p4().Et());
313 return StatusCode::SUCCESS;
317 m_truth_tauvisible_eta.clear();
318 m_truth_tauvisible_phi.clear();
319 m_truth_tauvisible_ET.clear();
322 for (
auto ite : *truthEvents) {
323 int nParticle = ite->nTruthParticles();
324 for(
int i = 0;
i < nParticle;
i++) {
331 if (std::abs(each_particle->
pdgId()) != 15)
continue;
332 std::unique_ptr<TLorentzVector> p4_visible = visibleTauP4(each_particle);
334 if (!p4_visible)
break;
335 m_truth_tauvisible_eta.push_back(p4_visible->Eta());
336 m_truth_tauvisible_phi.push_back(p4_visible->Phi());
337 m_truth_tauvisible_ET.push_back(p4_visible->Et());
340 return StatusCode::SUCCESS;
344 std::unique_ptr<TLorentzVector> psum(
new TLorentzVector(0,0,0,0));
355 int pid = std::abs(each_particle->
pdgId());
359 if (
pid == 12 ||
pid == 14 ||
pid == 16)
continue;
361 if (
pid == 11 ||
pid == 13)
return std::unique_ptr<TLorentzVector>(
nullptr);
362 (*psum) += each_particle->
p4();
365 std::unique_ptr<TLorentzVector> p4_tem = visibleTauP4(each_particle);
366 if (!p4_tem)
return std::unique_ptr<TLorentzVector>(
nullptr);
367 (*psum) += (*p4_tem);
374 std::unique_ptr<TLorentzVector> psum(
new TLorentzVector(0,0,0,0));
384 int pid = std::abs(each_particle->
pdgId());
388 if (
pid == 11 ||
pid == 13)
return std::unique_ptr<TLorentzVector>(
nullptr);
390 if (
pid == 12 ||
pid == 14 ||
pid == 16) (*psum) += each_particle->
p4();
393 std::unique_ptr<TLorentzVector> p4_tem = invisibleTauP4(each_particle);
394 if (!p4_tem)
return std::unique_ptr<TLorentzVector>(
nullptr);
395 (*psum) += (*p4_tem);
403 if (!productionVector)
return NULL;
406 if (mother->
pdgId()==motherPid)
return mother;
408 if (grandmother)
return grandmother;