ATLAS Offline Software
Loading...
Searching...
No Matches
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
13#include <algorithm>
14#include <cmath>
15
16// Bitwise implementation utils
18
19using std::sqrt;
20using std::round;
21
22//
23REGISTER_ALG_TCS(MetSort)
24
25
26// constructor
28
29 defineParameter( "InputWidth", 2 ); // for FW
30 defineParameter( "OutputWidth", 2 ); // for FW
31
32}
33
34// destructor
36
37
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
61TCS::MetSort::sort(const InputTOBArray & input, TOBArray & output) {
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
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
bool isLegacyTopo() const
const std::string & name() const
unsigned long quadraticSumBW(int i1, int i2)
void defineParameter(const std::string &name, TCS::parType_t value)
virtual ~MetSort()
Definition MetSort.cxx:35
virtual TCS::StatusCode sortBitCorrect(const InputTOBArray &input, TOBArray &output)
Definition MetSort.cxx:44
virtual StatusCode initialize()
Definition MetSort.cxx:39
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output)
Definition MetSort.cxx:61
MetSort(const std::string &name)
Definition MetSort.cxx:27
SortingAlg(const std::string &name)
Definition SortingAlg.h:21
STL namespace.
static int atan2leg(TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)
Definition Trigo.cxx:440
static int atan2(TSU::L1TopoDataTypes< 16, 0 > x, TSU::L1TopoDataTypes< 16, 0 > y)
Definition Trigo.cxx:512