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 
23 //
24 // constructors and destructor
25 //
26 
28  : m_digiMaxDistanceX(iConfig.getParameter<double>("digiMaxDistanceX")),
29  m_dtDigisToken(iC.consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("dtDigiCollectionLabel"))),
30  m_cscDigisToken(
31  iC.consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("cscDigiCollectionLabel"))),
32  m_dtGeometryToken(iC.esConsumes<edm::Transition::BeginRun>()),
33  m_cscGeometryToken(iC.esConsumes<edm::Transition::BeginRun>()) {}
34 
35 //
36 // member functions
37 //
38 
42 }
43 
45  iEvent.getByToken(m_dtDigisToken, m_dtDigis);
46  iEvent.getByToken(m_cscDigisToken, m_cscDigis);
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 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Handle< DTDigiCollection > m_dtDigis
void getDigis(edm::Event &iEvent)
edm::EDGetTokenT< CSCStripDigiCollection > m_cscDigisToken
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
void fillDefault(reco::MuonChamberMatch &muChMatch) const
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
Transition
Definition: Transition.h:12
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
static const int maxSuperLayerId
highest superlayer id
Definition: DTChamberId.h:66
edm::EDGetTokenT< DTDigiCollection > m_dtDigisToken
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > m_cscGeometryToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
void getES(const edm::EventSetup &iSetup)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void fill(reco::MuonChamberMatch &muChMatch) const
HLT enums.
edm::ESHandle< CSCGeometry > m_cscGeometry
edm::ESGetToken< DTGeometry, MuonGeometryRecord > m_dtGeometryToken
float xOfStrip(int strip, float y=0.) const
static constexpr int DT
Definition: MuonSubdetId.h:11
edm::Handle< CSCStripDigiCollection > m_cscDigis
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
static constexpr int CSC
Definition: MuonSubdetId.h:12
static int maxLayerId()
Definition: CSCDetId.h:243
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:63
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96