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 
10 
14 
17 // #include "CalibTracker/SiStripDCS/interface/SiStripPsuDetIdMapFromFile.h"
18 
19 #include "CoralBase/TimeStamp.h"
22 //#include "DataFormats/Provenance/interface/Timestamp.h"
23 
24 #include <fstream>
25 #include <iostream>
26 #include <memory>
27 
34 // Unit test class for SiStripDetVOffBuilder
35 class TestSiStripDetVOffBuilder;
36 
39 
40 public:
46  void BuildDetVOffObj();
48  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > getModulesVOff() {
50  return modulesOff;
51  }
53  std::vector<std::vector<uint32_t> > getPayloadStats() { return payloadStats; }
56  void setLastSiStripDetVOff(SiStripDetVOff* lastPayload, cond::Time_t lastTimeStamp);
57 
59  void reduce(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
60  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
61  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
62  const bool last = false);
63 
64  void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength);
65 
67  void discardIOVs(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
68  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
69  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
70  const bool last,
71  const unsigned int first);
73 
74 private:
75  // typedefs
76  typedef std::vector<std::pair<std::vector<uint32_t>, coral::TimeStamp> > DetIdTimeStampVector;
77 
78  bool whichQuery;
79 
80  void printPar(std::stringstream& ss, const std::vector<int>& par);
81 
82  std::string timeToStream(const coral::TimeStamp& coralTime, const string& comment = "");
83  std::string timeToStream(const cond::Time_t& condTime, const string& comment = "");
84 
86  int findSetting(uint32_t id,
87  const coral::TimeStamp& changeDate,
88  const std::vector<uint32_t>& settingID,
89  const std::vector<coral::TimeStamp>& settingDate);
90 
92  int findSetting(std::string dpname,
93  const coral::TimeStamp& changeDate,
94  const std::vector<std::string>& settingDpname,
95  const std::vector<coral::TimeStamp>& settingDate);
96 
98  void readLastValueFromFile(std::vector<uint32_t>& dpIDs,
99  std::vector<float>& vmonValues,
100  std::vector<coral::TimeStamp>& dateChange);
101 
103  cond::Time_t getCondTime(const coral::TimeStamp& coralTime);
104 
106  coral::TimeStamp getCoralTime(cond::Time_t iovTime);
107 
109  void removeDuplicates(std::vector<uint32_t>& vec);
111  cond::Time_t findMostRecentTimeStamp(const std::vector<coral::TimeStamp>& coralDate);
112 
113  // member data
114  std::vector<std::vector<uint32_t> > payloadStats;
115  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > modulesOff;
116  std::pair<SiStripDetVOff*, cond::Time_t> lastStoredCondObj;
117 
118  // configurable parameters
123  bool fromFile;
125  bool debug_;
126  coral::TimeStamp tmax, tmin, tsetmin;
127  std::vector<int> tDefault, tmax_par, tmin_par, tset_par;
129 
132  // Threshold to consider a high voltage channel on
134 
135  // Structure used to store variables needed when building the database objects
136  struct TimesAndValues {
138  std::vector<coral::TimeStamp> changeDate; // used by both
139  std::vector<std::string> dpname; // only used by DB access, not file access
140  std::vector<float> actualValue; // only used by DB access, not file access
141  std::vector<uint32_t> dpid; // only used by file access
142  std::vector<int> actualStatus; // filled using actualValue info
143  cond::Time_t latestTime; // used for timestamp when using lastValue from file
144  };
145 
147  DetIdListTimeAndStatus() : notMatched(0) {}
148  DetIdTimeStampVector detidV;
149  std::vector<bool> StatusGood;
150  unsigned int notMatched;
151  std::vector<std::string> psuName;
152  std::vector<unsigned int> isHV;
153  };
154 
155  void statusChange(cond::Time_t& lastTime, TimesAndValues& tStruct);
156  void lastValue(TimesAndValues& tStruct);
157  void lastValueFromFile(TimesAndValues& tStruct);
158 
159  void buildPSUdetIdMap(TimesAndValues& tStruct, DetIdListTimeAndStatus& dStruct);
160 
161  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
162  std::pair<int, int> extractDetIdVector(const unsigned int i,
163  SiStripDetVOff* modV,
164  DetIdListTimeAndStatus& detIdStruct);
165 
166  std::unique_ptr<SiStripCoralIface> coralInterface;
167 };
168 #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:16
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
#define comment(par)
Definition: vmac.h:163