ATLAS Offline Software
MetSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 // MetSort.cxx
5 // author: Joerg Stelzer
6 // creation: 27/08/14.
7 // modify V Sorin, algorithm to calculate MET and convert in genericTOB
8 
10 #include "L1TopoCommon/Exception.h"
12 #include "L1TopoEvent/GenericTOB.h"
13 #include <algorithm>
14 #include <cmath>
15 
16 // Bitwise implementation utils
18 
19 using std::sqrt;
20 using std::round;
21 
22 //
23 REGISTER_ALG_TCS(MetSort)
24 
25 
26 // constructor
27 TCS::MetSort::MetSort(const std::string & name) : SortingAlg(name) {
28 
29  defineParameter( "InputWidth", 2 ); // for FW
30  defineParameter( "OutputWidth", 2 ); // for FW
31 
32 }
33 
34 // destructor
36 
37 
41 }
42 
45 
46  if(input.size()!=1) {
47  TCS_EXCEPTION("MET sort alg expects exactly single MET TOB, got " << input.size());
48  }
49 
50  const MetTOBArray & mets = dynamic_cast<const MetTOBArray&>(input);
51  int missingET = quadraticSumBW(mets[0].Ex(), mets[0].Ey());
52  int metphi = isLegacyTopo()?TSU::Trigo::atan2leg(mets[0].Ex(),mets[0].Ey()):TSU::Trigo::atan2(mets[0].Ex(),mets[0].Ey());
53 
54  TRG_MSG_DEBUG("MET phi values " << metphi << " " );
55  output.push_back( GenericTOB( missingET, 0, metphi ) );
56 
58 }
59 
62 
63  if(input.size()!=1) {
64  TCS_EXCEPTION("MET sort alg expects exactly single MET TOB, got " << input.size());
65  }
66 
67  const MetTOBArray & mets = dynamic_cast<const MetTOBArray&>(input);
68  int missingET = sqrt(mets[0].Ex()*mets[0].Ex() + mets[0].Ey() * mets[0].Ey());
69  // this returns values between -pi and pi. it needs to match the format for phi for jets and em/tau. The algorithm that uses this is mindeltaphi which
70  // uses phiDouble, filled with the phi value as returned from calosim, which also uses -pi pi. However, if replaced by phi, this is an integer between 0 63, so
71  // atan2 should be changed to match this. If all is replaced by the bitwise then all should match as both , the trigo function below and the TOB phi are given in the range 0 63
72  int metphi = round(10*atan2(mets[0].Ey(),mets[0].Ex()));
73  // bitwise atan2
74  //int metphi = TSU::Trigo::atan2(mets[0].Ex(),mets[0].Ey());
75  //
76  TRG_MSG_DEBUG("MET phi values " << metphi << " " );
77  output.push_back( GenericTOB( missingET, 0, metphi ) );
78 
79  // later we will add the Kalman MET here and add it to the output list
80  // algorithms working with MET will have to modify their input check
81 
83 }
84 
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
TCS::MetTOBArray
Definition: MetTOBArray.h:14
TCS::MetSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output)
Definition: MetSort.cxx:61
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
TCS::MetSort::sortBitCorrect
virtual TCS::StatusCode sortBitCorrect(const InputTOBArray &input, TOBArray &output)
Definition: MetSort.cxx:44
TSU::Trigo::atan2
static int atan2(TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)
Definition: Trigo.cxx:512
TCS::InputTOBArray
Definition: InputTOBArray.h:15
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::MetSort::~MetSort
virtual ~MetSort()
Definition: MetSort.cxx:35
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::TOBArray
Definition: TOBArray.h:24
TCS::MetSort
Definition: MetSort.h:19
Trigo.h
merge.output
output
Definition: merge.py:17
TCS::GenericTOB
Definition: GenericTOB.h:35
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TCS::SortingAlg
Definition: SortingAlg.h:18
GenericTOB.h
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TSU::Trigo::atan2leg
static int atan2leg(TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)
Definition: Trigo.cxx:440
MetTOBArray.h
TCS::MetSort::initialize
virtual StatusCode initialize()
Definition: MetSort.cxx:39
Exception.h
MetSort.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