Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:00

0001 #ifndef DataFormats_Luminosity_LumiDetails_h
0002 #define DataFormats_Luminosity_LumiDetails_h
0003 
0004 /** \class LumiDetails
0005  *
0006  *
0007  * LumiDetails holds Details information: the lumi value, the error on this value, 
0008  * its quality, and 2 beam intensities for each bunch crossing (BX) in a given
0009  * luminosity section (LS)   
0010  *
0011  * \author Valerie Halyo, David Dagenhart, created June 7, 2007>
0012  *
0013  ************************************************************/
0014 
0015 #include <utility>
0016 #include <vector>
0017 #include <string>
0018 #include <iosfwd>
0019 
0020 class LumiDetails {
0021 public:
0022   // If in the future additional algorithm names are added,
0023   // it is important that they be added at the end of the list.
0024   // The LumiDetails::algoNames function in LumiDetails.cc also
0025   // would need to be updated to keep the list of names in sync.
0026   enum Algos { kOCC1, kOCC2, kET, kPLT, kMaxNumAlgos };
0027   typedef unsigned int AlgoType;
0028   typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ValueRange;
0029   typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ErrorRange;
0030   typedef std::pair<std::vector<short>::const_iterator, std::vector<short>::const_iterator> QualityRange;
0031 
0032   LumiDetails();
0033   explicit LumiDetails(std::string const& lumiVersion);
0034   ~LumiDetails();
0035 
0036   void setLumiVersion(std::string const& lumiVersion);
0037   std::string const& lumiVersion() const;
0038   bool isValid() const;
0039 
0040   // This will perform more efficiently if the calls to this
0041   // are in the same order as the Algos enumeration.  It will
0042   // work properly even if they are not.
0043   void fill(AlgoType algo,
0044             std::vector<float> const& values,
0045             std::vector<float> const& errors,
0046             std::vector<short> const& qualities);
0047 
0048   void fillBeamIntensities(std::vector<float> const& beam1Intensities, std::vector<float> const& beam2Intensities);
0049 
0050   float lumiValue(AlgoType algo, unsigned int bx) const;
0051   float lumiError(AlgoType algo, unsigned int bx) const;
0052   short lumiQuality(AlgoType algo, unsigned int bx) const;
0053   float lumiBeam1Intensity(unsigned int bx) const;
0054   float lumiBeam2Intensity(unsigned int bx) const;
0055 
0056   ValueRange lumiValuesForAlgo(AlgoType algo) const;
0057   ErrorRange lumiErrorsForAlgo(AlgoType algo) const;
0058   QualityRange lumiQualitiesForAlgo(AlgoType algo) const;
0059   std::vector<float> const& lumiBeam1Intensities() const;
0060   std::vector<float> const& lumiBeam2Intensities() const;
0061 
0062   bool isProductEqual(LumiDetails const& lumiDetails) const;
0063 
0064   static std::vector<std::string> const& algoNames();
0065 
0066   static std::vector<std::string> const& dipalgoNames();
0067 
0068 private:
0069   void checkAlgo(AlgoType algo) const;
0070   void checkAlgoAndBX(AlgoType algo, unsigned int bx) const;
0071 
0072   static std::vector<std::string> const m_algoNames;
0073 
0074   std::string m_lumiVersion;
0075 
0076   /* m_algoToFirstIndex is 'kMaxNumAlgos' long. Each algorithm's 
0077      numerical value from the enum Algos is used as the index into m_algoToFirstIndex
0078      to find the first entry into the m_all* vectors containing data for that
0079      algorithm.  The entry beyond the last entry is found by using the numerical value + 1.
0080      If the first and last index are the same then there is no information recorded for that
0081      algorithm.
0082   */
0083   std::vector<unsigned int> m_algoToFirstIndex;
0084   std::vector<float> m_allValues;
0085   std::vector<float> m_allErrors;
0086   std::vector<short> m_allQualities;
0087   std::vector<float> m_beam1Intensities;
0088   std::vector<float> m_beam2Intensities;
0089 };
0090 
0091 std::ostream& operator<<(std::ostream& s, LumiDetails const& lumiDetails);
0092 
0093 #endif