53 os << d.stid<<
'>' <<d.lid <<
'|'<<d.zi<<
'/'<<d.zo<<
':'<<d.uerr<<
'/'<<d.verr;
65 desc.
add<
std::string>(
"navigationSchool",
"SimpleNavigationSchool");
66 descriptions.
add(
"TkMSParameterizationBuilder",desc);
69 using ReturnType = std::shared_ptr<TkMSParameterization>;
77 theNavigationSchoolName(pset.getParameter<
std::
string>(
"navigationSchool")){
86 product = std::make_shared<TkMSParameterization>();
95 auto const & magfield = navSchool.
field();
100 auto const & ANprop = *propagatorHandle;
104 ROOT::Math::SMatrixIdentity
id;
122 auto sinth2 = 1.f/(1.f+tanlmd*tanlmd);
124 auto overp = sinth/
pt;
128 if(debug)
std::cout << tl <<
' ' << pz <<
' ' << 1./overp << std::endl;
134 for (
int iz=0;iz<2; ++iz) {
136 for (
float zz=lastzz;
zz<18.1f;
zz+=0.2f) {
145 std::function<void(int, TrajectoryStateOnSurface, DetLayer const *, float, int)>
148 for (
auto il=from+1; il<
maxLayers; ++il) {
151 std::stable_sort(compLayers.begin(),compLayers.end(),[](
auto a,
auto b){
return a->seqNum()<
b->seqNum();});
153 for(
auto it : compLayers){
154 if (it->basicComponents().empty()) {
156 edm::LogError(
"TkMSParameterizationBuilder") <<
"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate.";
159 if (debug)
std::cout << il << (it->isBarrel() ?
" Barrel" :
" Forward") <<
" layer " << it->seqNum() <<
" SubDet " << it->subDetector()<< std::endl;
160 auto const & detWithState = it->compatibleDets(tsos,ANprop,estimator);
161 if(detWithState.empty()) {
162 if(debug)
std::cout <<
"no det on this layer" << it->seqNum() << std::endl;
166 auto did = detWithState.front().first->geographicalId();
167 if (debug)
std::cout <<
"arrived at " <<
int(did) << std::endl;
168 tsos = detWithState.front().second;
169 if(debug)
std::cout << tsos.globalPosition() <<
' ' << tsos.localError().positionError() << std::endl;
174 auto gp = tsos.globalPosition();
176 float errorPhi =
std::sqrt(
float(globalError.phierr(gp)));
177 float errorR =
std::sqrt(
float(globalError.rerr(gp)));
178 float errorZ =
std::sqrt(
float(globalError.czz()));
179 float xerr = overp*errorPhi;
180 float zerr = overp*(layer->isBarrel() ? errorZ : errorR);
181 auto zo = layer->isBarrel() ? gp.z() :
r;
183 mserr[from][il-1].emplace_back(MSData{stid,it->seqNum(),z1,zo,xerr,zerr});
189 SiPixelRecHit hitpx(tsos.localPosition(),
he,1.,*detWithState.front().first,pref);
190 auto tsosl = kfu.
update(tsos, hitpx);
191 auto z1l = layer->isBarrel() ? tsos.
globalPosition().
z() : tsos.globalPosition().perp();
192 auto stidl = layer->seqNum();
193 propagate(il,tsosl,layer,z1l, stidl);
199 if(from==0) lastzz=
zz;
203 if (debug && mserr[from][from].
empty()) {
204 std::cout <<
"tl " << tanlmd << loc <<
' ' <<from<< std::endl;
206 for (
auto const &
e : mserr[from][il])
std::cout <<
e<<
' ';
213 for (
int ip=0;ip<5; ++ip) {
214 phi += (3.14159f/6.f)/5.
f;
221 auto startingPlane = pb.
plane( startingPosition,
rot);
224 startingMomentum, 1, &magfield),
225 err, *startingPlane);
226 auto tsos0 = startingStateP;
228 DetLayer const * layer0 = searchGeom.pixelBarrelLayers()[0];
229 if (goFw) layer0 = searchGeom.posPixelForwardLayers()[0];
230 int stid0 = layer0->
seqNum();
234 if(debug)
std::cout <<
"first layer " << (it->isBarrel() ?
" Barrel" :
" Forward") <<
" layer " << it->seqNum() <<
" SubDet " << it->subDetector()<< std::endl;
237 auto const & detWithState = layer0->
compatibleDets(tsos0,ANprop,estimator);
238 if(detWithState.empty()) {
239 if(debug)
std::cout <<
"no det on first layer" << layer0->
seqNum() << std::endl;
242 tsos0 = detWithState.front().second;
243 if(debug)
std::cout <<
"arrived at " <<
int(detWithState.front().first->geographicalId()) <<
' ' << tsos0.globalPosition() <<
' ' << tsos0.localError().positionError() << std::endl;
246 float z1l = tsos0.globalPosition().z();
249 z1l = tsos0.globalPosition().perp();
252 propagate(0,tsos0,layer0,z1l,stid0);
257 for (
auto from=0; from<
maxLayers; ++from)
259 if (mserr[from][il].
empty())
continue;
260 auto stid=mserr[from][il].front().stid;
261 auto lid=mserr[from][il].front().lid;
262 auto zi = mserr[from][il].front().zi;
266 for (
auto const &
e : mserr[from][il]) {
267 if (
e.stid!=stid)
continue;
271 for (
auto const &
e : mserr[from][il]) {
272 if (
e.stid!=stid || lid!=
e.lid)
continue;
273 xerr+=
e.uerr; zerr+=
e.verr; zo+=
e.zo; ++
nn;
275 xerr/=
nn; zerr/=
nn; zo/=
nn;
277 auto & md = msParam.data[iid].data[
ib].data;
279 ||
std::abs(xerr-md.back().uerr)>0.2
f*xerr
280 ||
std::abs(zerr-md.back().verr)>0.2
f*zerr
281 ) md.emplace_back(
Elem{zi,zo,xerr,zerr});
289 for (
auto &
e : msParam.data)
290 for (
auto &
d :
e.second.data) std::stable_sort(
d.data.begin(),
d.data.end(),[](
auto const &
a,
auto const &
b){
return a.vo<
b.vo;});
unsigned short packLID(unsigned int id, unsigned int od)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ReturnType produce(TkMSParameterizationRecord const &)
Sin< T >::type sin(const T &t)
ReturnType plane(const PositionType &pos, const RotationType &rot) const
const GeometricSearchTracker & searchTracker() const
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
std::string theNavigationSchoolName
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
const DepRecordT & getRecord() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
TkMSParameterizationBuilder(edm::ParameterSet const &)
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Vector3DBase unit() const
std::shared_ptr< TkMSParameterization > ReturnType
const MagneticField & field() const
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
NavigationDirection.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::ostream & operator<<(std::ostream &os, MSData d)
TkRotation< float > RotationType
T const * product() const