Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:06

0001 #ifndef MuonSeedGenerator_CosmicMuonSeedGenerator_H
0002 #define MuonSeedGenerator_CosmicMuonSeedGenerator_H
0003 
0004 /** \class CosmicMuonSeedGenerator
0005  *  SeedGenerator for Cosmic Muon
0006  *
0007  *  \author Chang Liu - Purdue University 
0008  */
0009 
0010 #include "FWCore/Framework/interface/stream/EDProducer.h"
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/Utilities/interface/ESGetToken.h"
0014 
0015 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0016 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0017 #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h"
0018 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0019 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
0020 #include "MagneticField/Engine/interface/MagneticField.h"
0021 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0022 
0023 #include <vector>
0024 
0025 class MuonDetLayerGeometry;
0026 
0027 struct TrajectoryStateTransform;
0028 
0029 namespace edm {
0030   class ParameterSet;
0031   class Event;
0032   class EventSetup;
0033 }  // namespace edm
0034 
0035 class CosmicMuonSeedGenerator : public edm::stream::EDProducer<> {
0036 public:
0037   /// Constructor
0038   CosmicMuonSeedGenerator(const edm::ParameterSet&);
0039 
0040   /// Destructor
0041   ~CosmicMuonSeedGenerator() override;
0042 
0043   // Operations
0044 
0045   /// reconstruct muon's seeds
0046   void produce(edm::Event&, const edm::EventSetup&) override;
0047 
0048 private:
0049   struct MuonRecHitPair {
0050     MuonRecHitPair(const MuonTransientTrackingRecHit::MuonRecHitPointer& a,
0051                    const MuonTransientTrackingRecHit::MuonRecHitPointer& b,
0052                    std::string c = "")
0053         : first(a), second(b), type(c) {}
0054 
0055     MuonTransientTrackingRecHit::MuonRecHitPointer first;
0056     MuonTransientTrackingRecHit::MuonRecHitPointer second;
0057     std::string type;
0058   };
0059 
0060   typedef std::vector<MuonRecHitPair> MuonRecHitPairVector;
0061 
0062   /// generate TrajectorySeeds and put them into results
0063   void createSeeds(TrajectorySeedCollection& results,
0064                    const MuonTransientTrackingRecHit::MuonRecHitContainer& hits,
0065                    const edm::EventSetup& eSetup) const;
0066 
0067   void createSeeds(TrajectorySeedCollection& results,
0068                    const CosmicMuonSeedGenerator::MuonRecHitPairVector& hits,
0069                    const edm::EventSetup& eSetup) const;
0070 
0071   /// determine if a MuonTransientTrackingRecHit is qualified to build seed
0072   bool checkQuality(const MuonTransientTrackingRecHit::MuonRecHitPointer&) const;
0073 
0074   /// select seed candidates from Segments in Event
0075   MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments(
0076       const MuonTransientTrackingRecHit::MuonRecHitContainer&) const;
0077 
0078   /// create TrajectorySeed from MuonTransientTrackingRecHit
0079   std::vector<TrajectorySeed> createSeed(const MuonTransientTrackingRecHit::MuonRecHitPointer&,
0080                                          const edm::EventSetup&) const;
0081 
0082   std::vector<MuonRecHitPair> makeSegPairs(const MuonTransientTrackingRecHit::MuonRecHitContainer&,
0083                                            const MuonTransientTrackingRecHit::MuonRecHitContainer&,
0084                                            std::string) const;
0085 
0086   /// create TrajectorySeed from MuonRecHitPair
0087   std::vector<TrajectorySeed> createSeed(const MuonRecHitPair&, const edm::EventSetup&) const;
0088 
0089   TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface&, uint32_t) const;
0090   TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface&, uint32_t, edm::OwnVector<TrackingRecHit>&) const;
0091 
0092   /// check if two rechits are correlated
0093   bool areCorrelated(const MuonTransientTrackingRecHit::MuonRecHitPointer&,
0094                      const MuonTransientTrackingRecHit::MuonRecHitPointer&) const;
0095 
0096   ///  compare quality of two rechits
0097   bool leftIsBetter(const MuonTransientTrackingRecHit::MuonRecHitPointer&,
0098                     const MuonTransientTrackingRecHit::MuonRecHitPointer&) const;
0099 
0100   struct DecreasingGlobalY {
0101     bool operator()(const MuonTransientTrackingRecHit::ConstMuonRecHitPointer& lhs,
0102                     const MuonTransientTrackingRecHit::ConstMuonRecHitPointer& rhs) const {
0103       return lhs->globalPosition().y() > rhs->globalPosition().y();
0104     }
0105   };
0106 
0107 private:
0108   /// enable DT Segment Flag
0109   bool theEnableDTFlag;
0110 
0111   /// enable CSCSegment Flag
0112   bool theEnableCSCFlag;
0113 
0114   /// the name of the DT rec hits collection
0115   edm::InputTag theDTRecSegmentLabel;
0116 
0117   /// the name of the CSC rec hits collection
0118   edm::InputTag theCSCRecSegmentLabel;
0119 
0120   /// the maximum number of Seeds
0121   unsigned int theMaxSeeds;
0122 
0123   /// the maximum chi2 required for dt and csc rechits
0124   double theMaxDTChi2;
0125   double theMaxCSCChi2;
0126   bool theForcePointDownFlag;
0127   edm::ESHandle<MuonDetLayerGeometry> theMuonLayers;
0128   edm::ESHandle<MagneticField> theField;
0129   edm::ESGetToken<MuonDetLayerGeometry, MuonRecoGeometryRecord> muonLayersToken;
0130   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken;
0131 
0132   std::map<std::string, float> theParameters;
0133 
0134   MuonDetLayerMeasurements* muonMeasurements;
0135 };
0136 #endif