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::unique_ptr<TkMSParameterization>;
76 theNavigationSchoolName(pset.getParameter<
std::
string>(
"navigationSchool")){
85 ReturnType product = std::make_unique<TkMSParameterization>();
87 auto & msParam = *product;
94 auto const & magfield = navSchool.
field();
99 auto const & ANprop = *propagatorHandle;
103 ROOT::Math::SMatrixIdentity
id;
121 auto sinth2 = 1.f/(1.f+tanlmd*tanlmd);
123 auto overp = sinth/
pt;
127 if(debug)
std::cout << tl <<
' ' << pz <<
' ' << 1./overp << std::endl;
133 for (
int iz=0;iz<2; ++iz) {
135 for (
float zz=lastzz;
zz<18.1f;
zz+=0.2f) {
144 std::function<void(int, TrajectoryStateOnSurface, DetLayer const *, float, int)>
147 for (
auto il=from+1; il<
maxLayers; ++il) {
150 std::stable_sort(compLayers.begin(),compLayers.end(),[](
auto a,
auto b){
return a->seqNum()<
b->seqNum();});
152 for(
auto it : compLayers){
153 if (it->basicComponents().empty()) {
155 edm::LogError(
"TkMSParameterizationBuilder") <<
"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate.";
158 if (debug)
std::cout << il << (it->isBarrel() ?
" Barrel" :
" Forward") <<
" layer " << it->seqNum() <<
" SubDet " << it->subDetector()<< std::endl;
159 auto const & detWithState = it->compatibleDets(tsos,ANprop,estimator);
160 if(detWithState.empty()) {
161 if(debug)
std::cout <<
"no det on this layer" << it->seqNum() << std::endl;
165 auto did = detWithState.front().first->geographicalId();
166 if (debug)
std::cout <<
"arrived at " <<
int(did) << std::endl;
167 tsos = detWithState.front().second;
168 if(debug)
std::cout << tsos.globalPosition() <<
' ' << tsos.localError().positionError() << std::endl;
173 auto gp = tsos.globalPosition();
175 float errorPhi =
std::sqrt(
float(globalError.phierr(gp)));
176 float errorR =
std::sqrt(
float(globalError.rerr(gp)));
177 float errorZ =
std::sqrt(
float(globalError.czz()));
178 float xerr = overp*errorPhi;
179 float zerr = overp*(layer->isBarrel() ? errorZ : errorR);
180 auto zo = layer->isBarrel() ? gp.z() :
r;
182 mserr[from][il-1].emplace_back(MSData{stid,it->seqNum(),z1,zo,xerr,zerr});
188 SiPixelRecHit hitpx(tsos.localPosition(),
he,1.,*detWithState.front().first,pref);
189 auto tsosl = kfu.
update(tsos, hitpx);
190 auto z1l = layer->isBarrel() ? tsos.
globalPosition().
z() : tsos.globalPosition().perp();
191 auto stidl = layer->seqNum();
192 propagate(il,tsosl,layer,z1l, stidl);
198 if(from==0) lastzz=
zz;
202 if (debug && mserr[from][from].
empty()) {
203 std::cout <<
"tl " << tanlmd << loc <<
' ' <<from<< std::endl;
205 for (
auto const &
e : mserr[from][il])
std::cout <<
e<<
' ';
212 for (
int ip=0;ip<5; ++ip) {
213 phi += (3.14159f/6.f)/5.
f;
220 auto startingPlane = pb.
plane( startingPosition,
rot);
223 startingMomentum, 1, &magfield),
224 err, *startingPlane);
225 auto tsos0 = startingStateP;
227 DetLayer const * layer0 = searchGeom.pixelBarrelLayers()[0];
228 if (goFw) layer0 = searchGeom.posPixelForwardLayers()[0];
229 int stid0 = layer0->
seqNum();
233 if(debug)
std::cout <<
"first layer " << (it->isBarrel() ?
" Barrel" :
" Forward") <<
" layer " << it->seqNum() <<
" SubDet " << it->subDetector()<< std::endl;
236 auto const & detWithState = layer0->
compatibleDets(tsos0,ANprop,estimator);
237 if(detWithState.empty()) {
238 if(debug)
std::cout <<
"no det on first layer" << layer0->
seqNum() << std::endl;
241 tsos0 = detWithState.front().second;
242 if(debug)
std::cout <<
"arrived at " <<
int(detWithState.front().first->geographicalId()) <<
' ' << tsos0.globalPosition() <<
' ' << tsos0.localError().positionError() << std::endl;
245 float z1l = tsos0.globalPosition().z();
248 z1l = tsos0.globalPosition().perp();
251 propagate(0,tsos0,layer0,z1l,stid0);
256 for (
auto from=0; from<
maxLayers; ++from)
258 if (mserr[from][il].
empty())
continue;
259 auto stid=mserr[from][il].front().stid;
260 auto lid=mserr[from][il].front().lid;
261 auto zi = mserr[from][il].front().zi;
265 for (
auto const &
e : mserr[from][il]) {
266 if (
e.stid!=stid)
continue;
270 for (
auto const &
e : mserr[from][il]) {
271 if (
e.stid!=stid || lid!=
e.lid)
continue;
272 xerr+=
e.uerr; zerr+=
e.verr; zo+=
e.zo; ++
nn;
274 xerr/=
nn; zerr/=
nn; zo/=
nn;
276 auto & md = msParam.data[iid].data[
ib].data;
278 ||
std::abs(xerr-md.back().uerr)>0.2
f*xerr
279 ||
std::abs(zerr-md.back().verr)>0.2
f*zerr
280 ) md.emplace_back(
Elem{zi,zo,xerr,zerr});
288 for (
auto &
e : msParam.data)
289 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)
std::unique_ptr< TkMSParameterization > ReturnType
Abs< T >::type abs(const T &t)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Vector3DBase unit() const
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