ATLAS Offline Software
LArTBH6TriggerTimeTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  IIncidentSvc* incsvc;
29  if (StatusCode::SUCCESS!=service("IncidentSvc",incsvc))
30  {
31  ATH_MSG_FATAL ( "Incident service not found" );
32  return StatusCode::FAILURE ;
33  }
34 
35  long int pri=100;
36  incsvc->addListener(this,"BeginEvent",pri);
37 
38  ATH_MSG_DEBUG ( " LArTBH6TriggerTimeTool initialized " );
39 
40  return StatusCode::SUCCESS;
41 
42 }
43 
44 
45 void LArTBH6TriggerTimeTool::handle(const Incident& incident){
46 
47  ATH_MSG_DEBUG ( " handle called " << "for incident "<< incident. type() );
48 
49  m_newEvent = true ;
50  return ;
51 }
52 
54 
55  if(m_fixed || !m_newEvent) return m_time;
56 
57  // new event, try to get it from FrontHit
58  // double t1 = trackRecordTime();
59  m_time = larTime() ;
60 
61  m_newEvent= false;
62  return m_time;
63 }
64 
65 
67 
68  double te = 0;
69  double e = 0;
70  int n=0;
71 
72  for(auto &it : m_hitcoll){
73 
74  for(const LArHit* hit : *it){
75  e += hit->energy();
76  te += hit->energy() * hit->time() ;
77  ++n;
78  }
79  }
80 
81  if(n==0){
82  ATH_MSG_INFO ( " no LArHit in this event" );
83  return 0 ;
84  }
85  if(e==0){
86  ATH_MSG_INFO ( " no LArHit energy in this event" );
87  return 0;
88  }
89 
90  double t = te/e;
91  ATH_MSG_DEBUG ( " average time from LArHit = " <<t );
92 
93  return t;
94 
95 
96 }
LArTBH6TriggerTimeTool::time
virtual double time()
returns the time offset of the current trigger
Definition: LArTBH6TriggerTimeTool.cxx:53
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: LArG4/LArG4H6SD/src/LArTBH6TriggerTimeTool.h:38
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LArTBH6TriggerTimeTool::larTime
double larTime()
Definition: LArTBH6TriggerTimeTool.cxx:66
LArTBH6TriggerTimeTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LArTBH6TriggerTimeTool::m_fixed
bool m_fixed
Definition: LArG4/LArG4H6SD/src/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: LArG4/LArG4H6SD/src/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:195
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
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
LArHitContainer.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
LArTBH6TriggerTimeTool::handle
virtual void handle(const Incident &incident)
Definition: LArTBH6TriggerTimeTool.cxx:45
LArTBH6TriggerTimeTool::m_hitcoll
std::vector< SG::ReadHandle< LArHitContainer > > m_hitcoll
Definition: LArG4/LArG4H6SD/src/LArTBH6TriggerTimeTool.h:42