Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:51

0001 #ifndef L1GCTGLOBALENERGYALGOS_H_
0002 #define L1GCTGLOBALENERGYALGOS_H_
0003 
0004 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtTotal.h"
0005 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtHad.h"
0006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtMiss.h"
0007 
0008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctProcessor.h"
0009 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctMet.h"
0010 
0011 #include <vector>
0012 
0013 class L1GctWheelEnergyFpga;
0014 class L1GctWheelJetFpga;
0015 class L1GctGlobalHfSumAlgos;
0016 
0017 /*!
0018  * \class L1GctGlobalEnergyAlgos
0019  * \brief Emulates the GCT global energy algorithms
0020  *
0021  * This class carries out the final stage of summing of
0022  * total Et, missing Et components Ex and Ey, calibrated
0023  * jet energy Ht, and jet counts. It converts the final
0024  * missing Ex and Ey sums to magnitude and direction.
0025  * The inputs come from the two Wheel cards
0026  * and the outputs are sent to the Global Trigger.
0027  *
0028  * \author Jim Brooke & Greg Heath
0029  * \date 20/2/2006
0030  * 
0031  */
0032 
0033 class L1GctGlobalEnergyAlgos : public L1GctProcessor {
0034 public:
0035   typedef L1GctUnsignedInt<L1GctEtTotal::kEtTotalNBits> etTotalType;
0036   typedef L1GctUnsignedInt<L1GctEtHad::kEtHadNBits> etHadType;
0037   typedef L1GctMet::etMissType etMissType;
0038   typedef L1GctMet::etMissPhiType etMissPhiType;
0039   typedef L1GctMet::etmiss_vec etmiss_vec;
0040   typedef L1GctWheelEnergyFpga::etComponentType etComponentType;
0041 
0042   enum maxValues {
0043     etTotalMaxValue = L1GctEtTotal::kEtTotalMaxValue,
0044     etHadMaxValue = L1GctEtHad::kEtHadMaxValue,
0045     etMissMaxValue = L1GctEtMiss::kEtMissMaxValue
0046   };
0047 
0048   /// Constructor needs the Wheel card Fpgas set up first
0049   L1GctGlobalEnergyAlgos(const std::vector<L1GctWheelEnergyFpga*>& WheelFpga,
0050                          const std::vector<L1GctWheelJetFpga*>& WheelJetFpga);
0051   /// Destructor
0052   ~L1GctGlobalEnergyAlgos() override;
0053 
0054   /// Overload << operator
0055   friend std::ostream& operator<<(std::ostream& os, const L1GctGlobalEnergyAlgos& fpga);
0056 
0057   /// clear internal buffers
0058   void reset();
0059 
0060   /// get input data from sources
0061   void fetchInput() override;
0062 
0063   /// process the data, fill output buffers
0064   void process() override;
0065 
0066   /// define the bunch crossing range to process
0067   void setBxRange(const int firstBx, const int numberOfBx);
0068 
0069   /// partially clear buffers
0070   void setNextBx(const int bx);
0071 
0072   /// set input Ex value per wheel (0 or 1); not used in normal operation
0073   void setInputWheelEx(unsigned wheel, int energy, bool overflow);
0074   /// set input Ey value per wheel (0 or 1); not used in normal operation
0075   void setInputWheelEy(unsigned wheel, int energy, bool overflow);
0076   /// set input Et value per wheel (0 or 1); not used in normal operation
0077   void setInputWheelEt(unsigned wheel, unsigned energy, bool overflow);
0078   /// set input Ht value per wheel (0 or 1); not used in normal operation
0079   void setInputWheelHt(unsigned wheel, unsigned energy, bool overflow);
0080   /// set input Ht component values per wheel (0 or 1); not used in normal operation
0081   void setInputWheelHx(unsigned wheel, unsigned energy, bool overflow);
0082   void setInputWheelHy(unsigned wheel, unsigned energy, bool overflow);
0083 
0084   /// set input jet count (number 0-11) per wheel (0 or 1); not used in normal operation
0085   void setInputWheelJc(unsigned wheel, unsigned jcnum, unsigned count);
0086 
0087   /// provide access to input pointer, Wheel Energy Fpga 1
0088   L1GctWheelEnergyFpga* getPlusWheelFpga() const { return m_plusWheelFpga; }
0089   /// provide access to input pointer, Wheel Energy Fpga 0
0090   L1GctWheelEnergyFpga* getMinusWheelFpga() const { return m_minusWheelFpga; }
0091   /// provide access to input pointer, Wheel Jet Fpga 1
0092   L1GctWheelJetFpga* getPlusWheelJetFpga() const { return m_plusWheelJetFpga; }
0093   /// provide access to input pointer, Wheel Jet Fpga 0
0094   L1GctWheelJetFpga* getMinusWheelJetFpga() const { return m_minusWheelJetFpga; }
0095   /// provide access to hf sum processor
0096   L1GctGlobalHfSumAlgos* getHfSumProcessor() const { return m_hfSumProcessor; }
0097 
0098   /// return input Ex value wheel 1
0099   inline std::vector<etComponentType> getInputExValPlusWheel() const { return m_exValPlusPipe.contents; }
0100   /// return input Ex value wheel 1
0101   inline std::vector<etComponentType> getInputEyValPlusWheel() const { return m_eyValPlusPipe.contents; }
0102   /// return input Ey value wheel 0
0103   inline std::vector<etComponentType> getInputExVlMinusWheel() const { return m_exVlMinusPipe.contents; }
0104   /// return input Ey value wheel 0
0105   inline std::vector<etComponentType> getInputEyVlMinusWheel() const { return m_eyVlMinusPipe.contents; }
0106   /// return input Et value wheel 1
0107   inline std::vector<etTotalType> getInputEtValPlusWheel() const { return m_etValPlusPipe.contents; }
0108   /// return input Ht value wheel 1
0109   inline std::vector<etHadType> getInputHtValPlusWheel() const { return m_htValPlusPipe.contents; }
0110   /// return input Ht component values wheel 1
0111   inline std::vector<etComponentType> getInputHxValPlusWheel() const { return m_hxValPlusPipe.contents; }
0112   inline std::vector<etComponentType> getInputHyValPlusWheel() const { return m_hyValPlusPipe.contents; }
0113   /// return input Et value wheel 0
0114   inline std::vector<etTotalType> getInputEtVlMinusWheel() const { return m_etVlMinusPipe.contents; }
0115   /// return input Ht value wheel 0
0116   inline std::vector<etHadType> getInputHtVlMinusWheel() const { return m_htVlMinusPipe.contents; }
0117   /// return input Ht value wheel 0
0118   inline std::vector<etComponentType> getInputHxVlMinusWheel() const { return m_hxVlMinusPipe.contents; }
0119   inline std::vector<etComponentType> getInputHyVlMinusWheel() const { return m_hyVlMinusPipe.contents; }
0120 
0121   /// Access to output quantities for all bunch crossings
0122   /// return output missing Et magnitude
0123   inline std::vector<etMissType> getEtMissColl() const { return m_outputEtMiss.contents; }
0124   /// return output missing Et value
0125   inline std::vector<etMissPhiType> getEtMissPhiColl() const { return m_outputEtMissPhi.contents; }
0126   /// return output total scalar Et
0127   inline std::vector<etTotalType> getEtSumColl() const { return m_outputEtSum.contents; }
0128   /// return std::vector< output calibrated jet Et
0129   inline std::vector<etHadType> getEtHadColl() const { return m_outputEtHad.contents; }
0130   /// return output missing Ht magnitude
0131   inline std::vector<etMissType> getHtMissColl() const { return m_outputHtMiss.contents; }
0132   /// return output missing Ht value
0133   inline std::vector<etMissPhiType> getHtMissPhiColl() const { return m_outputHtMissPhi.contents; }
0134 
0135   void setJetFinderParams(const L1GctJetFinderParams* const jfpars);
0136   void setHtMissScale(const L1CaloEtScale* const scale);
0137 
0138   // get the missing Ht LUT (used by L1GctPrintLuts)
0139   const L1GctHtMissLut* getHtMissLut() const { return m_mhtComponents.getHtMissLut(); }
0140 
0141   /// check setup
0142   bool setupOk() const;
0143 
0144 protected:
0145   /// Separate reset methods for the processor itself and any data stored in pipelines
0146   void resetProcessor() override;
0147   void resetPipelines() override;
0148 
0149   /// Initialise inputs with null objects for the correct bunch crossing if required
0150   void setupObjects() override {}
0151 
0152 private:
0153   // Here are the algorithm types we get our inputs from
0154   L1GctWheelEnergyFpga* m_plusWheelFpga;
0155   L1GctWheelEnergyFpga* m_minusWheelFpga;
0156   L1GctWheelJetFpga* m_plusWheelJetFpga;
0157   L1GctWheelJetFpga* m_minusWheelJetFpga;
0158 
0159   // Here's the class that does the Hf sums
0160   L1GctGlobalHfSumAlgos* m_hfSumProcessor;
0161 
0162   // Missing Et and missing Ht
0163   L1GctMet m_metComponents;
0164   L1GctMet m_mhtComponents;
0165 
0166   // input data
0167   etComponentType m_exValPlusWheel;
0168   etComponentType m_eyValPlusWheel;
0169   etTotalType m_etValPlusWheel;
0170   etHadType m_htValPlusWheel;
0171   etComponentType m_hxValPlusWheel;
0172   etComponentType m_hyValPlusWheel;
0173 
0174   etComponentType m_exVlMinusWheel;
0175   etComponentType m_eyVlMinusWheel;
0176   etTotalType m_etVlMinusWheel;
0177   etHadType m_htVlMinusWheel;
0178   etComponentType m_hxVlMinusWheel;
0179   etComponentType m_hyVlMinusWheel;
0180 
0181   // stored copies of input data
0182   Pipeline<etComponentType> m_exValPlusPipe;
0183   Pipeline<etComponentType> m_eyValPlusPipe;
0184   Pipeline<etTotalType> m_etValPlusPipe;
0185   Pipeline<etHadType> m_htValPlusPipe;
0186   Pipeline<etComponentType> m_hxValPlusPipe;
0187   Pipeline<etComponentType> m_hyValPlusPipe;
0188 
0189   Pipeline<etComponentType> m_exVlMinusPipe;
0190   Pipeline<etComponentType> m_eyVlMinusPipe;
0191   Pipeline<etTotalType> m_etVlMinusPipe;
0192   Pipeline<etHadType> m_htVlMinusPipe;
0193   Pipeline<etComponentType> m_hxVlMinusPipe;
0194   Pipeline<etComponentType> m_hyVlMinusPipe;
0195 
0196   // output data
0197   Pipeline<etMissType> m_outputEtMiss;
0198   Pipeline<etMissPhiType> m_outputEtMissPhi;
0199   Pipeline<etTotalType> m_outputEtSum;
0200   Pipeline<etHadType> m_outputEtHad;
0201   Pipeline<etMissType> m_outputHtMiss;
0202   Pipeline<etMissPhiType> m_outputHtMissPhi;
0203 
0204   bool m_setupOk;
0205 };
0206 
0207 std::ostream& operator<<(std::ostream& os, const L1GctGlobalEnergyAlgos& fpga);
0208 
0209 #endif /*L1GCTGLOBALENERGYALGOS_H_*/