CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
AngleConverterBase Class Reference

#include <AngleConverterBase.h>

Inheritance diagram for AngleConverterBase:
OmtfAngleConverter OmtfPhase2AngleConverter

Public Member Functions

 AngleConverterBase ()
 
virtual void checkAndUpdateGeometry (const edm::EventSetup &, const ProcConfigurationBase *config, const MuonGeometryTokens &muonGeometryTokens)
 Update the Geometry with current Event Setup. More...
 
float cscChamberEtaSize (const CSCDetId &id) const
 
virtual void getGlobalEta (const L1MuDTChambThDigi &thetaDigi, std::vector< EtaValue > &etaSegments) const
 
virtual std::vector< EtaValuegetGlobalEta (const L1MuDTChambThContainer *dtThDigis, int bxFrom, int bxTo) const
 
virtual EtaValue getGlobalEta (const CSCDetId &detId, const CSCCorrelatedLCTDigi &aDigi) const
 Convert local eta coordinate to global digital microGMT scale. More...
 
virtual EtaValue getGlobalEta (unsigned int rawid, const unsigned int &aDigi) const
 
virtual EtaValue getGlobalEtaCsc (const CSCDetId &detId) const
 returns the eta position of the CSC chamber More...
 
virtual EtaValue getGlobalEtaDt (const DTChamberId &detId) const
 
virtual int getProcessorPhi (int phiZero, l1t::tftype part, int dtScNum, int dtPhi) const
 
virtual int getProcessorPhi (int phiZero, l1t::tftype part, const CSCDetId &csc, const CSCCorrelatedLCTDigi &digi, unsigned int iInput) const
 
virtual int getProcessorPhi (unsigned int iProcessor, l1t::tftype part, const RPCDetId &rollId, const unsigned int &digi) const
 
virtual int getProcessorPhi (int phiZero, l1t::tftype part, const RPCDetId &rollId, const unsigned int &digi1, const unsigned int &digi2) const
 
virtual ~AngleConverterBase ()
 

Protected Member Functions

virtual const int findBTIgroup (const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
 Find BTI group. More...
 
virtual bool isCSCCounterClockwise (const CSCLayer *layer) const
 Check orientation of strips in given CSC chamber. More...
 

Protected Attributes

edm::ESHandle< CSCGeometry_geocsc
 
edm::ESHandle< DTGeometry_geodt
 
unsigned long long _geom_cache_id = 0
 
edm::ESHandle< RPCGeometry_georpc
 
const ProcConfigurationBaseconfig = nullptr
 
edm::ESWatcher< MuonGeometryRecordmuonGeometryRecordWatcher
 
unsigned int nPhiBins = 0
 Number of phi bins along 2Pi. More...
 

Detailed Description

Definition at line 49 of file AngleConverterBase.h.

Constructor & Destructor Documentation

◆ AngleConverterBase()

AngleConverterBase::AngleConverterBase ( )

Definition at line 41 of file AngleConverterBase.cc.

41 : _geom_cache_id(0ULL) {}
unsigned long long _geom_cache_id

◆ ~AngleConverterBase()

AngleConverterBase::~AngleConverterBase ( )
virtual

Definition at line 44 of file AngleConverterBase.cc.

44 {}

Member Function Documentation

◆ checkAndUpdateGeometry()

void AngleConverterBase::checkAndUpdateGeometry ( const edm::EventSetup es,
const ProcConfigurationBase config,
const MuonGeometryTokens muonGeometryTokens 
)
virtual

Update the Geometry with current Event Setup.

Definition at line 47 of file AngleConverterBase.cc.

References _geocsc, _geodt, _georpc, edm::ESWatcher< T >::check(), config, MuonGeometryTokens::cscGeometryEsToken, MuonGeometryTokens::dtGeometryEsToken, edm::EventSetup::getHandle(), muonGeometryRecordWatcher, nPhiBins, and MuonGeometryTokens::rpcGeometryEsToken.

49  {
51  _georpc = es.getHandle(muonGeometryTokens.rpcGeometryEsToken);
52  _geocsc = es.getHandle(muonGeometryTokens.cscGeometryEsToken);
53  _geodt = es.getHandle(muonGeometryTokens.dtGeometryEsToken);
54  }
55  this->config = config;
56  nPhiBins = config->nPhiBins();
57 }
edm::ESHandle< DTGeometry > _geodt
const ProcConfigurationBase * config
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeometryEsToken
edm::ESHandle< RPCGeometry > _georpc
Definition: config.py:1
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryEsToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
unsigned int nPhiBins
Number of phi bins along 2Pi.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryEsToken
edm::ESHandle< CSCGeometry > _geocsc
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< MuonGeometryRecord > muonGeometryRecordWatcher

◆ cscChamberEtaSize()

float AngleConverterBase::cscChamberEtaSize ( const CSCDetId id) const

ME1/1 lower eta (b?, eta < ~2.1), L1TkMuonBayes eta bins 6-11 - but getGlobalEtaCsc(const CSCDetId& detId) gives the midle of the full chamber, so here we put the size of the full chamber

ME1/1 higher eta (a?, eta > ~2.1), L1TkMuonBayes eta bins 10-15

Definition at line 303 of file AngleConverterBase.cc.

References hcalRecHitTable_cff::detId.

Referenced by getGlobalEtaCsc().

303  {
304  if (detId.station() == 1) {
305  if (detId.ring() == 1)
306  return (2.5 - 1.6) / 2.;
308  if (detId.ring() == 2)
309  return (1.7 - 1.2) / 2.;
310  if (detId.ring() == 3)
311  return (1.12 - 0.9) / 2.;
312  if (detId.ring() == 4)
313  return (2.5 - 1.6) / 2.;
314  } else if (detId.station() == 2) {
315  if (detId.ring() == 1)
316  return (2.5 - 1.6) / 2.;
317  if (detId.ring() == 2)
318  return (1.6 - 1.0) / 2.;
319  } else if (detId.station() == 3) {
320  if (detId.ring() == 1)
321  return (2.5 - 1.7) / 2.;
322  if (detId.ring() == 2)
323  return (1.7 - 1.1) / 2.;
324  } else if (detId.station() == 4) {
325  if (detId.ring() == 1)
326  return (2.45 - 1.8) / 2.;
327  if (detId.ring() == 2)
328  return (1.8 - 1.2) / 2.;
329  }
330  return 0;
331 }

◆ findBTIgroup()

const int AngleConverterBase::findBTIgroup ( const L1MuDTChambPhDigi aDigi,
const L1MuDTChambThContainer dtThDigis 
)
protectedvirtual

Find BTI group.

If there are more than one theta digi we do not take is due to unresolved ambiguity. In this case we take eta of the middle of the chamber.

Definition at line 436 of file AngleConverterBase.cc.

References L1MuDTChambPhDigi::bxNum(), L1MuDTChambThContainer::chThetaSegm(), mps_fire::i, L1MuDTChambThDigi::position(), L1MuDTChambPhDigi::scNum(), L1MuDTChambPhDigi::stNum(), and L1MuDTChambPhDigi::whNum().

436  {
437  int bti_group = -1;
438 
439  const L1MuDTChambThDigi* theta_segm =
440  dtThDigis->chThetaSegm(aDigi.whNum(), aDigi.stNum(), aDigi.scNum(), aDigi.bxNum());
441  if (!theta_segm)
442  return bti_group;
443 
444  for (unsigned int i = 0; i < 7; ++i) {
445  if (theta_segm->position(i) && bti_group < 0)
446  bti_group = i;
450  else if (theta_segm->position(i) && bti_group > -1)
451  return -1;
452  }
453 
454  return bti_group;
455 }
L1MuDTChambThDigi const * chThetaSegm(int wheel, int stat, int sect, int bx) const
int position(const int i) const

◆ getGlobalEta() [1/4]

void AngleConverterBase::getGlobalEta ( const L1MuDTChambThDigi thetaDigi,
std::vector< EtaValue > &  etaSegments 
) const
virtual

Definition at line 256 of file AngleConverterBase.cc.

References _geodt, L1MuDTChambThDigi::bxNum(), DTGeometry::chamber(), PV3DBase< T, PVType, FrameType >::eta(), DTTrigGeom::nCell(), L1MuDTChambThDigi::position(), L1MuDTChambThDigi::quality(), L1MuDTChambThDigi::scNum(), L1MuDTChambThDigi::stNum(), and L1MuDTChambThDigi::whNum().

Referenced by getGlobalEta().

256  {
257  const DTChamberId baseid(thetaDigi.whNum(), thetaDigi.stNum(), thetaDigi.scNum() + 1);
258  DTTrigGeom trig_geom(_geodt->chamber(baseid), false);
259 
260  // super layer 2 is the theta superlayer in a DT chamber
261  // station 4 does not have a theta super layer
262  // the BTI index from the theta trigger is an OR of some BTI outputs
263  // so, we choose the BTI that's in the middle of the group
264  // as the BTI that we get theta from
265  // TODO:::::>>> need to make sure this ordering doesn't flip under wheel sign
266  const int NBTI_theta = trig_geom.nCell(2);
267  for (unsigned int btiGroup = 0; btiGroup < 7; ++btiGroup) {
268  if (thetaDigi.position(btiGroup)) {
269  unsigned btiActual = btiGroup * NBTI_theta / 7 + NBTI_theta / 14 + 1;
270  DTBtiId thetaBTI = DTBtiId(baseid, 2, btiActual);
271  GlobalPoint theta_gp = trig_geom.CMSPosition(thetaBTI);
272 
273  EtaValue etaValue = {
274  config->etaToHwEta(theta_gp.eta()),
275  0,
276  thetaDigi.quality(btiGroup),
277  thetaDigi.bxNum(),
278  0 //TODO what about sub-bx timing???
279  };
280  etaSegments.emplace_back(etaValue);
281 
282  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" bx "<<thetaDigi.bxNum()<<" baseid "<<baseid<<" btiGroup "<<btiGroup<<" quality "<<thetaDigi.quality(btiGroup)<<" theta_gp.eta() "<<theta_gp.eta()<<" eta "<<etaValue.eta<<" etaSigma "<<etaValue.etaSigma<<std::endl;
283  }
284  }
285 }
edm::ESHandle< DTGeometry > _geodt
T eta() const
Definition: PV3DBase.h:73
int position(const int i) const
Definition: config.py:1
int quality(const int i) const
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
int nCell(int sl) const
Number of BTIs in a required superlayer (i.e. nCells in lay 1)
Definition: DTTrigGeom.h:88

◆ getGlobalEta() [2/4]

std::vector< EtaValue > AngleConverterBase::getGlobalEta ( const L1MuDTChambThContainer dtThDigis,
int  bxFrom,
int  bxTo 
) const
virtual

Definition at line 287 of file AngleConverterBase.cc.

References L1MuDTChambThContainer::getContainer(), and getGlobalEta().

289  {
290  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" dtThDigis size "<<dtThDigis->getContainer()->size()<<std::endl;
291 
292  std::vector<EtaValue> etaSegments;
293 
294  for (auto& thetaDigi : (*(dtThDigis->getContainer()))) {
295  if (thetaDigi.bxNum() >= bxFrom && thetaDigi.bxNum() <= bxTo) {
296  getGlobalEta(thetaDigi, etaSegments);
297  }
298  }
299  return etaSegments;
300 }
The_Container const * getContainer() const
virtual void getGlobalEta(const L1MuDTChambThDigi &thetaDigi, std::vector< EtaValue > &etaSegments) const

◆ getGlobalEta() [3/4]

EtaValue AngleConverterBase::getGlobalEta ( const CSCDetId detId,
const CSCCorrelatedLCTDigi aDigi 
) const
virtual

Convert local eta coordinate to global digital microGMT scale.

Code taken from GeometryTranslator. Will be replaced by direct CSC phi local to global scale transformation as used in FPGA implementation

Definition at line 333 of file AngleConverterBase.cc.

References _geocsc, CSCGeometry::chamber(), hcalRecHitTable_cff::detId, PV3DBase< T, PVType, FrameType >::eta(), CSCLayer::geometry(), CSCCorrelatedLCTDigi::getBX(), CSCCorrelatedLCTDigi::getKeyWG(), CSCConstants::KEY_ALCT_LAYER, nano_mu_digi_cff::layer, and CSCChamber::layer().

333  {
337 
338  // alot of this is transcription and consolidation of the CSC
339  // global phi calculation code
340  // this works directly with the geometry
341  // rather than using the old phi luts
342 
343  auto chamb = _geocsc->chamber(detId);
344  auto layer_geom = chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry();
345  auto layer = chamb->layer(CSCConstants::KEY_ALCT_LAYER);
346 
347  const uint16_t keyWG = aDigi.getKeyWG();
348 
349  const LocalPoint lpWg = layer_geom->localCenterOfWireGroup(keyWG);
350  const GlobalPoint gpWg = layer->surface().toGlobal(lpWg);
351 
352  EtaValue etaSegment = {
353  config->etaToHwEta(gpWg.eta()),
354  0, //config->etaToHwEta(cscChamberEtaSize(id) ),
355  0,
356  aDigi.getBX(),
357  0 //tming???
358  };
359 
360  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" csc "<<detId<<" eta "<<gpWg.eta()<<" etaHw "<<etaSegment.eta<<" etaSigma "<<etaSegment.etaSigma<<std::endl;
361  return etaSegment;
362 }
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
T eta() const
Definition: PV3DBase.h:73
Definition: config.py:1
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
uint16_t getBX() const
return BX
edm::ESHandle< CSCGeometry > _geocsc
uint16_t getKeyWG() const
return the key wire group. counts from 0.

◆ getGlobalEta() [4/4]

EtaValue AngleConverterBase::getGlobalEta ( unsigned int  rawid,
const unsigned int &  aDigi 
) const
virtual

Convert local eta coordinate to global digital microGMT scale. EtaValue::etaSigma is half of the strip

Definition at line 386 of file AngleConverterBase.cc.

References _georpc, funct::abs(), PV3DBase< T, PVType, FrameType >::eta(), runTauDisplay::gp, EcalPhiSymFlatTableProducers_cfi::id, nano_mu_digi_cff::layer, nano_mu_digi_cff::region, relativeConstraints::ring, nano_mu_digi_cff::roll, RPCGeometry::roll(), nano_mu_digi_cff::sector, relativeConstraints::station, nano_mu_digi_cff::strip, and nano_mu_digi_cff::subsector.

386  {
387  const RPCDetId id(rawid);
388 
389  auto roll = _georpc->roll(id);
390  const LocalPoint lp = roll->centreOfStrip((int)strip);
391  const GlobalPoint gp = roll->toGlobal(lp);
392 
393  int neighbRoll = 1; //neighbor roll in eta
394  //roll->chamber()->nrolls() does not work
395  if (id.region() == 0) { //barel
396  if (id.station() == 2 && ((std::abs(id.ring()) == 2 && id.layer() == 2) ||
397  (std::abs(id.ring()) != 2 && id.layer() == 1))) { //three-roll chamber
398  if (id.roll() == 2)
399  neighbRoll = 1;
400  else {
401  neighbRoll = 2;
402  }
403  } else //two-roll chamber
404  neighbRoll = (id.roll() == 1 ? 3 : 1);
405  } else { //endcap
406  neighbRoll = id.roll() + (id.roll() == 1 ? +1 : -1);
407  }
408 
409  const RPCDetId idNeigh =
410  RPCDetId(id.region(), id.ring(), id.station(), id.sector(), id.layer(), id.subsector(), neighbRoll);
411  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" rpc "<<id<<std::endl;
412  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" rpc "<<idNeigh<<std::endl;
413 
414  auto rollNeigh = _georpc->roll(idNeigh);
415  const LocalPoint lpNeigh = rollNeigh->centreOfStrip((int)strip);
416  const GlobalPoint gpNeigh = rollNeigh->toGlobal(lpNeigh);
417 
418  EtaValue etaValue = {config->etaToHwEta(gp.eta()),
419  config->etaToHwEta(std::abs(gp.eta() - gpNeigh.eta())) /
420  2, //half of the size of the strip in eta - not precise, but OK
421  0};
422 
423  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" rpc "<<id<<" eta "<<gp.eta()<<" etaHw "<<etaValue.eta<<" etaSigma "<<etaValue.etaSigma<<std::endl;
424  return etaValue;
425 }
edm::ESHandle< RPCGeometry > _georpc
T eta() const
Definition: PV3DBase.h:73
Definition: config.py:1
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getGlobalEtaCsc()

EtaValue AngleConverterBase::getGlobalEtaCsc ( const CSCDetId detId) const
virtual

returns the eta position of the CSC chamber

Definition at line 366 of file AngleConverterBase.cc.

References _geocsc, CSCGeometry::chamber(), cscChamberEtaSize(), hcalRecHitTable_cff::detId, and PV3DBase< T, PVType, FrameType >::eta().

366  {
367  auto chamb = _geocsc->chamber(detId);
368 
369  Local2DPoint chamberMiddleLP(0, 0);
370  GlobalPoint chamberMiddleGP = chamb->toGlobal(chamberMiddleLP);
371 
372  EtaValue etaValue = {
373  config->etaToHwEta(chamberMiddleGP.eta()),
374  config->etaToHwEta(cscChamberEtaSize(detId)),
375  0,
376  0, //bx
377  0 //timnig
378  };
379 
380  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" rawid "<<detId.rawId()<<" detId "<<detId<<" chamberMiddleGP.eta() "<<chamberMiddleGP.eta()<<" eta "<<etaValue.eta<<" etaSigma "<<etaValue.etaSigma<<std::endl;
381  return etaValue;
382 }
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
T eta() const
Definition: PV3DBase.h:73
Definition: config.py:1
float cscChamberEtaSize(const CSCDetId &id) const
edm::ESHandle< CSCGeometry > _geocsc

◆ getGlobalEtaDt()

EtaValue AngleConverterBase::getGlobalEtaDt ( const DTChamberId detId) const
virtual

returns the eta position of the DT chamber (n.b. in the DT phi and eta segments are independent)

Definition at line 235 of file AngleConverterBase.cc.

References _geodt, funct::abs(), DTGeometry::chamber(), hcalRecHitTable_cff::detId, PV3DBase< T, PVType, FrameType >::eta(), and GeomDet::toGlobal().

235  {
236  Local2DPoint chamberMiddleLP(0, 0);
237  GlobalPoint chamberMiddleGP = _geodt->chamber(detId)->toGlobal(chamberMiddleLP);
238 
239  const DTChamberId baseidNeigh(detId.wheel() + (detId.wheel() >= 0 ? -1 : +1), detId.station(), detId.sector());
240  GlobalPoint chambNeighMiddleGP = _geodt->chamber(baseidNeigh)->toGlobal(chamberMiddleLP);
241 
242  EtaValue etaValue = {
243  config->etaToHwEta(chamberMiddleGP.eta()),
244  config->etaToHwEta(std::abs(chamberMiddleGP.eta() - chambNeighMiddleGP.eta())) / 2,
245  0, //quality
246  0, //bx
247  0 //timin
248  };
249 
250  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" rawid "<<detId.rawId()<<" baseid "<<detId<<" chamberMiddleGP.eta() "<<chamberMiddleGP.eta()<<" eta "<<etaValue.eta<<" etaSigma "<<etaValue.etaSigma<<std::endl;
251  return etaValue;
252 }
edm::ESHandle< DTGeometry > _geodt
T eta() const
Definition: PV3DBase.h:73
Definition: config.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90

◆ getProcessorPhi() [1/4]

int AngleConverterBase::getProcessorPhi ( int  phiZero,
l1t::tftype  part,
int  dtScNum,
int  dtPhi 
) const
virtual

get phi of DT,CSC and RPC azimutal angle digi in processor scale, used by OMTF algorithm. in case of wrong phi returns OMTFConfiguration::instance()->nPhiBins phiZero - desired phi where the scale should start, should be in the desired scale, use getProcessorPhiZero to obtain it

Reimplemented in OmtfPhase2AngleConverter.

Definition at line 60 of file AngleConverterBase.cc.

References createfilelist::int, M_PI, nPhiBins, l1ctLayer1_cff::phiZero, funct::pow(), isotrackNtupler::scale, and nano_mu_digi_cff::sector.

Referenced by CscDigiToStubsConverterOmtf::addCSCstubs(), DtDigiToStubsConverterOmtf::addDTphiDigi(), DtPhase2DigiToStubsConverterOmtf::addDTphiDigi(), and RpcDigiToStubsConverterOmtf::addRPCstub().

60  {
61  int dtPhiBins = 4096;
62 
63  double hsPhiPitch = 2 * M_PI / nPhiBins; // width of phi Pitch, related to halfStrip at CSC station 2
64 
65  int sector = dtScNum + 1; //NOTE: there is a inconsistency in DT sector numb. Thus +1 needed to get detector numb.
66 
67  double scale = 1. / dtPhiBins / hsPhiPitch;
68  int scale_coeff = lround(scale * pow(2, 11)); // 216.2688
69 
70  int ichamber = sector - 1;
71  if (ichamber > 6)
72  ichamber = ichamber - 12;
73 
74  int offsetGlobal = (int)nPhiBins * ichamber / 12;
75 
76  int phiConverted = floor(dtPhi * scale_coeff / pow(2, 11)) + offsetGlobal - phiZero;
77 
78  //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" phiZero "<<phiZero<<" phiDT "<<phiDT<<" sector "<<sector<<" ichamber "<<ichamber<<" offsetGlobal "<<offsetGlobal<<" phi "<<phi<<" foldPhi(phi) "<<omtfConfig->foldPhi(phi)<<std::endl;
79  return config->foldPhi(phiConverted);
80 }
Definition: config.py:1
unsigned int nPhiBins
Number of phi bins along 2Pi.
#define M_PI
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ getProcessorPhi() [2/4]

int AngleConverterBase::getProcessorPhi ( int  phiZero,
l1t::tftype  part,
const CSCDetId csc,
const CSCCorrelatedLCTDigi digi,
unsigned int  iInput 
) const
virtual

Definition at line 83 of file AngleConverterBase.cc.

References _geocsc, funct::abs(), relativeConstraints::chamber, CSCGeometry::chamber(), CSCCorrelatedLCTDigi::getStrip(), nano_mu_digi_cff::layer, M_PI, nPhiBins, eventshapeDQM_cfi::order, phi, l1ctLayer1_cff::phiZero, isotrackNtupler::scale, and CSCChamberSpecs::stripPhiPitch().

84  {
85  const double hsPhiPitch = 2 * M_PI / nPhiBins;
86  //
87  // get offset for each chamber.
88  // FIXME: These parameters depends on processor and chamber only so may be precomputed and put in map
89  //
90 
91  int halfStrip = digi.getStrip(); // returns halfStrip 0..159
92 
94 
95  //in the PhaseIITDRSpring19DR dataset (generated with CMSSW_10_6_1_patch2?), in case of the ME1/1 ring 4 (higher eta) the detId in the CSCCorrelatedLCTDigiCollection is ME1/1 ring 1 (instead ME1/1/4 as it was before),
96  //and the digi.getStrip() is increased by 2*64 (i.e. number of half strips in the chamber roll)
97  if (csc.station() == 1 && csc.ring() == 1 && halfStrip > 128) {
98  CSCDetId cscME11 = CSCDetId(csc.endcap(), csc.station(), 4, csc.chamber()); //changing ring to 4
99  chamber = _geocsc->chamber(cscME11);
100  }
101 
102  const CSCChamberSpecs* cspec = chamber->specs();
103  const CSCLayer* layer = chamber->layer(3);
104  int order = (layer->centerOfStrip(2).phi() - layer->centerOfStrip(1).phi() > 0) ? 1 : -1;
105  double stripPhiPitch = cspec->stripPhiPitch();
106  double scale = std::abs(stripPhiPitch / hsPhiPitch / 2.);
107  if (std::abs(scale - 1.) < 0.0002)
108  scale = 1.;
109 
110  double phiHalfStrip0 = layer->centerOfStrip(1).phi() - order * stripPhiPitch / 4.;
111 
112  int offsetLoc = lround((phiHalfStrip0) / hsPhiPitch - phiZero);
113  offsetLoc = config->foldPhi(offsetLoc);
114 
115  if (csc.station() == 1 && csc.ring() == 1 && halfStrip > 128) { //ME1/1/
116  /* if(cspec->nStrips() != 64)
117  edm::LogImportant("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" cspec->nStrips() != 64 in case of the ME1/1, phi of the muon stub will be not correct. chamber "
118  <<csc<<" cspec->nStrips() "<<cspec->nStrips()<<std::endl;
119  this checks has no sense - the ME1/1/ ring 4 has cspec->nStrips() = 48. but the offset of 128 half strips in the digi.getStrip() looks to be good*/
120  halfStrip -= 128;
121  }
122 
123  //FIXME: to be checked (only important for ME1/3) keep more bits for offset, truncate at the end
124 
125  int fixOff = offsetLoc;
126  // a quick fix for towards geometry changes due to global tag.
127  // in case of MC tag fixOff should be identical to offsetLoc
128 
129  if (config->getFixCscGeometryOffset()) {
130  if (config->nProcessors() == 6) //phase1
131  fixOff = fixCscOffsetGeom(offsetLoc); //TODO does not work in when phiZero is always 0. Fix this
132  else if (config->nProcessors() == 3) { //phase2
133  //TODO fix this bricolage!!!!!!!!!!!!!!
134  if (iInput >= 14)
135  fixOff = fixCscOffsetGeom(offsetLoc - 900) + 900;
136  else
137  fixOff = fixCscOffsetGeom(offsetLoc);
138  }
139  }
140  int phi = fixOff + order * scale * halfStrip;
141  //the phi conversion is done like above - and not simply converting the layer->centerOfStrip(halfStrip/2 +1).phi() - to mimic this what is done by the firmware,
142  //where phi of the stub is calculated with use of the offset and scale provided by an register
143 
144  /*//debug
145  auto localPoint = layer->toLocal(layer->centerOfStrip(halfStrip));
146  LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << 147 << " csc: " <<csc.rawId()<<" "<< csc<<" layer "<<layer->id()<<" "<<layer->id().rawId()
147  << " halfStrip "<<halfStrip<<" phiGlobal " << layer->centerOfStrip(halfStrip).phi()<<" local phi "<<localPoint.phi()<<" x "<<localPoint.x()<<" y "<<localPoint.y() <<std::endl;
148  */
149 
150  /*//debug
151  auto radToDeg = [](double rad) { return (180. / M_PI * rad); };
152  LogTrace("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" "<<std::setw(16)<<csc<<" phiZero "<<phiZero<<" hs: "<<std::setw(3)<< halfStrip <<" phiHalfStrip0 "<<std::setw(10)<<radToDeg(phiHalfStrip0)<<" offset: " << offsetLoc
153  <<" oder*scale: "<<std::setw(10)<< order*scale
154  <<" phi: " <<phi<<" foldPhi(phi) "<<config->foldPhi(phi)<<" ("<<offsetLoc + order*scale*halfStrip<<")"<<" centerOfStrip "<<std::setw(10)<< radToDeg( layer->centerOfStrip(halfStrip/2 +1).phi() )
155  <<" centerOfStrip/hsPhiPitch "<< ( (layer->centerOfStrip(halfStrip/2 + 1).phi() )/hsPhiPitch)<<" hsPhiPitch "<<hsPhiPitch
156  //<<" phiSpan.f "<<layer->geometry()->phiSpan().first<<" phiSpan.s "<<layer->geometry()->phiSpan().second
157  <<" nStrips "<<cspec->nStrips()
158  //<<" strip 1 "<<radToDeg( layer->centerOfStrip(1).phi() )<<" strip last "<<radToDeg( layer->centerOfStrip(cspec->nStrips()).phi() )
159  << std::endl;*/
160 
161  return config->foldPhi(phi);
162 }
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
Definition: config.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int nPhiBins
Number of phi bins along 2Pi.
Definition: L1Track.h:19
#define M_PI
float stripPhiPitch() const
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
edm::ESHandle< CSCGeometry > _geocsc

◆ getProcessorPhi() [3/4]

int AngleConverterBase::getProcessorPhi ( unsigned int  iProcessor,
l1t::tftype  part,
const RPCDetId rollId,
const unsigned int &  digi 
) const
virtual

Definition at line 197 of file AngleConverterBase.cc.

References _georpc, M_PI, nPhiBins, nano_mu_digi_cff::roll, and RPCGeometry::roll().

200  {
201  const double hsPhiPitch = 2 * M_PI / nPhiBins;
202  const int dummy = nPhiBins;
203  int processor = iProcessor + 1;
204  const RPCRoll* roll = _georpc->roll(rollId);
205  if (!roll)
206  return dummy;
207 
208  double phi15deg = M_PI / 3. * (processor - 1) + M_PI / 12.;
209  // "0" is 15degree moved cyclically to each processor, note [0,2pi]
210 
211  double stripPhi = (roll->toGlobal(roll->centreOfStrip((int)digi))).phi(); // note [-pi,pi]
212 
213  // adjust [0,2pi] and [-pi,pi] to get deltaPhi difference properly
214  switch (processor) {
215  case 1:
216  break;
217  case 6: {
218  phi15deg -= 2 * M_PI;
219  break;
220  }
221  default: {
222  if (stripPhi < 0)
223  stripPhi += 2 * M_PI;
224  break;
225  }
226  }
227 
228  // local angle in CSC halfStrip usnits
229  int halfStrip = lround((stripPhi - phi15deg) / hsPhiPitch);
230 
231  return halfStrip;
232 }
edm::ESHandle< RPCGeometry > _georpc
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
unsigned int nPhiBins
Number of phi bins along 2Pi.
#define M_PI

◆ getProcessorPhi() [4/4]

int AngleConverterBase::getProcessorPhi ( int  phiZero,
l1t::tftype  part,
const RPCDetId rollId,
const unsigned int &  digi1,
const unsigned int &  digi2 
) const
virtual

Definition at line 166 of file AngleConverterBase.cc.

References _georpc, funct::abs(), LogTrace, M_PI, nPhiBins, l1ctLayer1_cff::phiZero, DetId::rawId(), nano_mu_digi_cff::roll, and RPCGeometry::roll().

167  {
168  const double hsPhiPitch = 2 * M_PI / nPhiBins;
169  const int dummy = nPhiBins;
170  const RPCRoll* roll = _georpc->roll(rollId);
171  if (!roll)
172  return dummy;
173 
174  double stripPhi1 = (roll->toGlobal(roll->centreOfStrip((int)digi1))).phi(); // note [-pi,pi]
175  double stripPhi2 = (roll->toGlobal(roll->centreOfStrip((int)digi2))).phi(); // note [-pi,pi]
176 
177  // the case when the two strips are on different sides of phi = pi
178  if (std::signbit(stripPhi1) != std::signbit(stripPhi2) && std::abs(stripPhi1) > M_PI / 2.) {
179  if (std::signbit(stripPhi1)) { //stripPhi1 is negative
180  stripPhi1 += 2 * M_PI;
181  } else //stripPhi2 is negative
182  stripPhi2 += 2 * M_PI;
183  }
184  int halfStrip = lround(((stripPhi1 + stripPhi2) / 2.) / hsPhiPitch);
185  halfStrip = config->foldPhi(halfStrip); //only for the case when the two strips are on different sides of phi = pi
186 
187  LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << 185 << " roll " << rollId.rawId() << " " << rollId
188  << " cluster: firstStrip " << digi1 << " stripPhi1Global " << stripPhi1
189  << " stripPhi1LocalPhi " << roll->centreOfStrip((int)digi1).x() << " y "
190  << roll->centreOfStrip((int)digi1).y() << " lastStrip " << digi2 << " stripPhi2Global "
191  << stripPhi2 << " stripPhi2LocalPhi x " << roll->centreOfStrip((int)digi2).x() << " y "
192  << roll->centreOfStrip((int)digi2).y() << " halfStrip " << halfStrip << std::endl;
193 
194  return config->foldPhi(halfStrip - phiZero);
195 }
edm::ESHandle< RPCGeometry > _georpc
Definition: config.py:1
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
#define LogTrace(id)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int nPhiBins
Number of phi bins along 2Pi.
#define M_PI
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57

◆ isCSCCounterClockwise()

bool AngleConverterBase::isCSCCounterClockwise ( const CSCLayer layer) const
protectedvirtual

Check orientation of strips in given CSC chamber.

Definition at line 428 of file AngleConverterBase.cc.

References funct::abs(), nano_mu_digi_cff::layer, M_PI, and me0TriggerPseudoDigis_cff::nStrips.

Referenced by OmtfAngleConverter::getGlobalEta().

428  {
429  const int nStrips = layer->geometry()->numberOfStrips();
430  const double phi1 = layer->centerOfStrip(1).phi();
431  const double phiN = layer->centerOfStrip(nStrips).phi();
432  return ((std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) || (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN));
433 }
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI

Member Data Documentation

◆ _geocsc

edm::ESHandle<CSCGeometry> AngleConverterBase::_geocsc
protected

◆ _geodt

edm::ESHandle<DTGeometry> AngleConverterBase::_geodt
protected

◆ _geom_cache_id

unsigned long long AngleConverterBase::_geom_cache_id = 0
protected

Definition at line 105 of file AngleConverterBase.h.

◆ _georpc

edm::ESHandle<RPCGeometry> AngleConverterBase::_georpc
protected

◆ config

const ProcConfigurationBase* AngleConverterBase::config = nullptr
protected

Definition at line 112 of file AngleConverterBase.h.

Referenced by checkAndUpdateGeometry().

◆ muonGeometryRecordWatcher

edm::ESWatcher<MuonGeometryRecord> AngleConverterBase::muonGeometryRecordWatcher
protected

Definition at line 110 of file AngleConverterBase.h.

Referenced by checkAndUpdateGeometry().

◆ nPhiBins

unsigned int AngleConverterBase::nPhiBins = 0
protected

Number of phi bins along 2Pi.

Definition at line 114 of file AngleConverterBase.h.

Referenced by checkAndUpdateGeometry(), OmtfPhase2AngleConverter::getProcessorPhi(), and getProcessorPhi().