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 ( )
inline

Definition at line 40 of file CSCComparatorDigiFitter.h.

40 {}
CSCComparatorDigiFitter::~CSCComparatorDigiFitter ( )
inline

Definition at line 41 of file CSCComparatorDigiFitter.h.

41 {}

Member Function Documentation

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

Definition at line 213 of file CSCComparatorDigiFitter.cc.

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

Referenced by fit(), and useKeyRadius().

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 }
alpha
zGenParticlesMatch = cms.InputTag(""),
bool CSCComparatorDigiFitter::comparatorInLCTPattern ( int  keyStrip,
int  pattern,
int  layer,
int  halfStrip 
) const
private

Definition at line 243 of file CSCComparatorDigiFitter.cc.

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

Referenced by matchingComparatorDigisLCT(), and useKeyRadius().

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 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
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
float CSCComparatorDigiFitter::cscHalfStripWidth ( const CSCDetId id) const
private

Definition at line 235 of file CSCComparatorDigiFitter.cc.

References degrees_, M_PI, and strips_.

Referenced by getComparatorDigiCoordinates(), and useKeyRadius().

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 }
const std::vector< int > strips_
const std::vector< float > degrees_
#define M_PI
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.

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(), and useKeyRadius().

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 }
int chamber() const
Definition: CSCDetId.h:62
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:81
T perp() const
Definition: PV3DBase.h:69
void getComparatorDigiCoordinates(const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &stub)
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
int endcap() const
Definition: CSCDetId.h:85
float getFractionalStrip() const
return the fractional strip. counts from 0.25
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
float middleWireOfGroup(int wireGroup) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
void matchingComparatorDigisLCT(const CSCDetId &ch_id, const CSCCorrelatedLCTDigi &, const CSCComparatorDigiCollection &)
int ring() const
Definition: CSCDetId.h:68
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
const CSCGeometry * cscGeometry_
int station() const
Definition: CSCDetId.h:79
void calculateSlopeIntercept(float &alpha, float &beta)
alpha
zGenParticlesMatch = cms.InputTag(""),
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
int getKeyWG() const
return the key wire group. counts from 0.
void CSCComparatorDigiFitter::getComparatorDigiCoordinates ( const CSCDetId ch_id,
const CSCCorrelatedLCTDigi stub 
)
private

Definition at line 94 of file CSCComparatorDigiFitter.cc.

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(), and useKeyRadius().

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 }
size
Write out results.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:81
T perp() const
Definition: PV3DBase.h:69
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
float cscHalfStripWidth(const CSCDetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
CSCComparatorDigiContainerIds compDigisIds_
#define M_PI
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
ESHandle< TrackerGeometry > geometry
const CSCGeometry * cscGeometry_
int getKeyWG() const
return the key wire group. counts from 0.
void CSCComparatorDigiFitter::matchingComparatorDigisLCT ( const CSCDetId ch_id,
const CSCCorrelatedLCTDigi stub,
const CSCComparatorDigiCollection hCSCComparators 
)
private

Definition at line 64 of file CSCComparatorDigiFitter.cc.

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

Referenced by fit(), and useKeyRadius().

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 }
int chamber() const
Definition: CSCDetId.h:62
int getStrip() const
return the key halfstrip from 0,159
std::vector< CSCComparatorDigi > CSCComparatorDigiContainer
int endcap() const
Definition: CSCDetId.h:85
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CSCComparatorDigiContainerIds compDigisIds_
int ring() const
Definition: CSCDetId.h:68
bool comparatorInLCTPattern(int keyStrip, int pattern, int layer, int halfStrip) const
int getPattern() const
return pattern
int station() const
Definition: CSCDetId.h:79
void CSCComparatorDigiFitter::setGeometry ( const CSCGeometry csc_g)
inline

Definition at line 44 of file CSCComparatorDigiFitter.h.

References cscGeometry_.

44 { cscGeometry_ = csc_g; }
const CSCGeometry * cscGeometry_
void CSCComparatorDigiFitter::setStripBits ( int  bits)
inline

Definition at line 47 of file CSCComparatorDigiFitter.h.

References bits, and nStripBits_.

47 { nStripBits_ = 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
void CSCComparatorDigiFitter::useKeyRadius ( bool  useKeyRadius)
inline

Member Data Documentation

CSCComparatorDigiContainerIds CSCComparatorDigiFitter::compDigisIds_
private
const CSCGeometry* CSCComparatorDigiFitter::cscGeometry_
private

Definition at line 80 of file CSCComparatorDigiFitter.h.

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

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().

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

Definition at line 91 of file CSCComparatorDigiFitter.h.

Referenced by getComparatorDigiCoordinates().

int CSCComparatorDigiFitter::nStripBits_
private

Definition at line 83 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and setStripBits().

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

Definition at line 92 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and getComparatorDigiCoordinates().

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().

bool CSCComparatorDigiFitter::useKeyRadius_
private

Definition at line 93 of file CSCComparatorDigiFitter.h.

Referenced by fit(), and useKeyRadius().

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