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 
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::readLastValueFromFile
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
Definition: SiStripDetVOffBuilder.cc:400
SiStripDetVOffBuilder::getPayloadStats
std::vector< std::vector< uint32_t > > getPayloadStats()
Definition: SiStripDetVOffBuilder.h:53
SiStripDetVOffBuilder
Builds the SiStripDetVOff object for transfer by O2O.
Definition: SiStripDetVOffBuilder.h:37
SiStripDetVOffBuilder::FileExists
bool FileExists(std::string filename)
Definition: SiStripDetVOffBuilder.cc:747
SiStripDetVOffBuilder::TimesAndValues::latestTime
cond::Time_t latestTime
Definition: SiStripDetVOffBuilder.h:143
SiStripDetVOffBuilder::whichQuery
bool whichQuery
Definition: SiStripDetVOffBuilder.h:78
SiStripDetVOffBuilder::lastValueFileName
std::string lastValueFileName
Definition: SiStripDetVOffBuilder.h:122
SiStripDetVOffBuilder::detIdListFile_
std::string detIdListFile_
Definition: SiStripDetVOffBuilder.h:130
SiStripDetVOffBuilder::SiStripDetVOffBuilder
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
Definition: SiStripDetVOffBuilder.cc:5
mps_fire.i
i
Definition: mps_fire.py:355
SiStripDetVOffBuilder::TimesAndValues::actualValue
std::vector< float > actualValue
Definition: SiStripDetVOffBuilder.h:140
MessageLogger.h
SiStripDetVOffBuilder::getCoralTime
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
Definition: SiStripDetVOffBuilder.cc:477
ESHandle.h
SiStripDetVOffBuilder::discardIOVs
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.
Definition: SiStripDetVOffBuilder.cc:564
SiStripDetVOffBuilder::tset_par
std::vector< int > tset_par
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::TimesAndValues::dpname
std::vector< std::string > dpname
Definition: SiStripDetVOffBuilder.h:139
SiStripDetVOffBuilder::~SiStripDetVOffBuilder
~SiStripDetVOffBuilder()
Definition: SiStripDetVOffBuilder.cc:86
SiStripDetVOffBuilder::lastStoredCondObj
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
Definition: SiStripDetVOffBuilder.h:116
Time.h
SiStripDetVOffBuilder::statusChange
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:629
SiStripDetVOffBuilder::TimesAndValues
Definition: SiStripDetVOffBuilder.h:136
SiStripDetVOffBuilder::findMostRecentTimeStamp
cond::Time_t findMostRecentTimeStamp(const std::vector< coral::TimeStamp > &coralDate)
Definition: SiStripDetVOffBuilder.cc:507
SiStripDetVOffBuilder::printPar
void printPar(std::stringstream &ss, const std::vector< int > &par)
Definition: SiStripDetVOffBuilder.cc:90
SiStripPsuDetIdMap.h
SiStripDetVOffBuilder::removeDuplicates
void removeDuplicates(std::vector< uint32_t > &vec)
Definition: SiStripDetVOffBuilder.cc:496
SiStripDetVOffBuilder::lastValueFromFile
void lastValueFromFile(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:691
SiStripDetVOffBuilder::setLastSiStripDetVOff
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
Definition: SiStripDetVOffBuilder.cc:502
dqmdumpme.first
first
Definition: dqmdumpme.py:55
SiStripDetVOffBuilder::DetIdTimeStampVector
std::vector< std::pair< std::vector< uint32_t >, coral::TimeStamp > > DetIdTimeStampVector
Definition: SiStripDetVOffBuilder.h:76
SiStripDetVOffBuilder::DetIdListTimeAndStatus
Definition: SiStripDetVOffBuilder.h:146
SiStripDetVOffBuilder::DetIdListTimeAndStatus::psuName
std::vector< std::string > psuName
Definition: SiStripDetVOffBuilder.h:151
SiStripDetVOffBuilder::TimesAndValues::TimesAndValues
TimesAndValues()
Definition: SiStripDetVOffBuilder.h:137
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripDetVOffBuilder::DetIdListTimeAndStatus::StatusGood
std::vector< bool > StatusGood
Definition: SiStripDetVOffBuilder.h:149
SiStripDetVOffBuilder::DetIdListTimeAndStatus::isHV
std::vector< unsigned int > isHV
Definition: SiStripDetVOffBuilder.h:152
dqmdumpme.last
last
Definition: dqmdumpme.py:56
SiStripDetVOffBuilder::lastValue
void lastValue(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:651
SiStripDetVOffBuilder::modulesOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
Definition: SiStripDetVOffBuilder.h:115
SiStripDetVOffBuilder::tDefault
std::vector< int > tDefault
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::TimesAndValues::actualStatus
std::vector< int > actualStatus
Definition: SiStripDetVOffBuilder.h:142
Service.h
edm::ActivityRegistry
Definition: ActivityRegistry.h:132
SiStripDetVOffBuilder::highVoltageOnThreshold_
double highVoltageOnThreshold_
Definition: SiStripDetVOffBuilder.h:133
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
SiStripDetInfoFileReader.h
SiStripDetVOffBuilder::DetIdListTimeAndStatus::detidV
DetIdTimeStampVector detidV
Definition: SiStripDetVOffBuilder.h:148
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripDetVOffBuilder::reduction
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
Definition: SiStripDetVOffBuilder.cc:588
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripDetVOffBuilder::authenticationPath
std::string authenticationPath
Definition: SiStripDetVOffBuilder.h:120
SiStripCondDataRecords.h
SiStripCoralIface.h
SiStripDetVOffBuilder::TimesAndValues::dpid
std::vector< uint32_t > dpid
Definition: SiStripDetVOffBuilder.h:141
SiStripDetVOffBuilder::BuildDetVOffObj
void BuildDetVOffObj()
Definition: SiStripDetVOffBuilder.cc:96
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
SiStripDetVOffBuilder::tmax
coral::TimeStamp tmax
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOff
Definition: SiStripDetVOff.h:31
SiStripDetVOffBuilder::tmax_par
std::vector< int > tmax_par
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::whichTable
std::string whichTable
Definition: SiStripDetVOffBuilder.h:121
SiStripDetVOffBuilder::onlineDbConnectionString
std::string onlineDbConnectionString
Definition: SiStripDetVOffBuilder.h:119
SiStripDetVOffBuilder::timeToStream
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
Definition: SiStripDetVOffBuilder.cc:740
SiStripDetVOffBuilder::maxIOVlength_
uint32_t maxIOVlength_
Definition: SiStripDetVOffBuilder.h:128
SiStripDetVOffBuilder::getCondTime
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
Definition: SiStripDetVOffBuilder.cc:467
SiStripDetVOffBuilder::deltaTmin_
uint32_t deltaTmin_
Definition: SiStripDetVOffBuilder.h:128
SiStripDetVOffBuilder::payloadStats
std::vector< std::vector< uint32_t > > payloadStats
Definition: SiStripDetVOffBuilder.h:114
SiStripDetVOffBuilder::extractDetIdVector
std::pair< int, int > extractDetIdVector(const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
Definition: SiStripDetVOffBuilder.cc:1272
SiStripDetVOffBuilder::tmin
coral::TimeStamp tmin
Definition: SiStripDetVOffBuilder.h:126
comment
#define comment(par)
Definition: vmac.h:163
SiStripDetVOffBuilder::buildPSUdetIdMap
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
Definition: SiStripDetVOffBuilder.cc:762
SiStripDetVOffBuilder::DetIdListTimeAndStatus::DetIdListTimeAndStatus
DetIdListTimeAndStatus()
Definition: SiStripDetVOffBuilder.h:147
SiStripDetVOffBuilder::fromFile
bool fromFile
Definition: SiStripDetVOffBuilder.h:123
SiStripDetVOffBuilder::TimesAndValues::changeDate
std::vector< coral::TimeStamp > changeDate
Definition: SiStripDetVOffBuilder.h:138
SiStripDetVOffBuilder::reduce
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.
Definition: SiStripDetVOffBuilder.cc:526
SiStripDetVOffBuilder::debug_
bool debug_
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::excludedDetIdListFile_
std::string excludedDetIdListFile_
Definition: SiStripDetVOffBuilder.h:131
SiStripDetVOffBuilder::coralInterface
std::unique_ptr< SiStripCoralIface > coralInterface
Definition: SiStripDetVOffBuilder.h:166
EventSetup.h
SiStripDetVOffBuilder::tmin_par
std::vector< int > tmin_par
Definition: SiStripDetVOffBuilder.h:127
TimeConversions.h
ParameterSet.h
SiStripDetVOffBuilder::findSetting
int findSetting(uint32_t id, const coral::TimeStamp &changeDate, const std::vector< uint32_t > &settingID, const std::vector< coral::TimeStamp > &settingDate)
Definition: SiStripDetVOffBuilder.cc:324
SiStripDetVOff.h
SiStripDetVOffBuilder::setPayloadStats
void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
Definition: SiStripDetVOffBuilder.cc:1264
SiStripDetVOffBuilder::psuDetIdMapFile_
std::string psuDetIdMapFile_
Definition: SiStripDetVOffBuilder.h:124
SiStripDetVOffBuilder::tsetmin
coral::TimeStamp tsetmin
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::getModulesVOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
Definition: SiStripDetVOffBuilder.h:48
SiStripDetVOffBuilder::TestSiStripDetVOffBuilder
friend class TestSiStripDetVOffBuilder
Definition: SiStripDetVOffBuilder.h:38
SiStripDetVOffBuilder::DetIdListTimeAndStatus::notMatched
unsigned int notMatched
Definition: SiStripDetVOffBuilder.h:150