CMS 3D CMS Logo

SiStripDetVOffBuilder.h
Go to the documentation of this file.
1 #ifndef SISTRIPDETVOFF_SRC_BUILDER_H
2 #define SISTRIPDETVOFF_SRC_BUILDER_H
3 #define USING_NEW_CORAL
4 
9 
12 
15 // #include "CalibTracker/SiStripDCS/interface/SiStripPsuDetIdMapFromFile.h"
16 
17 #include "CoralBase/TimeStamp.h"
20 //#include "DataFormats/Provenance/interface/Timestamp.h"
21 
22 #include <fstream>
23 #include <iostream>
24 #include <memory>
25 
32 // Unit test class for SiStripDetVOffBuilder
33 class TestSiStripDetVOffBuilder;
34 
37 
38 public:
44  void BuildDetVOffObj();
46  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > getModulesVOff() {
48  return modulesOff;
49  }
51  std::vector<std::vector<uint32_t> > getPayloadStats() { return payloadStats; }
54  void setLastSiStripDetVOff(SiStripDetVOff* lastPayload, cond::Time_t lastTimeStamp);
55 
57  void reduce(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
58  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
59  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
60  const bool last = false);
61 
62  void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength);
63 
65  void discardIOVs(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
66  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
67  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
68  const bool last,
69  const unsigned int first);
71 
72 private:
73  // typedefs
74  typedef std::vector<std::pair<std::vector<uint32_t>, coral::TimeStamp> > DetIdTimeStampVector;
75 
76  bool whichQuery;
77 
78  void printPar(std::stringstream& ss, const std::vector<int>& par);
79 
80  std::string timeToStream(const coral::TimeStamp& coralTime, const string& comment = "");
81  std::string timeToStream(const cond::Time_t& condTime, const string& comment = "");
82 
84  int findSetting(uint32_t id,
85  const coral::TimeStamp& changeDate,
86  const std::vector<uint32_t>& settingID,
87  const std::vector<coral::TimeStamp>& settingDate);
88 
90  int findSetting(std::string dpname,
91  const coral::TimeStamp& changeDate,
92  const std::vector<std::string>& settingDpname,
93  const std::vector<coral::TimeStamp>& settingDate);
94 
96  void readLastValueFromFile(std::vector<uint32_t>& dpIDs,
97  std::vector<float>& vmonValues,
98  std::vector<coral::TimeStamp>& dateChange);
99 
101  cond::Time_t getCondTime(const coral::TimeStamp& coralTime);
102 
104  coral::TimeStamp getCoralTime(cond::Time_t iovTime);
105 
107  void removeDuplicates(std::vector<uint32_t>& vec);
109  cond::Time_t findMostRecentTimeStamp(const std::vector<coral::TimeStamp>& coralDate);
110 
111  // member data
112  std::vector<std::vector<uint32_t> > payloadStats;
113  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > modulesOff;
114  std::pair<SiStripDetVOff*, cond::Time_t> lastStoredCondObj;
115 
116  // configurable parameters
121  bool fromFile;
123  bool debug_;
124  coral::TimeStamp tmax, tmin, tsetmin;
125  std::vector<int> tDefault, tmax_par, tmin_par, tset_par;
127 
130  // Threshold to consider a high voltage channel on
132 
133  // Structure used to store variables needed when building the database objects
134  struct TimesAndValues {
136  std::vector<coral::TimeStamp> changeDate; // used by both
137  std::vector<std::string> dpname; // only used by DB access, not file access
138  std::vector<float> actualValue; // only used by DB access, not file access
139  std::vector<uint32_t> dpid; // only used by file access
140  std::vector<int> actualStatus; // filled using actualValue info
141  cond::Time_t latestTime; // used for timestamp when using lastValue from file
142  };
143 
147  std::vector<bool> StatusGood;
148  unsigned int notMatched;
149  std::vector<std::string> psuName;
150  std::vector<unsigned int> isHV;
151  };
152 
153  void statusChange(cond::Time_t& lastTime, TimesAndValues& tStruct);
154  void lastValue(TimesAndValues& tStruct);
155  void lastValueFromFile(TimesAndValues& tStruct);
156 
157  void buildPSUdetIdMap(TimesAndValues& tStruct, DetIdListTimeAndStatus& dStruct);
158 
159  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
160  std::pair<int, int> extractDetIdVector(const unsigned int i,
161  SiStripDetVOff* modV,
162  DetIdListTimeAndStatus& detIdStruct);
163 
164  std::unique_ptr<SiStripCoralIface> coralInterface;
165 };
166 #endif
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
std::vector< std::pair< std::vector< uint32_t >, coral::TimeStamp > > DetIdTimeStampVector
Builds the SiStripDetVOff object for transfer by O2O.
void discardIOVs(std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &it, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &initialIt, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > &resultVec, const bool last, const unsigned int first)
Removes IOVs as dictated by reduction.
std::pair< int, int > extractDetIdVector(const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
void printPar(std::stringstream &ss, const std::vector< int > &par)
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
friend class TestSiStripDetVOffBuilder
std::vector< std::vector< uint32_t > > getPayloadStats()
int findSetting(uint32_t id, const coral::TimeStamp &changeDate, const std::vector< uint32_t > &settingID, const std::vector< coral::TimeStamp > &settingDate)
void removeDuplicates(std::vector< uint32_t > &vec)
bool FileExists(std::string filename)
std::vector< int > tDefault
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
std::unique_ptr< SiStripCoralIface > coralInterface
unsigned long long Time_t
Definition: Time.h:14
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
std::vector< coral::TimeStamp > changeDate
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
std::vector< std::vector< uint32_t > > payloadStats
void lastValue(TimesAndValues &tStruct)
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
cond::Time_t findMostRecentTimeStamp(const std::vector< coral::TimeStamp > &coralDate)
void lastValueFromFile(TimesAndValues &tStruct)
std::vector< int > tmax_par
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
std::vector< int > tmin_par
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
void reduce(std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &it, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > >::iterator &initialIt, std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > &resultVec, const bool last=false)
Operates the reduction of the fast sequences of ramping up and down of the voltages.
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
std::vector< int > tset_par