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 
13 
16 // #include "CalibTracker/SiStripDCS/interface/SiStripPsuDetIdMapFromFile.h"
17 
18 #include "CoralBase/TimeStamp.h"
21 //#include "DataFormats/Provenance/interface/Timestamp.h"
22 
23 #include <fstream>
24 #include <iostream>
25 #include <memory>
26 
33 // Unit test class for SiStripDetVOffBuilder
34 class TestSiStripDetVOffBuilder;
35 
38 
39 public:
45  void BuildDetVOffObj();
47  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > getModulesVOff() {
49  return modulesOff;
50  }
52  std::vector<std::vector<uint32_t> > getPayloadStats() { return payloadStats; }
55  void setLastSiStripDetVOff(SiStripDetVOff* lastPayload, cond::Time_t lastTimeStamp);
56 
58  void reduce(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
59  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
60  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
61  const bool last = false);
62 
63  void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength);
64 
66  void discardIOVs(std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& it,
67  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator& initialIt,
68  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >& resultVec,
69  const bool last,
70  const unsigned int first);
72 
73 private:
74  // typedefs
75  typedef std::vector<std::pair<std::vector<uint32_t>, coral::TimeStamp> > DetIdTimeStampVector;
76 
77  bool whichQuery;
78 
79  void printPar(std::stringstream& ss, const std::vector<int>& par);
80 
81  std::string timeToStream(const coral::TimeStamp& coralTime, const string& comment = "");
82  std::string timeToStream(const cond::Time_t& condTime, const string& comment = "");
83 
85  int findSetting(uint32_t id,
86  const coral::TimeStamp& changeDate,
87  const std::vector<uint32_t>& settingID,
88  const std::vector<coral::TimeStamp>& settingDate);
89 
91  int findSetting(std::string dpname,
92  const coral::TimeStamp& changeDate,
93  const std::vector<std::string>& settingDpname,
94  const std::vector<coral::TimeStamp>& settingDate);
95 
97  void readLastValueFromFile(std::vector<uint32_t>& dpIDs,
98  std::vector<float>& vmonValues,
99  std::vector<coral::TimeStamp>& dateChange);
100 
102  cond::Time_t getCondTime(const coral::TimeStamp& coralTime);
103 
105  coral::TimeStamp getCoralTime(cond::Time_t iovTime);
106 
108  void removeDuplicates(std::vector<uint32_t>& vec);
110  cond::Time_t findMostRecentTimeStamp(const std::vector<coral::TimeStamp>& coralDate);
111 
112  // member data
113  std::vector<std::vector<uint32_t> > payloadStats;
114  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > modulesOff;
115  std::pair<SiStripDetVOff*, cond::Time_t> lastStoredCondObj;
116 
117  // configurable parameters
122  bool fromFile;
124  bool debug_;
125  coral::TimeStamp tmax, tmin, tsetmin;
126  std::vector<int> tDefault, tmax_par, tmin_par, tset_par;
128 
131  // Threshold to consider a high voltage channel on
133 
134  // Structure used to store variables needed when building the database objects
135  struct TimesAndValues {
137  std::vector<coral::TimeStamp> changeDate; // used by both
138  std::vector<std::string> dpname; // only used by DB access, not file access
139  std::vector<float> actualValue; // only used by DB access, not file access
140  std::vector<uint32_t> dpid; // only used by file access
141  std::vector<int> actualStatus; // filled using actualValue info
142  cond::Time_t latestTime; // used for timestamp when using lastValue from file
143  };
144 
148  std::vector<bool> StatusGood;
149  unsigned int notMatched;
150  std::vector<std::string> psuName;
151  std::vector<unsigned int> isHV;
152  };
153 
154  void statusChange(cond::Time_t& lastTime, TimesAndValues& tStruct);
155  void lastValue(TimesAndValues& tStruct);
156  void lastValueFromFile(TimesAndValues& tStruct);
157 
158  void buildPSUdetIdMap(TimesAndValues& tStruct, DetIdListTimeAndStatus& dStruct);
159 
160  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
161  std::pair<int, int> extractDetIdVector(const unsigned int i,
162  SiStripDetVOff* modV,
163  DetIdListTimeAndStatus& detIdStruct);
164 
165  std::unique_ptr<SiStripCoralIface> coralInterface;
166 };
167 #endif
SiStripDetVOffBuilder::readLastValueFromFile
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
Definition: SiStripDetVOffBuilder.cc:402
SiStripDetVOffBuilder::getPayloadStats
std::vector< std::vector< uint32_t > > getPayloadStats()
Definition: SiStripDetVOffBuilder.h:52
SiStripDetVOffBuilder
Builds the SiStripDetVOff object for transfer by O2O.
Definition: SiStripDetVOffBuilder.h:36
SiStripDetVOffBuilder::FileExists
bool FileExists(std::string filename)
Definition: SiStripDetVOffBuilder.cc:749
SiStripDetVOffBuilder::TimesAndValues::latestTime
cond::Time_t latestTime
Definition: SiStripDetVOffBuilder.h:142
SiStripDetVOffBuilder::whichQuery
bool whichQuery
Definition: SiStripDetVOffBuilder.h:77
SiStripDetVOffBuilder::lastValueFileName
std::string lastValueFileName
Definition: SiStripDetVOffBuilder.h:121
SiStripDetVOffBuilder::detIdListFile_
std::string detIdListFile_
Definition: SiStripDetVOffBuilder.h:129
SiStripDetVOffBuilder::SiStripDetVOffBuilder
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
Definition: SiStripDetVOffBuilder.cc:7
mps_fire.i
i
Definition: mps_fire.py:428
SiStripDetVOffBuilder::TimesAndValues::actualValue
std::vector< float > actualValue
Definition: SiStripDetVOffBuilder.h:139
MessageLogger.h
SiStripDetVOffBuilder::getCoralTime
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
Definition: SiStripDetVOffBuilder.cc:479
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:566
SiStripDetVOffBuilder::tset_par
std::vector< int > tset_par
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::TimesAndValues::dpname
std::vector< std::string > dpname
Definition: SiStripDetVOffBuilder.h:138
SiStripDetVOffBuilder::~SiStripDetVOffBuilder
~SiStripDetVOffBuilder()
Definition: SiStripDetVOffBuilder.cc:88
SiStripDetVOffBuilder::lastStoredCondObj
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
Definition: SiStripDetVOffBuilder.h:115
Time.h
SiStripDetVOffBuilder::statusChange
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:631
SiStripDetVOffBuilder::TimesAndValues
Definition: SiStripDetVOffBuilder.h:135
SiStripDetVOffBuilder::findMostRecentTimeStamp
cond::Time_t findMostRecentTimeStamp(const std::vector< coral::TimeStamp > &coralDate)
Definition: SiStripDetVOffBuilder.cc:509
SiStripDetVOffBuilder::printPar
void printPar(std::stringstream &ss, const std::vector< int > &par)
Definition: SiStripDetVOffBuilder.cc:92
SiStripPsuDetIdMap.h
SiStripDetVOffBuilder::removeDuplicates
void removeDuplicates(std::vector< uint32_t > &vec)
Definition: SiStripDetVOffBuilder.cc:498
SiStripDetVOffBuilder::lastValueFromFile
void lastValueFromFile(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:693
SiStripDetVOffBuilder::setLastSiStripDetVOff
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
Definition: SiStripDetVOffBuilder.cc:504
dqmdumpme.first
first
Definition: dqmdumpme.py:55
SiStripDetVOffBuilder::DetIdTimeStampVector
std::vector< std::pair< std::vector< uint32_t >, coral::TimeStamp > > DetIdTimeStampVector
Definition: SiStripDetVOffBuilder.h:75
SiStripDetVOffBuilder::DetIdListTimeAndStatus
Definition: SiStripDetVOffBuilder.h:145
SiStripDetVOffBuilder::DetIdListTimeAndStatus::psuName
std::vector< std::string > psuName
Definition: SiStripDetVOffBuilder.h:150
SiStripDetVOffBuilder::TimesAndValues::TimesAndValues
TimesAndValues()
Definition: SiStripDetVOffBuilder.h:136
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripDetVOffBuilder::DetIdListTimeAndStatus::StatusGood
std::vector< bool > StatusGood
Definition: SiStripDetVOffBuilder.h:148
SiStripDetVOffBuilder::DetIdListTimeAndStatus::isHV
std::vector< unsigned int > isHV
Definition: SiStripDetVOffBuilder.h:151
dqmdumpme.last
last
Definition: dqmdumpme.py:56
SiStripDetVOffBuilder::lastValue
void lastValue(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:653
SiStripDetVOffBuilder::modulesOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
Definition: SiStripDetVOffBuilder.h:114
SiStripDetVOffBuilder::tDefault
std::vector< int > tDefault
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::TimesAndValues::actualStatus
std::vector< int > actualStatus
Definition: SiStripDetVOffBuilder.h:141
Service.h
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
SiStripDetVOffBuilder::highVoltageOnThreshold_
double highVoltageOnThreshold_
Definition: SiStripDetVOffBuilder.h:132
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
SiStripDetInfoFileReader.h
SiStripDetVOffBuilder::DetIdListTimeAndStatus::detidV
DetIdTimeStampVector detidV
Definition: SiStripDetVOffBuilder.h:147
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripDetVOffBuilder::reduction
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
Definition: SiStripDetVOffBuilder.cc:590
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripDetVOffBuilder::authenticationPath
std::string authenticationPath
Definition: SiStripDetVOffBuilder.h:119
SiStripCondDataRecords.h
SiStripCoralIface.h
SiStripDetVOffBuilder::TimesAndValues::dpid
std::vector< uint32_t > dpid
Definition: SiStripDetVOffBuilder.h:140
SiStripDetVOffBuilder::BuildDetVOffObj
void BuildDetVOffObj()
Definition: SiStripDetVOffBuilder.cc:98
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
SiStripDetVOffBuilder::tmax
coral::TimeStamp tmax
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOff
Definition: SiStripDetVOff.h:31
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SiStripDetVOffBuilder::tmax_par
std::vector< int > tmax_par
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::whichTable
std::string whichTable
Definition: SiStripDetVOffBuilder.h:120
SiStripDetVOffBuilder::onlineDbConnectionString
std::string onlineDbConnectionString
Definition: SiStripDetVOffBuilder.h:118
SiStripDetVOffBuilder::timeToStream
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
Definition: SiStripDetVOffBuilder.cc:742
SiStripDetVOffBuilder::maxIOVlength_
uint32_t maxIOVlength_
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::getCondTime
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
Definition: SiStripDetVOffBuilder.cc:469
SiStripDetVOffBuilder::deltaTmin_
uint32_t deltaTmin_
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::payloadStats
std::vector< std::vector< uint32_t > > payloadStats
Definition: SiStripDetVOffBuilder.h:113
SiStripDetVOffBuilder::extractDetIdVector
std::pair< int, int > extractDetIdVector(const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
Definition: SiStripDetVOffBuilder.cc:1274
SiStripDetVOffBuilder::tmin
coral::TimeStamp tmin
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::buildPSUdetIdMap
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
Definition: SiStripDetVOffBuilder.cc:764
SiStripDetVOffBuilder::DetIdListTimeAndStatus::DetIdListTimeAndStatus
DetIdListTimeAndStatus()
Definition: SiStripDetVOffBuilder.h:146
SiStripDetVOffBuilder::fromFile
bool fromFile
Definition: SiStripDetVOffBuilder.h:122
SiStripDetVOffBuilder::TimesAndValues::changeDate
std::vector< coral::TimeStamp > changeDate
Definition: SiStripDetVOffBuilder.h:137
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:528
SiStripDetVOffBuilder::debug_
bool debug_
Definition: SiStripDetVOffBuilder.h:124
SiStripDetVOffBuilder::excludedDetIdListFile_
std::string excludedDetIdListFile_
Definition: SiStripDetVOffBuilder.h:130
SiStripDetVOffBuilder::coralInterface
std::unique_ptr< SiStripCoralIface > coralInterface
Definition: SiStripDetVOffBuilder.h:165
EventSetup.h
SiStripDetVOffBuilder::tmin_par
std::vector< int > tmin_par
Definition: SiStripDetVOffBuilder.h:126
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:326
SiStripDetVOff.h
SiStripDetVOffBuilder::setPayloadStats
void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
Definition: SiStripDetVOffBuilder.cc:1266
SiStripDetVOffBuilder::psuDetIdMapFile_
std::string psuDetIdMapFile_
Definition: SiStripDetVOffBuilder.h:123
SiStripDetVOffBuilder::tsetmin
coral::TimeStamp tsetmin
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::getModulesVOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
Definition: SiStripDetVOffBuilder.h:47
SiStripDetVOffBuilder::TestSiStripDetVOffBuilder
friend class TestSiStripDetVOffBuilder
Definition: SiStripDetVOffBuilder.h:37
SiStripDetVOffBuilder::DetIdListTimeAndStatus::notMatched
unsigned int notMatched
Definition: SiStripDetVOffBuilder.h:149