20 #include <VAENetwork.h>
27 defineParameter(
"InputWidth1", 6);
28 defineParameter(
"InputWidth2", 6);
29 defineParameter(
"InputWidth3", 6);
30 defineParameter(
"InputWidth4", 1);
31 defineParameter(
"MaxTob1", 6);
32 defineParameter(
"MaxTob2", 4);
33 defineParameter(
"MaxTob3", 4);
34 defineParameter(
"MaxTob4", 1);
35 defineParameter(
"NumResultBits", 2);
38 defineParameter(
"ADVAEVersion", 1);
40 defineParameter(
"MinET1",0);
41 defineParameter(
"MinET2",0);
42 defineParameter(
"MinET3",0);
43 defineParameter(
"MinET4",0);
45 defineParameter(
"AnomalyScoreThresh", 1000000, 0);
46 defineParameter(
"AnomalyScoreThresh", 1000000, 1);
48 setNumberOutputBits(2);
56 p_NumberLeading1 = parameter(
"InputWidth1").value();
57 p_NumberLeading2 = parameter(
"InputWidth2").value();
58 p_NumberLeading3 = parameter(
"InputWidth3").value();
59 p_NumberLeading4 = parameter(
"InputWidth4").value();
61 if(parameter(
"MaxTob1").
value() > 0) p_NumberLeading1 = parameter(
"MaxTob1").value();
62 if(parameter(
"MaxTob2").
value() > 0) p_NumberLeading2 = parameter(
"MaxTob2").value();
63 if(parameter(
"MaxTob3").
value() > 0) p_NumberLeading3 = parameter(
"MaxTob3").value();
64 if(parameter(
"MaxTob4").
value() > 0) p_NumberLeading4 = parameter(
"MaxTob4").value();
66 p_minEt1 = parameter(
"MinET1").value();
67 p_minEt2 = parameter(
"MinET2").value();
68 p_minEt3 = parameter(
"MinET3").value();
69 p_minEt4 = parameter(
"MinET4").value();
71 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
72 p_AnomalyScoreThresh[
i] = parameter(
"AnomalyScoreThresh",
i).value();
78 for(
unsigned int i=0;
i<numberOutputBits(); ++
i) {
79 std::string hname_accept =
"hAnomalyScore_accept_bit"+
std::to_string((
int)
i);
80 std::string hname_reject =
"hAnomalyScore_reject_bit"+
std::to_string((
int)
i);
82 bookHist(m_histAccept, hname_accept,
"ADScore", 2000, 0, 2000000);
83 bookHist(m_histReject, hname_reject,
"ADScore", 2000, 0, 2000000);
93 const std::vector<TCS::TOBArray *> & output,
98 if( input.size() == 4) {
109 std::vector<u_int> jet_pt(6,0), tau_pt(4,0),
mu_pt(4,0), met_pt(1,0);
110 std::vector<int> jet_eta(6,0), tau_eta(4,0),
mu_eta(4,0);
111 std::vector<int>
jet_phi(6,0), tau_phi(4,0),
mu_phi(4,0), met_phi(1,0);
113 for (u_int
i = 0;
i<(*jets).size() &&
i<6; ++
i) {
115 jet_pt[
i] = (*jets)[
i].Et();
116 jet_eta[
i] = (*jets)[
i].eta();
119 for (u_int
i = 0;
i < (*taus).size() &&
i<4; ++
i) {
120 if (
parType_t( (*taus)[
i].Et() ) <= p_minEt2 )
continue;
121 tau_pt[
i] = (*taus)[
i].Et();
122 tau_eta[
i] = (*taus)[
i].eta();
123 tau_phi[
i] = (*taus)[
i].phi();
125 for (u_int
i = 0;
i < (*mus).size() &&
i<4; ++
i) {
126 if (
parType_t( (*mus)[
i].Et() ) <= p_minEt3 )
continue;
131 for (u_int
i = 0;
i < (*met).size() &&
i<1; ++
i) {
133 met_pt[
i] = (*met)[
i].Et();
134 met_phi[
i] = (*met)[
i].phi();
145 TRG_MSG_DEBUG(
"Tau0: " << tau_pt[0] <<
", " << tau_eta[0] <<
", " << tau_phi[0] );
146 TRG_MSG_DEBUG(
"Tau1: " << tau_pt[1] <<
", " << tau_eta[1] <<
", " << tau_phi[1] );
147 TRG_MSG_DEBUG(
"Tau2: " << tau_pt[2] <<
", " << tau_eta[2] <<
", " << tau_phi[2] );
148 TRG_MSG_DEBUG(
"Tau3: " << tau_pt[3] <<
", " << tau_eta[3] <<
", " << tau_phi[3] );
155 TRG_MSG_DEBUG(
"MET: " << met_pt[0] <<
", " << met_phi[0] << std::endl);
157 ADVAE2A::VAENetwork AD_Network( jet_pt[0], jet_eta[0],
jet_phi[0],
158 jet_pt[1], jet_eta[1],
jet_phi[1],
159 jet_pt[2], jet_eta[2],
jet_phi[2],
160 jet_pt[3], jet_eta[3],
jet_phi[3],
161 jet_pt[4], jet_eta[4],
jet_phi[4],
162 jet_pt[5], jet_eta[5],
jet_phi[5],
163 tau_pt[0], tau_eta[0], tau_phi[0],
164 tau_pt[1], tau_eta[1], tau_phi[1],
165 tau_pt[2], tau_eta[2], tau_phi[2],
166 tau_pt[3], tau_eta[3], tau_phi[3],
171 met_pt[0], met_phi[0] );
172 int64_t anomScoreInt64 = AD_Network.getAnomalyScoreInt64();
174 for(u_int
i=0;
i<numberOutputBits(); ++
i) {
176 int32_t
threshold = int32_t ( p_AnomalyScoreThresh[
i] );
180 for ( u_int j = 0; j<6 && j<(*jets).size(); ++j ) output[
i]->push_back((*
jets)[j]);
181 for ( u_int j = 0; j<4 && j<(*taus).size(); ++j ) output[
i]->push_back((*taus)[j]);
182 for ( u_int j = 0; j<4 && j<(*mus).size() ; ++j ) output[
i]->push_back((*mus) [j]);
183 output[
i]->push_back((*
met)[0]);
186 if(fillHistos() and
accept) {
187 fillHist1D(m_histAccept[
i],anomScoreInt64);
188 }
else if(fillHistos() && !
accept) {
189 fillHist1D(m_histReject[
i],anomScoreInt64);
192 TRG_MSG_DEBUG(
"Decision for bit" <<
i <<
": " << (
accept?
"pass":
"fail") <<
" anomaly score = " << anomScoreInt64 << std::endl);
195 TCS_EXCEPTION(
"ADVAE_2A alg must have 4 inputs, but got " << input.size());
203 const std::vector<TCS::TOBArray *> & output,
208 if( input.size() == 4) {
219 std::vector<u_int> jet_pt(6,0), tau_pt(4,0),
mu_pt(4,0), met_pt(1,0);
220 std::vector<int> jet_eta(6,0), tau_eta(4,0),
mu_eta(4,0);
221 std::vector<int>
jet_phi(6,0), tau_phi(4,0),
mu_phi(4,0), met_phi(1,0);
223 for (u_int
i = 0;
i<(*jets).size() &&
i<6; ++
i) {
225 jet_pt[
i] = (*jets)[
i].Et();
226 jet_eta[
i] = (*jets)[
i].eta();
229 for (u_int
i = 0;
i < (*taus).size() &&
i<4; ++
i) {
230 if (
parType_t( (*taus)[
i].Et() ) <= p_minEt2 )
continue;
231 tau_pt[
i] = (*taus)[
i].Et();
232 tau_eta[
i] = (*taus)[
i].eta();
233 tau_phi[
i] = (*taus)[
i].phi();
235 for (u_int
i = 0;
i < (*mus).size() &&
i<4; ++
i) {
236 if (
parType_t( (*mus)[
i].Et() ) <= p_minEt3 )
continue;
241 for (u_int
i = 0;
i < (*met).size() &&
i<1; ++
i) {
243 met_pt[
i] = (*met)[
i].Et();
244 met_phi[
i] = (*met)[
i].phi();
247 ADVAE2A::VAENetwork AD_Network( jet_pt[0], jet_eta[0],
jet_phi[0],
248 jet_pt[1], jet_eta[1],
jet_phi[1],
249 jet_pt[2], jet_eta[2],
jet_phi[2],
250 jet_pt[3], jet_eta[3],
jet_phi[3],
251 jet_pt[4], jet_eta[4],
jet_phi[4],
252 jet_pt[5], jet_eta[5],
jet_phi[5],
253 tau_pt[0], tau_eta[0], tau_phi[0],
254 tau_pt[1], tau_eta[1], tau_phi[1],
255 tau_pt[2], tau_eta[2], tau_phi[2],
256 tau_pt[3], tau_eta[3], tau_phi[3],
261 met_pt[0], met_phi[0] );
262 int64_t anomScoreInt64 = AD_Network.getAnomalyScoreInt64();
264 for(u_int
i=0;
i<numberOutputBits(); ++
i) {
266 int32_t
threshold = int32_t ( p_AnomalyScoreThresh[
i] );
270 for ( u_int j = 0; j<6 && j<(*jets).size(); ++j ) output[
i]->push_back((*
jets)[j]);
271 for ( u_int j = 0; j<4 && j<(*taus).size(); ++j ) output[
i]->push_back((*taus)[j]);
272 for ( u_int j = 0; j<4 && j<(*mus).size() ; ++j ) output[
i]->push_back((*mus) [j]);
273 output[
i]->push_back((*
met)[0]);
276 if(fillHistos() and
accept) {
277 fillHist1D(m_histAccept[
i],anomScoreInt64);
278 }
else if(fillHistos() && !
accept) {
279 fillHist1D(m_histReject[
i],anomScoreInt64);
282 TRG_MSG_DEBUG(
"Decision for bit" <<
i <<
": " << (
accept?
"pass":
"fail") <<
" anomaly score = " << anomScoreInt64 << std::endl);
285 TCS_EXCEPTION(
"ADVAE_2A alg must have 4 inputs, but got " << input.size());