27 std::atomic<int> instanceCounter(0);
28 thread_local
int localInstance = 0;
29 thread_local
MagVolume const* lastVolume =
nullptr;
33 const std::vector<MagBLayer*>& tbl,
34 const std::vector<MagESector*>& tes,
35 const std::vector<MagVolume6Faces*>& tbv,
36 const std::vector<MagVolume6Faces*>& tev)
44 const std::vector<MagBLayer const*>& tbl,
45 const std::vector<MagESector const*>& tes,
46 const std::vector<MagVolume6Faces const*>& tbv,
47 const std::vector<MagVolume6Faces const*>& tev)
48 : me_(++instanceCounter),
53 cacheLastVolume(
true),
55 vector<double> rBorders;
57 for (vector<MagBLayer const*>::const_iterator ilay =
theBLayers.begin(); ilay !=
theBLayers.end(); ++ilay) {
58 LogTrace(
"MagGeoBuilder") <<
" Barrel layer at " << (*ilay)->minR() << endl;
60 rBorders.push_back((*ilay)->minR() * (*ilay)->minR());
66 for (vector<MagESector const*>::const_iterator isec =
theESectors.begin(); isec !=
theESectors.end(); ++isec) {
67 LogTrace(
"MagGeoBuilder") <<
" Endcap sector at " << (*isec)->minPhi() << endl;
79 switch (geomVersion >= 120812 ? 0 : (geomVersion >= 90812 ? 1 : 2)) {
103 LogTrace(
"MagGeometry_cache") <<
"*** In MagGeometry ctor: me_=" <<
me_ <<
" instanceCounter=" << instanceCounter
113 for (vector<MagBLayer const*>::const_iterator ilay =
theBLayers.begin(); ilay !=
theBLayers.end(); ++ilay) {
117 for (vector<MagESector const*>::const_iterator ilay =
theESectors.begin(); ilay !=
theESectors.end(); ++ilay) {
128 return v->fieldInTesla(
gp);
134 LogWarning(
"MagneticField") <<
"Input value invalid (not a number): " <<
gp << endl;
137 LogWarning(
"MagneticField") <<
"MagGeometry::fieldInTesla: failed to find volume for " <<
gp << endl;
149 if ((*
v) ==
nullptr) {
150 LogError(
"MagGeometry") << endl <<
"***ERROR: MagGeometry::findVolume: MagVolume for barrel not set" << endl;
165 if ((*
v) ==
nullptr) {
166 LogError(
"MagGeometry") << endl <<
"***ERROR: MagGeometry::findVolume: MagVolume for endcap not set" << endl;
186 if (
me_ != localInstance) {
187 LogTrace(
"MagGeometry_cache") <<
"*** In MagGeometry::findVolume resetting cache: me=" <<
me_
188 <<
" localInstance=" << localInstance << endl;
190 lastVolume =
nullptr;
193 if (lastVolume !=
nullptr && lastVolume->inside(
gp)) {
199 double aRsq =
gp.perp2();
203 for (
int bin1 =
bin; bin1 >=
max(0,
bin - 3); --bin1) {
206 LogTrace(
"MagGeometry") <<
"***In blayer " << bin1 -
bin <<
" " << (
result ==
nullptr ?
" failed " :
" OK ")
218 LogTrace(
"MagGeometry") <<
"***In guessed esector " << (
result ==
nullptr ?
" failed " :
" OK ") << endl;
227 LogTrace(
"MagGeometry") <<
"Increasing the tolerance to 0.03" << endl;
238 double aZ = fabs(
gp.z());
239 double aRsq =
gp.perp2();