File indexing completed on 2024-04-06 12:30:46
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::ParameterSet &, edm::ConsumesCollector &&iC);
0033
0034 void initEvent(const edm::Event &, const edm::EventSetup &);
0035
0036 void analyze(const CSCRecHit2D &recHit);
0037 void analyze(const CSCStripDigi &stripDigi, int rawDetIdCorrespondingToCSCLayer);
0038 void analyze(const CSCWireDigi &wireDigi, int rawDetIdCorrespondingToCSCLayer);
0039
0040
0041 float muonFraction();
0042
0043 std::vector<PSimHit> muonHits();
0044
0045 std::vector<PSimHit> simHits();
0046
0047 const CSCBadChambers *cscBadChambers;
0048
0049 private:
0050 std::vector<PSimHit> hitsFromSimTrack(SimHitIdpr truthId);
0051
0052 int particleType(SimHitIdpr truthId);
0053
0054 void addChannel(const LayerLinks &layerLinks, int channel, float weight = 1.);
0055
0056 std::map<SimHitIdpr, float> theChargeMap;
0057 float theTotalCharge;
0058
0059 unsigned int theDetId;
0060
0061 const DigiSimLinks *theDigiSimLinks;
0062 const DigiSimLinks *theWireDigiSimLinks;
0063
0064 const edm::InputTag linksTag;
0065 const edm::InputTag wireLinksTag;
0066
0067 const bool crossingframe;
0068 const edm::InputTag CSCsimHitsTag;
0069 const edm::InputTag CSCsimHitsXFTag;
0070
0071 const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
0072 const edm::ESGetToken<CSCBadChambers, CSCBadChambersRcd> badToken_;
0073
0074 const edm::EDGetTokenT<DigiSimLinks> linksToken_;
0075 const edm::EDGetTokenT<DigiSimLinks> wireLinksToken_;
0076 edm::EDGetTokenT<CrossingFrame<PSimHit>> simHitsXFToken_;
0077 edm::EDGetTokenT<edm::PSimHitContainer> simHitsToken_;
0078
0079 std::map<unsigned int, edm::PSimHitContainer> theSimHitMap;
0080
0081 const CSCGeometry *cscgeom;
0082 };
0083
0084 #endif