CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DataFormats/Luminosity/interface/LumiDetails.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Luminosity_LumiDetails_h
00002 #define DataFormats_Luminosity_LumiDetails_h
00003 
00015 #include <utility>
00016 #include <vector>
00017 #include <string>
00018 #include <iosfwd>
00019 
00020 class LumiDetails {
00021 public:
00022 
00023   // If in the future additional algorithm names are added,
00024   // it is important that they be added at the end of the list.
00025   // The LumiDetails::algoNames function in LumiDetails.cc also
00026   // would need to be updated to keep the list of names in sync.
00027   enum Algos {
00028     kOCC1,
00029     kOCC2,
00030     kET,
00031     kPLT,
00032     kMaxNumAlgos
00033   };
00034   typedef unsigned int AlgoType;
00035   typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ValueRange;
00036   typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ErrorRange;
00037   typedef std::pair<std::vector<short>::const_iterator, std::vector<short>::const_iterator> QualityRange;
00038 
00039   LumiDetails();
00040   explicit LumiDetails(std::string const& lumiVersion);
00041   ~LumiDetails();
00042 
00043   void setLumiVersion(std::string const& lumiVersion);
00044   std::string const& lumiVersion() const;
00045   bool isValid() const;
00046 
00047   // This will perform more efficiently if the calls to this
00048   // are in the same order as the Algos enumeration.  It will
00049   // work properly even if they are not.
00050   void fill(AlgoType algo,
00051             std::vector<float> const& values,
00052             std::vector<float> const& errors,
00053             std::vector<short> const& qualities);
00054 
00055   void fillBeamIntensities(std::vector<float> const& beam1Intensities,
00056                            std::vector<float> const& beam2Intensities);
00057 
00058   float lumiValue(AlgoType algo, unsigned int bx) const;
00059   float lumiError(AlgoType algo, unsigned int bx) const;
00060   short lumiQuality(AlgoType algo, unsigned int bx) const;
00061   float lumiBeam1Intensity(unsigned int bx) const;
00062   float lumiBeam2Intensity(unsigned int bx) const;
00063 
00064   ValueRange lumiValuesForAlgo(AlgoType algo) const;
00065   ErrorRange lumiErrorsForAlgo(AlgoType algo) const;
00066   QualityRange lumiQualitiesForAlgo(AlgoType algo) const;
00067   std::vector<float> const& lumiBeam1Intensities() const;
00068   std::vector<float> const& lumiBeam2Intensities() const;
00069 
00070   bool isProductEqual(LumiDetails const& lumiDetails) const;
00071 
00072   static std::vector<std::string> const& algoNames();
00073 
00074   static std::vector<std::string> const& dipalgoNames();
00075 
00076 private:
00077 
00078   void checkAlgo(AlgoType algo) const;
00079   void checkAlgoAndBX(AlgoType algo, unsigned int bx) const;
00080 
00081   static std::vector<std::string> m_algoNames;
00082 
00083   std::string m_lumiVersion;
00084 
00085   /* m_algoToFirstIndex is 'kMaxNumAlgos' long. Each algorithm's 
00086      numerical value from the enum Algos is used as the index into m_algoToFirstIndex
00087      to find the first entry into the m_all* vectors containing data for that
00088      algorithm.  The entry beyond the last entry is found by using the numerical value + 1.
00089      If the first and last index are the same then there is no information recorded for that
00090      algorithm.
00091   */
00092   std::vector<unsigned int> m_algoToFirstIndex;
00093   std::vector<float> m_allValues;
00094   std::vector<float> m_allErrors;
00095   std::vector<short> m_allQualities;
00096   std::vector<float> m_beam1Intensities;
00097   std::vector<float> m_beam2Intensities;
00098 };
00099 
00100 std::ostream& operator<<(std::ostream & s, LumiDetails const& lumiDetails);
00101 
00102 #endif