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 
19 // system include files
20 
21 // user include files
23 
25 
26 //
27 // constructors and destructor
28 //
29 
31  m_digiMaxDistanceX(iConfig.getParameter<double>("digiMaxDistanceX")),
32  m_dtDigisToken(iC.consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("dtDigiCollectionLabel"))),
33  m_cscDigisToken(iC.consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("cscDigiCollectionLabel")))
34 {
35 
36 }
37 
38 
39 //
40 // member functions
41 //
42 
43 void
45 {
46 
47  iSetup.get<MuonGeometryRecord>().get(m_dtGeometry);
48  iSetup.get<MuonGeometryRecord>().get(m_cscGeometry);
49 
50 }
51 
52 void
54 {
55 
58 
59 }
60 
61 void
63 {
64 
65  int nDigisInRange = 0;
66 
67  // DT chamber
68  if( muChMatch.detector() == MuonSubdetId::DT )
69  {
70  double xTrack = muChMatch.x;
71 
72  for (int sl = 1; sl <= DTChamberId::maxSuperLayerId; sl += 2)
73  {
74  for (int layer = 1; layer <= DTChamberId::maxLayerId; ++layer)
75  {
76  const DTLayerId layerId(DTChamberId(muChMatch.id.rawId()),sl,layer);
77 
78  auto range = m_dtDigis->get(layerId);
79 
80  for (auto digiIt = range.first ;digiIt!=range.second; ++digiIt)
81  {
82  const auto topo = m_dtGeometry->layer(layerId)->specificTopology();
83 
84  double xWire = topo.wirePosition((*digiIt).wire());
85  double dX = std::abs(xWire - xTrack);
86 
87  if (dX < m_digiMaxDistanceX)
88  nDigisInRange++;
89  }
90  }
91  }
92  }
93 
94  else if(muChMatch.detector() == MuonSubdetId::CSC)
95  {
96 
97  double xTrack = muChMatch.x;
98  double yTrack = muChMatch.y;
99 
100  for (int iLayer = 1; iLayer <= CSCDetId::maxLayerId(); ++iLayer)
101  {
102  const CSCDetId chId(muChMatch.id.rawId());
103  const CSCDetId layerId(chId.endcap(), chId.station(),
104  chId.ring(), chId.chamber(),
105  iLayer);
106 
107  auto range = m_cscDigis->get(layerId);
108 
109  for (auto digiIt = range.first ;digiIt!=range.second; ++digiIt)
110  {
111 
112  std::vector<int> adcVals = digiIt->getADCCounts();
113  bool hasFired = false;
114  float pedestal = 0.5*(float)(adcVals[0]+adcVals[1]);
115  float threshold = 13.3 ;
116  float diff = 0.;
117  for (const auto & adcVal : adcVals)
118  {
119  diff = (float)adcVal - pedestal;
120  if (diff > threshold)
121  {
122  hasFired = true;
123  break;
124  }
125  }
126 
127  if (!hasFired) continue;
128 
129  const CSCLayerGeometry* layerGeom = m_cscGeometry->layer(layerId)->geometry();
130 
131  Float_t xStrip = layerGeom->xOfStrip(digiIt->getStrip(), yTrack);
132  float dX = std::abs(xStrip - xTrack);
133 
134  if (dX < m_digiMaxDistanceX)
135  nDigisInRange++;
136  }
137  }
138  }
139 
140  muChMatch.nDigisInRange = nDigisInRange;
141 
142 }
143 
144 void
146 {
147 
148  muChMatch.nDigisInRange = 0;
149 
150 }
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
MuonShowerDigiFiller(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
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:42
int iEvent
Definition: GenABIO.cc:224
static const int CSC
Definition: MuonSubdetId.h:13
edm::ESHandle< DTGeometry > m_dtGeometry
static const int maxLayerId
highest layer id
Definition: DTChamberId.h:85
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int maxSuperLayerId
highest superlayer id
Definition: DTChamberId.h:81
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:139
T get() const
Definition: EventSetup.h:71
edm::ESHandle< CSCGeometry > m_cscGeometry
static const int DT
Definition: MuonSubdetId.h:12
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
edm::Handle< CSCStripDigiCollection > m_cscDigis
static int maxLayerId()
Definition: CSCDetId.h:245
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
void fill(reco::MuonChamberMatch &muChMatch) const