66{
67
69
70
71 if(
m_mode ==
"TTRCavern" ) {
72
73
74
77
78 ComTime *theComTime = new ComTime();
80 return StatusCode::SUCCESS;
81 }
82
85 int nMuons = 0;
86 double earliestMuonTime = -1.;
87 const TrackRecord *earliestMuon=nullptr;
88
89 for(
const TrackRecord&
r : *coll) {
90
91 if(abs(
r.GetPDGCode()) == 13 ) {
92 nMuons++;
93 if( (nMuons==1) or (
r.GetTime() < earliestMuonTime) ) {
95 earliestMuonTime =
r.GetTime();
96 }
97 }
98 }
99
100 if( nMuons>=1 ) {
104
105 CLHEP::Hep3Vector cosThetaDir = CLHEP::Hep3Vector(
mom.x()/energy,
mom.y()/energy,
mom.z()/energy);
106
108
110 <<
pos.y() <<
" " <<
pos.z() );
112 << cosThetaDir.y() << " " << cosThetaDir.z() );
114
115
116
117
118
119
120
121 double PathCritical;
122 CLHEP::Hep3Vector PointCritical;
123
125 double dXdY = cosThetaDir.x()/cosThetaDir.y();
126 double dZdY = cosThetaDir.z()/cosThetaDir.y();
127
128 double XCritical =
pos.x()-dXdY*
pos.y();
129 double YCritical = 0.0;
130 double ZCritical =
pos.z()-dZdY*
pos.y();
131
132 PointCritical = CLHEP::Hep3Vector(XCritical,YCritical,ZCritical);
133
134 PathCritical = sqrt(
pow(XCritical-
pos.x(),2) +
pow(YCritical-
pos.y(),2) +
135 pow(ZCritical-
pos.z(),2));
136 if( (YCritical-
pos.y())*cosThetaDir.y() < 0 ) {
137 ATH_MSG_WARNING(
"Backwards extrapolation?? pos.y(),cosThetaDir.y() = "
138 <<
pos.y()<<
"," << cosThetaDir.y() );
139 PathCritical = -1.0 * PathCritical;
140 }
141 }
143 double dXdZ = cosThetaDir.x()/cosThetaDir.z();
144 double dYdZ = cosThetaDir.y()/cosThetaDir.z();
145
146 double XCritical =
pos.x()-dXdZ*
pos.z();
147 double YCritical =
pos.y()-dYdZ*
pos.z();
148 double ZCritical = 0.0;
149
150 PointCritical = CLHEP::Hep3Vector(XCritical,YCritical,ZCritical);
151
152 PathCritical = sqrt(
pow(XCritical-
pos.x(),2) +
pow(YCritical-
pos.y(),2) +
153 pow(ZCritical-
pos.z(),2));
154 if( (ZCritical-
pos.z())*cosThetaDir.z() < 0 ) {
155 ATH_MSG_WARNING(
"Backwards extrapolation?? pos.z(),cosThetaDir.z() = "
156 <<
pos.z()<<
"," << cosThetaDir.z() );
157 PathCritical = -1.0 * PathCritical;
158 }
159 }
161
162 PathCritical = -1.*(
pos.x()*cosThetaDir.x() +
pos.y()*cosThetaDir.y() +
163 pos.z()*cosThetaDir.z());
164 PointCritical = CLHEP::Hep3Vector(
pos.x() + PathCritical*cosThetaDir.x(),
165 pos.y() + PathCritical*cosThetaDir.y(),
166 pos.z() + PathCritical*cosThetaDir.z());
167 }
168 else {
170 return StatusCode::FAILURE;
171 }
172
175
176 ATH_MSG_DEBUG(
" Extrapolated muon xyz position " << PointCritical.x()<<
" "
177 << PointCritical.y()<<" " << PointCritical.z());
181
182 ComTime* theComTime = new ComTime(TTCTime,TimeCritical,PointCritical,cosThetaDir);
184
186
187 } else {
189 ComTime *theComTime = new ComTime();
191 }
192 }
else if(
m_mode ==
"CollisionMode" ) {
193
194
195 ComTime *theComTime = new ComTime();
197 return StatusCode::SUCCESS;
198 } else {
200 return StatusCode::SUCCESS;
201 }
202 return StatusCode::SUCCESS;
203}
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AtlasHitsVector< TrackRecord > TrackRecordCollection
constexpr int pow(int base, int exp) noexcept
ServiceHandle< StoreGateSvc > & evtStore()
CLHEP::Hep3Vector GetPosition() const
Position.
CLHEP::Hep3Vector GetMomentum() const
Momentum.
double GetTime() const
Time.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
time(flags, cells_name, *args, **kw)
retrieve(aClass, aKey=None)