26 defineParameter(
"InputWidth1", 9);
27 defineParameter(
"InputWidth2", 9);
28 defineParameter(
"MaxTob1", 0);
29 defineParameter(
"MaxTob2", 0);
30 defineParameter(
"NumResultBits", 6);
31 defineParameter(
"MinMSqr", 0, 0);
32 defineParameter(
"MaxMSqr", 999, 0);
33 defineParameter(
"MinMSqr", 0, 1);
34 defineParameter(
"MaxMSqr", 999, 1);
35 defineParameter(
"MinMSqr", 0, 2);
36 defineParameter(
"MaxMSqr", 999, 2);
37 defineParameter(
"MinMSqr", 0, 3);
38 defineParameter(
"MaxMSqr", 999, 3);
39 defineParameter(
"MinMSqr", 0, 4);
40 defineParameter(
"MaxMSqr", 999, 4);
41 defineParameter(
"MinMSqr", 0, 5);
42 defineParameter(
"MaxMSqr", 999, 5);
43 defineParameter(
"MinET1",0,0);
44 defineParameter(
"MinET2",0,0);
45 defineParameter(
"MinET1",0,1);
46 defineParameter(
"MinET2",0,1);
47 defineParameter(
"MinET1",0,2);
48 defineParameter(
"MinET2",0,2);
49 defineParameter(
"MinET1",0,3);
50 defineParameter(
"MinET2",0,3);
51 defineParameter(
"MinET1",0,4);
52 defineParameter(
"MinET2",0,4);
53 defineParameter(
"MinET1",0,5);
54 defineParameter(
"MinET2",0,5);
55 defineParameter(
"ApplyEtaCut", 0);
56 defineParameter(
"MinEta1", 0);
57 defineParameter(
"MaxEta1", 31);
58 defineParameter(
"MinEta2", 0);
59 defineParameter(
"MaxEta2", 31);
60 defineParameter(
"MinDeltaPhi", 0, 0);
61 defineParameter(
"MaxDeltaPhi", 31, 0);
62 defineParameter(
"MinDeltaPhi", 0, 1);
63 defineParameter(
"MaxDeltaPhi", 31, 1);
64 defineParameter(
"MinDeltaPhi", 0, 2);
65 defineParameter(
"MaxDeltaPhi", 31, 2);
66 defineParameter(
"MinDeltaPhi", 0, 3);
67 defineParameter(
"MaxDeltaPhi", 31, 3);
68 defineParameter(
"MinDeltaPhi", 0, 4);
69 defineParameter(
"MaxDeltaPhi", 31, 4);
70 defineParameter(
"MinDeltaPhi", 0, 5);
71 defineParameter(
"MaxDeltaPhi", 31, 5);
73 setNumberOutputBits(6);
81 p_NumberLeading1 = parameter(
"InputWidth1").value();
82 p_NumberLeading2 = parameter(
"InputWidth2").value();
83 if(parameter(
"MaxTob1").
value() > 0) p_NumberLeading1 = parameter(
"MaxTob1").value();
84 if(parameter(
"MaxTob2").
value() > 0) p_NumberLeading2 = parameter(
"MaxTob2").value();
86 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
87 p_InvMassMin[
i] = parameter(
"MinMSqr",
i).value();
88 p_InvMassMax[
i] = parameter(
"MaxMSqr",
i).value();
89 p_DeltaPhiMin[
i] = parameter(
"MinDeltaPhi",
i).value();
90 p_DeltaPhiMax[
i] = parameter(
"MaxDeltaPhi",
i).value();
91 p_MinET1[
i] = parameter(
"MinET1",
i).value();
92 p_MinET2[
i] = parameter(
"MinET2",
i).value();
97 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
106 p_ApplyEtaCut = parameter(
"ApplyEtaCut").value();
107 p_MinEta1 = parameter(
"MinEta1" ).value();
108 p_MaxEta1 = parameter(
"MaxEta1" ).value();
109 p_MinEta2 = parameter(
"MinEta2" ).value();
110 p_MaxEta2 = parameter(
"MaxEta2" ).value();
120 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
121 std::string hname_accept =
"hInvariantMassDeltaPhiInclusive2Charge_accept_bit"+
std::to_string(
static_cast<int>(
i));
122 std::string hname_reject =
"hInvariantMassDeltaPhiInclusive2Charge_reject_bit"+
std::to_string(
static_cast<int>(
i));
124 bookHist(m_histAcceptM, hname_accept,
"INVM vs DPHI", 100, std::sqrt(p_InvMassMin[
i]), std::sqrt(p_InvMassMax[
i]), 100, p_DeltaPhiMin[
i], p_DeltaPhiMax[
i]);
125 bookHist(m_histRejectM, hname_reject,
"INVM vs DPHI", 100, std::sqrt(p_InvMassMin[
i]), std::sqrt(p_InvMassMax[
i]), 100, p_DeltaPhiMin[
i], p_DeltaPhiMax[
i]);
127 bookHist(m_histAcceptEta1Eta2, hname_accept,
"ETA vs ETA", 100, p_MinEta1, p_MaxEta1, 100, p_MinEta2, p_MaxEta2);
128 bookHist(m_histRejectEta1Eta2, hname_reject,
"ETA vs ETA", 100, p_MinEta1, p_MaxEta1, 100, p_MinEta2, p_MaxEta2);
137 const std::vector<TCS::TOBArray *> &
output,
141 if(
input.size() == 2) {
152 unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
154 unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
155 const int eta1 = (*tob1)->eta();
156 const int eta2 = (*tob2)->eta();
157 const unsigned int aeta1 = std::abs(
eta1);
158 const unsigned int aeta2 = std::abs(
eta2);
160 int charge1 = (*tob1)->charge();
161 int charge2 = (*tob2)->charge();
162 int totalCharge = charge1 + charge2;
163 bool acceptCharge =
true;
164 if ( std::abs(totalCharge) == 2 ) { acceptCharge =
false; }
165 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
167 if(
static_cast<parType_t>((*tob1)->Et()) <= p_MinET1[
i])
continue;
168 if(
static_cast<parType_t>((*tob2)->Et()) <= p_MinET2[
i])
continue;
170 ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
171 (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) ))
continue;
172 accept = invmass2 >= p_InvMassMin[
i] && invmass2 <= p_InvMassMax[i] && deltaPhi >= p_DeltaPhiMin[
i] &&
deltaPhi <= p_DeltaPhiMax[
i] && acceptCharge;
173 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(
i) :
accept);
174 const bool fillReject = fillHistos() and not fillAccept;
175 const bool alreadyFilled = decision.
bit(
i);
180 if(fillAccept and not alreadyFilled) {
181 fillHist2D(m_histAcceptM[
i],std::sqrt(
static_cast<float>(invmass2)),
static_cast<float>(
deltaPhi));
182 fillHist2D(m_histAcceptEta1Eta2[
i],
eta1,
eta2);
183 }
else if(fillReject) {
184 fillHist2D(m_histRejectM[
i],std::sqrt(
static_cast<float>(invmass2)),
static_cast<float>(
deltaPhi));
185 fillHist2D(m_histRejectEta1Eta2[
i],
eta1,
eta2);
187 TRG_MSG_DEBUG(
"Decision " <<
i <<
": " << (
accept?
"pass":
"fail") <<
" invmass2 = " << invmass2);
193 TCS_EXCEPTION(
"InvariantMassDeltaPhiInclusive2Charge alg must have 2 inputs, but got " <<
input.size());
202 const std::vector<TCS::TOBArray *> &
output,
207 if(
input.size() == 2) {
216 unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
218 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
219 const int eta1 = (*tob1)->eta();
220 const int eta2 = (*tob2)->eta();
221 const unsigned int aeta1 = std::abs(
eta1);
222 const unsigned int aeta2 = std::abs(
eta2);
224 int charge1 = (*tob1)->charge();
225 int charge2 = (*tob2)->charge();
226 int totalCharge = charge1 + charge2;
227 bool acceptCharge =
true;
228 if ( std::abs(totalCharge) == 2 ) { acceptCharge =
true; }
229 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
230 if(
static_cast<parType_t>((*tob1)->Et()) <= p_MinET1[
i])
continue;
231 if(
static_cast<parType_t>((*tob2)->Et()) <= p_MinET2[
i])
continue;
233 ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
234 (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) ))
continue;
235 bool accept = invmass2 >= p_InvMassMin[
i] && invmass2 <= p_InvMassMax[i] && deltaPhi >= p_DeltaPhiMin[
i] &&
deltaPhi <= p_DeltaPhiMax[
i] && acceptCharge;
236 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(
i) :
accept);
237 const bool fillReject = fillHistos() and not fillAccept;
238 const bool alreadyFilled = decision.
bit(
i);
243 if(fillAccept and not alreadyFilled) {
244 fillHist2D(m_histAcceptM[
i],std::sqrt(
static_cast<float>(invmass2)),
static_cast<float>(
deltaPhi));
245 fillHist2D(m_histAcceptEta1Eta2[
i],
eta1,
eta2);
246 }
else if(fillReject) {
247 fillHist2D(m_histRejectM[
i],std::sqrt(
static_cast<float>(invmass2)),
static_cast<float>(
deltaPhi));
248 fillHist2D(m_histRejectEta1Eta2[
i],
eta1,
eta2);
250 TRG_MSG_DEBUG(
"Decision " <<
i <<
": " << (
accept ?
"pass":
"fail") <<
" invmass2 = " << invmass2);
255 TCS_EXCEPTION(
"InvariantMassDeltaPhiInclusive2Charge alg must have 2 inputs, but got " <<
input.size());