Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:40

0001 #ifndef DataFormats_Luminosity_LumiInfo_h
0002 #define DataFormats_Luminosity_LumiInfo_h
0003 
0004 /** 
0005  * \class LumiInfo
0006  *
0007  * LumiInfo has been created by merging the content of
0008  * the old LumiSummary and LumiDetails classes to streamline
0009  * the lumi information. Many old member variables have been
0010  * removed.
0011  * 
0012  *
0013  * \author Valerie Halyo
0014  *         David Dagenhart
0015  *         Zhen Xie
0016  *         Paul Lujan
0017  * \version   1st Version June 7 2007, merged September 10 2014
0018  * \version    October 2017 by Chris Palmer and Sam Higginbotham for PCC projects
0019  * 
0020  *
0021  */
0022 
0023 #include <vector>
0024 #include <iosfwd>
0025 #include <string>
0026 #include "DataFormats/Luminosity/interface/LumiConstants.h"
0027 
0028 class LumiInfo {
0029 public:
0030   /** 
0031      * default constructor
0032      */
0033   LumiInfo() : deadtimeFraction_(0) {
0034     instLumiByBX_.assign(LumiConstants::numBX, 0.0);
0035     instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
0036     totalInstLuminosity_ = 0;
0037     totalInstLumiStatErr_ = 0;
0038   }
0039 
0040   /** 
0041      * constructor with fill; if total algo is the same as summing
0042      */
0043   LumiInfo(float deadtimeFraction, const std::vector<float>& instLumiByBX)
0044       : deadtimeFraction_(deadtimeFraction), instLumiByBX_(instLumiByBX) {
0045     instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
0046     setTotalInstToBXSum();
0047     totalInstLumiStatErr_ = 0;
0048   }
0049 
0050   /** 
0051      * constructor with fill; if total algo DIFFERS from summing
0052      */
0053   LumiInfo(float deadtimeFraction, const std::vector<float>& instLumiByBX, float totalInstLumi)
0054       : deadtimeFraction_(deadtimeFraction), totalInstLuminosity_(totalInstLumi), instLumiByBX_(instLumiByBX) {
0055     instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
0056     totalInstLumiStatErr_ = 0;
0057   }
0058 
0059   /** 
0060      * constructor with fill; if total algo DIFFERS from summing and adding including stats
0061      */
0062   LumiInfo(float deadtimeFraction,
0063            const std::vector<float>& instLumiByBX,
0064            float totalInstLumi,
0065            const std::vector<float>& instLumiErrByBX,
0066            float totalInstLumiErr)
0067       : deadtimeFraction_(deadtimeFraction),
0068         totalInstLuminosity_(totalInstLumi),
0069         totalInstLumiStatErr_(totalInstLumiErr),
0070         instLumiByBX_(instLumiByBX),
0071         instLumiStatErrByBX_(instLumiErrByBX) {}
0072 
0073   /** 
0074      * destructor
0075      */
0076   ~LumiInfo() {}
0077 
0078   //
0079   // all getters
0080   //
0081 
0082   /** 
0083      *  Returns total instantanious luminosity in hz/uB
0084      */
0085   float getTotalInstLumi() const { return totalInstLuminosity_; }
0086   /** 
0087      *  Returns statistical error on total instantanious luminosity in hz/uB
0088      */
0089   float getTotalInstStatError() const { return totalInstLumiStatErr_; }
0090   /** 
0091      *  Returns instantaneous luminosity of all bunches
0092      */
0093   const std::vector<float>& getInstLumiAllBX() const { return instLumiByBX_; }
0094   /** 
0095      * Returns statistical error of instantaneous luminosity for all bunches
0096      */
0097   const std::vector<float>& getErrorLumiAllBX() const { return instLumiStatErrByBX_; }
0098   /** 
0099      *  Returns instantaneous luminosity of one bunch
0100      */
0101   float getInstLumiBX(int bx) const { return instLumiByBX_.at(bx); }
0102   /** 
0103      * Deadtime fraction
0104      */
0105   float getDeadFraction() const { return deadtimeFraction_; }
0106   /** 
0107      * Livetime fraction (1-deadtime frac)
0108      */
0109   float getLiveFraction() const { return 1 - deadtimeFraction_; }
0110 
0111   //
0112   // all setters
0113   //
0114 
0115   /** 
0116      * Set the deadtime fraction
0117      */
0118   void setDeadFraction(float deadtimeFraction) { deadtimeFraction_ = deadtimeFraction; }
0119   /** 
0120      * Set total instantanious luminosity in hz/uB
0121      */
0122   void setTotalInstLumi(float totalLumi) { totalInstLuminosity_ = totalLumi; }
0123   /** 
0124      *  Set statistical error on total instantanious luminosity in hz/uB
0125      */
0126   void setTotalInstStatError(float statError) { totalInstLumiStatErr_ = statError; }
0127   /** 
0128      *  Set statistical error of instantaneous luminosity for all bunches
0129      */
0130   void setInstLumiAllBX(std::vector<float>& instLumiByBX);
0131   /** 
0132      *  Set statistical error of instantaneous luminosity for all bunches
0133      */
0134   void setErrorLumiAllBX(std::vector<float>& errLumiByBX);
0135 
0136   /** 
0137      *  Resets totalInstLuminosity_ to be the sum of instantaneous 
0138      *  luminosity 
0139      */
0140   void setTotalInstToBXSum();
0141 
0142   /** 
0143      *  Returns the sum of the instantaneous luminosity in Hz/uB,
0144      *  which not always the same as totalInstLuminosity_.
0145      */
0146   float instLuminosityBXSum() const;
0147   /** 
0148      * Integrated (delivered) luminosity (in ub^-1)
0149      */
0150   float integLuminosity() const;
0151   /** 
0152      * Recorded (integrated) luminosity (in ub^-1)
0153      * (==integLuminosity * (1-deadtimeFraction))
0154      */
0155   float recordedLuminosity() const;
0156   /** 
0157      * lumi section length in seconds = numorbits*3564*25e-09
0158      */
0159   float lumiSectionLength() const;
0160   /** 
0161      *  This method checks if all the essential values of this LumiInfo are
0162      *  the same as the ones in the LumiInfo given as an argument.
0163      */
0164   bool isProductEqual(LumiInfo const& next) const;
0165 
0166 private:
0167   float deadtimeFraction_;
0168   float totalInstLuminosity_;
0169   float totalInstLumiStatErr_;
0170   std::vector<float> instLumiByBX_;
0171   std::vector<float> instLumiStatErrByBX_;
0172 };
0173 
0174 std::ostream& operator<<(std::ostream& s, const LumiInfo& lumiInfo);
0175 
0176 #endif  // DataFormats_Luminosity_LumiInfo_h