27 edm::LogInfo(
"CosmicTrackFinder")<<
"Minimum number of hits "<<theMinHits<<
" Cut on Chi2= "<<chi2cut;
66 RHBuilder= theBuilder.
product();
74 theFitter->setHitCloner(&hitCloner);
79 theSmoother->setHitCloner(&hitCloner);
89 vector<Trajectory> &trajoutput)
95 std::vector<Trajectory> trajSmooth;
96 std::vector<Trajectory>::iterator trajIter;
98 TrajectorySeedCollection::const_iterator
iseed;
100 for(iseed=collseed.begin();iseed!=collseed.end();iseed++){
107 vector<const TrackingRecHit*> allHits= SortHits(collstereo,collrphi,collmatched,collpixel,*iseed);
108 Trajectory startingTraj = createStartingTrajectory(*iseed);
109 AddHit(startingTraj,allHits);
110 for (trajIter=trajFit.begin(); trajIter!=trajFit.end();trajIter++){
111 trajSmooth=theSmoother->trajectories((*trajIter));
113 for (trajIter= trajSmooth.begin(); trajIter!=trajSmooth.end();trajIter++){
114 if((*trajIter).isValid()){
115 trajoutput.push_back((*trajIter));
120 delete thePropagator;
121 delete thePropagatorOp;
134 std::vector<TM> && seedMeas = seedMeasurements(seed);
135 for (
auto &
i : seedMeas)
result.push(std::move(
i));
140 std::vector<TrajectoryMeasurement>
143 std::vector<TrajectoryMeasurement>
result;
146 ihit != hitRange.second; ihit++) {
149 const GeomDet* hitGeomDet = (&(*tracker))->idToDet( ihit->geographicalId());
152 if (ihit == hitRange.second - 1) {
153 TSOS updatedState=startingTSOS(seed);
154 result.emplace_back(invalidState, updatedState, recHit);
157 result.emplace_back(invalidState, recHit);
169 vector<const TrackingRecHit*>
180 vector<const TrackingRecHit*> allHits;
186 for (ihit = hRange.first;
187 ihit != hRange.second; ihit++) {
188 yref=RHBuilder->build(&(*ihit))->globalPosition().y();
189 hits.push_back((RHBuilder->build(&(*ihit))));
190 LogDebug(
"CosmicTrackFinder")<<
"SEED HITS"<<RHBuilder->build(&(*ihit))->globalPosition();
194 if ((&collpixel)!=0){
196 for(ipix=collpixel.
data().begin();ipix!=collpixel.
data().end();ipix++){
197 float ych= RHBuilder->build(&(*ipix))->globalPosition().y();
198 if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
199 allHits.push_back(&(*ipix));
206 for(istrip=collrphi.
data().begin();istrip!=collrphi.
data().end();istrip++){
207 float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
208 if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
209 allHits.push_back(&(*istrip));
216 if ((&collstereo)!=0){
217 for(istrip=collstereo.
data().begin();istrip!=collstereo.
data().end();istrip++){
218 float ych= RHBuilder->build(&(*istrip))->globalPosition().y();
219 if ((seed_plus && (ych<yref)) || (!(seed_plus) && (ych>yref)))
220 allHits.push_back(&(*istrip));
247 const GeomDet* gdet = (&(*tracker))->idToDet(
DetId(pState.detId()));
255 const vector<const TrackingRecHit*>&Hits){
259 unsigned int ibestdet;
261 for (
unsigned int icosmhit=0;icosmhit<Hits.size();icosmhit++){
262 GlobalPoint gphit=RHBuilder->build(Hits[icosmhit])->globalPosition();
263 unsigned int iraw= Hits[icosmhit]->geographicalId().rawId();
264 LogDebug(
"CosmicTrackFinder")<<
" HIT POSITION "<< gphit;
268 tracker->idToDet(Hits[icosmhit]->geographicalId())->surface());
276 LogDebug(
"CosmicTrackFinder") <<
"STATE PROPAGATED AT DET "<<iraw<<
" "<<prSt;
277 for(icosm2=icosmhit;icosm2<Hits.size();icosm2++){
279 if (iraw==Hits[icosm2]->geographicalId().rawId()){
281 float contr= theEstimator->estimate(prSt, *tmphit).second;
286 if (icosm2!=icosmhit) icosmhit++;
289 else icosm2=Hits.size();
293 LogDebug(
"CosmicTrackFinder")<<
"Chi2 contribution for hit at "
294 <<RHBuilder->build(Hits[ibestdet])->globalPosition()
297 if(traj.
foundHits()<3 &&(chi2min<chi2cut)){
299 GlobalVector ck=RHBuilder->build(Hits[ibestdet])->globalPosition()-
301 if ((
abs(ck.
x()/ck.
y())>2)||(
abs(ck.
z()/ck.
y())>2)) chi2min=300;
303 if (chi2min<chi2cut){
304 if (
abs(prLoc.
x()) < 25 &&
abs(prLoc.
y()) < 25 ){
306 TSOS UpdatedState= theUpdator->
update( prSt, *tmphitbestdet);
309 traj.
push(std::move(
TM(prSt,UpdatedState,RHBuilder->build(Hits[ibestdet])
312 "STATE UPDATED WITH HIT AT POSITION "
313 <<tmphitbestdet->globalPosition()
317 hits.push_back(tmphitbestdet);
319 }
else LogDebug(
"CosmicTrackFinder")<<
" Hits outside module surface "<< prLoc;
320 }
else LogDebug(
"CosmicTrackFinder")<<
" State can not be updated with hit at position " <<gphit;
321 }
else LogDebug(
"CosmicTrackFinder")<<
" State can not be propagated at det "<< iraw;
326 if ( qualityFilter( traj)){
329 tracker->idToDet((*hits.begin())->geographicalId())->surface()).isValid()){
332 tracker->idToDet((*hits.begin())->geographicalId())->surface());
334 trajFit = theFitter->fit(tmpseed,hits, startingState );
345 auto hits = traj.recHits();
346 for(
auto hit=hits.begin();
hit!=hits.end();
hit++){
347 unsigned int iid=(*hit)->hit()->geographicalId().rawId();
349 if(((iid>>0)&0x3)!=1) ngoodhits++;
354 if ( ngoodhits >= theMinHits) {
PropagationDirection direction() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
LocalPoint localPosition() const
GlobalPoint globalPosition() const
const Plane & surface() const
The nominal surface of the GeomDet.
void init(const edm::EventSetup &es, bool)
std::vector< TrajectoryMeasurement > seedMeasurements(const TrajectorySeed &seed) const
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
TrajectoryMeasurement const & lastMeasurement() const
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
data_type const * data(size_t cell) const
Abs< T >::type abs(const T &t)
std::pair< const_iterator, const_iterator > range
TSOS startingTSOS(const TrajectorySeed &seed) const
tuple Chi2MeasurementEstimator
std::shared_ptr< TrackingRecHit const > RecHitPointer
TrajectoryMeasurement const & firstMeasurement() const
PTrajectoryStateOnDet const & startingState() const
void run(const TrajectorySeedCollection &collseed, const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const edm::EventSetup &es, edm::Event &e, std::vector< Trajectory > &trajoutput)
Runs the algorithm.
T const * product() const
std::vector< const TrackingRecHit * > SortHits(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const TrajectorySeed &seed)
void AddHit(Trajectory &traj, const std::vector< const TrackingRecHit * > &Hits)
ESHandle< TrackerGeometry > geometry
bool qualityFilter(const Trajectory &traj)
tuple KFTrajectorySmoother
TrajectoryStateOnSurface const & updatedState() const
Trajectory createStartingTrajectory(const TrajectorySeed &seed) const
CosmicTrajectoryBuilder(const edm::ParameterSet &conf)
~CosmicTrajectoryBuilder()
void push(const TrajectoryMeasurement &tm)