CMS 3D CMS Logo

MuonShowerDigiFiller.cc
Go to the documentation of this file.
1 //
2 // Package: MuonShowerDigiFiller
3 // Class: MuonShowerDigiFiller
4 //
12 //
13 // Original Author: Carlo Battilana, INFN BO
14 // Created: Sat Mar 23 14:36:22 CET 2019
15 //
16 //
17 
18 // system include files
19 
20 // user include files
22 
24 
25 //
26 // constructors and destructor
27 //
28 
30  : m_digiMaxDistanceX(iConfig.getParameter<double>("digiMaxDistanceX")),
31  m_dtDigisToken(iC.consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("dtDigiCollectionLabel"))),
32  m_cscDigisToken(
33  iC.consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("cscDigiCollectionLabel"))) {}
34 
35 //
36 // member functions
37 //
38 
40  iSetup.get<MuonGeometryRecord>().get(m_dtGeometry);
41  iSetup.get<MuonGeometryRecord>().get(m_cscGeometry);
42 }
43 
47 }
48 
50  int nDigisInRange = 0;
51 
52  // DT chamber
53  if (muChMatch.detector() == MuonSubdetId::DT) {
54  double xTrack = muChMatch.x;
55 
56  for (int sl = 1; sl <= DTChamberId::maxSuperLayerId; sl += 2) {
57  for (int layer = 1; layer <= DTChamberId::maxLayerId; ++layer) {
58  const DTLayerId layerId(DTChamberId(muChMatch.id.rawId()), sl, layer);
59 
60  auto range = m_dtDigis->get(layerId);
61 
62  for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
63  const auto topo = m_dtGeometry->layer(layerId)->specificTopology();
64 
65  double xWire = topo.wirePosition((*digiIt).wire());
66  double dX = std::abs(xWire - xTrack);
67 
68  if (dX < m_digiMaxDistanceX)
69  nDigisInRange++;
70  }
71  }
72  }
73  }
74 
75  else if (muChMatch.detector() == MuonSubdetId::CSC) {
76  double xTrack = muChMatch.x;
77  double yTrack = muChMatch.y;
78 
79  for (int iLayer = 1; iLayer <= CSCDetId::maxLayerId(); ++iLayer) {
80  const CSCDetId chId(muChMatch.id.rawId());
81  const CSCDetId layerId(chId.endcap(), chId.station(), chId.ring(), chId.chamber(), iLayer);
82 
83  auto range = m_cscDigis->get(layerId);
84 
85  for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
86  std::vector<int> adcVals = digiIt->getADCCounts();
87  bool hasFired = false;
88  float pedestal = 0.5 * (float)(adcVals[0] + adcVals[1]);
89  float threshold = 13.3;
90  float diff = 0.;
91  for (const auto& adcVal : adcVals) {
92  diff = (float)adcVal - pedestal;
93  if (diff > threshold) {
94  hasFired = true;
95  break;
96  }
97  }
98 
99  if (!hasFired)
100  continue;
101 
102  const CSCLayerGeometry* layerGeom = m_cscGeometry->layer(layerId)->geometry();
103 
104  Float_t xStrip = layerGeom->xOfStrip(digiIt->getStrip(), yTrack);
105  float dX = std::abs(xStrip - xTrack);
106 
107  if (dX < m_digiMaxDistanceX)
108  nDigisInRange++;
109  }
110  }
111  }
112 
113  muChMatch.nDigisInRange = nDigisInRange;
114 }
115 
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
MuonShowerDigiFiller(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::Handle< DTDigiCollection > m_dtDigis
void getDigis(edm::Event &iEvent)
edm::EDGetTokenT< CSCStripDigiCollection > m_cscDigisToken
float xOfStrip(int strip, float y=0.) const
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
int iEvent
Definition: GenABIO.cc:224
edm::ESHandle< DTGeometry > m_dtGeometry
static const int maxLayerId
highest layer id
Definition: DTChamberId.h:70
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int maxSuperLayerId
highest superlayer id
Definition: DTChamberId.h:66
edm::EDGetTokenT< DTDigiCollection > m_dtDigisToken
void fillDefault(reco::MuonChamberMatch &muChMatch) const
void getES(const edm::EventSetup &iSetup)
HLT enums.
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
T get() const
Definition: EventSetup.h:73
edm::ESHandle< CSCGeometry > m_cscGeometry
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
static constexpr int DT
Definition: MuonSubdetId.h:11
edm::Handle< CSCStripDigiCollection > m_cscDigis
static constexpr int CSC
Definition: MuonSubdetId.h:12
static int maxLayerId()
Definition: CSCDetId.h:228
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
void fill(reco::MuonChamberMatch &muChMatch) const