ATLAS Offline Software
Loading...
Searching...
No Matches
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
8 ATH_CHECK(m_larHitKeys.initialize());
9 ATH_CHECK(m_timeKey.initialize());
10 return StatusCode::SUCCESS;
11}
12
13
14StatusCode CosTriggerTimeAlg::execute(const EventContext& ctx) const {
15
16 double te = 0;
17 double e = 0;
18 int n=0;
19
21
22 for (auto& key : m_larHitKeys) {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
virtual StatusCode initialize()
SG::WriteHandleKey< CosTrigTime > m_timeKey
SG::ReadHandleKeyArray< LArHitContainer > m_larHitKeys
virtual StatusCode execute(const EventContext &cxt) const
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25