CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/L1Trigger/GlobalCaloTrigger/interface/L1GctJetFinderBase.h

Go to the documentation of this file.
00001 #ifndef L1GCTJETFINDERBASE_H_
00002 #define L1GCTJETFINDERBASE_H_
00003 
00004 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00005 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEtSum.h"
00006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHtMiss.h"
00007 
00008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctProcessor.h"
00009 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctRegion.h"
00010 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJet.h"
00011 
00012 #include "L1Trigger/GlobalCaloTrigger/src/L1GctUnsignedInt.h"
00013 #include "L1Trigger/GlobalCaloTrigger/src/L1GctJetCount.h"
00014 
00015 #include <boost/cstdint.hpp> //for uint16_t
00016 #include <vector>
00017 
00018 class L1GctInternJetData;
00019 class L1GctJetFinderParams;
00020 class L1GctJetEtCalibrationLut;
00021 class L1GctChannelMask;
00022 class L1CaloRegion;
00023 
00024 
00045 /*
00046  * \author Jim Brooke & Greg Heath
00047  * \date June 2006
00048  */
00049 
00050 class L1GctJetFinderBase : public L1GctProcessor
00051 {
00052 public:
00053   //Typedefs
00054   typedef unsigned long int ULong;
00055   typedef unsigned short int UShort;
00056   typedef std::vector<L1GctRegion>  RegionsVector;
00057   typedef std::vector<L1GctJet>     RawJetVector;
00058   typedef std::vector<L1GctJetCand> JetVector;
00059   typedef Pipeline<L1GctJet>        RawJetPipeline;
00060   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etTotalType;
00061   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etHadType;
00062   typedef L1GctTwosComplement<  L1GctInternEtSum::kJetMissEtNBits > etCompInternJfType;
00063   typedef L1GctTwosComplement< L1GctInternHtMiss::kJetMissHtNBits > htCompInternJfType;
00064 
00065   enum maxValues {
00066     etTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue,
00067     htTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue
00068   };
00069 
00070 
00071   // For HF-based triggers we sum the Et in the two "inner" (large eta) rings;
00072   // and count towers over threshold based on the "fineGrain" bit from the RCT.
00073   // Define a data type to transfer the result of all calculations.
00074   // The results are defined as L1GctJetCount types since they don't have
00075   // a separate overFlow bit. An overflow condition gives value=max.
00076 
00077   struct hfTowerSumsType {
00078 
00079     enum numberOfBits {
00080       kHfEtSumBits = 8,
00081       kHfCountBits = 5
00082     };
00083 
00084     L1GctJetCount< kHfEtSumBits > etSum0;
00085     L1GctJetCount< kHfEtSumBits > etSum1;
00086     L1GctJetCount< kHfCountBits > nOverThreshold0;
00087     L1GctJetCount< kHfCountBits > nOverThreshold1;
00088 
00089     // Define some constructors and an addition operator for our data type
00090     hfTowerSumsType() : etSum0(0), etSum1(0), nOverThreshold0(0), nOverThreshold1(0) {}
00091     hfTowerSumsType(unsigned e0, unsigned e1, unsigned n0, unsigned n1) : 
00092       etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
00093     hfTowerSumsType(L1GctJetCount< kHfEtSumBits > e0,
00094                     L1GctJetCount< kHfEtSumBits > e1,
00095                     L1GctJetCount< kHfCountBits > n0,
00096                     L1GctJetCount< kHfCountBits > n1) : etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
00097 
00098     void reset() { etSum0.reset(); etSum1.reset(); nOverThreshold0.reset(); nOverThreshold1.reset(); }
00099 
00100     hfTowerSumsType operator+(const hfTowerSumsType& rhs) const {
00101       hfTowerSumsType temp( (this->etSum0+rhs.etSum0),
00102                             (this->etSum1+rhs.etSum1),
00103                             (this->nOverThreshold0+rhs.nOverThreshold0),
00104                             (this->nOverThreshold1+rhs.nOverThreshold1) );
00105       return temp;
00106     } 
00107 
00108   };
00109 
00110   typedef L1GctJet::lutPtr lutPtr;
00111   typedef std::vector<lutPtr> lutPtrVector;
00112 
00113   //Statics
00114   static const unsigned int MAX_JETS_OUT;  
00115   static const unsigned int COL_OFFSET;  
00116   static const unsigned int N_JF_PER_WHEEL; 
00117   static const unsigned int N_EXTRA_REGIONS_ETA00; 
00118     
00120   L1GctJetFinderBase(int id);
00121                  
00122   ~L1GctJetFinderBase();
00123    
00125   void setNeighbourJetFinders(std::vector<L1GctJetFinderBase*> neighbours);
00126 
00128   void setJetFinderParams(const L1GctJetFinderParams* jfpars);
00129 
00131   void setJetEtCalibrationLuts(const lutPtrVector& jfluts);
00132 
00134   void setEnergySumMasks(const L1GctChannelMask* chmask);
00135 
00137   void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation) {
00138     m_useImprovedTauAlgo            = useImprovedAlgo;
00139     m_ignoreTauVetoBitsForIsolation = ignoreVetoBitsForIsolation;
00140   }
00141 
00143   bool setupOk() const { return m_idInRange
00144                            && m_gotNeighbourPointers
00145                            && m_gotJetFinderParams
00146                            && m_gotJetEtCalLuts
00147                            && m_gotChannelMask; }
00148 
00150   friend std::ostream& operator << (std::ostream& os, const L1GctJetFinderBase& algo);
00151 
00153   virtual void fetchInput() = 0;
00154 
00156   virtual void process() = 0;
00157 
00159   void setInputRegion(const L1CaloRegion& region);
00160     
00162   RegionsVector getInputRegions() const { return m_inputRegions; }
00163 
00165   RegionsVector getSentProtoJets() const { return m_sentProtoJets; }
00166 
00168   RegionsVector getRcvdProtoJets() const { return m_rcvdProtoJets; }
00169 
00171   RegionsVector getKeptProtoJets() const { return m_keptProtoJets; }
00172 
00174   RawJetVector getRawJets() const { return m_outputJetsPipe.contents; } 
00175 
00177   std::vector< L1GctInternJetData > getInternalJets() const;
00178 
00180   std::vector< L1GctInternEtSum  > getInternalEtSums() const;
00181   std::vector< L1GctInternHtMiss > getInternalHtMiss() const;
00182 
00184   const lutPtrVector getJetEtCalLuts() const { return m_jetEtCalLuts; }
00185 
00186   // The hardware output quantities
00187   JetVector getJets() const { return m_sortedJets; } 
00188   // The hardware output quantities - refactored
00189   etTotalType        getEtSum() const { return m_outputEtSum; }  
00190   etCompInternJfType getExSum() const { return m_outputExSum; }  
00191   etCompInternJfType getEySum() const { return m_outputEySum; }  
00192   etHadType          getHtSum() const { return m_outputHtSum; }  
00193   htCompInternJfType getHxSum() const { return m_outputHxSum; }  
00194   htCompInternJfType getHySum() const { return m_outputHySum; }  
00195 
00196   hfTowerSumsType getHfSums() const { return m_outputHfSums; }  
00197 
00198   // Access to threshold and cut values
00199   unsigned getCenJetSeed() const { return m_CenJetSeed; }
00200   unsigned getFwdJetSeed() const { return m_FwdJetSeed; }
00201   unsigned getTauJetSeed() const { return m_TauJetSeed; }
00202   unsigned getEtaBoundry() const { return m_EtaBoundry; }
00203   unsigned getTauIsolationThreshold() const { return m_tauIsolationThreshold; }
00204   unsigned getHttSumJetThreshold() const { return m_HttSumJetThreshold; }
00205   unsigned getHtmSumJetThreshold() const { return m_HtmSumJetThreshold; }
00206 
00207  protected:
00208 
00210   virtual void resetProcessor();
00211   virtual void resetPipelines();
00212 
00214   virtual void setupObjects();
00215 
00216  protected:
00217 
00219   enum fetchType { TOP, BOT, TOPBOT };
00220 
00222   int m_id;
00223         
00225   std::vector<L1GctJetFinderBase*> m_neighbourJetFinders;
00226   
00228   bool m_idInRange;
00229   
00231   bool m_gotNeighbourPointers;
00232 
00234   bool m_gotJetFinderParams;
00235 
00237   bool m_gotJetEtCalLuts;
00238 
00240   bool m_gotChannelMask;
00241 
00246   bool m_positiveEtaWheel;
00247 
00249   unsigned m_minColThisJf;
00256   unsigned m_CenJetSeed;
00257   unsigned m_FwdJetSeed;
00258   unsigned m_TauJetSeed;
00259   unsigned m_EtaBoundry;
00260 
00262   lutPtrVector m_jetEtCalLuts;
00263 
00265   // If the following parameter is set to false, the tau identification
00266   // is just based on the RCT tau veto bits from the nine regions
00267   bool m_useImprovedTauAlgo;
00268 
00269   // If useImprovedTauAlgo is true, these two parameters affect
00270   // the operation of the algorithm.
00271 
00272   // We can require the tau veto bits to be off in all nine regions,
00273   // or just in the central region.
00274   bool m_ignoreTauVetoBitsForIsolation;
00275     
00276   // In the improved tau algorithm, we require no more than one tower energy to be 
00277   // above the isolation threshold, in the eight regions surrounding the central one. 
00278   unsigned m_tauIsolationThreshold;
00279 
00280   // Thresholds on individual jet energies used in HTT and HTM summing
00281   unsigned m_HttSumJetThreshold;
00282   unsigned m_HtmSumJetThreshold;
00283 
00284   // Masks for restricting the eta range of energy sums
00285   bool m_EttMask[11];
00286   bool m_EtmMask[11];
00287   bool m_HttMask[11];
00288   bool m_HtmMask[11];
00289 
00298   RegionsVector m_inputRegions;
00299 
00301   RegionsVector m_sentProtoJets;
00303   RegionsVector m_rcvdProtoJets;
00305   RegionsVector m_keptProtoJets;
00306 
00308   RawJetVector m_outputJets;
00309   JetVector m_sortedJets;
00310 
00312   etTotalType        m_outputEtSum;
00313   etCompInternJfType m_outputExSum;
00314   etCompInternJfType m_outputEySum;
00315   etHadType          m_outputHtSum;
00316   htCompInternJfType m_outputHxSum;
00317   htCompInternJfType m_outputHySum;
00318 
00319   hfTowerSumsType m_outputHfSums;
00320     
00325   //PROTECTED METHODS
00326   // Return the values of constants that might be changed by different jetFinders.
00327   // Each jetFinder must define the constants as private and copy the
00328   // function definitions below.
00329   virtual unsigned maxRegionsIn() const { return MAX_REGIONS_IN; }
00330   virtual unsigned centralCol0() const { return CENTRAL_COL0; }
00331   virtual unsigned nCols() const { return N_COLS; }
00332 
00335   void fetchProtoJetsFromNeighbour(const fetchType ft);
00337   void sortJets();
00339   void doEnergySums();
00340     
00342   etTotalType calcEtStrip(const UShort strip) const;
00343 
00345   etTotalType calcHtStrip(const UShort strip) const;
00346   
00348   void doEtSums() ;
00349   
00351   void doHtSums() ;
00352   
00354   hfTowerSumsType calcHfSums() const;
00355 
00356  private:
00357 
00359   static const unsigned int MAX_REGIONS_IN; 
00360   static const unsigned int N_COLS;
00361   static const unsigned int CENTRAL_COL0;
00362 
00364   RawJetPipeline m_outputJetsPipe;
00365 
00367   Pipeline< etTotalType        > m_outputEtSumPipe;
00368   Pipeline< etCompInternJfType > m_outputExSumPipe;
00369   Pipeline< etCompInternJfType > m_outputEySumPipe;
00370   Pipeline< etHadType          > m_outputHtSumPipe;
00371   Pipeline< htCompInternJfType > m_outputHxSumPipe;
00372   Pipeline< htCompInternJfType > m_outputHySumPipe;
00373 
00375   template <int kBitsInput, int kBitsOutput>
00376     L1GctTwosComplement<kBitsOutput>
00377     etComponentForJetFinder(const L1GctUnsignedInt<kBitsInput>& etStrip0, const unsigned& fact0,
00378                             const L1GctUnsignedInt<kBitsInput>& etStrip1, const unsigned& fact1);
00379 
00380 
00381 };
00382 
00383 std::ostream& operator << (std::ostream& os, const L1GctJetFinderBase& algo);
00384 
00385 #endif /*L1GCTJETFINDERBASE_H_*/