ATLAS Offline Software
TeAsymmetry.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 /*********************************
5  * TeAsymmetry.cpp
6  * Created by Jack Harrison on 12/05/25.
7  *
8  * @brief Based on the JIRA ticket: https://its.cern.ch/jira/browse/ATR-31097
9  * Three conditions are implemented:
10  * abs(jTE_A - jTE_C) > deltaAbsMin
11  * abs(jTE_A - jTE_C) > asymFactor * (jTE + asymOffset)
12  * jTE_A * jTE_C < maxTeProduct
13  *
14  * @param deltaAbsMin, asymFactor, asymOffset, maxTeProduct
15 **********************************/
16 
17 
18 #include <cmath>
19 
21 #include "L1TopoCommon/Exception.h"
24 
25 REGISTER_ALG_TCS(TeAsymmetry)
26 
27 
29 {
30 
31  defineParameter("InputWidth", 1);
32  defineParameter("MaxTob", 0);
33  defineParameter("NumResultBits", 4);
34  defineParameter("Delay", 1);
35  setNumberOutputBits(4);
36 
37  for (unsigned int i=0;i<numberOutputBits();i++){
38  // Algo parameters
39  defineParameter("deltaAbsMin", 0, i);
40  defineParameter("asymFactor", 0, i);
41  defineParameter("asymOffset", 0, i);
42  defineParameter("maxTeProduct", 0, i);
43  }
44 
45  // Histo monitoring parameters
46  defineParameter("MinSidejTE",0);
47  defineParameter("MaxSidejTE",999);
48 
49 }
50 
52 
53 
56 
57  //Algo parameters
58  for (unsigned int i=0;i<numberOutputBits();i++){
59  p_deltaAbsMin[i] = parameter("deltaAbsMin", i).value();
60  p_asymFactor[i] = parameter("asymFactor", i).value();
61  p_asymOffset[i] = parameter("asymOffset", i).value();
62  p_maxTeProduct[i] = parameter("maxTeProduct", i).value();
63  }
64 
65  // Histo monitoring
66  p_MinSidejTE = parameter("MinSidejTE").value();
67  p_MaxSidejTE = parameter("MaxSidejTE").value();
68 
69  TRG_MSG_INFO("number output : " << numberOutputBits());
70 
71  // book histograms
72  for(unsigned int i=0; i<numberOutputBits(); ++i) {
73  std::string hname_accept = "hTeAsymmetry_accept_bit"+std::to_string((int)i);
74  std::string hname_reject = "hTeAsymmetry_reject_bit"+std::to_string((int)i);
75  bookHist(m_histAccept, hname_accept, "jTE SideA vs jTE SideC", 100, p_MinSidejTE, p_MaxSidejTE, 100, p_MinSidejTE, p_MaxSidejTE);
76  bookHist(m_histReject, hname_reject, "jTE SideA vs jTE SideC", 100, p_MinSidejTE, p_MaxSidejTE, 100, p_MinSidejTE, p_MaxSidejTE);
77  }
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
84 TCS::TeAsymmetry::processBitCorrect( const std::vector<TCS::TOBArray const *> & input,
85  const std::vector<TCS::TOBArray *> & output,
86  Decision & decision )
87 {
88  if(input.size() == 1) {
89 
90  if (input[0]->size()!=1) {
91  TCS_EXCEPTION("TeAsymmetry alg needs input list with a single jTE TOB, got " << input[0]->size());
92  }
93 
94  for( TOBArray::const_iterator jte = input[0]->begin();
95  jte != input[0]->end();
96  ++jte)
97  {
98 
99  for(unsigned int i=0; i<numberOutputBits(); ++i) {
100 
101  bool accept = false;
102 
103  // Cast to long to avoid overflow
104  long long jteSideA = (*jte)->sumEtSideA();
105  long long jteSideC = (*jte)->sumEtSideC();
106 
107  //std::cout << "jTE SideA: " << jteSideA << ", jTE SideC: " << jteSideC << " , " << p_deltaAbsMin[i] << " , " << abs(jteSideA - jteSideC) << std::endl;
108 
109  bool condition_1 = abs(jteSideA - jteSideC) > p_deltaAbsMin[i];
110 
111  //std::cout << "Condition 1: " << condition_1 << std::endl;
112  bool condition_2 = abs(jteSideA - jteSideC) > p_asymFactor[i]*((*jte)->sumEt() + p_asymOffset[i]);
113  //std::cout << "Condition 2: " << condition_2 << std::endl;
114  bool condition_3 = jteSideA * jteSideC < p_maxTeProduct[i];
115  //std::cout << "Condition 3: " << condition_3 << std::endl;
116 
117  //Write out to the output bit
118  accept = condition_1 && condition_2 && condition_3;
119  //std::cout << "Accept: " << accept << std::endl;
120 
121  const bool fillAccept = fillHistos() and (fillHistosBasedOnHardware() ? getDecisionHardwareBit(i) : accept);
122  const bool fillReject = fillHistos() and not fillAccept;
123  const bool alreadyFilled = decision.bit(i);
124 
125  TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " jTE_A = " << (*jte)->sumEtSideA() << " , jTE_C = " << (*jte)->sumEtSideC());
126 
127  if( accept ) {
128  decision.setBit(i, true);
129  output[i]->push_back( TCS::CompositeTOB(*jte) );
130  }
131  if(fillAccept and not alreadyFilled) {
132  fillHist2D(m_histAccept[i], jteSideA, jteSideC);
133  } else if(fillReject) {
134  fillHist2D(m_histReject[i], jteSideA, jteSideC);
135  }
136  }
137  }
139  } else {
140  TCS_EXCEPTION("TeAsymmetry alg must have 1 input, but got " << input.size());
141  }
142 }
143 
145 TCS::TeAsymmetry::process( const std::vector<TCS::TOBArray const *> & input,
146  const std::vector<TCS::TOBArray *> & output,
147  Decision & decision )
148 {
149  return processBitCorrect(input, output, decision);
150 }
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
Decision.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
TCS::DecisionAlg
Definition: Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/DecisionAlg.h:22
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TCS::TeAsymmetry::~TeAsymmetry
virtual ~TeAsymmetry()
Definition: TeAsymmetry.cxx:51
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
lumiFormat.i
int i
Definition: lumiFormat.py:85
TCS::CompositeTOB
Definition: CompositeTOB.h:16
TeAsymmetry.h
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TCS::TeAsymmetry::initialize
virtual StatusCode initialize()
Definition: TeAsymmetry.cxx:55
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TCS::TeAsymmetry
Definition: TeAsymmetry.h:19
TCS::TeAsymmetry::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: TeAsymmetry.cxx:145
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
jTETOBArray.h
TCS::TeAsymmetry::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition: TeAsymmetry.cxx:84
Exception.h
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15