Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:42

0001 #ifndef CosmicTrajectoryBuilder_h
0002 #define CosmicTrajectoryBuilder_h
0003 
0004 //
0005 // Package:         RecoTracker/SingleTrackPattern
0006 // Class:           CosmicTrajectoryBuilder
0007 // Original Author:  Michele Pioppi-INFN perugia
0008 
0009 #include <string>
0010 
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 
0015 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0016 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
0017 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
0018 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
0019 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
0020 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0021 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0022 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0023 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
0024 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
0025 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
0026 #include "MagneticField/Engine/interface/MagneticField.h"
0027 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0028 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0029 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
0030 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0031 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
0032 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0033 #include "DataFormats/TrackReco/interface/Track.h"
0034 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0035 #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
0036 #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
0037 #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h"
0038 #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h"
0039 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0040 
0041 #ifndef TrajectoryBuilder_CompareHitY
0042 #define TrajectoryBuilder_CompareHitY
0043 
0044 class CompareHitY {
0045 public:
0046   CompareHitY(const TrackerGeometry &tracker) : _tracker(tracker) {}
0047   bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2) {
0048     GlobalPoint gp1 = _tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
0049     GlobalPoint gp2 = _tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
0050     return gp1.y() < gp2.y();
0051   };
0052 
0053 private:
0054   //   edm::ESHandle<TrackerGeometry> _tracker;
0055   const TrackerGeometry &_tracker;
0056 };
0057 
0058 class CompareHitY_plus {
0059 public:
0060   CompareHitY_plus(const TrackerGeometry &tracker) : _tracker(tracker) {}
0061   bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2) {
0062     GlobalPoint gp1 = _tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
0063     GlobalPoint gp2 = _tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
0064     return gp1.y() > gp2.y();
0065   };
0066 
0067 private:
0068   //   edm::ESHandle<TrackerGeometry> _tracker;
0069   const TrackerGeometry &_tracker;
0070 };
0071 
0072 #endif
0073 
0074 class CosmicTrajectoryBuilder {
0075   typedef TrajectoryStateOnSurface TSOS;
0076   typedef TrajectoryMeasurement TM;
0077 
0078 public:
0079   CosmicTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector iC);
0080   ~CosmicTrajectoryBuilder();
0081 
0082   /// Runs the algorithm
0083 
0084   void run(const TrajectorySeedCollection &collseed,
0085            const SiStripRecHit2DCollection &collstereo,
0086            const SiStripRecHit2DCollection &collrphi,
0087            const SiStripMatchedRecHit2DCollection &collmatched,
0088            const SiPixelRecHitCollection &collpixel,
0089            const edm::EventSetup &es,
0090            edm::Event &e,
0091            std::vector<Trajectory> &trajoutput);
0092 
0093   void init(const edm::EventSetup &es, bool);
0094   Trajectory createStartingTrajectory(const TrajectorySeed &seed) const;
0095 
0096   const TransientTrackingRecHitBuilder *hitBuilder() const { return RHBuilder; }
0097 
0098 private:
0099   std::vector<TrajectoryMeasurement> seedMeasurements(const TrajectorySeed &seed) const;
0100 
0101   std::vector<const TrackingRecHit *> SortHits(const SiStripRecHit2DCollection &collstereo,
0102                                                const SiStripRecHit2DCollection &collrphi,
0103                                                const SiStripMatchedRecHit2DCollection &collmatched,
0104                                                const SiPixelRecHitCollection &collpixel,
0105                                                const TrajectorySeed &seed);
0106 
0107   TSOS startingTSOS(const TrajectorySeed &seed) const;
0108   void updateTrajectory(Trajectory &traj, const TM &tm, const TransientTrackingRecHit &hit) const;
0109 
0110   void AddHit(Trajectory &traj, const std::vector<const TrackingRecHit *> &Hits);
0111   //        edm::OwnVector<TransientTrackingRecHit> hits);
0112   bool qualityFilter(const Trajectory &traj);
0113 
0114 private:
0115   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magfieldToken_;
0116   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerToken_;
0117   const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> builderToken_;
0118   const MagneticField *magfield;
0119   const TrackerGeometry *tracker;
0120 
0121   PropagatorWithMaterial *thePropagator;
0122   PropagatorWithMaterial *thePropagatorOp;
0123   KFUpdator *theUpdator;
0124   Chi2MeasurementEstimator *theEstimator;
0125   const TransientTrackingRecHitBuilder *RHBuilder;
0126   TkClonerImpl hitCloner;
0127   KFTrajectorySmoother *theSmoother;
0128   KFTrajectoryFitter *theFitter;
0129 
0130   int theMinHits;
0131   double chi2cut;
0132   std::vector<Trajectory> trajFit;
0133   //RC edm::OwnVector<const TransientTrackingRecHit> hits;
0134   TransientTrackingRecHit::RecHitContainer hits;
0135   bool seed_plus;
0136   std::string geometry;
0137 };
0138 
0139 #endif