ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Commission
CommissionRec
src
CosTriggerTimeAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CosTriggerTimeAlg.h
"
6
7
StatusCode
CosTriggerTimeAlg::initialize
(){
8
ATH_CHECK
(
m_larHitKeys
.initialize());
9
ATH_CHECK
(
m_timeKey
.initialize());
10
return
StatusCode::SUCCESS;
11
}
12
13
14
StatusCode
CosTriggerTimeAlg::execute
(
const
EventContext& ctx)
const
{
15
16
double
te = 0;
17
double
e = 0;
18
int
n=0;
19
20
SG::WriteHandle<CosTrigTime>
out(
m_timeKey
,ctx);
21
22
for
(
auto
& key :
m_larHitKeys
) {
23
SG::ReadHandle<LArHitContainer>
hits(key,ctx);
24
if
(!hits.isValid())
return
StatusCode::FAILURE;
25
26
for
(
const
LArHit
*
hit
: *hits) {
27
e +=
hit
->energy();
28
te +=
hit
->energy() *
hit
->time() ;
29
++n;
30
}
31
}
32
33
double
t=0;
34
if
(n==0) {
35
ATH_MSG_INFO
(
"no LArHit in this event"
);
36
}
37
if
(e==0) {
38
ATH_MSG_INFO
(
"no LArHit energy in this event"
);
39
}
40
else
{
41
t = te/e;
42
ATH_MSG_DEBUG
(
"average time from LArHit = "
<<t );
43
}
44
auto
cosTime=std::make_unique<CosTrigTime>(t);
45
ATH_CHECK
(out.record(std::move(cosTime)));
46
47
return
StatusCode::SUCCESS;
48
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CosTriggerTimeAlg.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
CosTriggerTimeAlg::initialize
virtual StatusCode initialize()
Definition
CosTriggerTimeAlg.cxx:7
CosTriggerTimeAlg::m_timeKey
SG::WriteHandleKey< CosTrigTime > m_timeKey
Definition
CosTriggerTimeAlg.h:27
CosTriggerTimeAlg::m_larHitKeys
SG::ReadHandleKeyArray< LArHitContainer > m_larHitKeys
Definition
CosTriggerTimeAlg.h:26
CosTriggerTimeAlg::execute
virtual StatusCode execute(const EventContext &cxt) const
Definition
CosTriggerTimeAlg.cxx:14
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition
LArHit.h:25
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
Generated on
for ATLAS Offline Software by
1.17.0