test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
5 
11 
15 
18 // #include "CalibTracker/SiStripDCS/interface/SiStripPsuDetIdMapFromFile.h"
19 
20 #include "CoralBase/TimeStamp.h"
23 //#include "DataFormats/Provenance/interface/Timestamp.h"
24 
25 
26 #include <fstream>
27 #include <iostream>
28 #include <memory>
29 
36 // Unit test class for SiStripDetVOffBuilder
37 class TestSiStripDetVOffBuilder;
38 
40 {
42 
43  public:
49  void BuildDetVOffObj();
51  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > getModulesVOff() {
53  return modulesOff;
54  }
56  std::vector< std::vector<uint32_t> > getPayloadStats() {return payloadStats;}
59  void setLastSiStripDetVOff( SiStripDetVOff * lastPayload, cond::Time_t lastTimeStamp );
60 
62  void reduce( std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & it,
63  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
64  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
65  const bool last = false);
66 
67  void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength);
68 
70  void discardIOVs( std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & it,
71  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> >::iterator & initialIt,
72  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > & resultVec,
73  const bool last, const unsigned int first );
75  private:
76  // typedefs
77  typedef std::vector< std::pair< std::vector<uint32_t>,coral::TimeStamp> > DetIdTimeStampVector;
78 
79 
80  bool whichQuery;
81 
82 
83  void printPar(std::stringstream& ss, const std::vector<int>& par);
84 
85  std::string timeToStream(const coral::TimeStamp & coralTime, const string & comment = "");
86  std::string timeToStream(const cond::Time_t & condTime, const string & comment = "");
87 
89  int findSetting(uint32_t id,
90  const coral::TimeStamp& changeDate,
91  const std::vector<uint32_t>& settingID,
92  const std::vector<coral::TimeStamp>& settingDate);
93 
95  int findSetting(std::string dpname,
96  const coral::TimeStamp& changeDate,
97  const std::vector<std::string>& settingDpname,
98  const std::vector<coral::TimeStamp>& settingDate);
99 
101  void readLastValueFromFile(std::vector<uint32_t> &dpIDs,
102  std::vector<float> &vmonValues,
103  std::vector<coral::TimeStamp> &dateChange);
104 
106  cond::Time_t getCondTime(const coral::TimeStamp& coralTime);
107 
109  coral::TimeStamp getCoralTime(cond::Time_t iovTime);
110 
112  void removeDuplicates( std::vector<uint32_t> & vec );
114  cond::Time_t findMostRecentTimeStamp( const std::vector<coral::TimeStamp>& coralDate );
115 
116  // member data
117  std::vector< std::vector<uint32_t> > payloadStats;
118  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > modulesOff;
119  std::pair<SiStripDetVOff *, cond::Time_t> lastStoredCondObj;
120 
121  // configurable parameters
126  bool fromFile;
128  bool debug_;
129  coral::TimeStamp tmax, tmin, tsetmin;
130  std::vector<int> tDefault, tmax_par, tmin_par, tset_par;
132 
135  // Threshold to consider a high voltage channel on
137 
138  // Structure used to store variables needed when building the database objects
140  {
142  latestTime(0)
143  {}
144  std::vector<coral::TimeStamp> changeDate; // used by both
145  std::vector<std::string> dpname; // only used by DB access, not file access
146  std::vector<float> actualValue; // only used by DB access, not file access
147  std::vector<uint32_t> dpid; // only used by file access
148  std::vector<int> actualStatus; // filled using actualValue info
149  cond::Time_t latestTime; // used for timestamp when using lastValue from file
150  };
151 
153  {
155  notMatched(0)
156  {}
158  std::vector<bool> StatusGood;
159  unsigned int notMatched;
160  std::vector<std::string> psuName;
161  std::vector<unsigned int> isHV;
162  };
163 
164  void statusChange( cond::Time_t & lastTime, TimesAndValues & tStruct );
165  void lastValue( TimesAndValues & tStruct );
166  void lastValueFromFile( TimesAndValues & tStruct );
167 
168  void buildPSUdetIdMap(TimesAndValues & tStruct, DetIdListTimeAndStatus & dStruct);
169 
170  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
171  std::pair<int, int> extractDetIdVector(const unsigned int i, SiStripDetVOff * modV, DetIdListTimeAndStatus & detIdStruct);
172 
173  std::auto_ptr<SiStripCoralIface> coralInterface;
174 
175 };
176 #endif
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
int i
Definition: DBlmapReader.cc:9
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)
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
void printPar(std::stringstream &ss, const std::vector< int > &par)
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
friend class TestSiStripDetVOffBuilder
std::auto_ptr< SiStripCoralIface > coralInterface
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
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)
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)
std::vector< std::vector< uint32_t > > getPayloadStats()
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
std::vector< int > tmin_par
std::vector< std::vector< uint32_t > > payloadStats
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.
tuple filename
Definition: lut2db_cfg.py:20
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
std::vector< int > tset_par
#define comment(par)
Definition: vmac.h:161