25 defineParameter(
"InputWidth1", 9);
26 defineParameter(
"InputWidth2", 9);
27 defineParameter(
"MaxTob1", 0);
28 defineParameter(
"MaxTob2", 0);
29 defineParameter(
"NumResultBits", 6);
30 defineParameter(
"MinMSqr", 0, 0);
31 defineParameter(
"MaxMSqr", 999, 0);
32 defineParameter(
"MinMSqr", 0, 1);
33 defineParameter(
"MaxMSqr", 999, 1);
34 defineParameter(
"MinMSqr", 0, 2);
35 defineParameter(
"MaxMSqr", 999, 2);
36 defineParameter(
"MinMSqr", 0, 3);
37 defineParameter(
"MaxMSqr", 999, 3);
38 defineParameter(
"MinMSqr", 0, 4);
39 defineParameter(
"MaxMSqr", 999, 4);
40 defineParameter(
"MinMSqr", 0, 5);
41 defineParameter(
"MaxMSqr", 999, 5);
42 defineParameter(
"MinET1",0,0);
43 defineParameter(
"MinET2",0,0);
44 defineParameter(
"MinET1",0,1);
45 defineParameter(
"MinET2",0,1);
46 defineParameter(
"MinET1",0,2);
47 defineParameter(
"MinET2",0,2);
48 defineParameter(
"MinET1",0,3);
49 defineParameter(
"MinET2",0,3);
50 defineParameter(
"MinET1",0,4);
51 defineParameter(
"MinET2",0,4);
52 defineParameter(
"MinET1",0,5);
53 defineParameter(
"MinET2",0,5);
54 defineParameter(
"ApplyEtaCut", 0);
55 defineParameter(
"MinEta1", 0);
56 defineParameter(
"MaxEta1", 31);
57 defineParameter(
"MinEta2", 0);
58 defineParameter(
"MaxEta2", 31);
59 defineParameter(
"MinDeltaPhi", 0, 0);
60 defineParameter(
"MaxDeltaPhi", 31, 0);
61 defineParameter(
"MinDeltaPhi", 0, 1);
62 defineParameter(
"MaxDeltaPhi", 31, 1);
63 defineParameter(
"MinDeltaPhi", 0, 2);
64 defineParameter(
"MaxDeltaPhi", 31, 2);
65 defineParameter(
"MinDeltaPhi", 0, 3);
66 defineParameter(
"MaxDeltaPhi", 31, 3);
67 defineParameter(
"MinDeltaPhi", 0, 4);
68 defineParameter(
"MaxDeltaPhi", 31, 4);
69 defineParameter(
"MinDeltaPhi", 0, 5);
70 defineParameter(
"MaxDeltaPhi", 31, 5);
72 setNumberOutputBits(6);
80 p_NumberLeading1 = parameter(
"InputWidth1").value();
81 p_NumberLeading2 = parameter(
"InputWidth2").value();
82 if(parameter(
"MaxTob1").
value() > 0) p_NumberLeading1 = parameter(
"MaxTob1").value();
83 if(parameter(
"MaxTob2").
value() > 0) p_NumberLeading2 = parameter(
"MaxTob2").value();
85 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
86 p_InvMassMin[
i] = parameter(
"MinMSqr",
i).value();
87 p_InvMassMax[
i] = parameter(
"MaxMSqr",
i).value();
88 p_DeltaPhiMin[
i] = parameter(
"MinDeltaPhi",
i).value();
89 p_DeltaPhiMax[
i] = parameter(
"MaxDeltaPhi",
i).value();
90 p_MinET1[
i] = parameter(
"MinET1",
i).value();
91 p_MinET2[
i] = parameter(
"MinET2",
i).value();
96 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
105 p_ApplyEtaCut = parameter(
"ApplyEtaCut").value();
106 p_MinEta1 = parameter(
"MinEta1" ).value();
107 p_MaxEta1 = parameter(
"MaxEta1" ).value();
108 p_MinEta2 = parameter(
"MinEta2" ).value();
109 p_MaxEta2 = parameter(
"MaxEta2" ).value();
119 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
120 std::string hname_accept =
"hInvariantMassDeltaPhiInclusive2_accept_bit"+
std::to_string((
int)
i);
121 std::string hname_reject =
"hInvariantMassDeltaPhiInclusive2_reject_bit"+
std::to_string((
int)
i);
123 bookHist(m_histAcceptM, hname_accept,
"INVM vs DPHI", 100, sqrt(p_InvMassMin[
i]), sqrt(p_InvMassMax[
i]), 100, p_DeltaPhiMin[
i], p_DeltaPhiMax[
i]);
124 bookHist(m_histRejectM, hname_reject,
"INVM vs DPHI", 100, sqrt(p_InvMassMin[
i]), sqrt(p_InvMassMax[
i]), 100, p_DeltaPhiMin[
i], p_DeltaPhiMax[
i]);
126 bookHist(m_histAcceptEta1Eta2, hname_accept,
"ETA vs ETA", 100, p_MinEta1, p_MaxEta1, 100, p_MinEta2, p_MaxEta2);
127 bookHist(m_histRejectEta1Eta2, hname_reject,
"ETA vs ETA", 100, p_MinEta1, p_MaxEta1, 100, p_MinEta2, p_MaxEta2);
136 const std::vector<TCS::TOBArray *> &
output,
140 if(
input.size() == 2) {
145 if (p_NumberLeading1 <
input[0]->
size()) {
147 if ((*tob1)->Et() == (*tob1_plus1)->Et() &&
distance(
input[0]->
begin(), tob1) == p_NumberLeading1 - 1) {
148 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
149 output[
i]->setAmbiguityFlag(
true);
157 unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
159 unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
160 const int eta1 = (*tob1)->eta();
161 const int eta2 = (*tob2)->eta();
162 const unsigned int aeta1 = std::abs(
eta1);
163 const unsigned int aeta2 = std::abs(
eta2);
164 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
166 if(
parType_t((*tob1)->Et()) <= p_MinET1[
i])
continue;
167 if(
parType_t((*tob2)->Et()) <= p_MinET2[
i])
continue;
169 ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
170 (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) ))
continue;
171 accept = invmass2 >= p_InvMassMin[
i] && invmass2 <= p_InvMassMax[i] && deltaPhi >= p_DeltaPhiMin[
i] &&
deltaPhi <= p_DeltaPhiMax[
i];
172 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(
i) :
accept);
173 const bool fillReject = fillHistos() and not fillAccept;
174 const bool alreadyFilled = decision.
bit(
i);
179 if(fillAccept and not alreadyFilled) {
180 fillHist2D(m_histAcceptM[
i],sqrt((
float)invmass2),(
float)
deltaPhi);
181 fillHist2D(m_histAcceptEta1Eta2[
i],
eta1,
eta2);
182 }
else if(fillReject) {
183 fillHist2D(m_histRejectM[
i],sqrt((
float)invmass2),(
float)
deltaPhi);
184 fillHist2D(m_histRejectEta1Eta2[
i],
eta1,
eta2);
186 TRG_MSG_DEBUG(
"Decision " <<
i <<
": " << (
accept?
"pass":
"fail") <<
" invmass2 = " << invmass2);
192 TCS_EXCEPTION(
"InvariantMassDeltaPhiInclusive2 alg must have 2 inputs, but got " <<
input.size());
201 const std::vector<TCS::TOBArray *> &
output,
206 if(
input.size() == 2) {
211 if (p_NumberLeading1 <
input[0]->
size()) {
213 if ((*tob1)->Et() == (*tob1_plus1)->Et() &&
distance(
input[0]->
begin(), tob1) == p_NumberLeading1 - 1) {
214 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
215 output[
i]->setAmbiguityFlag(
true);
223 unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
225 unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
226 const int eta1 = (*tob1)->eta();
227 const int eta2 = (*tob2)->eta();
228 const unsigned int aeta1 = std::abs(
eta1);
229 const unsigned int aeta2 = std::abs(
eta2);
230 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
231 if(
parType_t((*tob1)->Et()) <= p_MinET1[
i])
continue;
232 if(
parType_t((*tob2)->Et()) <= p_MinET2[
i])
continue;
234 ((aeta1 < p_MinEta1 || aeta1 > p_MaxEta1 ) ||
235 (aeta2 < p_MinEta2 || aeta2 > p_MaxEta2 ) ))
continue;
236 bool accept = invmass2 >= p_InvMassMin[
i] && invmass2 <= p_InvMassMax[i] && deltaPhi >= p_DeltaPhiMin[
i] &&
deltaPhi <= p_DeltaPhiMax[
i];
237 const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(
i) :
accept);
238 const bool fillReject = fillHistos() and not fillAccept;
239 const bool alreadyFilled = decision.
bit(
i);
244 if(fillAccept and not alreadyFilled) {
245 fillHist2D(m_histAcceptM[
i],sqrt((
float)invmass2),(
float)
deltaPhi);
246 fillHist2D(m_histAcceptEta1Eta2[
i],
eta1,
eta2);
247 }
else if(fillReject) {
248 fillHist2D(m_histRejectM[
i],sqrt((
float)invmass2),(
float)
deltaPhi);
249 fillHist2D(m_histRejectEta1Eta2[
i],
eta1,
eta2);
251 TRG_MSG_DEBUG(
"Decision " <<
i <<
": " << (
accept ?
"pass":
"fail") <<
" invmass2 = " << invmass2);
256 TCS_EXCEPTION(
"InvariantMassDeltaPhiInclusive2 alg must have 2 inputs, but got " <<
input.size());