CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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 L1CaloRegion;
00022 
00023 
00044 /*
00045  * \author Jim Brooke & Greg Heath
00046  * \date June 2006
00047  */
00048 
00049 class L1GctJetFinderBase : public L1GctProcessor
00050 {
00051 public:
00052   //Typedefs
00053   typedef unsigned long int ULong;
00054   typedef unsigned short int UShort;
00055   typedef std::vector<L1GctRegion>  RegionsVector;
00056   typedef std::vector<L1GctJet>     RawJetVector;
00057   typedef std::vector<L1GctJetCand> JetVector;
00058   typedef Pipeline<L1GctJet>        RawJetPipeline;
00059   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etTotalType;
00060   typedef L1GctUnsignedInt<L1GctInternEtSum::kTotEtOrHtNBits> etHadType;
00061   typedef L1GctTwosComplement<  L1GctInternEtSum::kJetMissEtNBits > etCompInternJfType;
00062   typedef L1GctTwosComplement< L1GctInternHtMiss::kJetMissHtNBits > htCompInternJfType;
00063 
00064   enum maxValues {
00065     etTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue,
00066     htTotalMaxValue = L1GctInternEtSum::kTotEtOrHtMaxValue
00067   };
00068 
00069 
00070   // For HF-based triggers we sum the Et in the two "inner" (large eta) rings;
00071   // and count towers over threshold based on the "fineGrain" bit from the RCT.
00072   // Define a data type to transfer the result of all calculations.
00073   // The results are defined as L1GctJetCount types since they don't have
00074   // a separate overFlow bit. An overflow condition gives value=max.
00075 
00076   struct hfTowerSumsType {
00077 
00078     enum numberOfBits {
00079       kHfEtSumBits = 8,
00080       kHfCountBits = 5
00081     };
00082 
00083     L1GctJetCount< kHfEtSumBits > etSum0;
00084     L1GctJetCount< kHfEtSumBits > etSum1;
00085     L1GctJetCount< kHfCountBits > nOverThreshold0;
00086     L1GctJetCount< kHfCountBits > nOverThreshold1;
00087 
00088     // Define some constructors and an addition operator for our data type
00089     hfTowerSumsType() : etSum0(0), etSum1(0), nOverThreshold0(0), nOverThreshold1(0) {}
00090     hfTowerSumsType(unsigned e0, unsigned e1, unsigned n0, unsigned n1) : 
00091       etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
00092     hfTowerSumsType(L1GctJetCount< kHfEtSumBits > e0,
00093                     L1GctJetCount< kHfEtSumBits > e1,
00094                     L1GctJetCount< kHfCountBits > n0,
00095                     L1GctJetCount< kHfCountBits > n1) : etSum0(e0), etSum1(e1), nOverThreshold0(n0), nOverThreshold1(n1) {}
00096 
00097     void reset() { etSum0.reset(); etSum1.reset(); nOverThreshold0.reset(); nOverThreshold1.reset(); }
00098 
00099     hfTowerSumsType operator+(const hfTowerSumsType& rhs) const {
00100       hfTowerSumsType temp( (this->etSum0+rhs.etSum0),
00101                             (this->etSum1+rhs.etSum1),
00102                             (this->nOverThreshold0+rhs.nOverThreshold0),
00103                             (this->nOverThreshold1+rhs.nOverThreshold1) );
00104       return temp;
00105     } 
00106 
00107   };
00108 
00109   typedef L1GctJet::lutPtr lutPtr;
00110   typedef std::vector<lutPtr> lutPtrVector;
00111 
00112   //Statics
00113   static const unsigned int MAX_JETS_OUT;  
00114   static const unsigned int COL_OFFSET;  
00115   static const unsigned int N_JF_PER_WHEEL; 
00116   static const unsigned int N_EXTRA_REGIONS_ETA00; 
00117     
00119   L1GctJetFinderBase(int id);
00120                  
00121   ~L1GctJetFinderBase();
00122    
00124   void setNeighbourJetFinders(std::vector<L1GctJetFinderBase*> neighbours);
00125 
00127   void setJetFinderParams(const L1GctJetFinderParams* jfpars);
00128 
00130   void setJetEtCalibrationLuts(const lutPtrVector& jfluts);
00131 
00133   void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation) {
00134     m_useImprovedTauAlgo            = useImprovedAlgo;
00135     m_ignoreTauVetoBitsForIsolation = ignoreVetoBitsForIsolation;
00136   }
00137 
00139   bool setupOk() const { return m_idInRange
00140                            && m_gotNeighbourPointers
00141                            && m_gotJetFinderParams
00142                            && m_gotJetEtCalLuts; }
00143 
00145   friend std::ostream& operator << (std::ostream& os, const L1GctJetFinderBase& algo);
00146 
00148   virtual void fetchInput() = 0;
00149 
00151   virtual void process() = 0;
00152 
00154   void setInputRegion(const L1CaloRegion& region);
00155     
00157   RegionsVector getInputRegions() const { return m_inputRegions; }
00158 
00160   RegionsVector getSentProtoJets() const { return m_sentProtoJets; }
00161 
00163   RegionsVector getRcvdProtoJets() const { return m_rcvdProtoJets; }
00164 
00166   RegionsVector getKeptProtoJets() const { return m_keptProtoJets; }
00167 
00169   RawJetVector getRawJets() const { return m_outputJetsPipe.contents; } 
00170 
00172   std::vector< L1GctInternJetData > getInternalJets() const;
00173 
00175   std::vector< L1GctInternEtSum  > getInternalEtSums() const;
00176   std::vector< L1GctInternHtMiss > getInternalHtMiss() const;
00177 
00179   const lutPtrVector getJetEtCalLuts() const { return m_jetEtCalLuts; }
00180 
00181   // The hardware output quantities
00182   JetVector getJets() const { return m_sortedJets; } 
00183   // The hardware output quantities - refactored
00184   etTotalType        getEtSum() const { return m_outputEtSum; }  
00185   etCompInternJfType getExSum() const { return m_outputExSum; }  
00186   etCompInternJfType getEySum() const { return m_outputEySum; }  
00187   etHadType          getHtSum() const { return m_outputHtSum; }  
00188   htCompInternJfType getHxSum() const { return m_outputHxSum; }  
00189   htCompInternJfType getHySum() const { return m_outputHySum; }  
00190 
00191   hfTowerSumsType getHfSums() const { return m_outputHfSums; }  
00192 
00193   // Access to threshold and cut values
00194   unsigned getCenJetSeed() const { return m_CenJetSeed; }
00195   unsigned getFwdJetSeed() const { return m_FwdJetSeed; }
00196   unsigned getTauJetSeed() const { return m_TauJetSeed; }
00197   unsigned getEtaBoundry() const { return m_EtaBoundry; }
00198   unsigned getTauIsolationThreshold() const { return m_tauIsolationThreshold; }
00199   unsigned getHttSumJetThreshold() const { return m_HttSumJetThreshold; }
00200   unsigned getHtmSumJetThreshold() const { return m_HtmSumJetThreshold; }
00201 
00202  protected:
00203 
00205   virtual void resetProcessor();
00206   virtual void resetPipelines();
00207 
00209   virtual void setupObjects();
00210 
00211  protected:
00212 
00214   enum fetchType { TOP, BOT, TOPBOT };
00215 
00217   int m_id;
00218         
00220   std::vector<L1GctJetFinderBase*> m_neighbourJetFinders;
00221   
00223   bool m_idInRange;
00224   
00226   bool m_gotNeighbourPointers;
00227 
00229   bool m_gotJetFinderParams;
00230 
00232   bool m_gotJetEtCalLuts;
00233 
00235   unsigned m_CenJetSeed;
00236   unsigned m_FwdJetSeed;
00237   unsigned m_TauJetSeed;
00238   unsigned m_EtaBoundry;
00239 
00241   lutPtrVector m_jetEtCalLuts;
00242 
00244   // If the following parameter is set to false, the tau identification
00245   // is just based on the RCT tau veto bits from the nine regions
00246   bool m_useImprovedTauAlgo;
00247 
00248   // If useImprovedTauAlgo is true, these two parameters affect
00249   // the operation of the algorithm.
00250 
00251   // We can require the tau veto bits to be off in all nine regions,
00252   // or just in the central region.
00253   bool m_ignoreTauVetoBitsForIsolation;
00254     
00255   // In the improved tau algorithm, we require no more than one tower energy to be 
00256   // above the isolation threshold, in the eight regions surrounding the central one. 
00257   unsigned m_tauIsolationThreshold;
00258 
00260   RegionsVector m_inputRegions;
00261 
00263   RegionsVector m_sentProtoJets;
00265   RegionsVector m_rcvdProtoJets;
00267   RegionsVector m_keptProtoJets;
00268 
00270   RawJetVector m_outputJets;
00271   JetVector m_sortedJets;
00272 
00273   unsigned m_HttSumJetThreshold;
00274   unsigned m_HtmSumJetThreshold;
00275 
00277   etTotalType        m_outputEtSum;
00278   etCompInternJfType m_outputExSum;
00279   etCompInternJfType m_outputEySum;
00280   etHadType          m_outputHtSum;
00281   htCompInternJfType m_outputHxSum;
00282   htCompInternJfType m_outputHySum;
00283 
00284   hfTowerSumsType m_outputHfSums;
00285     
00286   //PROTECTED METHODS
00287   // Return the values of constants that might be changed by different jetFinders.
00288   // Each jetFinder must define the constants as private and copy the
00289   // function definitions below.
00290   virtual unsigned maxRegionsIn() const { return MAX_REGIONS_IN; }
00291   virtual unsigned centralCol0() const { return CENTRAL_COL0; }
00292   virtual unsigned nCols() const { return N_COLS; }
00293 
00296   void fetchProtoJetsFromNeighbour(const fetchType ft);
00298   void sortJets();
00300   void doEnergySums();
00301     
00303   etTotalType calcEtStrip(const UShort strip) const;
00304 
00306   etTotalType calcHtStrip(const UShort strip) const;
00307   
00309   void doEtSums() ;
00310   
00312   void doHtSums() ;
00313   
00315   hfTowerSumsType calcHfSums() const;
00316 
00318   unsigned m_minColThisJf;
00319 
00320  private:
00321 
00323   static const unsigned int MAX_REGIONS_IN; 
00324   static const unsigned int N_COLS;
00325   static const unsigned int CENTRAL_COL0;
00326 
00328   RawJetPipeline m_outputJetsPipe;
00329 
00331   Pipeline< etTotalType        > m_outputEtSumPipe;
00332   Pipeline< etCompInternJfType > m_outputExSumPipe;
00333   Pipeline< etCompInternJfType > m_outputEySumPipe;
00334   Pipeline< etHadType          > m_outputHtSumPipe;
00335   Pipeline< htCompInternJfType > m_outputHxSumPipe;
00336   Pipeline< htCompInternJfType > m_outputHySumPipe;
00337 
00339   template <int kBitsInput, int kBitsOutput>
00340     L1GctTwosComplement<kBitsOutput>
00341     etComponentForJetFinder(const L1GctUnsignedInt<kBitsInput>& etStrip0, const unsigned& fact0,
00342                             const L1GctUnsignedInt<kBitsInput>& etStrip1, const unsigned& fact1);
00343 
00344 
00345 };
00346 
00347 std::ostream& operator << (std::ostream& os, const L1GctJetFinderBase& algo);
00348 
00349 #endif /*L1GCTJETFINDERBASE_H_*/