Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:27

0001 #include "SimG4CMS/Muon/interface/MuonSlaveSD.h"
0002 #include "Geometry/MuonNumbering/interface/MuonSubDetector.h"
0003 
0004 #include "SimG4Core/Notification/interface/SimTrackManager.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 #include <iostream>
0008 
0009 MuonSlaveSD::MuonSlaveSD(MuonSubDetector* d, const SimTrackManager* manager)
0010     : TrackingSlaveSD(d->name()), m_trackManager(manager) {
0011   detector = d;
0012 }
0013 
0014 MuonSlaveSD::~MuonSlaveSD() {}
0015 
0016 void MuonSlaveSD::clearHits() {
0017   LogDebug("MuonSimDebug") << " MuonSlaveSD::clearHits " << detector->name() << std::endl;
0018   hits_.clear();
0019 }
0020 
0021 bool MuonSlaveSD::format() {
0022   LogDebug("MuonSimDebug") << " MuonSlaveSD " << detector->name() << " formatting " << hits_.size() << " hits."
0023                            << std::endl;
0024   if (detector->isBarrel()) {
0025     sort(hits_.begin(), hits_.end(), FormatBarrelHits());
0026   } else if (detector->isEndcap()) {
0027     sort(hits_.begin(), hits_.end(), FormatEndcapHits());
0028   } else if (detector->isRPC()) {
0029     sort(hits_.begin(), hits_.end(), FormatRpcHits());
0030   } else if (detector->isGEM()) {
0031     sort(hits_.begin(), hits_.end(), FormatGemHits());
0032   } else if (detector->isME0()) {
0033     sort(hits_.begin(), hits_.end(), FormatMe0Hits());
0034   }
0035   return true;
0036 }
0037 
0038 bool FormatBarrelHits::operator()(const PSimHit& a, const PSimHit& b) { return (sortId(a) < sortId(b)); }
0039 
0040 int FormatBarrelHits::sortId(const PSimHit& a) const { return a.detUnitId(); }
0041 
0042 bool FormatEndcapHits::operator()(const PSimHit& a, const PSimHit& b) { return (sortId(a) < sortId(b)); }
0043 
0044 int FormatEndcapHits::sortId(const PSimHit& a) const { return a.detUnitId(); }
0045 
0046 bool FormatRpcHits::operator()(const PSimHit& a, const PSimHit& b) { return (sortId(a) < sortId(b)); }
0047 
0048 int FormatRpcHits::sortId(const PSimHit& a) const { return a.detUnitId(); }
0049 
0050 bool FormatGemHits::operator()(const PSimHit& a, const PSimHit& b) { return (sortId(a) < sortId(b)); }
0051 
0052 int FormatGemHits::sortId(const PSimHit& a) const { return a.detUnitId(); }
0053 
0054 bool FormatMe0Hits::operator()(const PSimHit& a, const PSimHit& b) { return (sortId(a) < sortId(b)); }
0055 
0056 int FormatMe0Hits::sortId(const PSimHit& a) const { return a.detUnitId(); }