Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1GCTELECTRONSORTER_H_
0002 #define L1GCTELECTRONSORTER_H_
0003 
0004 #include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
0005 
0006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
0007 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctProcessor.h"
0008 
0009 #include <vector>
0010 
0011 /*!
0012  * \Class L1GctElectronSorter
0013  * \brief Class that sorts electron candidates
0014  *
0015  * This class can be constructed to sort iso or non-iso
0016  * electron candidates.
0017  * The electrons are sorted in ascending order and the 4
0018  * highest in rank will be returned.
0019  * It represents the 1st stage sorter FPGA's on the electron
0020  * leaf cards.
0021  *
0022  * \author  Maria Hansen
0023  * \date    21/04/06
0024  */
0025 
0026 class L1GctElectronSorter : public L1GctProcessor {
0027 public:
0028   /// Data type to associate each electron candidate with
0029   /// a priority based on its position in the sorting tree.
0030   /// Priority is used (as in the hardware) to decide which
0031   /// electron is preferred when they have equal rank.
0032 
0033   struct prioritisedEmCand {
0034     L1GctEmCand emCand;
0035     unsigned short priority;
0036 
0037     // Define some constructors
0038     prioritisedEmCand() : emCand(), priority(0) {}
0039     prioritisedEmCand(L1GctEmCand& c, unsigned short p) : emCand(c), priority(p) {}
0040     prioritisedEmCand(L1CaloEmCand& c, unsigned short p) : emCand(c), priority(p) {}
0041 
0042     // Enable some methods
0043     unsigned rank() const { return emCand.rank(); }
0044   };
0045 
0046   /// comparison operator for sort, used here and in the ElectronFinalSort
0047   /// Candidates of equal rank are sorted by priority, with the lower value given precedence
0048   static bool rankByGt(const prioritisedEmCand& x, const prioritisedEmCand& y) {
0049     return (x.rank() > y.rank() || ((x.rank() == y.rank()) && (x.priority < y.priority)));
0050   }
0051 
0052   /// constructor; set type (isolated or non-isolated)
0053   L1GctElectronSorter(int nInputs, bool iso);
0054   ///
0055   ~L1GctElectronSorter() override;
0056   ///
0057   /// get input data from sources
0058   void fetchInput() override;
0059   ///
0060   /// process the data, fill output buffers
0061   void process() override;
0062   ///
0063   /// set input candidate
0064   void setInputEmCand(const L1CaloEmCand& cand);
0065   ///
0066   /// get input candidates
0067   inline std::vector<L1CaloEmCand> getInputCands() { return m_inputCands; }
0068   ///
0069   /// get output candidates
0070   inline std::vector<L1GctEmCand> getOutputCands() { return m_outputCands; }
0071   ///
0072   /// overload of cout operator
0073   friend std::ostream& operator<<(std::ostream& s, const L1GctElectronSorter& card);
0074 
0075 protected:
0076   /// Separate reset methods for the processor itself and any data stored in pipelines
0077   void resetProcessor() override;
0078   void resetPipelines() override {}
0079 
0080   /// Initialise inputs with null objects for the correct bunch crossing if required
0081   void setupObjects() override;
0082 
0083 private:
0084   ///
0085   /// algo ID (is it FPGA 1 or 2 processing)
0086   int m_id;
0087   ///
0088   /// type of electron to sort (isolated = 0 or non isolated = 1)
0089   bool m_isolation;
0090   ///
0091   /// input data
0092   std::vector<L1CaloEmCand> m_inputCands;
0093   ///
0094   /// output data
0095   std::vector<L1GctEmCand> m_outputCands;
0096 };
0097 
0098 std::ostream& operator<<(std::ostream& s, const L1GctElectronSorter& card);
0099 #endif /*L1GCTELECTRONSORTER_H_*/