ATLAS Offline Software
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"
25 #include "InDetIdentifier/SCT_ID.h"
27 
28 //____________________________________________________________________
30 public:
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 //____________________________________________________________________
49 {
50  delete m_d;
51 }
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()) {
65  thehit->getEtaModule() );
66  //fixme: id is_valid ?
68  } else {
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 {
88  VP1Msg::messageVerbose("SimHitHandle_SiHit::momentumDirection() ERROR: posStart()==posEnd()");
89  return (posEnd()-posStart()).unit();
90 }
91 
92 //____________________________________________________________________
93 Amg::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 {
104 }
105 
106 //____________________________________________________________________
108 {
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 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
SimHitHandle_SiHit::Imp::ensureDetElemInit
bool ensureDetElemInit() const
Definition: SimHitHandle_SiHit.cxx:54
SimHitHandle_SiHit::Imp
Definition: SimHitHandle_SiHit.cxx:29
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SiHit::localEndPosition
HepGeom::Point3D< double > localEndPosition() const
Definition: SiHit.cxx:153
SiHit.h
VP1Msg.h
SiHit::getLayerDisk
int getLayerDisk() const
Definition: SiHit.cxx:164
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1DetInfo::pixelDetMgr
static const InDetDD::PixelDetectorManager * pixelDetMgr()
Definition: VP1DetInfo.cxx:145
SiHit::getPhiModule
int getPhiModule() const
Definition: SiHit.cxx:172
VP1DetInfo::pixelIDHelper
static const PixelID * pixelIDHelper()
Definition: VP1DetInfo.cxx:164
Trk::Perigee
ParametersT< 5, Charged, PerigeeSurface > Perigee
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:29
VP1ParticleData.h
SimHitHandle_SiHit::m_d
Imp * m_d
Definition: SimHitHandle_SiHit.h:45
SimHitHandle_SiHit::~SimHitHandle_SiHit
virtual ~SimHitHandle_SiHit()
Definition: SimHitHandle_SiHit.cxx:48
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
InDetDD::SCT_DetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Definition: SCT_DetectorManager.cxx:64
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
DetType::Barrel
@ Barrel
Definition: DetType.h:14
VP1TrackSanity.h
SiHit
Definition: SiHit.h:19
SiHit::meanTime
double meanTime() const
Definition: SiHit.h:180
VP1DetInfo.h
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
PixelDetectorManager.h
SimHitHandleBase::setCharge
void setCharge(const double &c)
Definition: SimHitHandleBase.h:57
SimHitHandle_SiHit::momentumDirection
Amg::Vector3D momentumDirection() const
Definition: SimHitHandle_SiHit.cxx:85
SimHitHandle_SiHit::Imp::thehit
const SiHit * thehit
Definition: SimHitHandle_SiHit.cxx:32
SiHit::getEtaModule
int getEtaModule() const
Definition: SiHit.cxx:168
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
SimHitHandle_SiHit.h
SimHitHandle_SiHit::Imp::Imp
Imp(const SiHit *h)
Definition: SimHitHandle_SiHit.cxx:31
VP1ParticleData::particleCharge
static double particleCharge(const int &pdgcode, bool &ok)
Definition: VP1ParticleData.cxx:104
SiHit::particleLink
const HepMcParticleLink & particleLink() const
Definition: SiHit.h:190
SimHitHandle_SiHit::particleLink
const HepMcParticleLink & particleLink() const
Definition: SimHitHandle_SiHit.cxx:119
SiHit::getBarrelEndcap
int getBarrelEndcap() const
Definition: SiHit.cxx:160
Trk::ParametersBase
Definition: ParametersBase.h:55
SimHitHandleBase::momentum
double momentum() const
Definition: SimHitHandleBase.h:41
InDetDD::local
@ local
Definition: InDetDD_Defs.h:16
SimHitHandle_SiHit::SimHitHandle_SiHit
SimHitHandle_SiHit(const SiHit *)
Definition: SimHitHandle_SiHit.cxx:40
SimHitHandle_SiHit
Definition: SimHitHandle_SiHit.h:26
python.selection.number
number
Definition: selection.py:20
SimHitHandle_SiHit::Imp::localToGlobal
Amg::Vector3D localToGlobal(const HepGeom::Point3D< double > &) const
Definition: SimHitHandle_SiHit.cxx:93
SiHit::getSide
int getSide() const
Definition: SiHit.cxx:176
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SimHitHandle_SiHit::posStart
Amg::Vector3D posStart() const
Definition: SimHitHandle_SiHit.cxx:101
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
VP1DetInfo::sctIDHelper
static const SCT_ID * sctIDHelper()
Definition: VP1DetInfo.cxx:165
SimHitHandleBase::pdg
int pdg() const
Definition: SimHitHandleBase.h:82
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
h
SiHit::isPixel
bool isPixel() const
Definition: SiHit.cxx:130
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
SimHitHandleBase::hasCharge
bool hasCharge() const
Definition: SimHitHandleBase.h:50
SimHitHandle_SiHit::posEnd
Amg::Vector3D posEnd() const
Definition: SimHitHandle_SiHit.cxx:107
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120
SimHitHandleBase
Definition: SimHitHandleBase.h:32
SimHitHandle_SiHit::hitTime
double hitTime() const
Definition: SimHitHandle_SiHit.cxx:113
SimHitHandleBase::charge
double charge() const
Definition: SimHitHandleBase.h:51
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
SimHitHandle_SiHit::Imp::detelem
const InDetDD::SiDetectorElement * detelem
Definition: SimHitHandle_SiHit.cxx:33
SCT_ID::wafer_id
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:464
SCT_DetectorManager.h
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
python.compressB64.c
def c
Definition: compressB64.py:93
SiHit::localStartPosition
HepGeom::Point3D< double > localStartPosition() const
Definition: SiHit.cxx:146
SimHitHandle_SiHit::createTrackParameters
Trk::TrackParameters * createTrackParameters() const
Definition: SimHitHandle_SiHit.cxx:125
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80
VP1DetInfo::sctDetMgr
static const InDetDD::SCT_DetectorManager * sctDetMgr()
Definition: VP1DetInfo.cxx:146