Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef GCTTESTENERGYALGOS_H_
0002 #define GCTTESTENERGYALGOS_H_
0003 
0004 /*!
0005  * \class gctTestEnergyAlgos
0006  * \brief Test of the wheel card and final stage energy summing
0007  * 
0008  * Energy sum test functionality migrated from standalone test programs
0009  *
0010  * \author Greg Heath
0011  * \date March 2007
0012  *
0013  */
0014 
0015 #include <vector>
0016 #include <fstream>
0017 #include <stdint.h>
0018 
0019 class L1GlobalCaloTrigger;
0020 class L1CaloRegion;
0021 
0022 class L1GctChannelMask;
0023 
0024 class gctTestEnergyAlgos {
0025 public:
0026   // structs and typedefs
0027   struct etmiss_vec {
0028     unsigned mag;
0029     unsigned phi;
0030   };
0031 
0032   // Constructor and destructor
0033   gctTestEnergyAlgos();
0034   ~gctTestEnergyAlgos();
0035 
0036   /// Load another event into the gct. Overloaded for the various ways of doing this.
0037   std::vector<L1CaloRegion> loadEvent(L1GlobalCaloTrigger*& gct, const bool simpleEvent, const int16_t bx);
0038   std::vector<L1CaloRegion> loadEvent(L1GlobalCaloTrigger*& gct,
0039                                       const std::string& fileName,
0040                                       bool& endOfFile,
0041                                       const int16_t bx);
0042   std::vector<L1CaloRegion> loadEvent(L1GlobalCaloTrigger*& gct,
0043                                       const std::vector<L1CaloRegion>& inputRegions,
0044                                       const int16_t bx);
0045 
0046   /// Set array sizes for the number of bunch crossings
0047   void setBxRange(const int bxStart, const int numOfBx);
0048 
0049   /// Check the energy sums algorithms
0050   bool checkEnergySums(const L1GlobalCaloTrigger* gct) const;
0051 
0052   /// Load setup information
0053   void configure(const L1GctChannelMask* mask) { m_chanMask = mask; }
0054 
0055 private:
0056   // FUNCTION PROTOTYPES FOR EVENT GENERATION
0057   /// Generates test data for missing Et as 2-vector (magnitude, direction)
0058   etmiss_vec randomMissingEtVector() const;
0059   /// Generates test data consisting of energies to be added together with their sum
0060   std::vector<unsigned> randomTestData(const int size, const unsigned max) const;
0061   /// Loads test input regions from a text file.
0062   L1CaloRegion nextRegionFromFile(const unsigned ieta, const unsigned iphi, const int16_t bx);
0063 
0064   /// Sends input regions to the gct and remembers strip sums for checking
0065   void loadInputRegions(L1GlobalCaloTrigger*& gct, const std::vector<L1CaloRegion>& inputRegions, const int16_t bx);
0066 
0067   //=========================================================================
0068 
0069   //
0070   // FUNCTION PROTOTYPES FOR ENERGY SUM CHECKING
0071   /// Integer calculation of Ex or Ey from magnitude for a given pair of phi bins
0072   int etComponent(const unsigned Emag0, const unsigned fact0, const unsigned Emag1, const unsigned fact1) const;
0073   /// Calculate et vector from ex and ey, using floating arithmetic and conversion back to integer
0074   etmiss_vec trueMissingEt(const int ex, const int ey) const;
0075   //=========================================================================
0076 
0077   // Required setup information
0078   const L1GctChannelMask* m_chanMask;
0079 
0080   int m_bxStart;
0081   int m_numOfBx;
0082 
0083   std::vector<unsigned> etStripSums;
0084   std::vector<bool> inMinusOvrFlow;
0085   std::vector<bool> inPlusOverFlow;
0086 
0087   std::ifstream regionEnergyMapInputFile;
0088 };
0089 
0090 #endif /*GCTTEST_H_*/