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 
37 {
38  public:
44  void BuildDetVOffObj();
46  std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > getModulesVOff(const int deltaTmin = 1, const int maxIOVlength = 120) {
47  reduction(deltaTmin, maxIOVlength);
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, const unsigned int first );
70  private:
71  // typedefs
72  typedef std::vector< std::pair< std::vector<uint32_t>,coral::TimeStamp> > DetIdTimeStampVector;
73 
74 
75  bool whichQuery;
76 
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;
126 
129  // Threshold to consider a high voltage channel on
131 
132  // Structure used to store variables needed when building the database objects
134  {
136  latestTime(0)
137  {}
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  {
149  notMatched(0)
150  {}
152  std::vector<bool> StatusGood;
153  unsigned int notMatched;
154  std::vector<std::string> psuName;
155  std::vector<unsigned int> isHV;
156  };
157 
158  void statusChange( cond::Time_t & lastTime, TimesAndValues & tStruct );
159  void lastValue( TimesAndValues & tStruct );
160  void lastValueFromFile( TimesAndValues & tStruct );
161 
162  void buildPSUdetIdMap(TimesAndValues & tStruct, DetIdListTimeAndStatus & dStruct);
163 
164  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
165  std::pair<int, int> extractDetIdVector(const unsigned int i, SiStripDetVOff * modV, DetIdListTimeAndStatus & detIdStruct);
166 
167  std::auto_ptr<SiStripCoralIface> coralInterface;
168 
169 };
170 #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)
void printPar(std::stringstream &ss, const std::vector< int > &par)
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff(const int deltaTmin=1, const int maxIOVlength=120)
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
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)
bool first
Definition: L1TdeRCT.cc:75
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