Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:56

0001 #ifndef BEAMSPOTONLINEOBJECTS_H
0002 #define BEAMSPOTONLINEOBJECTS_H
0003 /** \class BeamSpotOnlineObjects
0004  *
0005  * Class inheriting from BeamSpotObjects. 
0006  * New members of the class:
0007  *  - lastAnalyzedLumi : last lumisection analyzed
0008  *  - lastAnalyzedRun  : run of the last analyzed lumisection
0009  *  - lastAnalyzedFill : fill of the last analyzed lumisection
0010  *
0011  * \author Francisco Brivio, Milano-Bicocca (francesco.brivio@cern.ch)
0012  *
0013  */
0014 
0015 #include "CondFormats/Serialization/interface/Serializable.h"
0016 #include "CondFormats/Common/interface/Time.h"
0017 #include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
0018 
0019 #include <cmath>
0020 #include <sstream>
0021 #include <cstring>
0022 #include <vector>
0023 #include <string>
0024 
0025 class BeamSpotOnlineObjects : public BeamSpotObjects {
0026 public:
0027   /// default constructor
0028   BeamSpotOnlineObjects() {
0029     lastAnalyzedLumi_ = 0;
0030     lastAnalyzedRun_ = 0;
0031     lastAnalyzedFill_ = 0;
0032     intParams_.resize(ISIZE, std::vector<int>(1, 0));
0033     floatParams_.resize(FSIZE, std::vector<float>(1, 0.0));
0034     stringParams_.resize(SSIZE, std::vector<std::string>(1, ""));
0035     timeParams_.resize(TSIZE, std::vector<unsigned long long>(1, 0ULL));
0036   }
0037 
0038   ~BeamSpotOnlineObjects() override {}
0039 
0040   /// Enums
0041   enum IntParamIndex { NUM_TRACKS = 0, NUM_PVS = 1, USED_EVENTS = 2, MAX_PVS = 3, ISIZE = 4 };
0042   enum FloatParamIndex { MEAN_PV = 0, ERR_MEAN_PV = 1, RMS_PV = 2, ERR_RMS_PV = 3, FSIZE = 4 };
0043   enum StringParamIndex { START_TIME = 0, END_TIME = 1, LUMI_RANGE = 2, SSIZE = 3 };
0044   enum TimeParamIndex { CREATE_TIME = 0, START_TIMESTAMP = 1, END_TIMESTAMP = 2, TSIZE = 3 };
0045 
0046   /// Setters Methods
0047   // copy all copiable members from BeamSpotObjects
0048   void copyFromBeamSpotObject(const BeamSpotObjects& bs);
0049 
0050   // set lastAnalyzedLumi_, last analyzed lumisection
0051   void setLastAnalyzedLumi(int val) { lastAnalyzedLumi_ = val; }
0052 
0053   // set lastAnalyzedRun_, run of the last analyzed lumisection
0054   void setLastAnalyzedRun(int val) { lastAnalyzedRun_ = val; }
0055 
0056   // set lastAnalyzedFill_, fill of the last analyzed lumisection
0057   void setLastAnalyzedFill(int val) { lastAnalyzedFill_ = val; }
0058 
0059   // set number of tracks used in the BeamSpot fit
0060   void setNumTracks(int val);
0061 
0062   // set number of Primary Vertices used in the BeamSpot fit
0063   void setNumPVs(int val);
0064 
0065   // set number of Events used in the BeamSpot fit (for DIP)
0066   void setUsedEvents(int val);
0067 
0068   // set max number of Primary Vertices used in the BeamSpot fit (for DIP)
0069   void setMaxPVs(int val);
0070 
0071   // set mean number of PVs (for DIP)
0072   void setMeanPV(float val);
0073 
0074   // set error on mean number of PVs (for DIP)
0075   void setMeanErrorPV(float val);
0076 
0077   // set rms of number of PVs (for DIP)
0078   void setRmsPV(float val);
0079 
0080   // set error on rm of number of PVs (for DIP)
0081   void setRmsErrorPV(float val);
0082 
0083   // set start time of the firs LS as string (for DIP)
0084   void setStartTime(std::string val);
0085 
0086   // set end time of the last LS as string (for DIP)
0087   void setEndTime(std::string val);
0088 
0089   // set lumi range as string (for DIP)
0090   void setLumiRange(std::string val);
0091 
0092   // set creation time of the payload
0093   void setCreationTime(cond::Time_t val);
0094 
0095   // set timestamp of the first LS (for DIP)
0096   void setStartTimeStamp(cond::Time_t val);
0097 
0098   // set timestamp of the last LS (for DIP)
0099   void setEndTimeStamp(cond::Time_t val);
0100 
0101   /// Getters Methods
0102   // get lastAnalyzedLumi_, last analyzed lumisection
0103   int lastAnalyzedLumi() const { return lastAnalyzedLumi_; }
0104 
0105   // get lastAnalyzedRun_, run of the last analyzed lumisection
0106   int lastAnalyzedRun() const { return lastAnalyzedRun_; }
0107 
0108   // get lastAnalyzedFill_, fill of the last analyzed lumisection
0109   int lastAnalyzedFill() const { return lastAnalyzedFill_; }
0110 
0111   // get number of tracks used in the BeamSpot fit
0112   int numTracks() const;
0113 
0114   // get number of Primary Vertices used in the BeamSpot fit
0115   int numPVs() const;
0116 
0117   // get number of Events used in the BeamSpot fit (for DIP)
0118   int usedEvents() const;
0119 
0120   // get max number of Primary Vertices used in the BeamSpot fit (for DIP)
0121   int maxPVs() const;
0122 
0123   // get mean number of PVs (for DIP)
0124   float meanPV() const;
0125 
0126   // get error on mean number of PVs (for DIP)
0127   float meanErrorPV() const;
0128 
0129   // get rms of number of PVs (for DIP)
0130   float rmsPV() const;
0131 
0132   // get error on rm of number of PVs (for DIP)
0133   float rmsErrorPV() const;
0134 
0135   // get start time of the firs LS as string (for DIP)
0136   std::string startTime() const;
0137 
0138   // get end time of the last LS as string (for DIP)
0139   std::string endTime() const;
0140 
0141   // get lumi range as string (for DIP)
0142   std::string lumiRange() const;
0143 
0144   // get creation time of the payload
0145   cond::Time_t creationTime() const;
0146 
0147   // get timestamp of the first LS (for DIP)
0148   cond::Time_t startTimeStamp() const;
0149 
0150   // get timestamp of the last LS (for DIP)
0151   cond::Time_t endTimeStamp() const;
0152 
0153   /// Print BeamSpotOnline parameters
0154   void print(std::stringstream& ss) const;
0155 
0156 private:
0157   int lastAnalyzedLumi_;
0158   int lastAnalyzedRun_;
0159   int lastAnalyzedFill_;
0160   std::vector<std::vector<int> > intParams_;
0161   std::vector<std::vector<float> > floatParams_;
0162   std::vector<std::vector<std::string> > stringParams_;
0163   std::vector<std::vector<unsigned long long> > timeParams_;  // unsigned long long is equal to cond::Time_t
0164 
0165   COND_SERIALIZABLE;
0166 };
0167 
0168 std::ostream& operator<<(std::ostream&, BeamSpotOnlineObjects beam);
0169 
0170 #endif