Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:54

0001 #ifndef RecoMuon_GlobalTrackingTools_DynamicTruncation_h
0002 #define RecoMuon_GlobalTrackingTools_DynamicTruncation_h
0003 
0004 /**
0005  *  Class: DynamicTruncation
0006  *
0007  *  Description:
0008  *  class for the dynamical stop of the KF according to the
0009  *  compatibility degree between the extrapolated track
0010  *  state and the reconstructed segment in the muon chambers
0011  *
0012  *
0013  *  Authors :
0014  *  D. Pagano & G. Bruno - UCL Louvain
0015  *
0016  *  \modified by C. Caputo, UCLouvain
0017  **/
0018 
0019 #include <memory>
0020 #include "RecoMuon/GlobalTrackingTools/interface/DirectTrackerNavigation.h"
0021 #include "FWCore/Framework/interface/ConsumesCollector.h"
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "DataFormats/TrackReco/interface/Track.h"
0026 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0027 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0028 #include "RecoMuon/GlobalTrackingTools/interface/StateSegmentMatcher.h"
0029 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0030 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0031 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0032 #include "RecoMuon/Navigation/interface/MuonNavigableLayer.h"
0033 #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h"
0034 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0035 #include "RecoTracker/Record/interface/NavigationSchoolRecord.h"
0036 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0037 #include "RecoMuon/Navigation/interface/DirectMuonNavigation.h"
0038 #include "DataFormats/MuonReco/interface/DYTInfo.h"
0039 #include "RecoMuon/GlobalTrackingTools/interface/ThrParameters.h"
0040 #include "RecoMuon/GlobalTrackingTools/interface/ChamberSegmentUtility.h"
0041 
0042 class TransientRecHitRecord;
0043 
0044 namespace dyt_utils {
0045   enum class etaRegion { eta0p8, eta1p2, eta2p0, eta2p2, eta2p4 };
0046 };
0047 
0048 class DynamicTruncation {
0049 public:
0050   struct Config {
0051     Config(edm::ConsumesCollector);
0052 
0053     const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
0054     const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> muonRecHitBuilderToken_;
0055     const edm::ESGetToken<TrajectoryStateUpdator, TrackingComponentsRecord> updatorToken_;
0056     const edm::ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> navMuonToken_;
0057 
0058     const edm::ESGetToken<DYTThrObject, DYTThrObjectRcd> dytThresholdsToken_;
0059     const edm::ESGetToken<AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd> dtAlignmentErrorsToken_;
0060     const edm::ESGetToken<AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd> cscAlignmentErrorsToken_;
0061   };
0062 
0063   typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer;
0064   typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer;
0065 
0066   DynamicTruncation(Config const &, const edm::EventSetup &, const MuonServiceProxy &);
0067 
0068   ~DynamicTruncation();
0069 
0070   void setProd(const edm::Handle<DTRecSegment4DCollection> &DTSegProd,
0071                const edm::Handle<CSCSegmentCollection> &CSCSegProd) {
0072     getSegs->initCSU(DTSegProd, CSCSegProd);
0073   }
0074 
0075   void setSelector(int);
0076   void setThr(const std::vector<int> &);
0077   void setUpdateState(bool);
0078   void setUseAPE(bool);
0079   /*---- DyT v2-----*/
0080   void setThrsMap(const edm::ParameterSet &);
0081   void setParThrsMode(bool dytParThrsMode) { useParametrizedThr = dytParThrsMode; }
0082   void setRecoP(double p) { p_reco = p; }
0083   void setRecoEta(double eta) {
0084     eta_reco = eta;
0085     setEtaRegion();
0086   }
0087 
0088   // Return the vector with the tracker plus the selected muon hits
0089   TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory &);
0090 
0091   // Return the DYTInfo object
0092   reco::DYTInfo getDYTInfo() {
0093     dytInfo.setNStUsed(nStationsUsed);
0094     dytInfo.setDYTEstimators(estimatorMap);
0095     dytInfo.setUsedStations(usedStationMap);
0096     dytInfo.setIdChambers(idChamberMap);
0097     return dytInfo;
0098   }
0099 
0100 private:
0101   void compatibleDets(TrajectoryStateOnSurface &, std::map<int, std::vector<DetId>> &);
0102   void filteringAlgo();
0103   void fillSegmentMaps(std::map<int, std::vector<DetId>> &,
0104                        std::map<int, std::vector<DTRecSegment4D>> &,
0105                        std::map<int, std::vector<CSCSegment>> &);
0106   void preliminaryFit(std::map<int, std::vector<DetId>>,
0107                       std::map<int, std::vector<DTRecSegment4D>>,
0108                       std::map<int, std::vector<CSCSegment>>);
0109   bool chooseLayers(int &,
0110                     double const &,
0111                     DTRecSegment4D const &,
0112                     TrajectoryStateOnSurface const &,
0113                     double const &,
0114                     CSCSegment const &,
0115                     TrajectoryStateOnSurface const &);
0116   void fillDYTInfos(
0117       int const &, bool const &, int &, double const &, double const &, DTRecSegment4D const &, CSCSegment const &);
0118   int stationfromDet(DetId const &);
0119   void update(TrajectoryStateOnSurface &, ConstRecHitPointer);
0120   void updateWithDThits(TrajectoryStateOnSurface &, DTRecSegment4D const &);
0121   void updateWithCSChits(TrajectoryStateOnSurface &, CSCSegment const &);
0122   void getThresholdFromDB(double &, DetId const &);
0123   void correctThrByPAndEta(double &);
0124   void getThresholdFromCFG(double &, DetId const &);
0125   void testDTstation(TrajectoryStateOnSurface &,
0126                      std::vector<DTRecSegment4D> const &,
0127                      double &,
0128                      DTRecSegment4D &,
0129                      TrajectoryStateOnSurface &);
0130   void testCSCstation(
0131       TrajectoryStateOnSurface &, std::vector<CSCSegment> const &, double &, CSCSegment &, TrajectoryStateOnSurface &);
0132   void useSegment(DTRecSegment4D const &, TrajectoryStateOnSurface const &);
0133   void useSegment(CSCSegment const &, TrajectoryStateOnSurface const &);
0134   void sort(ConstRecHitContainer &);
0135   void setEtaRegion();
0136 
0137   ConstRecHitContainer result, prelFitMeas;
0138   bool useAPE;
0139   std::vector<int> Thrs;
0140   int nStationsUsed;
0141   int DYTselector;
0142   edm::ESHandle<Propagator> propagator;
0143   edm::ESHandle<Propagator> propagatorPF;
0144   edm::ESHandle<Propagator> propagatorCompatibleDet;
0145   edm::ESHandle<GlobalTrackingGeometry> theG;
0146   edm::ESHandle<CSCGeometry> cscGeom;
0147   edm::ESHandle<TransientTrackingRecHitBuilder> theMuonRecHitBuilder;
0148   edm::ESHandle<TrajectoryStateUpdator> updatorHandle;
0149   edm::ESHandle<MuonDetLayerGeometry> navMuon;
0150   std::unique_ptr<DirectMuonNavigation> navigation;
0151   edm::ESHandle<MagneticField> magfield;
0152   std::map<int, double> estimatorMap;
0153   std::map<int, bool> usedStationMap;
0154   std::map<int, DetId> idChamberMap;
0155   TrajectoryStateOnSurface currentState;
0156   TrajectoryStateOnSurface prelFitState;
0157   reco::DYTInfo dytInfo;
0158   std::map<DTChamberId, GlobalError> dtApeMap;
0159   std::map<CSCDetId, GlobalError> cscApeMap;
0160   double muonPTest, muonETAest;
0161   const DYTThrObject *dytThresholds;
0162   std::unique_ptr<ChamberSegmentUtility> getSegs;
0163   std::unique_ptr<ThrParameters> thrManager;
0164   bool useDBforThr;
0165   bool doUpdateOfKFStates;
0166   /* Variables for v2 */
0167   double p_reco;
0168   double eta_reco;
0169   bool useParametrizedThr;
0170   dyt_utils::etaRegion region;
0171   std::map<dyt_utils::etaRegion, std::vector<double>> parameters;
0172 };
0173 
0174 #endif