Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:49

0001 #ifndef L1GCTJETFINDERBASE_H_
0002 #define L1GCTJETFINDERBASE_H_
0003 
0004 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0005 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEtSum.h"
0006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHtMiss.h"
0007 
0008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctProcessor.h"
0009 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctRegion.h"
0010 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJet.h"
0011 
0012 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctUnsignedInt.h"
0013 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetCount.h"
0014 
0015 #include <vector>
0016 
0017 class L1GctInternJetData;
0018 class L1GctJetFinderParams;
0019 class L1GctJetEtCalibrationLut;
0020 class L1GctChannelMask;
0021 class L1CaloRegion;
0022 
0023 /*! \class L1GctJetFinderBase
0024  * \brief Base class to allow implementation of jetFinder algorithms
0025  *
0026  *  The base class defines the reset() method, setXxx() and getXxx() methods.
0027  *  Individual jetFinders must define the fetchInput() and process() methods,
0028  *  using protected methods of the base class where necessary.
0029  *
0030  *  The jetFinder looks for jets over a 2x11 search area. Its 
0031  *  input region are pushed in from the appropriate (phi, eta) range,
0032  *  including across the eta=0 boundary between Wheels. The input regions
0033  *  are copied into a vector of dimension N_COLS*COL_OFFSET.
0034  *
0035  *  The array of input regions is filled in a certain order with respect
0036  *  to the index i: 
0037  * 
0038  *  The jetFinder can also pull in "proto-jets" from adjacent jetFinders.
0039  *  If required by the algorithm, these must be calculated in the
0040  *  fetchInput() method;
0041  * 
0042  */
0043 /*
0044  * \author Jim Brooke & Greg Heath
0045  * \date June 2006
0046  */
0047 
0048 class L1GctJetFinderBase : public L1GctProcessor {
0049 public:
0050   //Typedefs
0051   typedef unsigned long int ULong;
0052   typedef unsigned short int UShort;
0053   typedef std::vector<L1GctRegion> RegionsVector;
0054   typedef std::vector<L1GctJet> RawJetVector;
0055   typedef std::vector<L1GctJetCand> JetVector;
0056   typedef Pipeline<L1GctJet> RawJetPipeline;
0057   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etTotalType;
0058   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etHadType;
0059   typedef L1GctTwosComplement<L1GctInternEtSum::kJetMissEtNBits> etCompInternJfType;
0060   typedef L1GctTwosComplement<L1GctInternHtMiss::kJetMissHtNBits> htCompInternJfType;
0061 
0062   enum maxValues {
0063     etTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue,
0064     htTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue
0065   };
0066 
0067   // For HF-based triggers we sum the Et in the two "inner" (large eta) rings;
0068   // and count towers over threshold based on the "fineGrain" bit from the RCT.
0069   // Define a data type to transfer the result of all calculations.
0070   // The results are defined as L1GctJetCount types since they don't have
0071   // a separate overFlow bit. An overflow condition gives value=max.
0072 
0073   struct hfTowerSumsType {
0074     enum numberOfBits { kHfEtSumBits = 8, kHfCountBits = 5 };
0075 
0076     L1GctJetCount<kHfEtSumBits> etSum0;
0077     L1GctJetCount<kHfEtSumBits> etSum1;
0078     L1GctJetCount<kHfCountBits> nOverThreshold0;
0079     L1GctJetCount<kHfCountBits> nOverThreshold1;
0080 
0081     // Define some constructors and an addition operator for our data type
0082     hfTowerSumsType() : etSum0(0), etSum1(0), nOverThreshold0(0), nOverThreshold1(0) {}
0083     hfTowerSumsType(unsigned e0, unsigned e1, unsigned n0, unsigned n1)
0084         : etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
0085     hfTowerSumsType(L1GctJetCount<kHfEtSumBits> e0,
0086                     L1GctJetCount<kHfEtSumBits> e1,
0087                     L1GctJetCount<kHfCountBits> n0,
0088                     L1GctJetCount<kHfCountBits> n1)
0089         : etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
0090 
0091     void reset() {
0092       etSum0.reset();
0093       etSum1.reset();
0094       nOverThreshold0.reset();
0095       nOverThreshold1.reset();
0096     }
0097 
0098     hfTowerSumsType operator+(const hfTowerSumsType& rhs) const {
0099       hfTowerSumsType temp((this->etSum0 + rhs.etSum0),
0100                            (this->etSum1 + rhs.etSum1),
0101                            (this->nOverThreshold0 + rhs.nOverThreshold0),
0102                            (this->nOverThreshold1 + rhs.nOverThreshold1));
0103       return temp;
0104     }
0105   };
0106 
0107   typedef L1GctJet::lutPtr lutPtr;
0108   typedef std::vector<lutPtr> lutPtrVector;
0109 
0110   //Statics
0111   static const unsigned int MAX_JETS_OUT;    ///< Max of 6 jets found per jetfinder in a 2*11 search area.
0112   static const unsigned int COL_OFFSET;      ///< The index offset between columns
0113   static const unsigned int N_JF_PER_WHEEL;  ///< No of jetFinders per Wheel
0114   static const unsigned int
0115       N_EXTRA_REGIONS_ETA00;  ///< Number of additional regions to process on the "wrong" side of eta=0 (determines COL_OFFSET)
0116 
0117   /// id is 0-8 for -ve Eta jetfinders, 9-17 for +ve Eta, for increasing Phi.
0118   L1GctJetFinderBase(int id);
0119 
0120   ~L1GctJetFinderBase() override;
0121 
0122   /// Set pointers to neighbours - needed to complete the setup
0123   void setNeighbourJetFinders(const std::vector<L1GctJetFinderBase*>& neighbours);
0124 
0125   /// Set pointer to parameters - needed to complete the setup
0126   void setJetFinderParams(const L1GctJetFinderParams* jfpars);
0127 
0128   /// Set pointer to calibration Lut - needed to complete the setup
0129   void setJetEtCalibrationLuts(const lutPtrVector& jfluts);
0130 
0131   /// Set masks for energy summing
0132   void setEnergySumMasks(const L1GctChannelMask* chmask);
0133 
0134   /// Setup the tau algorithm parameters
0135   void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation) {
0136     m_useImprovedTauAlgo = useImprovedAlgo;
0137     m_ignoreTauVetoBitsForIsolation = ignoreVetoBitsForIsolation;
0138   }
0139 
0140   /// Check setup is Ok
0141   bool setupOk() const {
0142     return m_idInRange && m_gotNeighbourPointers && m_gotJetFinderParams && m_gotJetEtCalLuts && m_gotChannelMask;
0143   }
0144 
0145   /// Overload << operator
0146   friend std::ostream& operator<<(std::ostream& os, const L1GctJetFinderBase& algo);
0147 
0148   /// get input data from sources; to be filled in by derived jetFinders
0149   void fetchInput() override = 0;
0150 
0151   /// process the data, fill output buffers; to be filled in by derived jetFinders
0152   void process() override = 0;
0153 
0154   /// Set input data
0155   void setInputRegion(const L1CaloRegion& region);
0156 
0157   /// Return input data
0158   RegionsVector getInputRegions() const { return m_inputRegions; }
0159 
0160   /// get protoJets sent to neighbour
0161   RegionsVector getSentProtoJets() const { return m_sentProtoJets; }
0162 
0163   /// get protoJets received from neighbour
0164   RegionsVector getRcvdProtoJets() const { return m_rcvdProtoJets; }
0165 
0166   /// get protoJets kept
0167   RegionsVector getKeptProtoJets() const { return m_keptProtoJets; }
0168 
0169   /// get output jets in raw format
0170   RawJetVector getRawJets() const { return m_outputJetsPipe.contents; }
0171 
0172   /// get output jets in raw format - to be stored in the event
0173   std::vector<L1GctInternJetData> getInternalJets() const;
0174 
0175   /// get et sums in raw format - to be stored in the event
0176   std::vector<L1GctInternEtSum> getInternalEtSums() const;
0177   std::vector<L1GctInternHtMiss> getInternalHtMiss() const;
0178 
0179   /// Return pointers to calibration LUTs
0180   const lutPtrVector getJetEtCalLuts() const { return m_jetEtCalLuts; }
0181 
0182   // The hardware output quantities
0183   JetVector getJets() const { return m_sortedJets; }  ///< Get the located jets.
0184   // The hardware output quantities - refactored
0185   etTotalType getEtSum() const { return m_outputEtSum; }  ///< Get the scalar sum of Et summed over the input regions
0186   etCompInternJfType getExSum() const {
0187     return m_outputExSum;
0188   }  ///< Get the x component of vector Et summed over the input regions
0189   etCompInternJfType getEySum() const {
0190     return m_outputEySum;
0191   }  ///< Get the y component of vector Et summed over the input regions
0192   etHadType getHtSum() const { return m_outputHtSum; }  ///< Get the scalar sum of Ht summed over jets above threshold
0193   htCompInternJfType getHxSum() const {
0194     return m_outputHxSum;
0195   }  ///< Get the x component of vector Ht summed over jets above threshold
0196   htCompInternJfType getHySum() const {
0197     return m_outputHySum;
0198   }  ///< Get the y component of vector Ht summed over jets above threshold
0199 
0200   hfTowerSumsType getHfSums() const {
0201     return m_outputHfSums;
0202   }  ///< Get the Hf tower Et sums and tower-over-threshold counts
0203 
0204   // Access to threshold and cut values
0205   unsigned getCenJetSeed() const { return m_CenJetSeed; }
0206   unsigned getFwdJetSeed() const { return m_FwdJetSeed; }
0207   unsigned getTauJetSeed() const { return m_TauJetSeed; }
0208   unsigned getEtaBoundry() const { return m_EtaBoundry; }
0209   unsigned getTauIsolationThreshold() const { return m_tauIsolationThreshold; }
0210   unsigned getHttSumJetThreshold() const { return m_HttSumJetThreshold; }
0211   unsigned getHtmSumJetThreshold() const { return m_HtmSumJetThreshold; }
0212 
0213 protected:
0214   /// Separate reset methods for the processor itself and any data stored in pipelines
0215   void resetProcessor() override;
0216   void resetPipelines() override;
0217 
0218   /// Initialise inputs with null objects for the correct bunch crossing if required
0219   void setupObjects() override;
0220 
0221 protected:
0222   /// different ways of getting the neighbour data
0223   enum fetchType { TOP, BOT, TOPBOT };
0224 
0225   /// algo ID
0226   int m_id;
0227 
0228   /// Store neighbour pointers
0229   std::vector<L1GctJetFinderBase*> m_neighbourJetFinders;
0230 
0231   /// Remember whether range check on the input ID was ok
0232   bool m_idInRange;
0233 
0234   /// Remember whether the neighbour pointers have been stored
0235   bool m_gotNeighbourPointers;
0236 
0237   /// Remember whether jetfinder parameters have been stored
0238   bool m_gotJetFinderParams;
0239 
0240   /// Remember whether jet Et calibration Lut pointers have been stored
0241   bool m_gotJetEtCalLuts;
0242 
0243   /// Remember whether channel mask have been stored
0244   bool m_gotChannelMask;
0245 
0246   ///
0247   /// *** Geometry parameters ***
0248   ///
0249   /// Positive/negative eta flag
0250   bool m_positiveEtaWheel;
0251 
0252   /// parameter to determine which Regions belong in our acceptance
0253   unsigned m_minColThisJf;
0254   ///
0255   ///---------------------------------------------------------------------------------------
0256   ///
0257   /// *** Setup parameters for this jetfinder instance ***
0258   ///
0259   /// jetFinder parameters (from EventSetup)
0260   unsigned m_CenJetSeed;
0261   unsigned m_FwdJetSeed;
0262   unsigned m_TauJetSeed;
0263   unsigned m_EtaBoundry;
0264 
0265   /// Jet Et Conversion LUT pointer
0266   lutPtrVector m_jetEtCalLuts;
0267 
0268   /// Setup parameters for the tau jet algorithm
0269   // If the following parameter is set to false, the tau identification
0270   // is just based on the RCT tau veto bits from the nine regions
0271   bool m_useImprovedTauAlgo;
0272 
0273   // If useImprovedTauAlgo is true, these two parameters affect
0274   // the operation of the algorithm.
0275 
0276   // We can require the tau veto bits to be off in all nine regions,
0277   // or just in the central region.
0278   bool m_ignoreTauVetoBitsForIsolation;
0279 
0280   // In the improved tau algorithm, we require no more than one tower energy to be
0281   // above the isolation threshold, in the eight regions surrounding the central one.
0282   unsigned m_tauIsolationThreshold;
0283 
0284   // Thresholds on individual jet energies used in HTT and HTM summing
0285   unsigned m_HttSumJetThreshold;
0286   unsigned m_HtmSumJetThreshold;
0287 
0288   // Masks for restricting the eta range of energy sums
0289   bool m_EttMask[11];
0290   bool m_EtmMask[11];
0291   bool m_HttMask[11];
0292   bool m_HtmMask[11];
0293 
0294   ///
0295   /// *** End of setup parameters ***
0296   ///
0297   ///---------------------------------------------------------------------------------------
0298   ///
0299   /// *** Start of event data ***
0300   ///
0301   /// input data required for jet finding
0302   RegionsVector m_inputRegions;
0303 
0304   /// List of pre-clustered jets to be sent to neighbour after the first stage of clustering
0305   RegionsVector m_sentProtoJets;
0306   /// List of pre-clustered jets received from neighbour before the final stage of clustering
0307   RegionsVector m_rcvdProtoJets;
0308   /// List of pre-clustered jets retained locally as input to the final clustering
0309   RegionsVector m_keptProtoJets;
0310 
0311   /// output jets
0312   RawJetVector m_outputJets;
0313   JetVector m_sortedJets;
0314 
0315   /// output Et strip sums and Ht - refactored
0316   etTotalType m_outputEtSum;
0317   etCompInternJfType m_outputExSum;
0318   etCompInternJfType m_outputEySum;
0319   etHadType m_outputHtSum;
0320   htCompInternJfType m_outputHxSum;
0321   htCompInternJfType m_outputHySum;
0322 
0323   hfTowerSumsType m_outputHfSums;
0324 
0325   ///
0326   /// *** End of event data ***
0327   ///
0328   ///---------------------------------------------------------------------------------------
0329   //PROTECTED METHODS
0330   // Return the values of constants that might be changed by different jetFinders.
0331   // Each jetFinder must define the constants as private and copy the
0332   // function definitions below.
0333   virtual unsigned maxRegionsIn() const { return MAX_REGIONS_IN; }
0334   virtual unsigned centralCol0() const { return CENTRAL_COL0; }
0335   virtual unsigned nCols() const { return N_COLS; }
0336 
0337   /// Helper functions for the fetchInput() and process() methods
0338   /// fetch the protoJets from neighbour jetFinder
0339   void fetchProtoJetsFromNeighbour(const fetchType ft);
0340   /// Sort the found jets. All jetFinders should call this in process().
0341   void sortJets();
0342   /// Fill the Et strip sums and Ht sum. All jetFinders should call this in process().
0343   void doEnergySums();
0344 
0345   /// Calculates total (raw) energy in a phi strip
0346   etTotalType calcEtStrip(const UShort strip) const;
0347 
0348   /// Calculates total calibrated energy in jets (Ht) sum
0349   etTotalType calcHtStrip(const UShort strip) const;
0350 
0351   /// Calculates scalar and vector sum of Et over input regions
0352   void doEtSums();
0353 
0354   /// Calculates scalar and vector sum of Ht over calibrated jets
0355   void doHtSums();
0356 
0357   /// Calculates Et sum and number of towers over threshold in Hf
0358   hfTowerSumsType calcHfSums() const;
0359 
0360 private:
0361   /// The real jetFinders must define these constants
0362   static const unsigned int MAX_REGIONS_IN;  ///< Dependent on number of rows and columns.
0363   static const unsigned int N_COLS;
0364   static const unsigned int CENTRAL_COL0;
0365 
0366   /// Output jets "pipeline memory" for checking
0367   RawJetPipeline m_outputJetsPipe;
0368 
0369   /// "Pipeline memories" for energy sums
0370   Pipeline<etTotalType> m_outputEtSumPipe;
0371   Pipeline<etCompInternJfType> m_outputExSumPipe;
0372   Pipeline<etCompInternJfType> m_outputEySumPipe;
0373   Pipeline<etHadType> m_outputHtSumPipe;
0374   Pipeline<htCompInternJfType> m_outputHxSumPipe;
0375   Pipeline<htCompInternJfType> m_outputHySumPipe;
0376 
0377   /// Private method for calculating MEt and MHt components
0378   template <int kBitsInput, int kBitsOutput>
0379   L1GctTwosComplement<kBitsOutput> etComponentForJetFinder(const L1GctUnsignedInt<kBitsInput>& etStrip0,
0380                                                            const unsigned& fact0,
0381                                                            const L1GctUnsignedInt<kBitsInput>& etStrip1,
0382                                                            const unsigned& fact1);
0383 };
0384 
0385 std::ostream& operator<<(std::ostream& os, const L1GctJetFinderBase& algo);
0386 
0387 #endif /*L1GCTJETFINDERBASE_H_*/