CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CSCComparatorDigiFitter Class Reference

#include <CSCComparatorDigiFitter.h>

Public Member Functions

 CSCComparatorDigiFitter ()
 
void fit (const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &, const CSCComparatorDigiCollection &, std::vector< float > &fit_phi_layers, std::vector< float > &fit_z_layers, float &keyRadius)
 
void setGeometry (const CSCGeometry *csc_g)
 
void setStripBits (int bits)
 
void useKeyRadius (bool useKeyRadius)
 
 ~CSCComparatorDigiFitter ()
 

Private Member Functions

void calculateSlopeIntercept (float &alpha, float &beta)
 
bool comparatorInLCTPattern (int keyStrip, int pattern, int layer, int halfStrip) const
 
float cscHalfStripWidth (const CSCDetId &id) const
 
void getComparatorDigiCoordinates (const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &stub)
 
void matchingComparatorDigisLCT (const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &, const CSCComparatorDigiCollection &)
 

Private Attributes

CSCComparatorDigiContainerIds compDigisIds_
 
const CSCGeometrycscGeometry_
 
const std::vector< float > degrees_ = {10., 10., 10., 10., 20., 10., 20., 10., 20., 10.}
 
std::vector< float > ephis_
 
std::vector< float > ezs_
 
int nStripBits_
 
std::vector< float > phis_
 
float radius_
 
const std::vector< int > strips_ = {48, 64, 80, 64, 80, 80, 80, 80, 80, 80}
 
bool useKeyRadius_
 
std::vector< float > zs_
 

Detailed Description

Definition at line 38 of file CSCComparatorDigiFitter.h.

Constructor & Destructor Documentation

◆ CSCComparatorDigiFitter()

CSCComparatorDigiFitter::CSCComparatorDigiFitter ( )
inline

Definition at line 40 of file CSCComparatorDigiFitter.h.

40 {}

◆ ~CSCComparatorDigiFitter()

CSCComparatorDigiFitter::~CSCComparatorDigiFitter ( )
inline

Definition at line 41 of file CSCComparatorDigiFitter.h.

41 {}

Member Function Documentation

◆ calculateSlopeIntercept()

void CSCComparatorDigiFitter::calculateSlopeIntercept ( float &  alpha,
float &  beta 
)
private

Definition at line 213 of file CSCComparatorDigiFitter.cc.

213  {
214  // if there are at least 3 hits in the chamber, do a linear fit to the
215  // comparator digi positions with the chi2 method
216  if (phis_.size() >= 3) {
217  float Sxx = 0, Sxy = 0, Sx = 0, Sy = 0, S = 0;
218  for (unsigned i = 0; i < phis_.size(); ++i) {
219  float sigma2_inv = 1. / ephis_[i] * ephis_[i];
220  Sxx += zs_[i] * zs_[i] * sigma2_inv;
221  Sxy += zs_[i] * phis_[i] * sigma2_inv;
222  Sx += zs_[i] * zs_[i] * sigma2_inv;
223  Sy += phis_[i] * sigma2_inv;
224  S += sigma2_inv;
225  }
226  float delta = S * Sxx - Sx * Sx;
227  alpha = (Sxx * Sy - Sx * Sxy) / delta;
228  beta = (S * Sxy - Sx * Sy) / delta;
229  } else {
230  alpha = -99;
231  beta = 0.0;
232  }
233 }

References zMuMuMuonUserData::alpha, zMuMuMuonUserData::beta, dumpMFGeometry_cfg::delta, ephis_, mps_fire::i, phis_, and zs_.

Referenced by fit().

◆ comparatorInLCTPattern()

bool CSCComparatorDigiFitter::comparatorInLCTPattern ( int  keyStrip,
int  pattern,
int  layer,
int  halfStrip 
) const
private

Definition at line 243 of file CSCComparatorDigiFitter.cc.

243  {
244  // get the (sub)pattern
245  const std::vector<int>& subpat = patIndexToPatternDelta[pattern].at(layer - 1);
246 
247  // due to comparator digi time extension in the CLCT processor we need to
248  // search a bigger region around the key HS. +/-1, 0 should be sufficient
249  const int halfStripDelta = halfStrip - keyStrip;
250  return (std::find(subpat.begin(), subpat.end(), halfStripDelta + 1) != subpat.end() or
251  std::find(subpat.begin(), subpat.end(), halfStripDelta) != subpat.end() or
252  std::find(subpat.begin(), subpat.end(), halfStripDelta - 1) != subpat.end());
253 }

References spr::find(), or, and topSingleLeptonDQM_PU_cfi::pattern.

Referenced by matchingComparatorDigisLCT().

◆ cscHalfStripWidth()

float CSCComparatorDigiFitter::cscHalfStripWidth ( const CSCDetId id) const
private

Definition at line 235 of file CSCComparatorDigiFitter.cc.

235  {
236  // what is the chamber type?
237  int index = id.iChamberType() - 1;
238 
239  // calculate the half strip width of this chamber
240  return degrees_[index] * M_PI / 180. / (2. * strips_[index]);
241 }

References degrees_, M_PI, and strips_.

Referenced by getComparatorDigiCoordinates().

◆ fit()

void CSCComparatorDigiFitter::fit ( const CSCDetId ch_id,
const CSCCorrelatedLCTDigi stub,
const CSCComparatorDigiCollection hCSCComparators,
std::vector< float > &  fit_phi_layers,
std::vector< float > &  fit_z_layers,
float &  keyRadius 
)

Definition at line 150 of file CSCComparatorDigiFitter.cc.

155  {
156  // clear fit results
157  fit_phi_layers.clear();
158  fit_z_layers.clear();
159  keyRadius = 0;
160 
161  // first, match the comparator digis to the LCT
162  matchingComparatorDigisLCT(ch_id, stub, hCSCComparators);
163 
164  // second, get the coordinates
165  getComparatorDigiCoordinates(ch_id, stub);
166 
167  // get radius of the stub from key layer
168  const CSCDetId key_id(ch_id.endcap(), ch_id.station(), ch_id.ring(), ch_id.chamber(), CSCConstants::KEY_CLCT_LAYER);
169  const float fractional_strip = stub.getFractionalStrip();
170 
171  const auto& cscChamber = cscGeometry_->chamber(ch_id);
172  const auto& layer_geo = cscChamber->layer(CSCConstants::KEY_CLCT_LAYER)->geometry();
173 
174  // LCT::getKeyWG() also starts from 0
175  const float wire = layer_geo->middleWireOfGroup(stub.getKeyWG() + 1);
176  const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
177  const GlobalPoint& csc_gp = cscGeometry_->idToDet(key_id)->surface().toGlobal(csc_intersect);
178 
179  // get radius from key layer
180  if (useKeyRadius_)
181  radius_ = radius_ / phis_.size();
182  else
183  radius_ = csc_gp.perp();
184 
185  float alpha = -99., beta = 0.;
186  // do a fit to the comparator digis
188  if (phis_.size() <= 2 or std::abs(alpha) >= 99) {
189  alpha = csc_gp.phi();
190  beta = 0.0;
191  }
192 
193  // determine the pitch of the chamber
194  // option to discretize the pitch
195  float stripPhiPitch = layer_geo->stripPhiPitch();
196  if (nStripBits_)
197  stripPhiPitch = stripPhiPitch / nStripBits_;
198 
199  // get the fit results
200  // option to discretize the fitted phi value
201  keyRadius = radius_;
202 
203  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
204  const float fit_z = cscChamber->layer(i + 1)->centerOfStrip(20).z();
205  const float fit_phi = normalizedPhi(alpha + beta * fit_z);
206  fit_z_layers.push_back(fit_z);
207  fit_phi_layers.push_back(fit_phi);
208  if (nStripBits_)
209  fit_phi_layers.push_back((std::floor(fit_phi / stripPhiPitch) + 0.5) * stripPhiPitch);
210  }
211 }

References funct::abs(), zMuMuMuonUserData::alpha, zMuMuMuonUserData::beta, calculateSlopeIntercept(), CSCDetId::chamber(), CSCGeometry::chamber(), cscGeometry_, CSCDetId::endcap(), CSCLayer::geometry(), getComparatorDigiCoordinates(), CSCCorrelatedLCTDigi::getFractionalStrip(), CSCCorrelatedLCTDigi::getKeyWG(), mps_fire::i, CSCGeometry::idToDet(), CSCConstants::KEY_CLCT_LAYER, CSCChamber::layer(), matchingComparatorDigisLCT(), CSCLayerGeometry::middleWireOfGroup(), normalizedPhi(), nStripBits_, CSCConstants::NUM_LAYERS, or, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phis_, radius_, CSCDetId::ring(), CSCDetId::station(), GeomDet::surface(), Surface::toGlobal(), and useKeyRadius_.

Referenced by trackingPlots.Iteration::modules().

◆ getComparatorDigiCoordinates()

void CSCComparatorDigiFitter::getComparatorDigiCoordinates ( const CSCDetId ch_id,
const CSCCorrelatedLCTDigi stub 
)
private

Definition at line 94 of file CSCComparatorDigiFitter.cc.

94  {
95  const auto& cscChamber = cscGeometry_->chamber(ch_id);
96 
97  // get the z and phi positions of the comparator digis
98  float radius_ = 0.0;
99 
100  // loop on all matching digis
101  for (const auto& p : compDigisIds_) {
102  const auto& detId = p.first;
103 
104  float phi_tmp = 0.0;
105  float radius_tmp = 0.0;
106  float z_tmp = 0.0;
107 
108  // ignore layers with no digis
109  if (p.second.empty())
110  continue;
111 
112  // loop on all matching digis in this layer
113  for (const auto& hit : p.second) {
114  const float fractional_strip = hit.getFractionalStrip();
115  const auto& layer_geo = cscChamber->layer(detId.layer())->geometry();
116  const float wire = layer_geo->middleWireOfGroup(stub.getKeyWG() + 1);
117 
118  // get the phi of each comparator digi
119  const LocalPoint& csc_intersect = layer_geo->intersectionOfStripAndWire(fractional_strip, wire);
120  const GlobalPoint& csc_gp = cscGeometry_->idToDet(detId)->surface().toGlobal(csc_intersect);
121  const float gpphi = csc_gp.phi();
122 
123  // normalize phi values according to first one
124  if (!phis_.empty() and gpphi > 0 and phis_[0] < 0 and (gpphi - phis_[0]) > M_PI)
125  phi_tmp += (gpphi - 2 * M_PI);
126  else if (!phis_.empty() and gpphi < 0 and phis_[0] > 0 and (gpphi - phis_[0]) < -M_PI)
127  phi_tmp += (gpphi + 2 * M_PI);
128  else
129  phi_tmp += (csc_gp.phi());
130 
131  z_tmp = csc_gp.z();
132  radius_tmp += csc_gp.perp();
133  }
134 
135  //in case there are more than one comparator digis in one layer
136  radius_tmp = radius_tmp / (p.second).size();
137  radius_ += radius_tmp;
138 
139  zs_.push_back(z_tmp);
140  ezs_.push_back(0);
141 
142  phi_tmp = phi_tmp / (p.second).size();
143  phis_.push_back(phi_tmp);
144  // assume that the charge is flat distributed across the half-strip
145  // this is only approximately valid, but good enough for now
146  ephis_.push_back(cscHalfStripWidth(detId) / sqrt(12));
147  }
148 }

References CSCGeometry::chamber(), compDigisIds_, cscGeometry_, cscHalfStripWidth(), ephis_, ezs_, geometry, CSCCorrelatedLCTDigi::getKeyWG(), CSCGeometry::idToDet(), M_PI, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phis_, radius_, findQualityFiles::size, mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), PV3DBase< T, PVType, FrameType >::z(), and zs_.

Referenced by fit().

◆ matchingComparatorDigisLCT()

void CSCComparatorDigiFitter::matchingComparatorDigisLCT ( const CSCDetId ch_id,
const CSCCorrelatedLCTDigi stub,
const CSCComparatorDigiCollection hCSCComparators 
)
private

Definition at line 64 of file CSCComparatorDigiFitter.cc.

66  {
67  // fetch the CSC comparator digis in this chamber
68  for (int iLayer = 1; iLayer <= CSCConstants::NUM_LAYERS; ++iLayer) {
69  const CSCDetId layerId(ch_id.endcap(), ch_id.station(), ch_id.ring(), ch_id.chamber(), iLayer);
70 
71  // get the digis per layer
72  const auto& compRange = hCSCComparators.get(layerId);
74 
75  for (auto compDigiItr = compRange.first; compDigiItr != compRange.second; compDigiItr++) {
76  const auto& compDigi = *compDigiItr;
77 
78  //if (stub.getTimeBin() < 4 or stub.getTimeBin() > 8) continue;
79  const int stubHalfStrip(compDigi.getHalfStrip());
80 
81  // these comparator digis never fit the pattern anyway!
82  if (std::abs(stubHalfStrip - stub.getStrip()) > 5)
83  continue;
84 
85  // check if this comparator digi fits the pattern
86  if (comparatorInLCTPattern(stub.getStrip(), stub.getPattern(), iLayer, stubHalfStrip)) {
87  compDigis.push_back(compDigi);
88  }
89  }
90  compDigisIds_.emplace_back(layerId, compDigis);
91  }
92 }

References funct::abs(), CSCDetId::chamber(), comparatorInLCTPattern(), compDigisIds_, CSCDetId::endcap(), CSCCorrelatedLCTDigi::getPattern(), CSCCorrelatedLCTDigi::getStrip(), CSCConstants::NUM_LAYERS, CSCDetId::ring(), and CSCDetId::station().

Referenced by fit().

◆ setGeometry()

void CSCComparatorDigiFitter::setGeometry ( const CSCGeometry csc_g)
inline

Definition at line 44 of file CSCComparatorDigiFitter.h.

44 { cscGeometry_ = csc_g; }

References cscGeometry_.

◆ setStripBits()

void CSCComparatorDigiFitter::setStripBits ( int  bits)
inline

Definition at line 47 of file CSCComparatorDigiFitter.h.

47 { nStripBits_ = bits; }

References bits, and nStripBits_.

◆ useKeyRadius()

void CSCComparatorDigiFitter::useKeyRadius ( bool  useKeyRadius)
inline

Definition at line 50 of file CSCComparatorDigiFitter.h.

References useKeyRadius(), and useKeyRadius_.

Referenced by useKeyRadius().

Member Data Documentation

◆ compDigisIds_

CSCComparatorDigiContainerIds CSCComparatorDigiFitter::compDigisIds_
private

◆ cscGeometry_

const CSCGeometry* CSCComparatorDigiFitter::cscGeometry_
private

Definition at line 80 of file CSCComparatorDigiFitter.h.

Referenced by fit(), getComparatorDigiCoordinates(), and setGeometry().

◆ degrees_

const std::vector<float> CSCComparatorDigiFitter::degrees_ = {10., 10., 10., 10., 20., 10., 20., 10., 20., 10.}
private

Definition at line 98 of file CSCComparatorDigiFitter.h.

Referenced by cscHalfStripWidth().

◆ ephis_

std::vector<float> CSCComparatorDigiFitter::ephis_
private

◆ ezs_

std::vector<float> CSCComparatorDigiFitter::ezs_
private

Definition at line 91 of file CSCComparatorDigiFitter.h.

Referenced by getComparatorDigiCoordinates().

◆ nStripBits_

int CSCComparatorDigiFitter::nStripBits_
private

Definition at line 83 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and setStripBits().

◆ phis_

std::vector<float> CSCComparatorDigiFitter::phis_
private

◆ radius_

float CSCComparatorDigiFitter::radius_
private

Definition at line 92 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and getComparatorDigiCoordinates().

◆ strips_

const std::vector<int> CSCComparatorDigiFitter::strips_ = {48, 64, 80, 64, 80, 80, 80, 80, 80, 80}
private

Definition at line 97 of file CSCComparatorDigiFitter.h.

Referenced by cscHalfStripWidth().

◆ useKeyRadius_

bool CSCComparatorDigiFitter::useKeyRadius_
private

Definition at line 93 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and useKeyRadius().

◆ zs_

std::vector<float> CSCComparatorDigiFitter::zs_
private
CSCComparatorDigiFitter::radius_
float radius_
Definition: CSCComparatorDigiFitter.h:92
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
mps_fire.i
i
Definition: mps_fire.py:355
CSCComparatorDigiFitter::phis_
std::vector< float > phis_
Definition: CSCComparatorDigiFitter.h:88
CSCChamber::layer
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
CSCComparatorDigiFitter::ephis_
std::vector< float > ephis_
Definition: CSCComparatorDigiFitter.h:90
CSCComparatorDigiFitter::calculateSlopeIntercept
void calculateSlopeIntercept(float &alpha, float &beta)
Definition: CSCComparatorDigiFitter.cc:213
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCCorrelatedLCTDigi::getStrip
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
Definition: CSCCorrelatedLCTDigi.cc:66
CSCGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
CSCCorrelatedLCTDigi::getKeyWG
uint16_t getKeyWG() const
return the key wire group. counts from 0.
Definition: CSCCorrelatedLCTDigi.h:56
CSCCorrelatedLCTDigi::getFractionalStrip
float getFractionalStrip(uint16_t n=2) const
return the fractional strip. counts from 0.25
Definition: CSCCorrelatedLCTDigi.cc:102
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
CSCComparatorDigiFitter::degrees_
const std::vector< float > degrees_
Definition: CSCComparatorDigiFitter.h:98
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
CSCComparatorDigiFitter::cscHalfStripWidth
float cscHalfStripWidth(const CSCDetId &id) const
Definition: CSCComparatorDigiFitter.cc:235
CSCComparatorDigiFitter::useKeyRadius
void useKeyRadius(bool useKeyRadius)
Definition: CSCComparatorDigiFitter.h:50
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CSCConstants::NUM_LAYERS
Definition: CSCConstants.h:46
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
CSCLayerGeometry::middleWireOfGroup
float middleWireOfGroup(int wireGroup) const
Definition: CSCLayerGeometry.h:191
CSCLayer::geometry
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
Point3DBase< float, LocalTag >
CSCComparatorDigiFitter::matchingComparatorDigisLCT
void matchingComparatorDigisLCT(const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &, const CSCComparatorDigiCollection &)
Definition: CSCComparatorDigiFitter.cc:64
CSCComparatorDigiFitter::getComparatorDigiCoordinates
void getComparatorDigiCoordinates(const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &stub)
Definition: CSCComparatorDigiFitter.cc:94
CSCComparatorDigiFitter::strips_
const std::vector< int > strips_
Definition: CSCComparatorDigiFitter.h:97
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
CSCDetId
Definition: CSCDetId.h:26
CSCComparatorDigiFitter::useKeyRadius_
bool useKeyRadius_
Definition: CSCComparatorDigiFitter.h:93
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
CSCComparatorDigiFitter::ezs_
std::vector< float > ezs_
Definition: CSCComparatorDigiFitter.h:91
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
CSCComparatorDigiFitter::compDigisIds_
CSCComparatorDigiContainerIds compDigisIds_
Definition: CSCComparatorDigiFitter.h:85
bits
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
Definition: EventSelector-behavior.doc:35
CSCComparatorDigiFitter::comparatorInLCTPattern
bool comparatorInLCTPattern(int keyStrip, int pattern, int layer, int halfStrip) const
Definition: CSCComparatorDigiFitter.cc:243
CSCCorrelatedLCTDigi::getPattern
uint16_t getPattern() const
Definition: CSCCorrelatedLCTDigi.h:78
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
CSCConstants::KEY_CLCT_LAYER
Definition: CSCConstants.h:46
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
S
Definition: CSCDBL1TPParametersExtended.h:16
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CSCComparatorDigiContainer
std::vector< CSCComparatorDigi > CSCComparatorDigiContainer
Definition: CSCComparatorDigiFitter.h:35
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CSCComparatorDigiFitter::nStripBits_
int nStripBits_
Definition: CSCComparatorDigiFitter.h:83
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCComparatorDigiFitter::zs_
std::vector< float > zs_
Definition: CSCComparatorDigiFitter.h:89
CSCComparatorDigiFitter::cscGeometry_
const CSCGeometry * cscGeometry_
Definition: CSCComparatorDigiFitter.h:80
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
CSCGeometry::chamber
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
hit
Definition: SiStripHitEffFromCalibTree.cc:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443