Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1GLOBALCALOTRIGGER_H_
0002 #define L1GLOBALCALOTRIGGER_H_
0003 
0004 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0005 #include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
0006 
0007 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0008 
0009 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctUnsignedInt.h"
0010 
0011 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetFinderBase.h"
0012 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetLeafCard.h"
0013 
0014 #include <vector>
0015 
0016 /*!
0017  * \author Jim Brooke
0018  * \date Feb 2006
0019  */
0020 
0021 /*!
0022  * \class L1GlobalCaloTrigger
0023  * \brief Bit-level emulation of the Global Calorimeter Trigger
0024  * 
0025  * 
0026  */
0027 
0028 class L1GctJetLeafCard;
0029 class L1GctJetFinderBase;
0030 class L1GctEmLeafCard;
0031 class L1GctElectronSorter;
0032 
0033 class L1GctWheelJetFpga;
0034 class L1GctWheelEnergyFpga;
0035 class L1GctJetFinalStage;
0036 class L1GctGlobalEnergyAlgos;
0037 class L1GctGlobalHfSumAlgos;
0038 class L1GctElectronFinalSort;
0039 class L1GctJetFinderParams;
0040 class L1GctJetEtCalibrationLut;
0041 class L1GctChannelMask;
0042 class L1CaloEtScale;
0043 
0044 class L1GlobalCaloTrigger {
0045 public:
0046   /// Number of Leaf Cards configured for jet processing
0047   static const int N_JET_LEAF_CARDS;
0048   /// Number of Leaf Cards configured for EM processing
0049   static const int N_EM_LEAF_CARDS;
0050   /// Number of Wheel Cards
0051   static const int N_WHEEL_CARDS;
0052 
0053   /// typedefs for energy values in fixed numbers of bits
0054   typedef L1GctUnsignedInt<L1GctEtTotal::kEtTotalNBits> etTotalType;
0055   typedef L1GctUnsignedInt<L1GctEtHad::kEtHadNBits> etHadType;
0056   typedef L1GctUnsignedInt<L1GctEtMiss::kEtMissNBits> etMissType;
0057   typedef L1GctUnsignedInt<L1GctEtMiss::kEtMissPhiNBits> etMissPhiType;
0058 
0059   typedef L1GctJetFinderBase::lutPtr lutPtr;
0060   typedef L1GctJetFinderBase::lutPtrVector lutPtrVector;
0061 
0062   /// construct the GCT
0063   L1GlobalCaloTrigger(const L1GctJetLeafCard::jetFinderType jfType = L1GctJetLeafCard::hardwareJetFinder,
0064                       unsigned jetLeafMask = 0);
0065 
0066   /// dismantle the GCT
0067   ~L1GlobalCaloTrigger();
0068 
0069   /// Reset internal buffers
0070   void reset();
0071 
0072   /// process an event
0073   void process();
0074 
0075   ///=================================================================================================
0076   /// Configuration options for the GCT
0077   ///
0078   /// Setup the jet finder parameters
0079   void setJetFinderParams(const L1GctJetFinderParams* const jfpars);
0080 
0081   /// setup the Jet Calibration Luts
0082   void setJetEtCalibrationLuts(const lutPtrVector& jfluts);
0083 
0084   /// setup the tau algorithm parameters
0085   void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation);
0086 
0087   /// setup scale for missing Ht
0088   void setHtMissScale(const L1CaloEtScale* const scale);
0089 
0090   /// setup Hf sum LUTs
0091   void setupHfSumLuts(const L1CaloEtScale* const scale);
0092 
0093   /// setup the input channel mask
0094   void setChannelMask(const L1GctChannelMask* const mask);
0095 
0096   ///=================================================================================================
0097   /// Multiple bunch operation
0098   ///
0099   /// set parameters for multiple bunch operation
0100   /// process crossings from (firstBx) to (lastBx)
0101   void setBxRange(const int firstBx, const int lastBx);
0102   /// process crossings from (-numOfBx) to (numOfBx)
0103   void setBxRangeSymmetric(const int numOfBx);
0104   /// process all crossings present in the input (and only those crossings)
0105   void setBxRangeAutomatic();
0106 
0107   /// accessor methods
0108   int getFirstBx() const { return m_bxStart; }
0109   int getLastBx() const { return (m_bxStart + m_numOfBx - 1); }
0110   int getTotalBx() const { return m_numOfBx; }
0111 
0112   ///=================================================================================================
0113   /// Input data set methods
0114   ///
0115   /// Use the following two methods for full emulator operation
0116   /// set jet regions from the RCT at the input to be processed
0117   void fillRegions(const std::vector<L1CaloRegion>& rgn);
0118 
0119   /// set electrons from the RCT at the input to be processed
0120   void fillEmCands(const std::vector<L1CaloEmCand>& rgn);
0121 
0122   /// Other methods for debugging
0123   /// set a jet region at the input to be processed
0124   void setRegion(const L1CaloRegion& region);
0125 
0126   /// construct a jet region and set it at the input to be processed
0127   void setRegion(const unsigned et,
0128                  const unsigned ieta,
0129                  const unsigned iphi,
0130                  const bool overFlow = false,
0131                  const bool fineGrain = true);
0132 
0133   /// set an isolated EM candidate to be processed
0134   void setIsoEm(const L1CaloEmCand& em);
0135 
0136   /// set a non-isolated EM candidate to be processed
0137   void setNonIsoEm(const L1CaloEmCand& em);
0138 
0139   ///=================================================================================================
0140   /// Output data get methods
0141   ///
0142   /// iso electron outputs to GT
0143   L1GctEmCandCollection getIsoElectrons() const;
0144 
0145   /// non-iso electron outputs to GT
0146   L1GctEmCandCollection getNonIsoElectrons() const;
0147 
0148   /// central jet outputs to GT
0149   L1GctJetCandCollection getCentralJets() const;
0150 
0151   /// forward jet outputs to GT
0152   L1GctJetCandCollection getForwardJets() const;
0153 
0154   /// tau jet outputs to GT
0155   L1GctJetCandCollection getTauJets() const;
0156 
0157   /// all jets from jetfinders in raw format
0158   L1GctInternJetDataCollection getInternalJets() const;
0159 
0160   /// Total Et output to GT
0161   L1GctEtTotalCollection getEtSumCollection() const;
0162 
0163   /// Total hadronic Et output to GT
0164   L1GctEtHadCollection getEtHadCollection() const;
0165 
0166   /// Etmiss output to GT
0167   L1GctEtMissCollection getEtMissCollection() const;
0168 
0169   /// Htmiss output to GT
0170   L1GctHtMissCollection getHtMissCollection() const;
0171 
0172   /// Et sums and components in internal format
0173   L1GctInternEtSumCollection getInternalEtSums() const;
0174   L1GctInternHtMissCollection getInternalHtMiss() const;
0175 
0176   // Hf sums output to GT
0177   L1GctHFBitCountsCollection getHFBitCountsCollection() const;
0178   L1GctHFRingEtSumsCollection getHFRingEtSumsCollection() const;
0179 
0180   ///=================================================================================================
0181   /// Access to GCT component processors
0182   ///
0183   /// get the Jet Leaf cards
0184   std::vector<L1GctJetLeafCard*> getJetLeafCards() const { return theJetLeafCards; }
0185 
0186   /// get the Jet Leaf cards
0187   std::vector<L1GctEmLeafCard*> getEmLeafCards() const { return theEmLeafCards; }
0188 
0189   /// get the Wheel Jet FPGAs
0190   std::vector<L1GctWheelJetFpga*> getWheelJetFpgas() const { return theWheelJetFpgas; }
0191 
0192   /// get the Wheel Energy Fpgas
0193   std::vector<L1GctWheelEnergyFpga*> getWheelEnergyFpgas() const { return theWheelEnergyFpgas; }
0194 
0195   /// get the jet final stage
0196   L1GctJetFinalStage* getJetFinalStage() const { return theJetFinalStage; }
0197 
0198   /// get the energy final stage
0199   L1GctGlobalEnergyAlgos* getEnergyFinalStage() const { return theEnergyFinalStage; }
0200 
0201   /// provide access to hf sum processor
0202   L1GctGlobalHfSumAlgos* getHfSumProcessor() const;
0203 
0204   /// get the electron final stage sorters
0205   L1GctElectronFinalSort* getIsoEmFinalStage() const { return theIsoEmFinalStage; }
0206   L1GctElectronFinalSort* getNonIsoEmFinalStage() const { return theNonIsoEmFinalStage; }
0207 
0208   /// get the jetFinder parameters
0209   const L1GctJetFinderParams* getJetFinderParams() const { return m_jetFinderParams; }
0210 
0211   /// get the Jet Et calibration LUT
0212   const lutPtrVector getJetEtCalibLuts() const { return m_jetEtCalLuts; }
0213 
0214   ///=================================================================================================
0215   /// Print method
0216   ///
0217   /// print setup info
0218   void print();
0219 
0220   /// control output messages
0221   void setVerbose();
0222   void setTerse();
0223 
0224 private:
0225   /// Steps in the processing treating input arriving over several bunch crossings
0226   /// Sort the input data by bunch crossing number
0227   void sortInputData();
0228   /// Setup bunch crossing range (depending on input data)
0229   void bxSetup();
0230   /// Partial reset for a new bunch crossing
0231   void bxReset(const int bx);
0232   /// Fill input data for a new bunch crossing
0233   void fillEmCands(std::vector<L1CaloEmCand>::iterator& emc, const int bx);
0234   void fillRegions(std::vector<L1CaloRegion>::iterator& rgn, const int bx);
0235   /// Process a new bunch crossing
0236   void bxProcess(const int bx);
0237 
0238   /// instantiate the hardware & algo objects and wire up the system
0239   void build(L1GctJetLeafCard::jetFinderType jfType, unsigned jetLeafMask);
0240 
0241   /// check we have done all the setup
0242   bool setupOk() const;
0243 
0244   /// ordering of the electron sorters to give the correct
0245   /// priority to the candidates in the final sort
0246   unsigned sorterNo(const L1CaloEmCand& em) const;
0247 
0248   /// to process multiple bunch crossings, we need
0249   /// to select and order input candidates and regions
0250   /// by beam crossing number
0251   template <class T>
0252   struct CompareBx {
0253     bool operator()(const T& i, const T& j) const { return i.bx() < j.bx(); }
0254   };
0255   CompareBx<L1CaloEmCand> emcBxComparator;
0256   CompareBx<L1CaloRegion> rgnBxComparator;
0257 
0258 private:
0259   /// pointers to the Jet Leaf cards
0260   std::vector<L1GctJetLeafCard*> theJetLeafCards;
0261 
0262   /// pointers to the Jet Finders
0263   std::vector<L1GctJetFinderBase*> theJetFinders;
0264 
0265   /// pointers to the EM Leaf cards
0266   std::vector<L1GctEmLeafCard*> theEmLeafCards;
0267 
0268   /// pointers to the electron sorters
0269   std::vector<L1GctElectronSorter*> theIsoElectronSorters;
0270   std::vector<L1GctElectronSorter*> theNonIsoElectronSorters;
0271 
0272   /// Wheel Card Jet Fpgas
0273   std::vector<L1GctWheelJetFpga*> theWheelJetFpgas;
0274 
0275   /// Wheel Card Energy Fpgas
0276   std::vector<L1GctWheelEnergyFpga*> theWheelEnergyFpgas;
0277 
0278   /// jet final stage algo
0279   L1GctJetFinalStage* theJetFinalStage;
0280 
0281   /// energy final stage algos
0282   L1GctGlobalEnergyAlgos* theEnergyFinalStage;
0283 
0284   /// iso electron final stage sorter
0285   L1GctElectronFinalSort* theIsoEmFinalStage;
0286 
0287   /// non-iso electron final stage sorter
0288   L1GctElectronFinalSort* theNonIsoEmFinalStage;
0289 
0290   /// Jetfinder parameters
0291   const L1GctJetFinderParams* m_jetFinderParams;
0292 
0293   /// Jet Et calibration LUT
0294   lutPtrVector m_jetEtCalLuts;
0295 
0296   /// Input channel mask
0297   const L1GctChannelMask* m_inputChannelMask;
0298 
0299   /// Multiple bunch crossing operation
0300   bool m_bxRangeAuto;
0301   int m_bxStart;
0302   int m_numOfBx;
0303 
0304   /// Local copies of input data, sorted by bunch crossing
0305   /// then sent to the processors one bunch crossing at a time
0306   std::vector<L1CaloEmCand> m_allInputEmCands;
0307   std::vector<L1CaloRegion> m_allInputRegions;
0308 };
0309 
0310 #endif /*L1GLOBALCALOTRIGGER_H_*/