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;
120 int processor= iProcessor+1;
123 int sector = digi.
scNum()+1;
126 int phiDT = digi.
phi();
128 if (posneg*2 != wheel)
return dummy;
129 if (station > 3 )
return dummy;
132 if (processor !=6 && !(sector >= processor*2-1 && sector <= processor*2+1) )
return dummy;
133 if (processor ==6 && !(sector >= 11 || sector==1) )
return dummy;
136 int ichamber = sector-1-2*(processor-1);
137 if (ichamber < 0) ichamber += 12;
139 int offsetLoc = lround( ((ichamber-1)*
M_PI/6+
M_PI/12.)/hsPhiPitch );
140 double scale = 1./4096/hsPhiPitch;
141 int scale_coeff = lround(scale*
pow(2,11));
143 int phi = floor(phiDT*scale_coeff/
pow(2,11)) + offsetLoc;
154 int processor= iProcessor+1;
161 if (posneg != csc.
zendcap())
return dummy;
164 if (csc.
chamber() < (processor-1)*6 + 2)
return dummy;
165 if (csc.
chamber() > (processor-1)*6 + 8)
return dummy;
185 double scale = fabs(stripPhiPitch/hsPhiPitch/2.);
if ( fabs(scale-1.) < 0.0002) scale=1.;
186 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
187 double phiHalfStrip0 = layer->
centerOfStrip(10).
phi() - order*9*stripPhiPitch - order*stripPhiPitch/4.;
188 if ( processor==6 || phiHalfStrip0<0) phiHalfStrip0 += 2*
M_PI;
189 int offsetLoc = lround( (phiHalfStrip0-phi15deg)/hsPhiPitch );
193 int phi = offsetLoc + order*scale*halfStrip;
208 int processor = iProcessor+1;
210 if (!roll)
return dummy;
212 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
221 case 6: {phi15deg -= 2*
M_PI;
break; }
222 default : {
if (stripPhi1 < 0) stripPhi1 += 2*
M_PI;
if(stripPhi2 < 0 ) stripPhi2 += 2*
M_PI;
break; }
226 int halfStrip = lround ( ( (stripPhi1+stripPhi2)/2.-phi15deg)/hsPhiPitch );
236 int processor = iProcessor+1;
238 if (!roll)
return dummy;
240 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
246 case 6: {phi15deg -= 2*
M_PI;
break; }
247 default : {
if (stripPhi < 0) stripPhi += 2*
M_PI;
break; }
251 int halfStrip = lround ( (stripPhi-phi15deg)/hsPhiPitch );
265 std::unique_ptr<DTChamber> chamb(const_cast<DTChamber*>(
_geodt->
chamber(baseid)));
267 std::unique_ptr<DTTrigGeom> trig_geom(
new DTTrigGeom(chamb.get(),
false) );
275 const int NBTI_theta = ( (baseid.station() != 4) ? trig_geom->nCell(2) : trig_geom->nCell(3) );
294 for(
unsigned int i = 0;
i < 7; ++
i )
if(theta_segm->
position(
i) && bti_group<0) bti_group =
i;
295 else if(theta_segm->
position(
i) && bti_group>-1) bti_group = 511;
299 if (bti_group == 511) iEta = 95;
300 else if ( bti_group == -1 && aDigi.
stNum() == 1) iEta = 92;
301 else if ( bti_group == -1 && aDigi.
stNum() == 2) iEta = 79;
302 else if ( bti_group == -1 && aDigi.
stNum() == 3) iEta = 75;
303 else if (baseid.station() != 4 && bti_group >= 0) {
305 unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
307 GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
308 iEta = etaVal2Code( fabs(theta_gp.
eta()) );
332 std::unique_ptr<const CSCLayerGeometry> layer_geom(
335 std::unique_ptr<const CSCLayer> layer(
339 const uint16_t halfstrip = aDigi.
getStrip();
341 const uint16_t keyWG = aDigi.
getKeyWG();
351 const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
352 const unsigned strip = halfstrip_offs/2 + 1;
357 layer_geom->stripWireGroupIntersection(strip,keyWG);
358 const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
362 const double hs_offset = layer_geom->stripPhiPitch()/4.0;
367 const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
368 ( ccw ? -hs_offset : hs_offset ) );
373 (coarse_gp.
phi().value() +
378 layer_geom.release();
386 return etaKeyWG2Code(
id,keyWG);
397 std::unique_ptr<const RPCRoll> roll(
_georpc->
roll(
id));
398 const LocalPoint lp = roll->centreOfStrip((
int)strip);
402 return etaVal2Code(gp.
eta());
411 const int nStrips = layer->geometry()->numberOfStrips();
412 const double phi1 = layer->centerOfStrip(1).phi();
413 const double phiN = layer->centerOfStrip(nStrips).phi();
414 return ( (
std::abs(phi1 - phiN) <
M_PI && phi1 >= phiN) ||
428 if(!theta_segm)
return bti_group;
430 for(
unsigned int i = 0;
i < 7; ++
i ){
431 if(theta_segm->
position(
i) && bti_group<0) bti_group =
i;
435 else if(theta_segm->
position(
i) && bti_group>-1)
return -1;
unsigned long long cacheIdentifier() const
LocalPoint centreOfStrip(int strip) const
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
unsigned long long _geom_cache_id
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const L1MuDTChambPhDigi &digi) const
float stripPhiPitch() const
const CSCChamberSpecs * specs() const
void get(HolderT &iHolder) 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
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
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