Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:24

0001 #ifndef CondFormats_Luminosity_LumiSectionData_h
0002 #define CondFormats_Luminosity_LumiSectionData_h
0003 /** 
0004  *
0005  * BunchCrossingInfo holds Details information the lumi value, the error on this value 
0006  * and its quality for each bunch crossing (BX) in a given luminosity section (LS)   
0007  * BX definition: There are 3564 bunch crossing (BX) in each LHC orbit 
0008  * each event will occur at one of these BX. BX is defined to be the number of the
0009  * bunch crossing where this event occurred.
0010  *
0011  * $Id: LumiSectionData.h,v 1.2 2009/10/07 14:33:02 xiezhen Exp $
0012  *
0013  ************************************************************/
0014 
0015 #include "CondFormats/Serialization/interface/Serializable.h"
0016 
0017 #include <vector>
0018 #include <string>
0019 
0020 namespace lumi {
0021   static const int BXMIN = 1;
0022   static const int BXMAX = 3564;
0023   static const int LUMIALGOMAX = 3;
0024 
0025   typedef enum { ET = 0, OCCD1 = 1, OCCD2 = 2 } LumiAlgoType;
0026   typedef enum { ALGO = 0, TECH = 1 } TriggerType;
0027 
0028   struct HLTInfo {
0029     HLTInfo() : pathname(""), inputcount(-99), acceptcount(-99), prescale(-99) {}
0030     HLTInfo(const std::string& pathnameIN, int i, int a, int p)
0031         : pathname(pathnameIN), inputcount(i), acceptcount(a), prescale(p) {}
0032     std::string pathname;
0033     int inputcount;
0034     int acceptcount;
0035     int prescale;
0036 
0037     COND_SERIALIZABLE;
0038   };
0039 
0040   struct TriggerInfo {
0041     TriggerInfo() : name(""), triggercount(-99), deadtimecount(-99), prescale(-99) {}
0042     TriggerInfo(const std::string& trgname, int trgcount, int deadcount, int p)
0043         : name(trgname), triggercount(trgcount), deadtimecount(deadcount), prescale(p) {}
0044     std::string name;
0045     int triggercount;
0046     int deadtimecount;  //max 2**20*3564=3737124864, so wrong type
0047     int prescale;
0048 
0049     COND_SERIALIZABLE;
0050   };
0051 
0052   struct BunchCrossingInfo {
0053     BunchCrossingInfo() {}
0054     BunchCrossingInfo(int idx, float value, float err, int quality)
0055         : BXIdx(idx), lumivalue(value), lumierr(err), lumiquality(quality) {}
0056     int BXIdx;  //starting from 1
0057     float lumivalue;
0058     float lumierr;
0059     int lumiquality;
0060 
0061     COND_SERIALIZABLE;
0062   };
0063 
0064   static const BunchCrossingInfo BXNULL = BunchCrossingInfo(-99, -99.0, -99.0, -99);
0065   typedef std::vector<BunchCrossingInfo>::const_iterator BunchCrossingIterator;
0066   typedef std::vector<HLTInfo>::const_iterator HLTIterator;
0067   typedef std::vector<TriggerInfo>::const_iterator TriggerIterator;
0068 
0069   class LumiSectionData {
0070   public:
0071     LumiSectionData();
0072     ~LumiSectionData() {}
0073 
0074   public:
0075     ///
0076     ///getter methods
0077     ///
0078     std::string lumiVersion() const;
0079     int lumisectionID() const;
0080     size_t nBunchCrossing() const;
0081     //radom access to instant LumiAverage
0082     float lumiAverage() const;
0083     float lumiError() const;
0084     float deadFraction() const;
0085     int lumiquality() const;
0086     unsigned long long startorbit() const;
0087     //get bunchCrossingInfo by algorithm
0088     void bunchCrossingInfo(const LumiAlgoType lumialgotype, std::vector<BunchCrossingInfo>& result) const;
0089     //random access to bunchCrossingInfo by bunchcrossing index
0090     const BunchCrossingInfo bunchCrossingInfo(const int BXIndex, const LumiAlgoType lumialgotype) const;
0091     //sequential access to bunchCrossingInfo
0092     BunchCrossingIterator bunchCrossingBegin(const LumiAlgoType lumialgotype) const;
0093     BunchCrossingIterator bunchCrossingEnd(const LumiAlgoType lumialgotype) const;
0094     //total number of HLT paths
0095     size_t nHLTPath() const;
0096     bool HLThasData() const;
0097     HLTIterator hltBegin() const;
0098     HLTIterator hltEnd() const;
0099 
0100     bool TriggerhasData() const;
0101     TriggerIterator trgBegin() const;
0102     TriggerIterator trgEnd() const;
0103 
0104     short qualityFlag() const;
0105     ///
0106     ///setter methods.
0107     ///
0108     void setLumiNull();  //set versionid number to -99, signal no lumi data written.
0109     void setLumiVersion(const std::string& versionid);
0110     void setLumiSectionId(int sectionid);
0111     void setLumiAverage(float lumiavg);
0112     void setLumiQuality(int lumiquality);
0113     void setDeadFraction(float deadfrac);
0114     void setLumiError(float lumierr);
0115     void setStartOrbit(unsigned long long orbtnumber);
0116     void setBunchCrossingData(const std::vector<BunchCrossingInfo>& BXs, const LumiAlgoType algotype);
0117     void setHLTData(const std::vector<HLTInfo>& hltdetail);
0118     void setTriggerData(const std::vector<TriggerInfo>& triggerinfo);
0119     void setQualityFlag(short qualityflag);
0120     void print(std::ostream& s) const;
0121 
0122   private:
0123     std::vector<BunchCrossingInfo> m_bx;  //Lumi detail info sorted by algoright+BX number stored as blob
0124     int m_sectionid;                      //LS id counting from 1 as required by evt. Instead from 0
0125     std::string m_versionid;              //Lumi version
0126     float m_lumiavg;                      //instant lumi , selected from best algo
0127     float m_lumierror;                    //instant lumi err,
0128     short m_quality;                      //use 7 bits PIXEL,STRIP,MUON,HCAL,ECAL,HF,HLX
0129     float m_deadfrac;                     //deadtime fraction
0130     unsigned long long m_startorbit;      //first orbit number of this LS
0131     std::vector<HLTInfo> m_hlt;           //hlt scaler information sorted by hltpath independent of lumiversion
0132     std::vector<TriggerInfo> m_trigger;  //trigger scaler sorted by bit number 128algo+64tech independent of lumiversion
0133 
0134     COND_SERIALIZABLE;
0135   };
0136 }  // namespace lumi
0137 #endif