ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CosmicTriggerTimeTool Class Reference

#include <CosmicTriggerTimeTool.h>

Inheritance diagram for CosmicTriggerTimeTool:
Collaboration diagram for CosmicTriggerTimeTool:

Public Member Functions

 CosmicTriggerTimeTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode initialize () override
 
virtual ~CosmicTriggerTimeTool ()
 
virtual double time () override
 returns the time offset of the current trigger More...
 
virtual void handle (const Incident &incident) override
 
double larTime ()
 
double trackRecordTime ()
 
void setComTime (const ComTime *comTime)
 

Private Attributes

double m_time
 
bool m_newEvent
 
const ComTimem_comTime
 
bool m_useLArTime
 

Detailed Description

Definition at line 14 of file CosmicTriggerTimeTool.h.

Constructor & Destructor Documentation

◆ CosmicTriggerTimeTool()

CosmicTriggerTimeTool::CosmicTriggerTimeTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 16 of file CosmicTriggerTimeTool.cxx.

18  :
19  base_class(type,name,parent), m_time(0), m_newEvent(true),
20  m_comTime(0) , m_useLArTime(false)
21 {
22 
23  declareProperty("UseLArTime", m_useLArTime);
24 
25 }

◆ ~CosmicTriggerTimeTool()

virtual CosmicTriggerTimeTool::~CosmicTriggerTimeTool ( )
inlinevirtual

Definition at line 25 of file CosmicTriggerTimeTool.h.

25 {}

Member Function Documentation

◆ handle()

void CosmicTriggerTimeTool::handle ( const Incident &  incident)
overridevirtual

Definition at line 44 of file CosmicTriggerTimeTool.cxx.

45 {
46 
47  ATH_MSG_DEBUG( "handle called" );
48 
49  m_newEvent = true ;
50  m_comTime = 0 ;
51  return ;
52 }

◆ initialize()

StatusCode CosmicTriggerTimeTool::initialize ( )
overridevirtual

Definition at line 28 of file CosmicTriggerTimeTool.cxx.

29 {
30 
31  ServiceHandle<IIncidentSvc> incsvc("IncidentSvc", name());
32  CHECK( incsvc.retrieve() );
33 
34  long int pri=100;
35  incsvc->addListener(this,"BeginEvent",pri);
36 
37  ATH_MSG_DEBUG( "CosmicTriggerTimeTool initialized" );
38 
39  return StatusCode::SUCCESS;
40 
41 }

◆ larTime()

double CosmicTriggerTimeTool::larTime ( )

Definition at line 124 of file CosmicTriggerTimeTool.cxx.

125 {
126 
127  std::vector<std::string> keys ;
128  keys.push_back("LArHitEMB") ;
129  keys.push_back("LArHitEMEC") ;
130  keys.push_back("LArHitHEC") ;
131  keys.push_back("LArHitFCAL") ;
132 
133  std::vector<std::string>::const_iterator it = keys.begin() ;
134  std::vector<std::string>::const_iterator it_e = keys.end() ;
135  double te = 0;
136  double e = 0;
137  int n=0;
138 
139  for (;it!=it_e;++it) {
140  const LArHitContainer* cont;
141 
142  CHECK( evtStore()->retrieve(cont,(*it)), 0 );
143 
144  LArHitContainer::const_iterator hit_it = cont->begin();
145  LArHitContainer::const_iterator hit_it_e = cont->end();
146  for (;hit_it!=hit_it_e;++hit_it) {
147  const LArHit * hit = (*hit_it);
148  e += hit->energy();
149  te += hit->energy() * hit->time() ;
150  ++n;
151  }
152  }
153 
154  if (n==0) {
155  ATH_MSG_INFO( "no LArHit in this event" );
156  return 0;
157  }
158  if (e==0) {
159  ATH_MSG_INFO( "no LArHit energy in this event" );
160  return 0;
161  }
162 
163  double t = te/e;
164  ATH_MSG_DEBUG( "average time from LArHit = " <<t );
165 
166  return t;
167 }

◆ setComTime()

void CosmicTriggerTimeTool::setComTime ( const ComTime comTime)
inline

Definition at line 35 of file CosmicTriggerTimeTool.h.

36  {
37  m_comTime = comTime;
38  return;
39  }

◆ time()

double CosmicTriggerTimeTool::time ( )
overridevirtual

returns the time offset of the current trigger

Definition at line 96 of file CosmicTriggerTimeTool.cxx.

97 {
98 
99  if (!m_newEvent) return m_time;
100 
101  // new event, try to get it from LArTime
102  if (m_useLArTime) {
103  // double t1 = trackRecordTime();
104  m_time = larTime() ;
105  }
106  else if ( m_comTime ) {
107  m_time = m_comTime->getTime() ;
108  ATH_MSG_DEBUG( "got time from ComTime "<< m_time );
109  }
110  else if ( StatusCode::SUCCESS == evtStore()->retrieve(m_comTime) ) {
111  m_time = m_comTime->getTime() ;
112  ATH_MSG_DEBUG( "retrieved ComTime, t= "<< m_time );
113  }
114  else {
115  // double t1 = trackRecordTime();
116  m_time = larTime() ;
117  }
118 
119  m_newEvent= false;
120  return m_time;
121 }

◆ trackRecordTime()

double CosmicTriggerTimeTool::trackRecordTime ( )

Definition at line 55 of file CosmicTriggerTimeTool.cxx.

56 {
57 
58  // const TimedTrackRecordCollection* coll;
59  const TrackRecordCollection* coll = nullptr;
60  StatusCode sc = evtStore()->retrieve(coll,"CaloMuonRecorder");
61  if (sc!=StatusCode::SUCCESS) {
62  ATH_MSG_ERROR( "can not retrieve CaloMuonRecorder" );
63  return 0;
64  }
65 
66  int n = coll->size() ;
67 
68  if ( 0 == n ) {
69  ATH_MSG_WARNING( "size of CaloMuonRecorder == 0" );
70  return 0;
71  }
72 
73  double t = 0;
74  for (auto it : *coll) {
75  // TimedTrackRecord * r = const_cast<TimedTrackRecord*>( *it );
76  CLHEP::Hep3Vector pos = it.GetPosition();
77  CLHEP::Hep3Vector p = it.GetMomentum();
78  // ATH_MSG_DEBUG( "TimedTrackRecord xyz position " <<pos.x()<<" "
79  ATH_MSG_DEBUG( "TrackRecord xyz position " <<pos.x()<<" "
80  << pos.y() << " " << pos.z() );
81  ATH_MSG_DEBUG( " momentum " <<p.x() << " "
82  << p.y() << " " << p.z() );
83  ATH_MSG_DEBUG( " time " << it.GetTime() );
84  t += it.GetTime() ;
85  }
86 
87  t = t/n ;
88 
89  ATH_MSG_DEBUG( "Average time from track record = " << t );
90 
91  return t ;
92 
93 }

Member Data Documentation

◆ m_comTime

const ComTime* CosmicTriggerTimeTool::m_comTime
private

Definition at line 45 of file CosmicTriggerTimeTool.h.

◆ m_newEvent

bool CosmicTriggerTimeTool::m_newEvent
private

Definition at line 44 of file CosmicTriggerTimeTool.h.

◆ m_time

double CosmicTriggerTimeTool::m_time
private

Definition at line 43 of file CosmicTriggerTimeTool.h.

◆ m_useLArTime

bool CosmicTriggerTimeTool::m_useLArTime
private

Definition at line 46 of file CosmicTriggerTimeTool.h.


The documentation for this class was generated from the following files:
CosmicTriggerTimeTool::m_newEvent
bool m_newEvent
Definition: CosmicTriggerTimeTool.h:44
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ComTime::getTime
double getTime() const
Definition: ComTime.h:44
AtlasHitsVector
Definition: AtlasHitsVector.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CosmicTriggerTimeTool::larTime
double larTime()
Definition: CosmicTriggerTimeTool.cxx:124
LArHit::energy
double energy() const
Definition: LArHit.h:113
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
CosmicTriggerTimeTool::m_useLArTime
bool m_useLArTime
Definition: CosmicTriggerTimeTool.h:46
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthenaHitsVector< LArHit >::const_iterator
boost::transform_iterator< make_const, typename CONT::const_iterator > const_iterator
Definition: AthenaHitsVector.h:58
CosmicTriggerTimeTool::m_time
double m_time
Definition: CosmicTriggerTimeTool.h:43
CosmicTriggerTimeTool::m_comTime
const ComTime * m_comTime
Definition: CosmicTriggerTimeTool.h:45
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
LArHit::time
double time() const
Definition: LArHit.h:118
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
AthenaHitsVector::end
const_iterator end() const
Definition: AthenaHitsVector.h:143
AthenaHitsVector::begin
const_iterator begin() const
Definition: AthenaHitsVector.h:139
ServiceHandle< IIncidentSvc >