31 pt_xml = fmin(20., pt);
32 pt_scale = 1.2 / (1 - 0.015*pt_xml);
42 float pt_unscale = -99;
46 pt_unscale = 1 / (1.2 + 0.015*
pt);
47 pt_unscale = fmax( pt_unscale, (1 - 0.015*20)/1.2 );
62 int nHits = (mode / 8) + ((mode % 8) / 4) + ((mode % 4) / 2) + ((mode % 2) / 1);
63 if (not(nHits > 1 && nHits < 5))
68 int iA = -1, iB = -1, iC = -1, iD = -1;
69 int iAB, iAC, iAD, iBC, iCD;
72 case 15: mode_ID = 0b1 ; iA = 0; iB = 1; iC = 2; iD = 3;
break;
73 case 14: mode_ID = 0b11 ; iA = 0; iB = 1; iC = 2;
break;
74 case 13: mode_ID = 0b10 ; iA = 0; iB = 1; iC = 3;
break;
75 case 11: mode_ID = 0b01 ; iA = 0; iB = 2; iC = 3;
break;
76 case 7: mode_ID = 0b1 ; iA = 1; iB = 2; iC = 3;
break;
77 case 12: mode_ID = 0b111; iA = 0; iB = 1;
break;
78 case 10: mode_ID = 0b110; iA = 0; iB = 2;
break;
79 case 9: mode_ID = 0b101; iA = 0; iB = 3;
break;
80 case 6: mode_ID = 0b100; iA = 1; iB = 2;
break;
81 case 5: mode_ID = 0b011; iA = 1; iB = 3;
break;
82 case 3: mode_ID = 0b010; iA = 2; iB = 3;
break;
85 iAB = (iA >= 0 && iB >= 0) ? iA + iB - (iA == 0) : -1;
86 iAC = (iA >= 0 && iC >= 0) ? iA + iC - (iA == 0) : -1;
87 iAD = (iA >= 0 && iD >= 0) ? 2 : -1;
88 iBC = (iB >= 0 && iC >= 0) ? iB + iC : -1;
89 iCD = (iC >= 0 && iD >= 0) ? 5 : -1;
93 int st1_ring2, dTheta;
94 int dPhiAB, dPhiBC, dPhiCD;
95 int sPhiAB, sPhiBC, sPhiCD;
97 int clctA, clctB, clctC, clctD;
107 sPhiBC = (data.
sign_ph[iBC] == sPhiAB);
108 sPhiCD = (data.
sign_ph[iCD] == sPhiAB);
115 }
else if (nHits == 3) {
119 sPhiBC = (data.
sign_ph[iBC] == sPhiAB);
126 }
else if (nHits == 2) {
143 mode15_8b =
aux().
get8bMode15( theta, st1_ring2, endcap, (sPhiAB == 1 ? 1 : -1), clctA, clctB, clctC, clctD );
144 }
else if (nHits == 3) {
149 clctA =
aux().
getCLCT ( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 2 );
151 }
else if (nHits == 2) {
154 clctA =
aux().
getCLCT ( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 3 );
155 clctB =
aux().
getCLCT ( clctB, endcap, (sPhiAB == 1 ? 1 : -1), 3 );
162 address |= (dPhiAB & ((1<<7)-1)) << (0);
163 address |= (dPhiBC & ((1<<5)-1)) << (0+7);
164 address |= (dPhiCD & ((1<<4)-1)) << (0+7+5);
165 address |= (sPhiBC & ((1<<1)-1)) << (0+7+5+4);
166 address |= (sPhiCD & ((1<<1)-1)) << (0+7+5+4+1);
167 address |= (dTheta & ((1<<2)-1)) << (0+7+5+4+1+1);
168 address |= (frA & ((1<<1)-1)) << (0+7+5+4+1+1+2);
169 address |= (mode15_8b & ((1<<8)-1)) << (0+7+5+4+1+1+2+1);
170 address |= (mode_ID & ((1<<1)-1)) << (0+7+5+4+1+1+2+1+8);
171 if (not(address <
pow(2, 30) && address >=
pow(2, 29)))
172 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
174 else if (nHits == 3) {
175 address |= (dPhiAB & ((1<<7)-1)) << (0);
176 address |= (dPhiBC & ((1<<5)-1)) << (0+7);
177 address |= (sPhiBC & ((1<<1)-1)) << (0+7+5);
178 address |= (dTheta & ((1<<3)-1)) << (0+7+5+1);
179 address |= (frA & ((1<<1)-1)) << (0+7+5+1+3);
182 address |= (frB & ((1<<1)-1)) << (0+7+5+1+3+1); bit = 1;
184 address |= (clctA & ((1<<2)-1)) << (0+7+5+1+3+1+bit);
185 address |= (rpc_2b & ((1<<2)-1)) << (0+7+5+1+3+1+bit+2);
186 address |= (theta & ((1<<5)-1)) << (0+7+5+1+3+1+bit+2+2);
188 address |= (mode_ID & ((1<<2)-1)) << (0+7+5+1+3+1+bit+2+2+5);
189 if (not(address <
pow(2, 29) && address >=
pow(2, 27)))
190 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
192 address |= (mode_ID & ((1<<1)-1)) << (0+7+5+1+3+1+bit+2+2+5);
193 if (not(address <
pow(2, 27) && address >=
pow(2, 26)))
194 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
197 else if (nHits == 2) {
198 address |= (dPhiAB & ((1<<7)-1)) << (0);
199 address |= (dTheta & ((1<<3)-1)) << (0+7);
200 address |= (frA & ((1<<1)-1)) << (0+7+3);
201 address |= (frB & ((1<<1)-1)) << (0+7+3+1);
202 address |= (clctA & ((1<<3)-1)) << (0+7+3+1+1);
203 address |= (clctB & ((1<<3)-1)) << (0+7+3+1+1+3);
204 address |= (theta & ((1<<5)-1)) << (0+7+3+1+1+3+3);
205 address |= (mode_ID & ((1<<3)-1)) << (0+7+3+1+1+3+3+5);
206 if (not(address <
pow(2, 26) && address >=
pow(2, 24)))
207 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
225 int nHits = -1,
mode = -1;
227 if (not(address <
pow(2, 30)))
228 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
229 if (address >=
pow(2, 29)) { nHits = 4;
mode = 15; }
230 else if (address >=
pow(2, 27)) { nHits = 3; }
231 else if (address >=
pow(2, 26)) { nHits = 3;
mode = 7; }
232 else if (address >=
pow(2, 24)) { nHits = 2; }
236 int mode_ID,
theta, dTheta;
237 int dPhiAB, dPhiBC = -1, dPhiCD = -1;
238 int sPhiAB, sPhiBC = -1, sPhiCD = -1;
240 int clctA, clctB = -1;
241 int rpcA, rpcB, rpcC, rpcD;
242 int endcap = 1; sPhiAB = 1;
249 dPhiAB = (address >> (0) & ((1<<7)-1));
250 dPhiBC = (address >> (0+7) & ((1<<5)-1));
251 dPhiCD = (address >> (0+7+5) & ((1<<4)-1));
252 sPhiBC = (address >> (0+7+5+4) & ((1<<1)-1));
253 sPhiCD = (address >> (0+7+5+4+1) & ((1<<1)-1));
254 dTheta = (address >> (0+7+5+4+1+1) & ((1<<2)-1));
255 frA = (address >> (0+7+5+4+1+1+2) & ((1<<1)-1));
256 mode15_8b = (address >> (0+7+5+4+1+1+2+1) & ((1<<8)-1));
257 mode_ID = (address >> (0+7+5+4+1+1+2+1+8) & ((1<<1)-1));
258 if (not(address <
pow(2, 30)))
259 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
261 else if (nHits == 3) {
262 dPhiAB = (address >> (0) & ((1<<7)-1));
263 dPhiBC = (address >> (0+7) & ((1<<5)-1));
264 sPhiBC = (address >> (0+7+5) & ((1<<1)-1));
265 dTheta = (address >> (0+7+5+1) & ((1<<3)-1));
266 frA = (address >> (0+7+5+1+3) & ((1<<1)-1));
269 frB = (address >> (0+7+5+1+3+1) & ((1<<1)-1)); bit = 1;
271 clctA = (address >> (0+7+5+1+3+1+bit) & ((1<<2)-1));
272 rpc_2b = (address >> (0+7+5+1+3+1+bit+2) & ((1<<2)-1));
273 theta = (address >> (0+7+5+1+3+1+bit+2+2) & ((1<<5)-1));
275 mode_ID = (address >> (0+7+5+1+3+1+bit+2+2+5) & ((1<<2)-1));
276 if (not(address <
pow(2, 29)))
277 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
279 mode_ID = (address >> (0+7+5+1+3+1+bit+2+2+5) & ((1<<1)-1));
280 if (not(address <
pow(2, 27)))
281 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
284 else if (nHits == 2) {
285 dPhiAB = (address >> (0) & ((1<<7)-1));
286 dTheta = (address >> (0+7) & ((1<<3)-1));
287 frA = (address >> (0+7+3) & ((1<<1)-1));
288 frB = (address >> (0+7+3+1) & ((1<<1)-1));
289 clctA = (address >> (0+7+3+1+1) & ((1<<3)-1));
290 clctB = (address >> (0+7+3+1+1+3) & ((1<<3)-1));
291 theta = (address >> (0+7+3+1+1+3+3) & ((1<<5)-1));
292 mode_ID = (address >> (0+7+3+1+1+3+3+5) & ((1<<3)-1));
293 if (not(address <
pow(2, 26)))
294 {
edm::LogError(
"L1T") <<
"address = " << address;
return 0; }
298 if (nHits == 3 &&
mode != 7) {
300 case 0b11:
mode = 14;
break;
301 case 0b10:
mode = 13;
break;
302 case 0b01:
mode = 11;
break;
305 }
else if (nHits == 2) {
307 case 0b111:
mode = 12;
break;
308 case 0b110:
mode = 10;
break;
309 case 0b101:
mode = 9;
break;
310 case 0b100:
mode = 6;
break;
311 case 0b011:
mode = 5;
break;
312 case 0b010:
mode = 3;
break;
327 aux().
unpack8bMode15 ( mode15_8b, theta, St1_ring2, endcap, (sPhiAB == 1 ? 1 : -1), clctA, rpcA, rpcB, rpcC, rpcD );
332 }
else if (nHits == 3) {
348 }
else if (nHits == 2) {
370 std::vector<int> predictors;
373 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
377 predictors = {
theta, St1_ring2, dPhiAB, dPhiBC, dPhiCD, dPhiAB + dPhiBC,
378 dPhiAB + dPhiBC + dPhiCD, dPhiBC + dPhiCD, frA, clctA };
381 dPhiAB, dPhiAB + dPhiBC, dPhiAB + dPhiBC + dPhiCD,
382 dPhiBC, dPhiBC + dPhiCD, dPhiCD );
384 int tmp[10] = {dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTheta, rpcA, rpcB, rpcC, rpcD };
385 predictors.insert( predictors.end(),
tmp, tmp+10 );
387 else if (nHits == 3) {
389 predictors = {
theta, St1_ring2, dPhiAB, dPhiBC, dPhiAB + dPhiBC,
390 frA, frB, clctA, dTheta, rpcA, rpcB, rpcC };
392 predictors = {
theta, St1_ring2, dPhiAB, dPhiAB + dPhiBC, dPhiBC,
393 frA, frB, clctA, dTheta, rpcA, rpcB, rpcC };
395 predictors = {
theta, St1_ring2, dPhiBC, dPhiAB, dPhiAB + dPhiBC,
396 frA, frB, clctA, dTheta, rpcA, rpcB, rpcC };
398 predictors = {
theta, dPhiAB, dPhiBC, dPhiAB + dPhiBC,
399 frA, clctA, dTheta, rpcA, rpcB, rpcC };
401 else if (nHits == 2 &&
mode >= 8) {
402 predictors = {
theta, St1_ring2, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0) };
404 else if (nHits == 2 &&
mode < 8) {
405 predictors = {
theta, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0) };
408 {
edm::LogError(
"L1T") <<
"nHits = " << nHits <<
", mode = " <<
mode;
return 0; }
411 std::vector<double> tree_data(predictors.cbegin(),predictors.cend());
413 auto tree_event = std::make_unique<emtf::Event>();
414 tree_event->predictedValue = 0;
415 tree_event->data = tree_data;
425 float inv_pt = tree_event->predictedValue;
426 pt_xml = 1.0 / fmax(0.001, inv_pt);
439 auto contain = [](
const std::vector<int>& vec,
int elem) {
440 return (
std::find(vec.begin(), vec.end(),
elem) != vec.end());
451 int st1 = (mode >= 8);
452 int st2 = ((mode % 8) >= 4);
453 int st3 = ((mode % 4) >= 2);
454 int st4 = ((mode % 2) == 1);
457 int dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34, dPhiSign;
458 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
459 int dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34;
460 int FR_1, FR_2, FR_3, FR_4;
461 int bend_1, bend_2, bend_3, bend_4;
462 int RPC_1, RPC_2, RPC_3, RPC_4;
465 int ph1 = -99, ph2 = -99, ph3 = -99, ph4 = -99;
466 int th1 = -99, th2 = -99, th3 = -99, th4 = -99;
467 int pat1 = -99, pat2 = -99, pat3 = -99, pat4 = -99;
477 if (st3 && st4) ph4 = ph3 + data.
delta_ph[5]*(data.
sign_ph[5] ? 1 : -1);
482 if (st1 && st3) th3 = th1 + data.
delta_th[1]*(data.
sign_th[1] ? 1 : -1);
484 if (st1 && st4) th4 = th1 + data.
delta_th[2]*(data.
sign_th[2] ? 1 : -1);
492 if (st1 && st4) th4 = th1 + data.
delta_th[2]*(data.
sign_th[2] ? 1 : -1);
508 theta =
CalcTrackTheta( th1, th2, th3, th4, St1_ring2, mode,
true );
510 CalcDeltaPhis( dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34, dPhiSign,
511 dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi,
512 ph1, ph2, ph3, ph4, mode,
true );
515 th1, th2, th3, th4, mode,
true );
517 FR_1 = (st1 ? data.
fr[0] : -99);
518 FR_2 = (st2 ? data.
fr[1] : -99);
519 FR_3 = (st3 ? data.
fr[2] : -99);
520 FR_4 = (st4 ? data.
fr[3] : -99);
522 CalcBends( bend_1, bend_2, bend_3, bend_4,
523 pat1, pat2, pat3, pat4,
524 dPhiSign, endcap, mode,
true );
526 RPC_1 = (st1 ? (pat1 == 0) : -99);
527 RPC_2 = (st2 ? (pat2 == 0) : -99);
528 RPC_3 = (st3 ? (pat3 == 0) : -99);
529 RPC_4 = (st4 ? (pat4 == 0) : -99);
531 CalcRPCs( RPC_1, RPC_2, RPC_3, RPC_4, mode, St1_ring2, theta,
true );
538 std::vector<int> predictors;
541 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_34, dPhi_13, dPhi_14, dPhi_24, FR_1, bend_1,
542 dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTh_14, RPC_1, RPC_2, RPC_3, RPC_4 };
545 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_13, FR_1, FR_2, bend_1, dTh_13, RPC_1, RPC_2, RPC_3 };
break;
547 predictors = {
theta, St1_ring2, dPhi_12, dPhi_14, dPhi_24, FR_1, FR_2, bend_1, dTh_14, RPC_1, RPC_2, RPC_4 };
break;
549 predictors = {
theta, St1_ring2, dPhi_34, dPhi_13, dPhi_14, FR_1, FR_3, bend_1, dTh_14, RPC_1, RPC_3, RPC_4 };
break;
551 predictors = {
theta, dPhi_23, dPhi_34, dPhi_24, FR_2, bend_2, dTh_24, RPC_2, RPC_3, RPC_4 };
break;
553 predictors = {
theta, St1_ring2, dPhi_12, FR_1, FR_2, bend_1, bend_2, dTh_12, RPC_1, RPC_2 };
break;
555 predictors = {
theta, St1_ring2, dPhi_13, FR_1, FR_3, bend_1, bend_3, dTh_13, RPC_1, RPC_3 };
break;
557 predictors = {
theta, St1_ring2, dPhi_14, FR_1, FR_4, bend_1, bend_4, dTh_14, RPC_1, RPC_4 };
break;
559 predictors = {
theta, dPhi_23, FR_2, FR_3, bend_2, bend_3, dTh_23, RPC_2, RPC_3 };
break;
561 predictors = {
theta, dPhi_24, FR_2, FR_4, bend_2, bend_4, dTh_24, RPC_2, RPC_4 };
break;
563 predictors = {
theta, dPhi_34, FR_3, FR_4, bend_3, bend_4, dTh_34, RPC_3, RPC_4 };
break;
566 std::vector<double> tree_data(predictors.cbegin(),predictors.cend());
568 auto tree_event = std::make_unique<emtf::Event>();
569 tree_event->predictedValue = 0;
570 tree_event->data = tree_data;
580 float inv_pt = tree_event->predictedValue;
581 pt_xml = 1.0 / fmax(0.001, inv_pt);
int getTheta(int theta, int ring2, int bits=5) const
void predictEvent(Event *e, unsigned int trees)
int CalcTrackTheta(const int th1, const int th2, const int th3, const int th4, const int ring1, const int mode, const bool BIT_COMP=false)
static PFTauRenderPlugin instance
float scale_pt(const float pt, const int mode=15) const override
const PtAssignmentEngineAux2017 & aux() const
void CalcDeltaThetas(int &dTh12, int &dTh13, int &dTh14, int &dTh23, int &dTh24, int &dTh34, const int th1, const int th2, const int th3, const int th4, const int mode, const bool BIT_COMP=false)
Geom::Theta< T > theta() const
void CalcDeltaPhiSums(int &dPhSum4, int &dPhSum4A, int &dPhSum3, int &dPhSum3A, int &outStPh, const int dPh12, const int dPh13, const int dPh14, const int dPh23, const int dPh24, const int dPh34)
void unpack8bMode15(int mode15_8b, int &theta, int &st1_ring2, int endcap, int sPhiAB, int &clctA, int &rpcA, int &rpcB, int &rpcC, int &rpcD) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
int get2bRPC(int clctA, int clctB, int clctC) const
void unpack2bRPC(int rpc_2b, int &rpcA, int &rpcB, int &rpcC) const
void CalcRPCs(int &RPC1, int &RPC2, int &RPC3, int &RPC4, const int mode, const int st1_ring2, const int theta, const bool BIT_COMP=false)
address_t calculate_address(const EMTFTrack &track) const override
void CalcDeltaPhis(int &dPh12, int &dPh13, int &dPh14, int &dPh23, int &dPh24, int &dPh34, int &dPhSign, int &dPhSum4, int &dPhSum4A, int &dPhSum3, int &dPhSum3A, int &outStPh, const int ph1, const int ph2, const int ph3, const int ph4, const int mode, const bool BIT_COMP=false)
int getCLCT(int clct, int endcap, int dPhiSign, int bits=3) const
float calculate_pt_xml(const address_t &address) const override
def elem(elemtype, innerHTML='', html_class='', kwargs)
float unscale_pt(const float pt, const int mode=15) const override
std::array< emtf::Forest, 16 > forests_
void CalcBends(int &bend1, int &bend2, int &bend3, int &bend4, const int pat1, const int pat2, const int pat3, const int pat4, const int dPhSign, const int endcap, const int mode, const bool BIT_COMP=false)
int getdPhiFromBin(int dPhiBin, int bits=7, int max=512) const
int getdTheta(int dTheta, int bits=3) const
std::vector< std::vector< double > > tmp
int get8bMode15(int theta, int st1_ring2, int endcap, int sPhiAB, int clctA, int clctB, int clctC, int clctD) const
char data[epos_bytes_allocation]
std::vector< int > allowedModes_
int unpackSt1Ring2(int theta, int bits) const
int getNLBdPhiBin(int dPhi, int bits=7, int max=512) const
Power< A, B >::type pow(const A &a, const B &b)