Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //
0002 // Package:    MuonShowerDigiFiller
0003 // Class:      MuonShowerDigiFiller
0004 //
0005 /**\class MuonShowerDigiFiller MuonShowerDigiFiller.cc RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc
0006 
0007  Description: Class filling shower information using DT and CSC digis 
0008 
0009  Implementation:
0010      <Notes on implementation>
0011 */
0012 //
0013 // Original Author:  Carlo Battilana, INFN BO
0014 //         Created:  Sat Mar 23 14:36:22 CET 2019
0015 //
0016 //
0017 
0018 // system include files
0019 
0020 // user include files
0021 #include "RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h"
0022 
0023 //
0024 // constructors and destructor
0025 //
0026 
0027 MuonShowerDigiFiller::MuonShowerDigiFiller(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0028     : m_digiMaxDistanceX(iConfig.getParameter<double>("digiMaxDistanceX")),
0029       m_dtDigisToken(iC.consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("dtDigiCollectionLabel"))),
0030       m_cscDigisToken(
0031           iC.consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("cscDigiCollectionLabel"))),
0032       m_dtGeometryToken(iC.esConsumes<edm::Transition::BeginRun>()),
0033       m_cscGeometryToken(iC.esConsumes<edm::Transition::BeginRun>()) {}
0034 
0035 //
0036 // member functions
0037 //
0038 
0039 void MuonShowerDigiFiller::getES(const edm::EventSetup& iSetup) {
0040   m_dtGeometry = iSetup.getHandle(m_dtGeometryToken);
0041   m_cscGeometry = iSetup.getHandle(m_cscGeometryToken);
0042 }
0043 
0044 void MuonShowerDigiFiller::getDigis(edm::Event& iEvent) {
0045   iEvent.getByToken(m_dtDigisToken, m_dtDigis);
0046   iEvent.getByToken(m_cscDigisToken, m_cscDigis);
0047 }
0048 
0049 void MuonShowerDigiFiller::fill(reco::MuonChamberMatch& muChMatch) const {
0050   int nDigisInRange = 0;
0051 
0052   // DT chamber
0053   if (muChMatch.detector() == MuonSubdetId::DT) {
0054     double xTrack = muChMatch.x;
0055 
0056     for (int sl = 1; sl <= DTChamberId::maxSuperLayerId; sl += 2) {
0057       for (int layer = 1; layer <= DTChamberId::maxLayerId; ++layer) {
0058         const DTLayerId layerId(DTChamberId(muChMatch.id.rawId()), sl, layer);
0059 
0060         auto range = m_dtDigis->get(layerId);
0061 
0062         for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
0063           const auto topo = m_dtGeometry->layer(layerId)->specificTopology();
0064 
0065           double xWire = topo.wirePosition((*digiIt).wire());
0066           double dX = std::abs(xWire - xTrack);
0067 
0068           if (dX < m_digiMaxDistanceX)
0069             nDigisInRange++;
0070         }
0071       }
0072     }
0073   }
0074 
0075   else if (muChMatch.detector() == MuonSubdetId::CSC) {
0076     double xTrack = muChMatch.x;
0077     double yTrack = muChMatch.y;
0078 
0079     for (int iLayer = 1; iLayer <= CSCDetId::maxLayerId(); ++iLayer) {
0080       const CSCDetId chId(muChMatch.id.rawId());
0081       const CSCDetId layerId(chId.endcap(), chId.station(), chId.ring(), chId.chamber(), iLayer);
0082 
0083       auto range = m_cscDigis->get(layerId);
0084 
0085       for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
0086         std::vector<int> adcVals = digiIt->getADCCounts();
0087         bool hasFired = false;
0088         float pedestal = 0.5 * (float)(adcVals[0] + adcVals[1]);
0089         float threshold = 13.3;
0090         float diff = 0.;
0091         for (const auto& adcVal : adcVals) {
0092           diff = (float)adcVal - pedestal;
0093           if (diff > threshold) {
0094             hasFired = true;
0095             break;
0096           }
0097         }
0098 
0099         if (!hasFired)
0100           continue;
0101 
0102         const CSCLayerGeometry* layerGeom = m_cscGeometry->layer(layerId)->geometry();
0103 
0104         Float_t xStrip = layerGeom->xOfStrip(digiIt->getStrip(), yTrack);
0105         float dX = std::abs(xStrip - xTrack);
0106 
0107         if (dX < m_digiMaxDistanceX)
0108           nDigisInRange++;
0109       }
0110     }
0111   }
0112 
0113   muChMatch.nDigisInRange = nDigisInRange;
0114 }
0115 
0116 void MuonShowerDigiFiller::fillDefault(reco::MuonChamberMatch& muChMatch) const { muChMatch.nDigisInRange = 0; }