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 
12 
15 // #include "CalibTracker/SiStripDCS/interface/SiStripPsuDetIdMapFromFile.h"
16 
17 #include "CoralBase/TimeStamp.h"
20 //#include "DataFormats/Provenance/interface/Timestamp.h"
21 
22 #include <fstream>
23 #include <iostream>
24 #include <memory>
25 
32 // Unit test class for SiStripDetVOffBuilder
33 class TestSiStripDetVOffBuilder;
34 
37 
38 public:
44  void BuildDetVOffObj();
46  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > getModulesVOff() {
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,
69  const unsigned int first);
71 
72 private:
73  // typedefs
74  typedef std::vector<std::pair<std::vector<uint32_t>, coral::TimeStamp> > DetIdTimeStampVector;
75 
76  bool whichQuery;
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;
127 
130  // Threshold to consider a high voltage channel on
132 
133  // Structure used to store variables needed when building the database objects
134  struct TimesAndValues {
136  std::vector<coral::TimeStamp> changeDate; // used by both
137  std::vector<std::string> dpname; // only used by DB access, not file access
138  std::vector<float> actualValue; // only used by DB access, not file access
139  std::vector<uint32_t> dpid; // only used by file access
140  std::vector<int> actualStatus; // filled using actualValue info
141  cond::Time_t latestTime; // used for timestamp when using lastValue from file
142  };
143 
147  std::vector<bool> StatusGood;
148  unsigned int notMatched;
149  std::vector<std::string> psuName;
150  std::vector<unsigned int> isHV;
151  };
152 
153  void statusChange(cond::Time_t& lastTime, TimesAndValues& tStruct);
154  void lastValue(TimesAndValues& tStruct);
155  void lastValueFromFile(TimesAndValues& tStruct);
156 
157  void buildPSUdetIdMap(TimesAndValues& tStruct, DetIdListTimeAndStatus& dStruct);
158 
159  void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved);
160  std::pair<int, int> extractDetIdVector(const unsigned int i,
161  SiStripDetVOff* modV,
162  DetIdListTimeAndStatus& detIdStruct);
163 
164  std::unique_ptr<SiStripCoralIface> coralInterface;
165 };
166 #endif
SiStripDetVOffBuilder::readLastValueFromFile
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
Definition: SiStripDetVOffBuilder.cc:398
SiStripDetVOffBuilder::getPayloadStats
std::vector< std::vector< uint32_t > > getPayloadStats()
Definition: SiStripDetVOffBuilder.h:51
SiStripDetVOffBuilder
Builds the SiStripDetVOff object for transfer by O2O.
Definition: SiStripDetVOffBuilder.h:35
SiStripDetVOffBuilder::FileExists
bool FileExists(std::string filename)
Definition: SiStripDetVOffBuilder.cc:745
SiStripDetVOffBuilder::TimesAndValues::latestTime
cond::Time_t latestTime
Definition: SiStripDetVOffBuilder.h:141
SiStripDetVOffBuilder::whichQuery
bool whichQuery
Definition: SiStripDetVOffBuilder.h:76
SiStripDetVOffBuilder::lastValueFileName
std::string lastValueFileName
Definition: SiStripDetVOffBuilder.h:120
SiStripDetVOffBuilder::detIdListFile_
std::string detIdListFile_
Definition: SiStripDetVOffBuilder.h:128
SiStripDetVOffBuilder::SiStripDetVOffBuilder
SiStripDetVOffBuilder(const edm::ParameterSet &, const edm::ActivityRegistry &)
Definition: SiStripDetVOffBuilder.cc:8
mps_fire.i
i
Definition: mps_fire.py:428
SiStripDetVOffBuilder::TimesAndValues::actualValue
std::vector< float > actualValue
Definition: SiStripDetVOffBuilder.h:138
MessageLogger.h
SiStripDetVOffBuilder::getCoralTime
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
Definition: SiStripDetVOffBuilder.cc:475
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:562
SiStripDetVOffBuilder::tset_par
std::vector< int > tset_par
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::TimesAndValues::dpname
std::vector< std::string > dpname
Definition: SiStripDetVOffBuilder.h:137
SiStripDetVOffBuilder::~SiStripDetVOffBuilder
~SiStripDetVOffBuilder()
Definition: SiStripDetVOffBuilder.cc:89
SiStripDetVOffBuilder::lastStoredCondObj
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
Definition: SiStripDetVOffBuilder.h:114
Time.h
SiStripDetVOffBuilder::statusChange
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:627
SiStripDetVOffBuilder::TimesAndValues
Definition: SiStripDetVOffBuilder.h:134
SiStripDetVOffBuilder::findMostRecentTimeStamp
cond::Time_t findMostRecentTimeStamp(const std::vector< coral::TimeStamp > &coralDate)
Definition: SiStripDetVOffBuilder.cc:505
SiStripDetVOffBuilder::printPar
void printPar(std::stringstream &ss, const std::vector< int > &par)
Definition: SiStripDetVOffBuilder.cc:93
SiStripPsuDetIdMap.h
SiStripDetVOffBuilder::removeDuplicates
void removeDuplicates(std::vector< uint32_t > &vec)
Definition: SiStripDetVOffBuilder.cc:494
SiStripDetVOffBuilder::lastValueFromFile
void lastValueFromFile(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:689
SiStripDetVOffBuilder::setLastSiStripDetVOff
void setLastSiStripDetVOff(SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
Definition: SiStripDetVOffBuilder.cc:500
SiStripDetVOffBuilder::DetIdTimeStampVector
std::vector< std::pair< std::vector< uint32_t >, coral::TimeStamp > > DetIdTimeStampVector
Definition: SiStripDetVOffBuilder.h:74
SiStripDetVOffBuilder::DetIdListTimeAndStatus
Definition: SiStripDetVOffBuilder.h:144
SiStripDetVOffBuilder::DetIdListTimeAndStatus::psuName
std::vector< std::string > psuName
Definition: SiStripDetVOffBuilder.h:149
SiStripDetVOffBuilder::TimesAndValues::TimesAndValues
TimesAndValues()
Definition: SiStripDetVOffBuilder.h:135
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripDetVOffBuilder::DetIdListTimeAndStatus::StatusGood
std::vector< bool > StatusGood
Definition: SiStripDetVOffBuilder.h:147
SiStripDetVOffBuilder::DetIdListTimeAndStatus::isHV
std::vector< unsigned int > isHV
Definition: SiStripDetVOffBuilder.h:150
dqmdumpme.last
last
Definition: dqmdumpme.py:56
SiStripDetVOffBuilder::lastValue
void lastValue(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:649
SiStripDetVOffBuilder::modulesOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
Definition: SiStripDetVOffBuilder.h:113
SiStripDetVOffBuilder::tDefault
std::vector< int > tDefault
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::TimesAndValues::actualStatus
std::vector< int > actualStatus
Definition: SiStripDetVOffBuilder.h:140
Service.h
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
SiStripDetVOffBuilder::highVoltageOnThreshold_
double highVoltageOnThreshold_
Definition: SiStripDetVOffBuilder.h:131
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
SiStripDetVOffBuilder::DetIdListTimeAndStatus::detidV
DetIdTimeStampVector detidV
Definition: SiStripDetVOffBuilder.h:146
SiStripDetVOffBuilder::reduction
void reduction(const uint32_t deltaTmin, const uint32_t maxIOVlength)
Definition: SiStripDetVOffBuilder.cc:586
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripDetVOffBuilder::authenticationPath
std::string authenticationPath
Definition: SiStripDetVOffBuilder.h:118
SiStripCondDataRecords.h
SiStripCoralIface.h
SiStripDetVOffBuilder::TimesAndValues::dpid
std::vector< uint32_t > dpid
Definition: SiStripDetVOffBuilder.h:139
SiStripDetVOffBuilder::BuildDetVOffObj
void BuildDetVOffObj()
Definition: SiStripDetVOffBuilder.cc:99
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
SiStripDetVOffBuilder::tmax
coral::TimeStamp tmax
Definition: SiStripDetVOffBuilder.h:124
SiStripDetVOff
Definition: SiStripDetVOff.h:31
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SiStripDetVOffBuilder::tmax_par
std::vector< int > tmax_par
Definition: SiStripDetVOffBuilder.h:125
SiStripDetVOffBuilder::whichTable
std::string whichTable
Definition: SiStripDetVOffBuilder.h:119
SiStripDetVOffBuilder::onlineDbConnectionString
std::string onlineDbConnectionString
Definition: SiStripDetVOffBuilder.h:117
SiStripDetVOffBuilder::timeToStream
std::string timeToStream(const coral::TimeStamp &coralTime, const string &comment="")
Definition: SiStripDetVOffBuilder.cc:738
SiStripDetVOffBuilder::maxIOVlength_
uint32_t maxIOVlength_
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::getCondTime
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
Definition: SiStripDetVOffBuilder.cc:465
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripDetVOffBuilder::deltaTmin_
uint32_t deltaTmin_
Definition: SiStripDetVOffBuilder.h:126
SiStripDetVOffBuilder::payloadStats
std::vector< std::vector< uint32_t > > payloadStats
Definition: SiStripDetVOffBuilder.h:112
SiStripDetVOffBuilder::extractDetIdVector
std::pair< int, int > extractDetIdVector(const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
Definition: SiStripDetVOffBuilder.cc:1270
SiStripDetVOffBuilder::tmin
coral::TimeStamp tmin
Definition: SiStripDetVOffBuilder.h:124
SiStripDetVOffBuilder::buildPSUdetIdMap
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
Definition: SiStripDetVOffBuilder.cc:760
SiStripDetVOffBuilder::DetIdListTimeAndStatus::DetIdListTimeAndStatus
DetIdListTimeAndStatus()
Definition: SiStripDetVOffBuilder.h:145
SiStripDetVOffBuilder::fromFile
bool fromFile
Definition: SiStripDetVOffBuilder.h:121
SiStripDetVOffBuilder::TimesAndValues::changeDate
std::vector< coral::TimeStamp > changeDate
Definition: SiStripDetVOffBuilder.h:136
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:524
SiStripDetVOffBuilder::debug_
bool debug_
Definition: SiStripDetVOffBuilder.h:123
SiStripDetVOffBuilder::excludedDetIdListFile_
std::string excludedDetIdListFile_
Definition: SiStripDetVOffBuilder.h:129
SiStripDetVOffBuilder::coralInterface
std::unique_ptr< SiStripCoralIface > coralInterface
Definition: SiStripDetVOffBuilder.h:164
EventSetup.h
SiStripDetVOffBuilder::tmin_par
std::vector< int > tmin_par
Definition: SiStripDetVOffBuilder.h:125
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:322
SiStripDetVOff.h
SiStripDetVOffBuilder::setPayloadStats
void setPayloadStats(const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
Definition: SiStripDetVOffBuilder.cc:1262
SiStripDetVOffBuilder::psuDetIdMapFile_
std::string psuDetIdMapFile_
Definition: SiStripDetVOffBuilder.h:122
SiStripDetVOffBuilder::tsetmin
coral::TimeStamp tsetmin
Definition: SiStripDetVOffBuilder.h:124
SiStripDetVOffBuilder::getModulesVOff
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff()
Definition: SiStripDetVOffBuilder.h:46
SiStripDetVOffBuilder::TestSiStripDetVOffBuilder
friend class TestSiStripDetVOffBuilder
Definition: SiStripDetVOffBuilder.h:36
SiStripDetVOffBuilder::DetIdListTimeAndStatus::notMatched
unsigned int notMatched
Definition: SiStripDetVOffBuilder.h:148