ATLAS Offline Software
Loading...
Searching...
No Matches
CBNTAA_TBScint.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#include "CBNTAA_TBScint.h"
6
8#include <fstream>
9#include <string>
11
12
13CBNTAA_TBScint::CBNTAA_TBScint(const std::string & name, ISvcLocator * pSvcLocator) : CBNT_TBRecBase(name, pSvcLocator),m_scint_num(0),m_scint_en(0),m_scint_trackid(0),m_scint_pdg(0) {
14}
15
17 ATH_MSG_DEBUG ( "in initialize()" );
18
19 // Add scint parameters
20 addBranch("bm_scint_num", m_scint_num);
21 addBranch("bm_scint_en", m_scint_en);
22 addBranch("bm_scint_trackid", m_scint_trackid);
23 addBranch("bm_scint_pdg", m_scint_pdg);
24
25 return StatusCode::SUCCESS;
26}
27
29 ATH_MSG_DEBUG ( "in execute()" );
30
31 double edep;
32 int scnum, pcode, trid;
33 unsigned i;
34
35 // Get scint. hits
36 const LArG4H6FrontHitCollection *frontcoll = nullptr;
37 const LArG4H6FrontHitCollection *movecoll = nullptr;
38 StatusCode sc = evtStore()->retrieve(frontcoll,"Front::Hits");
39 if (sc.isSuccess()){
40 for (const LArG4H6FrontHit* hit : *frontcoll) {
41 scnum = hit->GetSC();
42 if(scnum <= 0) continue; // not a scintilator hit
43 edep = hit->GetEdep();
44 pcode = hit->GetPcode();
45 trid = hit->GetTrackID();
46 // Check if we have already such combination
47 for(i=0; i<m_scint_num->size(); ++i){
48 if( (scnum == (*m_scint_num)[i]) && (pcode == (*m_scint_pdg)[i]) &&
49 (trid == (*m_scint_trackid)[i]) ) { //add energy
50
51 (*m_scint_en)[i] += edep;
52 break;
53 }
54 }
55 if(i == m_scint_num->size()) { // new combination
56 m_scint_num->push_back(scnum);
57 m_scint_pdg->push_back(pcode);
58 m_scint_trackid->push_back(trid);
59 m_scint_en->push_back(edep);
60 }
61 }
62 } else {
63 ATH_MSG_WARNING ( "Retrieval of Front Hits failed..." );
64 return StatusCode::FAILURE;
65 }
66
67 sc = evtStore()->retrieve(movecoll,"Movable::Hits");
68 if (sc.isSuccess()){
69 for (const LArG4H6FrontHit* hit : *movecoll) {
70 scnum = hit->GetSC();
71 if(scnum <= 0) continue; // not a scintilator hit
72 edep = hit->GetEdep();
73 pcode = hit->GetPcode();
74 trid = hit->GetTrackID();
75 // Check if we have already such combination
76 for(i=0; i<m_scint_num->size(); ++i){
77 if( (scnum == (*m_scint_num)[i]) && (pcode == (*m_scint_pdg)[i]) &&
78 (trid == (*m_scint_trackid)[i]) ) { //add energy
79
80 (*m_scint_en)[i] += edep;
81 break;
82 }
83 }
84 if(i == m_scint_num->size()) { // new combination
85 m_scint_num->push_back(scnum);
86 m_scint_pdg->push_back(pcode);
87 m_scint_trackid->push_back(trid);
88 m_scint_en->push_back(edep);
89 }
90 }
91 } else {
92 ATH_MSG_WARNING ( "Retrieval of Movable Hits failed" );
93 }
94
95 return StatusCode::SUCCESS;
96}
97
99 ATH_MSG_DEBUG ( "in finalize()" );
100 return StatusCode::SUCCESS;
101}
102
103
105{
106 if(m_scint_num) m_scint_num->clear();
107 if(m_scint_en) m_scint_en->clear();
108 if(m_scint_trackid) m_scint_trackid->clear();
109 if(m_scint_pdg) m_scint_pdg->clear();
110 return StatusCode::SUCCESS;
111}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthenaHitsVector< LArG4H6FrontHit > LArG4H6FrontHitCollection
static Double_t sc
std::vector< int > * m_scint_trackid
virtual StatusCode CBNT_initialize() override
virtual StatusCode CBNT_execute() override
CBNTAA_TBScint(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< int > * m_scint_pdg
virtual StatusCode CBNT_finalize() override
std::vector< float > * m_scint_en
virtual StatusCode CBNT_clear() override
std::vector< int > * m_scint_num
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
CBNT_TBRecBase(const std::string &name, ISvcLocator *pSvcLocator)