Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:19

0001 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHitBreaker.h"
0002 
0003 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0004 
0005 TransientTrackingRecHit::ConstRecHitContainer MuonTransientTrackingRecHitBreaker::breakInSubRecHits(
0006     TransientTrackingRecHit::ConstRecHitPointer muonRecHit, int granularity) {
0007   const std::string metname = "Muon|RecoMuon|MuonTransientTrackingRecHitBreaker";
0008 
0009   TransientTrackingRecHit::ConstRecHitContainer recHitsForFit;
0010 
0011   int subDet = muonRecHit->geographicalId().subdetId();
0012 
0013   switch (granularity) {
0014     case 0: {
0015       // Asking for 4D segments for the CSC/DT and a point for the RPC
0016       recHitsForFit.push_back(muonRecHit);
0017       break;
0018     }
0019     case 1: {
0020       if (subDet == MuonSubdetId::DT || subDet == MuonSubdetId::CSC)
0021         // measurement->recHit() returns a 4D segment, then
0022         // DT case: asking for 2D segments.
0023         // CSC case: asking for 2D points.
0024         recHitsForFit = muonRecHit->transientHits();
0025 
0026       else if (subDet == MuonSubdetId::RPC)
0027         recHitsForFit.push_back(muonRecHit);
0028 
0029       break;
0030     }
0031 
0032     case 2: {
0033       if (subDet == MuonSubdetId::DT) {
0034         // Asking for 2D segments. measurement->recHit() returns a 4D segment
0035         TransientTrackingRecHit::ConstRecHitContainer segments2D = muonRecHit->transientHits();
0036 
0037         // loop over segment
0038         for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator segment = segments2D.begin();
0039              segment != segments2D.end();
0040              ++segment) {
0041           // asking for 1D Rec Hit
0042           TransientTrackingRecHit::ConstRecHitContainer rechit1D = (**segment).transientHits();
0043 
0044           // load them into the recHitsForFit container
0045           copy(rechit1D.begin(), rechit1D.end(), back_inserter(recHitsForFit));
0046         }
0047       }
0048 
0049       else if (subDet == MuonSubdetId::RPC)
0050         recHitsForFit.push_back(muonRecHit);
0051 
0052       else if (subDet == MuonSubdetId::CSC)
0053         // Asking for 2D points. measurement->recHit() returns a 4D segment
0054         recHitsForFit = (*muonRecHit).transientHits();
0055 
0056       break;
0057     }
0058 
0059     default: {
0060       throw cms::Exception(metname) << "Wrong granularity chosen!"
0061                                     << "it will be set to 0";
0062       break;
0063     }
0064   }
0065 
0066   return recHitsForFit;
0067 }