ATLAS Offline Software
Loading...
Searching...
No Matches
SimHitHandle_SiHit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7// //
8// Implementation of class SimHitHandle_SiHit //
9// //
10// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11// Initial version: March 2008 //
12// //
14
16#include "VP1Base/VP1Msg.h"
17#include "VP1Utils/VP1DetInfo.h"
19
20#include "InDetSimEvent/SiHit.h"
27
28//____________________________________________________________________
30public:
31 Imp( const SiHit * h ) : thehit(h),detelem(nullptr) {}
32 const SiHit * thehit;
34 bool ensureDetElemInit() const;
35 Amg::Vector3D localToGlobal(const HepGeom::Point3D<double>&) const;
36};
37
38
39//____________________________________________________________________
41 : SimHitHandleBase(), m_d(new Imp(h))
42{
43 if (!h)
44 VP1Msg::message("SimHitHandle_SiHit constructor ERROR: Received null hit pointer");
45}
46
47//____________________________________________________________________
52
53//____________________________________________________________________
55{
56 if (detelem)
57 return true;
58 int Barrel = thehit->getBarrelEndcap();
59 //Not needed anymore and spoils stuff for slhc studies: if (Barrel== 1) Barrel = -2;//Found this hack in GeoSiHit.
60
61 if (thehit->isPixel()) {
63 thehit->getLayerDisk(),
64 thehit->getPhiModule(),
65 thehit->getEtaModule() );
66 //fixme: id is_valid ?
68 } else {
70 thehit->getLayerDisk(),
71 thehit->getPhiModule(),
72 thehit->getEtaModule(),
73 thehit->getSide() );
74 //fixme: id is_valid ?
76 }
77 //Fixme : Handle case where detelem can not be found gracefully. And check pointers from VP1DetInfo!!
78 if (!detelem)
79 VP1Msg::messageDebug("SimHitHandle_SiHit ERROR: Could not get detector element for hit!");
80 return detelem!=nullptr;
81}
82
83//____________________________________________________________________
84//Trk::GlobalMomentum SimHitHandle_SiHit::momentumDirection() const
86{
87 if (VP1Msg::verbose()&&m_d->thehit->localEndPosition()==m_d->thehit->localStartPosition())
88 VP1Msg::messageVerbose("SimHitHandle_SiHit::momentumDirection() ERROR: posStart()==posEnd()");
89 return (posEnd()-posStart()).unit();
90}
91
92//____________________________________________________________________
93Amg::Vector3D SimHitHandle_SiHit::Imp::localToGlobal( const HepGeom::Point3D<double>& local ) const
94{
95 if (!ensureDetElemInit())
96 return Amg::Vector3D(0,0,0);
97 return Amg::Vector3D(Amg::EigenTransformToCLHEP(detelem->transformHit()) * local);
98}
99
100//____________________________________________________________________
102{
103 return m_d->localToGlobal(m_d->thehit->localStartPosition());
104}
105
106//____________________________________________________________________
108{
109 return m_d->localToGlobal(m_d->thehit->localEndPosition());
110}
111
112//____________________________________________________________________
114{
115 return m_d->thehit->meanTime();
116}
117
118//____________________________________________________________________
120{
121 return m_d->thehit->particleLink();
122}
123
124//____________________________________________________________________
126{
127 //Find charge and magnitude of momentum:
128 double c;
129 if ( !hasCharge() ) {
130 bool ok;
132 if (!ok) {
133 VP1Msg::message("SimHitHandle_SiHit::createTrackParameters ERROR: Could not find particle charge (pdg="
134 +QString::number(pdg())+"). Assuming charge=+1.");
135 c = +1.0;
136 } else {
137 if (VP1Msg::verbose())
138 VP1Msg::messageVerbose("Looked up particle charge for silicon simhit with pdg code "+VP1Msg::str(pdg())+": "+VP1Msg::str(c));
139 }
140 const_cast<SimHitHandle_SiHit*>(this)->setCharge(c);
141 } else {
142 c = charge();
143 }
144
145 double mom = momentum();
146 if (mom<=0) {
147 VP1Msg::message("SimHitHandle_SiHit::createTrackParameters ERROR: Unknown momentum. Using 1 GeV");
148 mom = 1*CLHEP::GeV;
149 }
150
152 // if (!m_d->ensureDetElemInit()) {
153 // VP1Msg::messageDebug("SimHitHandle_SiHit WARNING: Could not get detector element!");
154 // return 0;
155 // }
156 // const Trk::PlaneSurface * surf
157 // = dynamic_cast<const Trk::PlaneSurface *>( &(m_d->detelem->surface()));
158 // if (!surf) {
159 // VP1Msg::message("SimHitHandle_SiHit::createTrackParameters ERROR: could not get Trk::PlaneSurface");
160 // return 0;
161 // }
165
166 const Amg::Vector3D globpos = posStart();
167
168// const Trk::GlobalMomentum u(momentumDirection());
170
171 return new Trk::Perigee(0, 0, u.phi(), u.theta(), c/mom, globpos);
172}
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
Header file for AthHistogramAlgorithm.
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Class to hold geometrical description of a silicon detector element.
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:360
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition SCT_ID.h:459
Definition SiHit.h:19
double charge() const
void setCharge(const double &c)
bool hasCharge() const
double momentum() const
const InDetDD::SiDetectorElement * detelem
Amg::Vector3D localToGlobal(const HepGeom::Point3D< double > &) const
const HepMcParticleLink & particleLink() const
Amg::Vector3D momentumDirection() const
SimHitHandle_SiHit(const SiHit *)
Amg::Vector3D posEnd() const
Trk::TrackParameters * createTrackParameters() const
Amg::Vector3D posStart() const
static const InDetDD::SCT_DetectorManager * sctDetMgr()
static const InDetDD::PixelDetectorManager * pixelDetMgr()
static const PixelID * pixelIDHelper()
static const SCT_ID * sctIDHelper()
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static bool verbose()
Definition VP1Msg.h:31
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static double particleCharge(const int &pdgcode, bool &ok)
static QString str(const QString &s)
Definition VP1String.h:49
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters