Algos

LumiDetails

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
#ifndef DataFormats_Luminosity_LumiDetails_h
#define DataFormats_Luminosity_LumiDetails_h

/** \class LumiDetails
 *
 *
 * LumiDetails holds Details information: the lumi value, the error on this value, 
 * its quality, and 2 beam intensities for each bunch crossing (BX) in a given
 * luminosity section (LS)   
 *
 * \author Valerie Halyo, David Dagenhart, created June 7, 2007>
 *
 ************************************************************/

#include <utility>
#include <vector>
#include <string>
#include <iosfwd>

class LumiDetails {
public:
  // If in the future additional algorithm names are added,
  // it is important that they be added at the end of the list.
  // The LumiDetails::algoNames function in LumiDetails.cc also
  // would need to be updated to keep the list of names in sync.
  enum Algos { kOCC1, kOCC2, kET, kPLT, kMaxNumAlgos };
  typedef unsigned int AlgoType;
  typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ValueRange;
  typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ErrorRange;
  typedef std::pair<std::vector<short>::const_iterator, std::vector<short>::const_iterator> QualityRange;

  LumiDetails();
  explicit LumiDetails(std::string const& lumiVersion);
  ~LumiDetails();

  void setLumiVersion(std::string const& lumiVersion);
  std::string const& lumiVersion() const;
  bool isValid() const;

  // This will perform more efficiently if the calls to this
  // are in the same order as the Algos enumeration.  It will
  // work properly even if they are not.
  void fill(AlgoType algo,
            std::vector<float> const& values,
            std::vector<float> const& errors,
            std::vector<short> const& qualities);

  void fillBeamIntensities(std::vector<float> const& beam1Intensities, std::vector<float> const& beam2Intensities);

  float lumiValue(AlgoType algo, unsigned int bx) const;
  float lumiError(AlgoType algo, unsigned int bx) const;
  short lumiQuality(AlgoType algo, unsigned int bx) const;
  float lumiBeam1Intensity(unsigned int bx) const;
  float lumiBeam2Intensity(unsigned int bx) const;

  ValueRange lumiValuesForAlgo(AlgoType algo) const;
  ErrorRange lumiErrorsForAlgo(AlgoType algo) const;
  QualityRange lumiQualitiesForAlgo(AlgoType algo) const;
  std::vector<float> const& lumiBeam1Intensities() const;
  std::vector<float> const& lumiBeam2Intensities() const;

  bool isProductEqual(LumiDetails const& lumiDetails) const;

  static std::vector<std::string> const& algoNames();

  static std::vector<std::string> const& dipalgoNames();

private:
  void checkAlgo(AlgoType algo) const;
  void checkAlgoAndBX(AlgoType algo, unsigned int bx) const;

  static std::vector<std::string> const m_algoNames;

  std::string m_lumiVersion;

  /* m_algoToFirstIndex is 'kMaxNumAlgos' long. Each algorithm's 
     numerical value from the enum Algos is used as the index into m_algoToFirstIndex
     to find the first entry into the m_all* vectors containing data for that
     algorithm.  The entry beyond the last entry is found by using the numerical value + 1.
     If the first and last index are the same then there is no information recorded for that
     algorithm.
  */
  std::vector<unsigned int> m_algoToFirstIndex;
  std::vector<float> m_allValues;
  std::vector<float> m_allErrors;
  std::vector<short> m_allQualities;
  std::vector<float> m_beam1Intensities;
  std::vector<float> m_beam2Intensities;
};

std::ostream& operator<<(std::ostream& s, LumiDetails const& lumiDetails);

#endif