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;
124 int wheel = digi.
whNum();
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;
142 int phi =
static_cast<int>(phiDT*
scale) + offsetLoc;
153 int processor= iProcessor+1;
160 if (posneg != csc.
zendcap())
return dummy;
163 if (csc.
chamber() < (processor-1)*6 + 2)
return dummy;
164 if (csc.
chamber() > (processor-1)*6 + 8)
return dummy;
184 double scale = fabs(stripPhiPitch/hsPhiPitch/2.);
if ( fabs(scale-1.) < 0.0002) scale=1.;
185 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
186 double phiHalfStrip0 = layer->
centerOfStrip(10).
phi() - order*9*stripPhiPitch - order*stripPhiPitch/4.;
187 if ( processor==6 || phiHalfStrip0<0) phiHalfStrip0 += 2*
M_PI;
188 int offsetLoc = lround( (phiHalfStrip0-phi15deg)/hsPhiPitch );
192 int phi = offsetLoc + order*scale*halfStrip;
204 int processor = iProcessor+1;
206 if (!roll)
return dummy;
208 double phi15deg =
M_PI/3.*(processor-1)+
M_PI/12.;
214 case 6: {phi15deg -= 2*
M_PI;
break; }
215 default : {
if (stripPhi < 0) stripPhi += 2*
M_PI;
break; }
219 int halfStrip = lround ( (stripPhi-phi15deg)/hsPhiPitch );
233 std::unique_ptr<DTChamber> chamb(const_cast<DTChamber*>(
_geodt->chamber(baseid)));
235 std::unique_ptr<DTTrigGeom> trig_geom(
new DTTrigGeom(chamb.get(),
false) );
243 const int NBTI_theta = ( (baseid.station() != 4) ?
244 trig_geom->nCell(2) : trig_geom->nCell(3) );
246 const unsigned bti_actual = bti_group*NBTI_theta/7 + NBTI_theta/14 + 1;
248 if ( baseid.station() != 4 && bti_group != -1) {
249 thetaBTI =
DTBtiId(baseid,2,bti_actual);
253 thetaBTI =
DTBtiId(baseid,3,1);
255 const GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI);
256 return etaVal2Code(theta_gp.
eta());
276 std::unique_ptr<const CSCChamber> chamb(
_geocsc->chamber(
id));
277 std::unique_ptr<const CSCLayerGeometry> layer_geom(
280 std::unique_ptr<const CSCLayer> layer(
284 const uint16_t halfstrip = aDigi.
getStrip();
286 const uint16_t keyWG = aDigi.
getKeyWG();
296 const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset);
297 const unsigned strip = halfstrip_offs/2 + 1;
302 layer_geom->stripWireGroupIntersection(strip,keyWG);
303 const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp);
307 const double hs_offset = layer_geom->stripPhiPitch()/4.0;
312 const double phi_offset = ( ( halfstrip_offs%2 ? 1 : -1)*
313 ( ccw ? -hs_offset : hs_offset ) );
323 layer_geom.release();
331 return etaKeyWG2Code(
id,keyWG);
342 std::unique_ptr<const RPCRoll> roll(
_georpc->roll(
id));
343 const LocalPoint lp = roll->centreOfStrip((
int)strip);
347 return etaVal2Code(gp.
eta());
356 const int nStrips = layer->geometry()->numberOfStrips();
357 const double phi1 = layer->centerOfStrip(1).phi();
358 const double phiN = layer->centerOfStrip(nStrips).phi();
359 return ( (
std::abs(phi1 - phiN) <
M_PI && phi1 >= phiN) ||
373 if(!theta_segm)
return bti_group;
375 for(
unsigned int i = 0;
i < 7; ++
i ){
376 if(theta_segm->
position(
i) && bti_group<0) bti_group =
i;
380 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
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.
T value() const
Explicit access to value in case implicit conversion not OK.
short int zendcap() const
GlobalPoint centerOfStrip(int strip) const
static double get2007Position(int pattern)
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
edm::ESHandle< DTGeometry > _geodt