23 template <
typename T>
int sgn(
T val) {
return (
T(0) < val) - (val <
T(0)); }
25 std::vector<float> bounds = { 1.24, 1.14353, 1.09844, 1.05168, 1.00313, 0.952728, 0.90037, 0.8};
38 int etaVal2Bit(
float eta) {
return bounds.rend() -
std::lower_bound (bounds.rbegin(), bounds.rend(), fabs(eta) ); }
40 int etaBit2Code(
unsigned int bit) {
43 case 0 : {code = 115;
break;}
44 case 1 : {code = 110;
break; }
45 case 2 : {code = 103;
break; }
46 case 3 : {code = 99;
break; }
47 case 4 : {code = 94;
break; }
48 case 5 : {code = 90;
break; }
49 case 6 : {code = 85;
break; }
50 case 7 : {code = 78;
break; }
51 case 8 : {code = 73;
break; }
52 default: {code = 95;
break; }
57 int etaVal2Code(
double etaVal) {
59 int bit = etaVal2Bit( fabs(etaVal) );
60 int code = etaBit2Code(bit);
64 int etaKeyWG2Code(
const CSCDetId& detId, uint16_t keyWG) {
65 signed int etaCode = 121;
67 if (keyWG < 49) etaCode = 121;
68 else if (keyWG <=57) etaCode = etaBit2Code(0);
69 else if (keyWG <=63) etaCode = etaBit2Code(1);
72 if (keyWG <= 2) etaCode = etaBit2Code(2);
73 else if (keyWG <= 8) etaCode = etaBit2Code(3);
74 else if (keyWG <= 15) etaCode = etaBit2Code(4);
75 else if (keyWG <= 23) etaCode = etaBit2Code(5);
76 else if (keyWG <= 31) etaCode = etaBit2Code(6);
79 if (keyWG < 24) etaCode = 121;
80 else if (keyWG <= 29) etaCode = etaBit2Code(0);
81 else if (keyWG <= 43) etaCode = etaBit2Code(1);
82 else if (keyWG <= 49) etaCode = etaBit2Code(2);
83 else if (keyWG <= 56) etaCode = etaBit2Code(3);
84 else if (keyWG <= 63) etaCode = etaBit2Code(4);
87 if (detId.
endcap()==2) etaCode *= -1;
92 int fixCscOffsetGeom(
int offsetLoc) {
96 const std::vector<int> offCSC = { -154, -133, -17, -4, 4, 17, 133, 146, 154, 167,
97 283, 296, 304, 317, 433, 446, 454, 467,
98 583, 596, 604, 617, 733, 746, 754, 767, 883, 904};
100 int fixOff = (gep != offCSC.end()) ? *gep : *(gep-1);
101 if (gep != offCSC.begin() &&
std::abs(*(gep-1)-offsetLoc) <
std::abs(fixOff-offsetLoc) ) fixOff= *(gep-1);
134 int processor= iProcessor+1;
137 int sector = digi.
scNum()+1;
140 int phiDT = digi.
phi();
142 if (posneg*2 != wheel)
return dummy;
143 if (station > 3 )
return dummy;
146 if (processor !=6 && !(sector >= processor*2-1 && sector <= processor*2+1) )
return dummy;
147 if (processor ==6 && !(sector >= 11 || sector==1) )
return dummy;
150 int ichamber = sector-1-2*(processor-1);
151 if (ichamber < 0) ichamber += 12;
153 int offsetLoc = lround( ((ichamber-1)*
M_PI/6+
M_PI/12.)/hsPhiPitch );
154 double scale = 1./4096/hsPhiPitch;
155 int scale_coeff = lround(scale*
pow(2,11));
157 int phi = floor(phiDT*scale_coeff/
pow(2,11)) + offsetLoc;
168 int processor= iProcessor+1;
175 if (posneg != csc.
zendcap())
return dummy;
178 if (csc.
chamber() < (processor-1)*6 + 2)
return dummy;
179 if (csc.
chamber() > (processor-1)*6 + 8)
return dummy;
199 double scale = fabs(stripPhiPitch/hsPhiPitch/2.);
if ( fabs(scale-1.) < 0.0002) scale=1.;
200 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
201 double phiHalfStrip0 = layer->
centerOfStrip(10).
phi() - order*9*stripPhiPitch - order*stripPhiPitch/4.;
202 if ( processor==6 || phiHalfStrip0<0) phiHalfStrip0 += 2*
M_PI;
203 int offsetLoc = lround( (phiHalfStrip0-phi15deg)/hsPhiPitch );
210 int fixOff = fixCscOffsetGeom(offsetLoc);
212 int phi = fixOff + order*scale*halfStrip;
227 int processor = iProcessor+1;
229 if (!roll)
return dummy;
231 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
240 case 6: {phi15deg -= 2*
M_PI;
break; }
241 default : {
if (stripPhi1 < 0) stripPhi1 += 2*
M_PI;
if(stripPhi2 < 0 ) stripPhi2 += 2*
M_PI;
break; }
245 int halfStrip = lround ( ( (stripPhi1+stripPhi2)/2.-phi15deg)/hsPhiPitch );
255 int processor = iProcessor+1;
257 if (!roll)
return dummy;
259 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
265 case 6: {phi15deg -= 2*
M_PI;
break; }
266 default : {
if (stripPhi < 0) stripPhi += 2*
M_PI;
break; }
270 int halfStrip = lround ( (stripPhi-phi15deg)/hsPhiPitch );
284 std::unique_ptr<DTChamber> chamb(const_cast<DTChamber*>(
_geodt->
chamber(baseid)));
286 std::unique_ptr<DTTrigGeom> trig_geom(
new DTTrigGeom(chamb.get(),
false) );
294 const int NBTI_theta = ( (baseid.station() != 4) ? trig_geom->nCell(2) : trig_geom->nCell(3) );
313 for(
unsigned int i = 0;
i < 7; ++
i )
if(theta_segm->
position(
i) && bti_group<0) bti_group =
i;
314 else if(theta_segm->
position(
i) && bti_group>-1) bti_group = 511;
318 if (bti_group == 511) iEta = 95;
319 else if ( bti_group == -1 && aDigi.
stNum() == 1) iEta = 92;
320 else if ( bti_group == -1 && aDigi.
stNum() == 2) iEta = 79;
321 else if ( bti_group == -1 && aDigi.
stNum() == 3) iEta = 75;
322 else if (baseid.station() != 4 && bti_group >= 0) {
324 unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
326 GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
327 iEta = etaVal2Code( fabs(theta_gp.
eta()) );
351 std::unique_ptr<const CSCLayerGeometry> layer_geom(
354 std::unique_ptr<const CSCLayer> layer(
358 const uint16_t halfstrip = aDigi.
getStrip();
360 const uint16_t keyWG = aDigi.
getKeyWG();
370 const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
371 const unsigned strip = halfstrip_offs/2 + 1;
376 layer_geom->stripWireGroupIntersection(strip,keyWG);
377 const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
381 const double hs_offset = layer_geom->stripPhiPitch()/4.0;
386 const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
387 ( ccw ? -hs_offset : hs_offset ) );
392 (coarse_gp.
phi().value() +
397 layer_geom.release();
405 return etaKeyWG2Code(
id,keyWG);
416 std::unique_ptr<const RPCRoll> roll(
_georpc->
roll(
id));
417 const LocalPoint lp = roll->centreOfStrip((
int)strip);
421 return etaVal2Code(gp.
eta());
430 const int nStrips = layer->geometry()->numberOfStrips();
431 const double phi1 = layer->centerOfStrip(1).phi();
432 const double phiN = layer->centerOfStrip(nStrips).phi();
433 return ( (
std::abs(phi1 - phiN) <
M_PI && phi1 >= phiN) ||
447 if(!theta_segm)
return bti_group;
449 for(
unsigned int i = 0;
i < 7; ++
i ){
450 if(theta_segm->
position(
i) && bti_group<0) bti_group =
i;
454 else if(theta_segm->
position(
i) && bti_group>-1)
return -1;
unsigned long long cacheIdentifier() const
LocalPoint centreOfStrip(int strip) const
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
int getGlobalEta(unsigned int rawid, const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Convert local eta coordinate to global digital microGMT scale.
unsigned long long _geom_cache_id
int position(const int i) const
Geom::Theta< T > theta() const
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const L1MuDTChambPhDigi &digi) const
float stripPhiPitch() const
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
const CSCChamberSpecs * specs() const
Abs< T >::type abs(const T &t)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
const int findBTIgroup(const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Find BTI group.
bool isCSCCounterClockwise(const std::unique_ptr< const CSCLayer > &layer) const
Check orientation of strips in given CSC chamber.
unsigned int nPhiBins
Number of phi bins along 2Pi.
short int zendcap() const
GlobalPoint centerOfStrip(int strip) const
static double get2007Position(int pattern)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
L1MuDTChambThDigi const * chThetaSegm(int wheel, int stat, int sect, int bx) const
edm::ESHandle< CSCGeometry > _geocsc
void checkAndUpdateGeometry(const edm::EventSetup &, unsigned int)
Update the Geometry with current Event Setup.
edm::ESHandle< RPCGeometry > _georpc
Power< A, B >::type pow(const A &a, const B &b)
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
edm::ESHandle< DTGeometry > _geodt