ATLAS Offline Software
LArTBH6TriggerTimeTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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), m_time(0), m_newEvent(true),
14  m_fixed(true)
15 {
16  declareProperty("isFixed",m_fixed);
17  declareProperty("FixedTime",m_time);
18 
19  m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitEMEC") );
20  m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitHEC") );
21  m_hitcoll.push_back( SG::ReadHandle< LArHitContainer >("LArHitFCAL") );
22 }
23 
24 
26 {
27 
28  SmartIF<IIncidentSvc> incsvc{Gaudi::svcLocator()->service("IncidentSvc")};
29  if (!incsvc) {
30  ATH_MSG_FATAL ( "Incident service not found" );
31  return StatusCode::FAILURE ;
32  }
33 
34  long int pri=100;
35  incsvc->addListener(this,"BeginEvent",pri);
36 
37  ATH_MSG_DEBUG ( " LArTBH6TriggerTimeTool initialized " );
38 
39  return StatusCode::SUCCESS;
40 
41 }
42 
43 
44 void LArTBH6TriggerTimeTool::handle(const Incident& incident){
45 
46  ATH_MSG_DEBUG ( " handle called " << "for incident "<< incident. type() );
47 
48  m_newEvent = true ;
49  return ;
50 }
51 
53 
54  if(m_fixed || !m_newEvent) return m_time;
55 
56  // new event, try to get it from FrontHit
57  // double t1 = trackRecordTime();
58  m_time = larTime() ;
59 
60  m_newEvent= false;
61  return m_time;
62 }
63 
64 
66 
67  double te = 0;
68  double e = 0;
69  int n=0;
70 
71  for(auto &it : m_hitcoll){
72 
73  for(const LArHit* hit : *it){
74  e += hit->energy();
75  te += hit->energy() * hit->time() ;
76  ++n;
77  }
78  }
79 
80  if(n==0){
81  ATH_MSG_INFO ( " no LArHit in this event" );
82  return 0 ;
83  }
84  if(e==0){
85  ATH_MSG_INFO ( " no LArHit energy in this event" );
86  return 0;
87  }
88 
89  double t = te/e;
90  ATH_MSG_DEBUG ( " average time from LArHit = " <<t );
91 
92  return t;
93 
94 
95 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
LArTBH6TriggerTimeTool.h
LArTBH6TriggerTimeTool::time
virtual double time()
returns the time offset of the current trigger
Definition: LArTBH6TriggerTimeTool.cxx:52
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle< LArHitContainer >
LArTBH6TriggerTimeTool::m_time
double m_time
Definition: LArTBH6TriggerTimeTool.h:38
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArTBH6TriggerTimeTool::larTime
double larTime()
Definition: LArTBH6TriggerTimeTool.cxx:65
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LArTBH6TriggerTimeTool::m_fixed
bool m_fixed
Definition: LArTBH6TriggerTimeTool.h:40
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LArTBH6TriggerTimeTool::m_newEvent
bool m_newEvent
Definition: LArTBH6TriggerTimeTool.h:39
LArTBH6TriggerTimeTool::LArTBH6TriggerTimeTool
LArTBH6TriggerTimeTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArTBH6TriggerTimeTool.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArTBH6TriggerTimeTool::initialize
virtual StatusCode initialize()
Definition: LArTBH6TriggerTimeTool.cxx:25
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
LArHitContainer.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArTBH6TriggerTimeTool::handle
virtual void handle(const Incident &incident)
Definition: LArTBH6TriggerTimeTool.cxx:44
LArTBH6TriggerTimeTool::m_hitcoll
std::vector< SG::ReadHandle< LArHitContainer > > m_hitcoll
Definition: LArTBH6TriggerTimeTool.h:42