Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-15 22:20:56

0001 #ifndef MCTruth_MuonTruth_h
0002 #define MCTruth_MuonTruth_h
0003 
0004 #include "CondFormats/CSCObjects/interface/CSCBadChambers.h"
0005 #include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
0006 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
0007 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0008 #include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
0009 #include "DataFormats/Common/interface/DetSetVector.h"
0010 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Utilities/interface/InputTag.h"
0016 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0017 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0018 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0019 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0020 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0021 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0022 #include "SimDataFormats/TrackerDigiSimLink/interface/StripDigiSimLink.h"
0023 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0024 
0025 class MuonTruth {
0026 public:
0027   typedef edm::DetSetVector<StripDigiSimLink> DigiSimLinks;
0028   typedef edm::DetSetVector<StripDigiSimLink> WireDigiSimLinks;
0029   typedef edm::DetSet<StripDigiSimLink> LayerLinks;
0030   typedef std::pair<uint32_t, EncodedEventId> SimHitIdpr;
0031 
0032   MuonTruth(const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &, edm::ConsumesCollector &);
0033   MuonTruth(const edm::ParameterSet &, edm::ConsumesCollector &&iC);
0034 
0035   void initEvent(const edm::Event &, const edm::EventSetup &);
0036 
0037   void analyze(const CSCRecHit2D &recHit);
0038   void analyze(const CSCStripDigi &stripDigi, int rawDetIdCorrespondingToCSCLayer);
0039   void analyze(const CSCWireDigi &wireDigi, int rawDetIdCorrespondingToCSCLayer);
0040 
0041   /// analyze() must be called before any of the following
0042   float muonFraction();
0043 
0044   std::vector<PSimHit> muonHits();
0045 
0046   std::vector<PSimHit> simHits();
0047 
0048   const CSCBadChambers *cscBadChambers;
0049 
0050 private:
0051   std::vector<PSimHit> hitsFromSimTrack(SimHitIdpr truthId);
0052   // goes to SimHits for information
0053   int particleType(SimHitIdpr truthId);
0054 
0055   void addChannel(const LayerLinks &layerLinks, int channel, float weight = 1.);
0056 
0057   std::map<SimHitIdpr, float> theChargeMap;
0058   float theTotalCharge;
0059 
0060   unsigned int theDetId;
0061 
0062   const DigiSimLinks *theDigiSimLinks;
0063   const DigiSimLinks *theWireDigiSimLinks;
0064 
0065   const edm::InputTag linksTag;
0066   const edm::InputTag wireLinksTag;
0067 
0068   const bool crossingframe;
0069   const edm::InputTag CSCsimHitsTag;
0070   const edm::InputTag CSCsimHitsXFTag;
0071 
0072   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
0073   const edm::ESGetToken<CSCBadChambers, CSCBadChambersRcd> badToken_;
0074 
0075   const edm::EDGetTokenT<DigiSimLinks> linksToken_;
0076   const edm::EDGetTokenT<DigiSimLinks> wireLinksToken_;
0077   edm::EDGetTokenT<CrossingFrame<PSimHit>> simHitsXFToken_;
0078   edm::EDGetTokenT<edm::PSimHitContainer> simHitsToken_;
0079 
0080   std::map<unsigned int, edm::PSimHitContainer> theSimHitMap;
0081 
0082   const CSCGeometry *cscgeom;
0083 };
0084 
0085 #endif