ATLAS Offline Software
Loading...
Searching...
No Matches
LArTBH6TriggerTimeTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/IIncidentSvc.h"
7
9
11 const std::string& name,
12 const IInterface* parent) :
13 base_class(type,name,parent)
14{
15 m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitEMEC") );
16 m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitHEC") );
17 m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitFCAL") );
18}
19
20
22{
23
24 SmartIF<IIncidentSvc> incsvc{Gaudi::svcLocator()->service("IncidentSvc")};
25 if (!incsvc) {
26 ATH_MSG_FATAL ( "Incident service not found" );
27 return StatusCode::FAILURE ;
28 }
29
30 long int pri=100;
31 incsvc->addListener(this,"BeginEvent",pri);
32
33 ATH_MSG_DEBUG ( " LArTBH6TriggerTimeTool initialized " );
34
35 return StatusCode::SUCCESS;
36
37}
38
39
40void LArTBH6TriggerTimeTool::handle(const Incident& incident){
41
42 ATH_MSG_DEBUG ( " handle called " << "for incident "<< incident. type() );
43
44 m_newEvent = true ;
45 return ;
46}
47
49
50 if(m_fixed || !m_newEvent) return m_time;
51
52 // new event, try to get it from FrontHit
53 // double t1 = trackRecordTime();
54 m_time = larTime() ;
55
56 m_newEvent= false;
57 return m_time;
58}
59
60
62
63 double te = 0;
64 double e = 0;
65 int n=0;
66
67 for(auto &it : m_hitcoll){
68
69 for(const LArHit* hit : *it){
70 e += hit->energy();
71 te += hit->energy() * hit->time() ;
72 ++n;
73 }
74 }
75
76 if(n==0){
77 ATH_MSG_INFO ( " no LArHit in this event" );
78 return 0 ;
79 }
80 if(e==0){
81 ATH_MSG_INFO ( " no LArHit energy in this event" );
82 return 0;
83 }
84
85 double t = te/e;
86 ATH_MSG_DEBUG ( " average time from LArHit = " <<t );
87
88 return t;
89
90
91}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
virtual void handle(const Incident &incident) override
virtual double time() override
returns the time offset of the current trigger
Gaudi::Property< double > m_time
LArTBH6TriggerTimeTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< bool > m_fixed
std::vector< SG::ReadHandle< LArHitContainer > > m_hitcoll
virtual StatusCode initialize() override