jFEXFPGA.h 7.2 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
*/

//***************************************************************************
//                           jFEXFPGA.h  -  
//                              -------------------
//     begin                : 15 10 2019
//     email                : jacob.julian.kempster@cern.ch
//  ***************************************************************************/


#ifndef jFEXFPGA_H
#define jFEXFPGA_H

#include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/CLASS_DEF.h"
#include "L1CaloFEXToolInterfaces/IjFEXFPGA.h"
#include "L1CaloFEXSim/jTower.h"
#include "L1CaloFEXSim/jTowerContainer.h"
21
#include "L1CaloFEXToolInterfaces/IjFEXSmallRJetAlgo.h"
22
#include "L1CaloFEXToolInterfaces/IjFEXLargeRJetAlgo.h"
23
#include "L1CaloFEXToolInterfaces/IjFEXtauAlgo.h"
24
25
#include "L1CaloFEXToolInterfaces/IjFEXsumETAlgo.h"
#include "L1CaloFEXToolInterfaces/IjFEXmetAlgo.h"
26
#include "L1CaloFEXToolInterfaces/IjFEXForwardJetsAlgo.h"
27
#include "L1CaloFEXToolInterfaces/IjFEXPileupAndNoise.h"
28
29
30
#include "CaloEvent/CaloCellContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
31
#include "L1CaloFEXSim/jFEXOutputCollection.h"
32
#include "L1CaloFEXSim/FEXAlgoSpaceDefs.h"
33
#include "TrigConfData/L1Menu.h"
34
#include <vector>
35
36
37
38
39
40
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/ITHistSvc.h"
#include "GaudiKernel/IClassIDSvc.h"
#include "SGTools/StlMapClids.h"
#include "SGTools/TestStore.h"
41
42
#include "StoreGate/WriteHandle.h"
#include "StoreGate/ReadHandle.h"
43
44
#include "StoreGate/StoreGateSvc.h"

45
46
47
48
49
50
namespace LVL1 {
  
  //Doxygen class description below:
  /** The jFEXFPGA class defines the structure of a single jFEX FPGA
      Its purpose is:
      - to emulate the steps taken in processing data for a single jFEX FPGA in hardware and firmware
51
      - It will need to interact with jTowers and produce the jTOBs.  It will be created and handed data by jFEXSim
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  */
  
  class jFEXFPGA : public AthAlgTool, virtual public IjFEXFPGA {
    
  public:
    /** Constructors */
    jFEXFPGA(const std::string& type,const std::string& name,const IInterface* parent);

    /** standard Athena-Algorithm method */
    virtual StatusCode initialize() override;
    /** Destructor */
    virtual ~jFEXFPGA();

    virtual StatusCode init(int id, int efexid) override ;

67
    virtual StatusCode execute(jFEXOutputCollection* inputOutputCollection) override ;
68
69
70
71
72

    virtual void reset() override ;

    virtual int ID() override {return m_id;}

73
74
    virtual void SetTowersAndCells_SG( int [][FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width] ) override ;
    virtual void SetTowersAndCells_SG( int [][FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width] ) override ;
75
76
77

    /**Form a tob word out of the potential candidate SmallRJet tob */
    virtual uint32_t formSmallRJetTOB(int &, int &) override;
78
79
80
    virtual uint32_t formLargeRJetTOB(int &, int &) override;
    virtual std::vector <uint32_t> getSmallRJetTOBs() override;
    virtual std::vector <uint32_t> getLargeRJetTOBs() override;
81
82
83
84

    /**Form a tob word out of the potential candidate Tau tob */
    virtual uint32_t formTauTOB(int &, int &) override;
    virtual std::vector <uint32_t> getTauTOBs() override;    
85
86
87
88
89
90
91
92
93
    virtual std::vector <uint32_t> getTauxTOBs() override; 
       
    /**Form a tob word out of the potential candidate SumET tob */
    virtual uint32_t formSumETTOB(int , int ) override;
    virtual std::vector <uint32_t> getSumEtTOBs() override;    
       
    /**Form a tob word out of the potential candidate MET tob */
    virtual uint32_t formMetTOB(int , int ) override;
    virtual std::vector <uint32_t> getMetTOBs() override;    
94
    
95
96
97
98
99
    int getTTowerET_EM     (unsigned int TTID ) override; 
    int getTTowerET_HAD    (unsigned int TTID ) override; 
    int getTTowerET        (unsigned int TTID ) override; 
    int getTTowerET_forMET (unsigned int TTID ) override; 
    
100
   /** Internal data */
101
  private:
102
103
    static bool etSRJetSort(uint32_t i, uint32_t j){ return (((i >> 12 ) & 0x7ff)> ((j >> 12) & 0x7ff));}
    static bool etLRJetSort(uint32_t i, uint32_t j){return (((i >>10) & 0x1fff)> ((j>>10) & 0x1fff));}
104
105
106
    static bool etTauSort(uint32_t i, uint32_t j) {
      return (((i >> 0 ) & 0x7ff000)> ((j >> 0) & 0x7ff000));
    }
107
108
    int m_id;
    int m_jfexid;
Varsiha Sothilingam's avatar
Varsiha Sothilingam committed
109
110
    std::vector<uint32_t> m_SRJet_tobwords;
    std::vector<uint32_t> m_LRJet_tobwords;
111
    std::vector<uint32_t> m_tau_tobwords;
112
113
    std::vector<uint32_t> m_sumET_tobwords;
    std::vector<uint32_t> m_Met_tobwords;
114
115
116
    int m_jTowersIDs_Wide [FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width] = {{0}};
    int m_jTowersIDs_Thin [FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width] = {{0}};
    int m_jTowersIDs      [FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width] = {{0}};
117
118
119
120
    std::unordered_map<int,jTower> m_jTowersColl;
    std::unordered_map<int,std::vector<int> > m_map_Etvalues_FPGA;
    std::unordered_map<int,std::vector<int> > m_map_HAD_Etvalues_FPGA;
    std::unordered_map<int,std::vector<int> > m_map_EM_Etvalues_FPGA;
121
    
122

123
    std::unordered_map<int, jFEXForwardJetsInfo> m_FCALJets; 
124

125
126
127
    int m_SRJetET;
    int m_LRJetET;

128
129
130
    CaloCellContainer m_sCellsCollection;

    SG::ReadHandleKey<LVL1::jTowerContainer> m_jFEXFPGA_jTowerContainerKey {this, "MyETowers", "jTowerContainer", "Input container for jTowers"};
131
    SG::ReadHandleKey<TrigConf::L1Menu> m_l1MenuKey{this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu","Name of the L1Menu object to read configuration from"}; 
132
    SG::WriteHandleKey<LVL1::jFEXOutputCollection> m_jFEXFPGA_jFEXOutputCollectionKey {this, "jFEXOutputCollection", "jFEXOutputCollection", "Input container for jFEXOutputCollection"};
133
    ToolHandle<IjFEXSmallRJetAlgo> m_jFEXSmallRJetAlgoTool {this, "jFEXSmallRJetAlgoTool", "LVL1::jFEXSmallRJetAlgo", "Tool that runs the jFEX Small R Jet algorithm"};
134
    ToolHandle<IjFEXLargeRJetAlgo> m_jFEXLargeRJetAlgoTool {this, "jFEXLargeRJetAlgoTool", "LVL1::jFEXLargeRJetAlgo", "Tool that runs the jFEX Large R Jet algorithm"};
135
    ToolHandle<IjFEXtauAlgo> m_jFEXtauAlgoTool             {this, "jFEXtauAlgoTool"      , "LVL1::jFEXtauAlgo"      , "Tool that runs the jFEX tau algorithm"};
136
137
    ToolHandle<IjFEXsumETAlgo> m_jFEXsumETAlgoTool         {this, "jFEXsumETAlgoTool"    , "LVL1::jFEXsumETAlgo"    , "Tool that runs the jFEX sumET algorithm"};
    ToolHandle<IjFEXmetAlgo> m_jFEXmetAlgoTool             {this, "jFEXmetAlgoTool"      , "LVL1::jFEXmetAlgo"      , "Tool that runs the jFEX met algorithm"};
138
    ToolHandle<IjFEXForwardJetsAlgo> m_jFEXForwardJetsAlgoTool {this, "jFEXForwardJetsAlgoTool"      , "LVL1::jFEXForwardJetsAlgo"      , "Tool that runs the jFEX FCAL Jets algorithm"};
139
140
141
142
143

    //ToolHandle<IjFEXegAlgo> m_jFEXegAlgoTool {this, "jFEXegAlgoTool", "LVL1::jFEXegAlgo", "Tool that runs the jFEX e/gamma algorithm"};
    ToolHandle<IjFEXPileupAndNoise> m_jFEXPileupAndNoiseTool {this, "jFEXPileupAndNoiseTool", "LVL1::jFEXPileupAndNoise", "Tool that applies Pileup and Noise"};
    
    int getTTowerET_SG(unsigned int TTID);
144
    std::string m_jfex_string[6] = {"1C","2C","3C","3A","2A","1A"};
145
146
147
148
  };
  
} // end of namespace

149

150
CLASS_DEF( LVL1::jFEXFPGA , 76081081 , 1 )
151
#endif