34 pt_xml = fmin(20., pt);
35 pt_scale = 1.2 / (1 - 0.015 * pt_xml);
47 float pt_unscale = -99;
51 pt_unscale = 1 / (1.2 + 0.015 *
pt);
52 pt_unscale = fmax(pt_unscale, (1 - 0.015 * 20) / 1.2);
66 int nHits = (mode / 8) + ((mode % 8) / 4) + ((mode % 4) / 2) + ((mode % 2) / 1);
67 if (not(nHits > 1 && nHits < 5)) {
74 int iA = -1, iB = -1, iC = -1, iD = -1;
75 int iAB, iAC, iAD, iBC, iCD;
142 iAB = (iA >= 0 && iB >= 0) ? iA + iB - (iA == 0) : -1;
143 iAC = (iA >= 0 && iC >= 0) ? iA + iC - (iA == 0) : -1;
144 iAD = (iA >= 0 && iD >= 0) ? 2 : -1;
145 iBC = (iB >= 0 && iC >= 0) ? iB + iC : -1;
146 iCD = (iC >= 0 && iD >= 0) ? 5 : -1;
149 int st1_ring2, dTheta;
150 int dPhiAB, dPhiBC, dPhiCD;
151 int sPhiAB, sPhiBC, sPhiCD;
153 int clctA, clctB, clctC, clctD;
163 sPhiBC = (data.
sign_ph[iBC] == sPhiAB);
164 sPhiCD = (data.
sign_ph[iCD] == sPhiAB);
171 }
else if (nHits == 3) {
175 sPhiBC = (data.
sign_ph[iBC] == sPhiAB);
182 }
else if (nHits == 2) {
198 mode15_8b =
aux().
get8bMode15(theta, st1_ring2, endcap, (sPhiAB == 1 ? 1 : -1), clctA, clctB, clctC, clctD);
199 }
else if (nHits == 3) {
204 clctA =
aux().
getCLCT(clctA, endcap, (sPhiAB == 1 ? 1 : -1), 2);
206 }
else if (nHits == 2) {
209 clctA =
aux().
getCLCT(clctA, endcap, (sPhiAB == 1 ? 1 : -1), 3);
210 clctB =
aux().
getCLCT(clctB, endcap, (sPhiAB == 1 ? 1 : -1), 3);
216 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
217 address |= (dPhiBC & ((1 << 5) - 1)) << (0 + 7);
218 address |= (dPhiCD & ((1 << 4) - 1)) << (0 + 7 + 5);
219 address |= (sPhiBC & ((1 << 1) - 1)) << (0 + 7 + 5 + 4);
220 address |= (sPhiCD & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1);
221 address |= (dTheta & ((1 << 2) - 1)) << (0 + 7 + 5 + 4 + 1 + 1);
222 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2);
223 address |= (mode15_8b & ((1 << 8) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1);
224 address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8);
225 if (not(address <
pow(2, 30) && address >=
pow(2, 29))) {
229 }
else if (nHits == 3) {
230 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
231 address |= (dPhiBC & ((1 << 5) - 1)) << (0 + 7);
232 address |= (sPhiBC & ((1 << 1) - 1)) << (0 + 7 + 5);
233 address |= (dTheta & ((1 << 3) - 1)) << (0 + 7 + 5 + 1);
234 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3);
237 address |= (frB & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3 + 1);
240 address |= (clctA & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit);
241 address |= (rpc_2b & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2);
242 address |= (theta & ((1 << 5) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2);
244 address |= (mode_ID & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5);
245 if (not(address <
pow(2, 29) && address >=
pow(2, 27))) {
250 address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5);
251 if (not(address <
pow(2, 27) && address >=
pow(2, 26))) {
256 }
else if (nHits == 2) {
257 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
258 address |= (dTheta & ((1 << 3) - 1)) << (0 + 7);
259 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 3);
260 address |= (frB & ((1 << 1) - 1)) << (0 + 7 + 3 + 1);
261 address |= (clctA & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1);
262 address |= (clctB & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3);
263 address |= (theta & ((1 << 5) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3);
264 address |= (mode_ID & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5);
265 if (not(address <
pow(2, 26) && address >=
pow(2, 24))) {
284 int nHits = -1,
mode = -1;
286 if (not(address <
pow(2, 30))) {
290 if (address >=
pow(2, 29)) {
293 }
else if (address >=
pow(2, 27)) {
295 }
else if (address >=
pow(2, 26)) {
298 }
else if (address >=
pow(2, 24)) {
304 int mode_ID,
theta, dTheta;
305 int dPhiAB, dPhiBC = -1, dPhiCD = -1;
306 int sPhiAB, sPhiBC = -1, sPhiCD = -1;
308 int clctA, clctB = -1;
309 int rpcA, rpcB, rpcC, rpcD;
317 dPhiAB = (address >> (0) & ((1 << 7) - 1));
318 dPhiBC = (address >> (0 + 7) & ((1 << 5) - 1));
319 dPhiCD = (address >> (0 + 7 + 5) & ((1 << 4) - 1));
320 sPhiBC = (address >> (0 + 7 + 5 + 4) & ((1 << 1) - 1));
321 sPhiCD = (address >> (0 + 7 + 5 + 4 + 1) & ((1 << 1) - 1));
322 dTheta = (address >> (0 + 7 + 5 + 4 + 1 + 1) & ((1 << 2) - 1));
323 frA = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2) & ((1 << 1) - 1));
324 mode15_8b = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1) & ((1 << 8) - 1));
325 mode_ID = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8) & ((1 << 1) - 1));
326 if (not(address <
pow(2, 30))) {
330 }
else if (nHits == 3) {
331 dPhiAB = (address >> (0) & ((1 << 7) - 1));
332 dPhiBC = (address >> (0 + 7) & ((1 << 5) - 1));
333 sPhiBC = (address >> (0 + 7 + 5) & ((1 << 1) - 1));
334 dTheta = (address >> (0 + 7 + 5 + 1) & ((1 << 3) - 1));
335 frA = (address >> (0 + 7 + 5 + 1 + 3) & ((1 << 1) - 1));
338 frB = (address >> (0 + 7 + 5 + 1 + 3 + 1) & ((1 << 1) - 1));
341 clctA = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit) & ((1 << 2) - 1));
342 rpc_2b = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2) & ((1 << 2) - 1));
343 theta = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2) & ((1 << 5) - 1));
345 mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 2) - 1));
346 if (not(address <
pow(2, 29))) {
351 mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 1) - 1));
352 if (not(address <
pow(2, 27))) {
357 }
else if (nHits == 2) {
358 dPhiAB = (address >> (0) & ((1 << 7) - 1));
359 dTheta = (address >> (0 + 7) & ((1 << 3) - 1));
360 frA = (address >> (0 + 7 + 3) & ((1 << 1) - 1));
361 frB = (address >> (0 + 7 + 3 + 1) & ((1 << 1) - 1));
362 clctA = (address >> (0 + 7 + 3 + 1 + 1) & ((1 << 3) - 1));
363 clctB = (address >> (0 + 7 + 3 + 1 + 1 + 3) & ((1 << 3) - 1));
364 theta = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3) & ((1 << 5) - 1));
365 mode_ID = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5) & ((1 << 3) - 1));
366 if (not(address <
pow(2, 26))) {
373 if (nHits == 3 &&
mode != 7) {
387 }
else if (nHits == 2) {
424 aux().
unpack8bMode15(mode15_8b, theta, St1_ring2, endcap, (sPhiAB == 1 ? 1 : -1), clctA, rpcA, rpcB, rpcC, rpcD);
429 }
else if (nHits == 3) {
445 }
else if (nHits == 2) {
466 std::vector<int> predictors;
469 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
474 theta, St1_ring2, dPhiAB, dPhiBC, dPhiCD, dPhiAB + dPhiBC, dPhiAB + dPhiBC + dPhiCD, dPhiBC + dPhiCD, frA, clctA};
483 dPhiAB + dPhiBC + dPhiCD,
488 int tmp[10] = {dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTheta, rpcA, rpcB, rpcC, rpcD};
489 predictors.insert(predictors.end(),
tmp, tmp + 10);
490 }
else if (nHits == 3) {
492 predictors = {
theta, St1_ring2, dPhiAB, dPhiBC, dPhiAB + dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
494 predictors = {
theta, St1_ring2, dPhiAB, dPhiAB + dPhiBC, dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
496 predictors = {
theta, St1_ring2, dPhiBC, dPhiAB, dPhiAB + dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
498 predictors = {
theta, dPhiAB, dPhiBC, dPhiAB + dPhiBC, frA, clctA, dTheta, rpcA, rpcB, rpcC};
499 }
else if (nHits == 2 &&
mode >= 8) {
500 predictors = {
theta, St1_ring2, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0)};
501 }
else if (nHits == 2 &&
mode < 8) {
502 predictors = {
theta, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0)};
509 std::vector<double> tree_data(predictors.cbegin(), predictors.cend());
511 auto tree_event = std::make_unique<emtf::Event>();
512 tree_event->predictedValue = 0;
513 tree_event->data = tree_data;
523 float inv_pt = tree_event->predictedValue;
524 pt_xml = 1.0 / fmax(0.001, inv_pt);
536 auto contain = [](
const std::vector<int>& vec,
int elem) {
537 return (
std::find(vec.begin(), vec.end(),
elem) != vec.end());
548 int st1 = (mode >= 8);
549 int st2 = ((mode % 8) >= 4);
550 int st3 = ((mode % 4) >= 2);
551 int st4 = ((mode % 2) == 1);
554 int dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34, dPhiSign;
555 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
556 int dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34;
557 int FR_1, FR_2, FR_3, FR_4;
558 int bend_1, bend_2, bend_3, bend_4;
559 int RPC_1, RPC_2, RPC_3, RPC_4;
562 int ph1 = -99, ph2 = -99, ph3 = -99, ph4 = -99;
563 int th1 = -99, th2 = -99, th3 = -99, th4 = -99;
564 int pat1 = -99, pat2 = -99, pat3 = -99, pat4 = -99;
625 theta =
CalcTrackTheta(th1, th2, th3, th4, St1_ring2, mode,
true);
646 CalcDeltaThetas(dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34, th1, th2, th3, th4, mode,
true);
648 FR_1 = (st1 ? data.
fr[0] : -99);
649 FR_2 = (st2 ? data.
fr[1] : -99);
650 FR_3 = (st3 ? data.
fr[2] : -99);
651 FR_4 = (st4 ? data.
fr[3] : -99);
653 CalcBends(bend_1, bend_2, bend_3, bend_4, pat1, pat2, pat3, pat4, dPhiSign, endcap, mode,
true);
655 RPC_1 = (st1 ? (pat1 == 0) : -99);
656 RPC_2 = (st2 ? (pat2 == 0) : -99);
657 RPC_3 = (st3 ? (pat3 == 0) : -99);
658 RPC_4 = (st4 ? (pat4 == 0) : -99);
660 CalcRPCs(RPC_1, RPC_2, RPC_3, RPC_4, mode, St1_ring2, theta,
true);
666 std::vector<int> predictors;
669 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_34, dPhi_13, dPhi_14, dPhi_24, FR_1, bend_1,
670 dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTh_14, RPC_1, RPC_2, RPC_3, RPC_4};
673 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_13, FR_1, FR_2, bend_1, dTh_13, RPC_1, RPC_2, RPC_3};
676 predictors = {
theta, St1_ring2, dPhi_12, dPhi_14, dPhi_24, FR_1, FR_2, bend_1, dTh_14, RPC_1, RPC_2, RPC_4};
679 predictors = {
theta, St1_ring2, dPhi_34, dPhi_13, dPhi_14, FR_1, FR_3, bend_1, dTh_14, RPC_1, RPC_3, RPC_4};
682 predictors = {
theta, dPhi_23, dPhi_34, dPhi_24, FR_2, bend_2, dTh_24, RPC_2, RPC_3, RPC_4};
685 predictors = {
theta, St1_ring2, dPhi_12, FR_1, FR_2, bend_1, bend_2, dTh_12, RPC_1, RPC_2};
688 predictors = {
theta, St1_ring2, dPhi_13, FR_1, FR_3, bend_1, bend_3, dTh_13, RPC_1, RPC_3};
691 predictors = {
theta, St1_ring2, dPhi_14, FR_1, FR_4, bend_1, bend_4, dTh_14, RPC_1, RPC_4};
694 predictors = {
theta, dPhi_23, FR_2, FR_3, bend_2, bend_3, dTh_23, RPC_2, RPC_3};
697 predictors = {
theta, dPhi_24, FR_2, FR_4, bend_2, bend_4, dTh_24, RPC_2, RPC_4};
700 predictors = {
theta, dPhi_34, FR_3, FR_4, bend_3, bend_4, dTh_34, RPC_3, RPC_4};
704 std::vector<double> tree_data(predictors.cbegin(), predictors.cend());
706 auto tree_event = std::make_unique<emtf::Event>();
707 tree_event->predictedValue = 0;
708 tree_event->data = tree_data;
718 float inv_pt = tree_event->predictedValue;
719 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)
static PFTauRenderPlugin instance
float scale_pt(const float pt, const int mode=15) const override
const PtAssignmentEngineAux2017 & aux() const
Geom::Theta< T > theta() 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)
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
address_t calculate_address(const EMTFTrack &track) const override
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)
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)
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
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)
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)
std::array< emtf::Forest, 16 > forests_
int getdPhiFromBin(int dPhiBin, int bits=7, int max=512) const
int getdTheta(int dTheta, int bits=3) const
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]
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)
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)