CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
SiStripDetVOffBuilder Class Reference

Builds the SiStripDetVOff object for transfer by O2O. More...

#include <SiStripDetVOffBuilder.h>

Classes

struct  DetIdListTimeAndStatus
 
struct  TimesAndValues
 

Public Member Functions

void BuildDetVOffObj ()
 
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. More...
 
bool FileExists (std::string filename)
 
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > getModulesVOff ()
 
std::vector< std::vector< uint32_t > > getPayloadStats ()
 
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. More...
 
void reduction (const uint32_t deltaTmin, const uint32_t maxIOVlength)
 
void setLastSiStripDetVOff (SiStripDetVOff *lastPayload, cond::Time_t lastTimeStamp)
 
 SiStripDetVOffBuilder (const edm::ParameterSet &, const edm::ActivityRegistry &)
 
 ~SiStripDetVOffBuilder ()
 

Private Types

typedef std::vector< std::pair< std::vector< uint32_t >, coral::TimeStamp > > DetIdTimeStampVector
 

Private Member Functions

void buildPSUdetIdMap (TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
 
std::pair< int, int > extractDetIdVector (const unsigned int i, SiStripDetVOff *modV, DetIdListTimeAndStatus &detIdStruct)
 
cond::Time_t findMostRecentTimeStamp (const std::vector< coral::TimeStamp > &coralDate)
 
int findSetting (std::string dpname, const coral::TimeStamp &changeDate, const std::vector< std::string > &settingDpname, const std::vector< coral::TimeStamp > &settingDate)
 
int findSetting (uint32_t id, const coral::TimeStamp &changeDate, const std::vector< uint32_t > &settingID, const std::vector< coral::TimeStamp > &settingDate)
 
cond::Time_t getCondTime (const coral::TimeStamp &coralTime)
 
coral::TimeStamp getCoralTime (cond::Time_t iovTime)
 
void lastValue (TimesAndValues &tStruct)
 
void lastValueFromFile (TimesAndValues &tStruct)
 
void printPar (std::stringstream &ss, const std::vector< int > &par)
 
void readLastValueFromFile (std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
 
void removeDuplicates (std::vector< uint32_t > &vec)
 
void setPayloadStats (const uint32_t afterV, const uint32_t numAdded, const uint32_t numRemoved)
 
void statusChange (cond::Time_t &lastTime, TimesAndValues &tStruct)
 
std::string timeToStream (const cond::Time_t &condTime, const string &comment="")
 
std::string timeToStream (const coral::TimeStamp &coralTime, const string &comment="")
 

Private Attributes

std::string authenticationPath
 
std::unique_ptr< SiStripCoralIfacecoralInterface
 
bool debug_
 
uint32_t deltaTmin_
 
std::string detIdListFile_
 
std::string excludedDetIdListFile_
 
bool fromFile
 
double highVoltageOnThreshold_
 
std::pair< SiStripDetVOff *, cond::Time_tlastStoredCondObj
 
std::string lastValueFileName
 
uint32_t maxIOVlength_
 
std::vector< std::pair< SiStripDetVOff *, cond::Time_t > > modulesOff
 
std::string onlineDbConnectionString
 
std::vector< std::vector< uint32_t > > payloadStats
 
std::string psuDetIdMapFile_
 
std::vector< int > tDefault
 
coral::TimeStamp tmax
 
std::vector< int > tmax_par
 
coral::TimeStamp tmin
 
std::vector< int > tmin_par
 
std::vector< int > tset_par
 
coral::TimeStamp tsetmin
 
bool whichQuery
 
std::string whichTable
 

Friends

class TestSiStripDetVOffBuilder
 

Detailed Description

Builds the SiStripDetVOff object for transfer by O2O.

Author
J.Cole modified by Marco De Mattia

Definition at line 36 of file SiStripDetVOffBuilder.h.

Member Typedef Documentation

◆ DetIdTimeStampVector

typedef std::vector<std::pair<std::vector<uint32_t>, coral::TimeStamp> > SiStripDetVOffBuilder::DetIdTimeStampVector
private

Definition at line 75 of file SiStripDetVOffBuilder.h.

Constructor & Destructor Documentation

◆ ~SiStripDetVOffBuilder()

SiStripDetVOffBuilder::~SiStripDetVOffBuilder ( )

Destructor.

Definition at line 88 of file SiStripDetVOffBuilder.cc.

88  {
89  edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: destructing ...";
90 }

◆ SiStripDetVOffBuilder()

SiStripDetVOffBuilder::SiStripDetVOffBuilder ( const edm::ParameterSet pset,
const edm::ActivityRegistry  
)

Default constructor.

Definition at line 7 of file SiStripDetVOffBuilder.cc.

8  : onlineDbConnectionString(pset.getParameter<std::string>("onlineDB")),
9  authenticationPath(pset.getParameter<std::string>("authPath")),
10  whichTable(pset.getParameter<std::string>("queryType")),
11  lastValueFileName(pset.getParameter<std::string>("lastValueFile")),
12  fromFile(pset.getParameter<bool>("lastValueFromFile")),
13  psuDetIdMapFile_(pset.getParameter<std::string>("PsuDetIdMapFile")),
14  debug_(pset.getParameter<bool>("debugModeOn")),
15  tDefault(7, 0),
16  tmax_par(pset.getParameter<std::vector<int> >("Tmax")),
17  tmin_par(pset.getParameter<std::vector<int> >("Tmin")),
18  tset_par(pset.getParameter<std::vector<int> >("TSetMin")),
19  deltaTmin_(pset.getParameter<uint32_t>("DeltaTmin")),
20  maxIOVlength_(pset.getParameter<uint32_t>("MaxIOVlength")),
21  detIdListFile_(pset.getParameter<std::string>("DetIdListFile")),
22  excludedDetIdListFile_(pset.getParameter<std::string>("ExcludedDetIdListFile")),
23  highVoltageOnThreshold_(pset.getParameter<double>("HighVoltageOnThreshold")) {
24  lastStoredCondObj.first = nullptr;
25  lastStoredCondObj.second = 0;
26 
27  edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] constructor" << endl;
28 
29  // set up vectors based on pset parameters (tDefault purely for initialization)
30 
31  whichQuery = (whichTable == "STATUSCHANGE" || (whichTable == "LASTVALUE" && !fromFile));
32 
33  //Define the query interval [Tmin, Tmax]
34  //where Tmax comes from the cfg
35  // Tmin comes from the cfg for the first o2o, after that it is extracted from Offline DB
36 
37  tmax = coral::TimeStamp(tmax_par[0], tmax_par[1], tmax_par[2], tmax_par[3], tmax_par[4], tmax_par[5], tmax_par[6]);
38 
39  if (whichQuery) {
40  // Is there a better way to do this? TODO - investigate
41  tmin = coral::TimeStamp(tmin_par[0], tmin_par[1], tmin_par[2], tmin_par[3], tmin_par[4], tmin_par[5], tmin_par[6]);
42  }
43 
44  if (whichTable == "LASTVALUE") {
45  tsetmin =
46  coral::TimeStamp(tset_par[0], tset_par[1], tset_par[2], tset_par[3], tset_par[4], tset_par[5], tset_par[6]);
47  }
48 
49  if (onlineDbConnectionString.empty()) {
50  edm::LogError("SiStripDetVOffBuilder")
51  << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
52  return;
53  }
54 
55  if (fromFile && whichTable == "LASTVALUE" && lastValueFileName.empty()) {
56  edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for "
57  "lastValue table, but filename not specified ... Returning ...";
58  return;
59  }
60 
61  // write out the parameters
62  std::stringstream ss;
63  ss << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder]\n"
64  << " Parameters:\n"
65  << " DB connection string: " << onlineDbConnectionString << "\n"
66  << " Authentication path: " << authenticationPath << "\n"
67  << " Table to be queried: " << whichTable << "\n"
68  << " MapFile: " << psuDetIdMapFile_ << "\n";
69 
70  if (whichQuery) {
71  ss << " Tmin: ";
73  ss << std::endl;
74  }
75  ss << " Tmax: ";
77  ss << std::endl;
78 
79  if (whichTable == "LASTVALUE") {
80  ss << " TSetMin: ";
82  ss << std::endl;
83  }
84  edm::LogError("SiStripDetVOffBuilder") << ss.str();
85 }

References authenticationPath, fromFile, lastStoredCondObj, lastValueFileName, onlineDbConnectionString, printPar(), psuDetIdMapFile_, contentValuesCheck::ss, tmax, tmax_par, tmin, tmin_par, tset_par, tsetmin, whichQuery, and whichTable.

Member Function Documentation

◆ BuildDetVOffObj()

void SiStripDetVOffBuilder::BuildDetVOffObj ( )

Build the SiStripDetVOff object for transfer.

Definition at line 98 of file SiStripDetVOffBuilder.cc.

98  {
99  // vectors for storing output from DB or text file
100  TimesAndValues timesAndValues;
101 
102  // Open the PVSS DB connection
103  coralInterface = std::make_unique<SiStripCoralIface>(onlineDbConnectionString, authenticationPath, debug_);
104  edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Query type is " << whichTable
105  << endl;
106 
107  if (whichTable == "LASTVALUE") {
108  edm::LogError("SiStripDetVOffBuilder")
109  << "[SiStripDetVOffBuilder::BuildDetVOff]: Use file? " << ((fromFile) ? "TRUE" : "FALSE");
110  }
111 
112  if (lastStoredCondObj.second > 0) {
113  edm::LogError("SiStripDetVOffBuilder")
114  << "[SiStripDetVOffBuilder::BuildDetVOff]: retrieved last time stamp from DB: " << lastStoredCondObj.second
115  << endl;
116  }
117  // access the information!
118  //We've been using the STATUSCHANGE query only in last year or so... LASTVALUE may have untested issues...
119  //In either case the idea is that the results of the query are saved into the timesAndValues struct
120  //ready to be anaylized (i.e. translated into detIDs, HV/LV statuses)
121 
122  if (whichQuery) {
123  if (whichTable == "STATUSCHANGE") {
124  statusChange(lastStoredCondObj.second, timesAndValues);
125  }
126  if (whichTable == "LASTVALUE") {
127  if (fromFile) {
128  lastValueFromFile(timesAndValues);
129  } else {
130  lastValue(timesAndValues);
131  }
132  }
133  }
134 
135  //Initialize the stuct that will be used to keep the detID-translated information
136  DetIdListTimeAndStatus dStruct;
137 
138  // build PSU - det ID map
139  //The following method actually "builds" 4 maps: LVMap, HVMap, HVUnmapped_Map, HVCrosstalking_Map.
140  //It also takes the timesAndValues from the query above and using the maps, it processes the information
141  //populating the DetIDListTimeAndStatus struct that will hold the information by detid.
142  buildPSUdetIdMap(timesAndValues, dStruct);
143 
144  // initialize variables
145  modulesOff.clear();
146  cond::Time_t saveIovTime = 0;
147 
148  // - If there is already an object stored in the database
149  // -- store it in the modulesOff vector
150  // -- set the saveIovTime as that
151  // -- set the payload stats to empty
152  // Successivamente:
153  // - loop su tutti gli elementi del detidV, che stato letto dal pvss (questi elementi sono pair<vettore di detid, time>)
154  // -- setta il tempo dell'IOV:
155  // --- LASTVALUE -> iovtime settato a latestTime
156  // --- altrimenti iovtime = tempo associato al detId vector del loop
157 
158  // check if there is already an object stored in the DB
159  // This happens only if you are using STATUSCHANGE
160  if (lastStoredCondObj.first != nullptr && lastStoredCondObj.second > 0) {
161  modulesOff.push_back(lastStoredCondObj);
162  saveIovTime = lastStoredCondObj.second;
163  setPayloadStats(0, 0, 0);
164  }
165 
166  //Master loop over all the results of the query stored in the dStruct (that contains vectors with vectors of detids, statuses, isHV flags, etc and in particular a vector of timestamps for which the info is valid... basically it is a loop over the timestamps (i.e. IOVs).
167  for (unsigned int i = 0; i < dStruct.detidV.size(); i++) {
168  // std::vector<uint32_t> detids = dStruct.detidV[i].first;
169  // removeDuplicates(detids);
170  std::vector<uint32_t>* detids = &(dStruct.detidV[i].first);
171 
172  // set the condition time for the transfer
173  cond::Time_t iovtime = 0;
174 
175  if (whichTable == "LASTVALUE") {
176  iovtime = timesAndValues.latestTime;
177  }
178 
179  else {
180  iovtime = getCondTime((dStruct.detidV[i]).second);
181  }
182 
183  // decide how to initialize modV
184  SiStripDetVOff* modV = nullptr;
185 
186  // When using STATUSCHANGE they are equal only for the first
187  // When using LASTVALUE they are equal only if the tmin was set to tsetmin
188 
189  if (iovtime != saveIovTime) { // time is different, so create new object
190 
191  // This can be only when using LASTVALUE or with a new tag
192  if (modulesOff.empty()) {
193  // create completely new object and set the initial state to Tracker all off
194  modV = new SiStripDetVOff();
195 
196  // Use the file
198  SiStripDetInfoFileReader reader(fp.fullPath());
199  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>& detInfos = reader.getAllData();
200 
201  //FIXME:
202  //Following code is actually broken (well not until the cfg has "" for excludedDetIDListFile parameter!
203  //Fix it if felt necessary (remember that it assumes that whatever detids are excluded should NOT be in the regular map
204  //breaking our current situation with a fully mapped (LV-wise) tracker...
205  // Careful: if a module is in the exclusion list it must be ignored and the initial status is set to ON.
206  // These modules are expected to not be in the PSU-DetId map, so they will never get any status change from the query.
208  std::vector<std::pair<uint32_t, std::string> > excludedDetIdMap;
209  if (!excludedDetIdListFile_.empty()) {
210  map.BuildMap(excludedDetIdListFile_, excludedDetIdMap);
211  }
212  for (std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = detInfos.begin();
213  it != detInfos.end();
214  ++it) {
215  std::vector<std::pair<uint32_t, std::string> >::const_iterator exclIt = excludedDetIdMap.begin();
216  bool excluded = false;
217  for (; exclIt != excludedDetIdMap.end(); ++exclIt) {
218  if (it->first == exclIt->first) {
219  excluded = true;
220  break;
221  }
222  }
223  if (!excluded) {
224  modV->put(it->first, 1, 1);
225  }
226  }
227 
228  } else {
229  modV = new SiStripDetVOff(*(modulesOff.back().first));
230  } // start from copy of previous object
231  } else {
232  modV =
233  (modulesOff.back())
234  .first; // modify previous object (TEST THIS if possible! it's fundamental in handling changes at the edges of O2O executions and also in case of PVSS DB buffering!
235  }
236 
237  // extract the detID vector before modifying for stats calculation
238  std::vector<uint32_t> beforeV;
239  modV->getDetIds(beforeV);
240 
241  //CHECKTHIS
242  //The following method call is potentially problematic:
243  //passing modV as argument while extracting information about dStruct,
244  //modV is not currently used in the method!
245  std::pair<int, int> hvlv = extractDetIdVector(
246  i, modV, dStruct); //Returns a pair like this HV OFF->1,-1 HV ON->0,-1 LV OFF->-1,1 LV ON->-1,0
247  //Basically a LV OFF of -1 means that the information (IOV) in question is from an HV channel turning on or off and viceversa for an HVOFF of -1.
248  //This could be confusing when reading the debug output!
249 
250  for (unsigned int j = 0; j < detids->size(); j++) {
251  if (debug_)
252  cout << "at time = " << iovtime << " detid[" << j << "] = " << (*detids)[j] << " has hv = " << hvlv.first
253  << " and lv = " << hvlv.second << endl;
254  modV->put((*detids)[j], hvlv.first, hvlv.second);
255  }
256 
257  // calculate the stats for storage
258  unsigned int numAdded = 0, numRemoved = 0;
259  if (iovtime == saveIovTime) {
260  std::vector<uint32_t> oldStats = payloadStats.back();
261  numAdded = oldStats[1];
262  numRemoved = oldStats[2];
263  }
264  std::vector<uint32_t> afterV;
265  modV->getDetIds(afterV);
266 
267  if ((afterV.size() - beforeV.size()) > 0) {
268  numAdded += afterV.size() - beforeV.size();
269  } else if ((beforeV.size() - afterV.size()) > 0) {
270  numRemoved += beforeV.size() - afterV.size();
271  }
272 
273  // store the object if it's a new object
274  if (iovtime != saveIovTime) {
275  SiStripDetVOff* testV = nullptr;
276  if (!modulesOff.empty()) {
277  testV = modulesOff.back().first;
278  }
279  if (modulesOff.empty() || !(*modV == *testV)) {
280  modulesOff.push_back(std::make_pair(modV, iovtime));
281  // save the time of the object
282  saveIovTime = iovtime;
283  // save stats
284  setPayloadStats(afterV.size(), numAdded, numRemoved);
285  } else {
286  // modV will not be used anymore, DELETE it to avoid memory leak!
287  delete modV;
288  }
289  } else {
290  (payloadStats.back())[0] = afterV.size();
291  (payloadStats.back())[1] = numAdded;
292  (payloadStats.back())[2] = numRemoved;
293  }
294  }
295 
296  // compare the first element and the last from previous transfer
297  if (lastStoredCondObj.first != nullptr && lastStoredCondObj.second > 0) {
298  if (*(lastStoredCondObj.first) == *(modulesOff[0].first)) {
299  if (modulesOff.size() == 1) {
300  // if no HV/LV transition was found in this period: update the last IOV to be tmax
301  modulesOff[0].second = getCondTime(tmax);
302  } else {
303  // HV/LV transitions found: remove the first one (which came from previous transfer)
304  modulesOff.erase(modulesOff.begin());
305  payloadStats.erase(payloadStats.begin());
306  }
307  }
308  }
309 
310  if (debug_) {
311  std::cout << std::endl;
312  std::cout << "Size of modulesOff = " << modulesOff.size() << std::endl;
313  for (unsigned int i = 0; i < modulesOff.size(); i++) {
314  std::vector<uint32_t> finalids;
315  (modulesOff[i].first)->getDetIds(finalids);
316  std::cout << "Index = " << i << " Size of DetIds vector = " << finalids.size() << std::endl;
317  std::cout << "Time = " << modulesOff[i].second << std::endl;
318  for (unsigned int j = 0; j < finalids.size(); j++) {
319  std::cout << "detid = " << finalids[j] << " LV off = " << (modulesOff[i].first)->IsModuleLVOff(finalids[j])
320  << " HV off = " << (modulesOff[i].first)->IsModuleHVOff(finalids[j]) << std::endl;
321  }
322  }
323  }
324 }

References authenticationPath, buildPSUdetIdMap(), coralInterface, gather_cfg::cout, debug_, detIdListFile_, SiStripDetVOffBuilder::DetIdListTimeAndStatus::detidV, excludedDetIdListFile_, extractDetIdVector(), first, personalPlayback::fp, fromFile, getCondTime(), SiStripDetVOff::getDetIds(), mps_fire::i, dqmiolumiharvest::j, lastStoredCondObj, lastValue(), lastValueFromFile(), SiStripDetVOffBuilder::TimesAndValues::latestTime, genParticles_cff::map, modulesOff, onlineDbConnectionString, payloadStats, SiStripDetVOff::put(), DQM::reader, setPayloadStats(), statusChange(), tmax, whichQuery, and whichTable.

Referenced by SiStripDetVOffHandler::analyze().

◆ buildPSUdetIdMap()

void SiStripDetVOffBuilder::buildPSUdetIdMap ( TimesAndValues tStruct,
DetIdListTimeAndStatus dStruct 
)
private

Definition at line 764 of file SiStripDetVOffBuilder.cc.

769 {
770  SiStripPsuDetIdMap map_;
771  if (psuDetIdMapFile_.empty()) {
772  std::cout << "PLEASE provide the name of a valid PSUDetIDMapFile in the cfg: currently still necessary to have a "
773  "file, soon will access the info straight from the DB!"
774  << endl;
775  //map_.BuildMap();//This method is not currently used (it would try to build a map based on a query to SiStripConfigDB, and the info there is STALE!)
776  } else {
777  map_.BuildMap(psuDetIdMapFile_, debug_); //This is the method used to build the map.
778  }
779  LogTrace("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff] PSU(Channel)-detID map(s) built";
780  //Following method to be replaced by printMaps... to print all 4 maps built!
781  map_.printMap(); //This method prints to the info.log file, notice that it is overwritten by each individual O2O job running in the same dir.
782 
783  // use map info to build input for list of objects
784  // no need to check for duplicates, as put method for SiStripDetVOff checks for you!
785 
786  //Debug variables
787  unsigned int ch0bad = 0, ch1bad = 0, ch2bad = 0, ch3bad = 0;
788  std::vector<unsigned int> numLvBad, numHvBad;
789 
790  //Create 2 extra maps that we'll use to keep track of unmapped and crosstalking detids when turning ON and OFF HV:
791  //-unmapped need to be both turned OFF when any HV goes OFF and to be turned ON when both are ON
792  //-crosstaling need to be both turned ON when any HV goes ON and to be turned OFF ONLY when BOTH are OFF.
793  std::map<std::string, bool> UnmappedState, CrosstalkingState;
794  //Get the HVUnmapped map from the map, so that we can set know which PSU are unmapped:
795  std::map<std::string, std::vector<uint32_t> > UnmappedPSUs = map_.getHVUnmappedMap();
796  //Check here if there is a file already, otherwise initialize to OFF all channels in these PSU!
797  if (FileExists("HVUnmappedChannelState.dat")) {
798  std::cout << "File HVUnmappedChannelState.dat exists!" << std::endl;
799  std::ifstream ifs("HVUnmappedChannelState.dat");
800  string line;
801  while (getline(ifs, line)) {
802  if (!line.empty()) {
803  // split the line and insert in the map
804  stringstream ss(line);
805  string PSUChannel;
806  bool HVStatus;
807  ss >> PSUChannel;
808  ss >> HVStatus;
809  //Extract the PSU from the PSUChannel (since the HVUnmapped_Map uses PSU as key
810  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
811  //Look for the PSU in the unmapped map!
812  std::map<std::string, std::vector<uint32_t> >::iterator iter = UnmappedPSUs.find(PSU);
813  if (iter != UnmappedPSUs.end()) {
814  UnmappedState[PSUChannel] = HVStatus;
815  } else {
816  std::cout << "WARNING!!! There are channels in the local file with the channel status for HVUnmapped "
817  "channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"
818  << std::endl;
819  }
820  }
821  } //End of the while loop reading and initializing UnmappedState map from file
822  //Extra check:
823  //Should check if there any HVUnmapped channels in the map that are not listed in the local file!
824  bool MissingChannels = false;
825  for (std::map<std::string, vector<uint32_t> >::iterator it = UnmappedPSUs.begin(); it != UnmappedPSUs.end(); it++) {
826  std::string chan002 = it->first + "channel002";
827  std::string chan003 = it->first + "channel003";
828  std::map<std::string, bool>::iterator iter = UnmappedState.find(chan002);
829  if (iter == UnmappedState.end()) {
830  std::cout << "ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the "
831  "following unmapped channel voltage status information:"
832  << std::endl;
833  std::cout << chan002 << std::endl;
834  MissingChannels = true;
835  }
836  iter = UnmappedState.find(chan003);
837  if (iter == UnmappedState.end()) {
838  std::cout << "ERROR! The local file with the channel status for HVUnmapped channels IS MISSING one of the "
839  "following unmapped channel voltage status information:"
840  << std::endl;
841  std::cout << chan003 << std::endl;
842  MissingChannels = true;
843  }
844  }
845  //Now if any channel WAS missing, exit!
846  if (MissingChannels) {
847  std::cout << "!!!!\n"
848  << "Exiting now... please check the local HVUnmappedChannelState.dat and the mapfile you provided ("
849  << psuDetIdMapFile_ << ")" << std::endl;
850  exit(1);
851  }
852  } else { //If the file HVUnmappedChannelState.dat does not exist, initialize the map to all OFF.
853  //(see below for creating the file at the end of the execution with the latest state of unmapped channels.
854  for (std::map<std::string, vector<uint32_t> >::iterator it = UnmappedPSUs.begin(); it != UnmappedPSUs.end(); it++) {
855  std::string chan002 = it->first + "channel002";
856  std::string chan003 = it->first + "channel003";
857  UnmappedState[chan002] = false;
858  UnmappedState[chan003] = false;
859  }
860  }
861  //Get the HVCrosstalking map from the map, so that we can set know which PSU are crosstalking:
862  std::map<std::string, std::vector<uint32_t> > CrosstalkingPSUs = map_.getHVCrosstalkingMap();
863  //Check here if there is a file already, otherwise initialize to OFF all channels in these PSU!
864  if (FileExists("HVCrosstalkingChannelState.dat")) {
865  std::cout << "File HVCrosstalkingChannelState.dat exists!" << std::endl;
866  std::ifstream ifs("HVCrosstalkingChannelState.dat");
867  string line;
868  while (getline(ifs, line)) {
869  if (!line.empty()) {
870  // split the line and insert in the map
871  stringstream ss(line);
872  string PSUChannel;
873  bool HVStatus;
874  ss >> PSUChannel;
875  ss >> HVStatus;
876  //Extract the PSU from the PSUChannel (since the HVCrosstalking_Map uses PSU as key
877  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
878  //Look for the PSU in the unmapped map!
879  std::map<std::string, std::vector<uint32_t> >::iterator iter = CrosstalkingPSUs.find(PSU);
880  if (iter != CrosstalkingPSUs.end()) {
881  CrosstalkingState[PSUChannel] = HVStatus;
882  } else {
883  std::cout << "WARNING!!! There are channels in the local file with the channel status for HVUnmapped "
884  "channels, that ARE NOT CONSIDERED AS UNMAPPED in the current map!"
885  << std::endl;
886  }
887  }
888  } //End of the while loop reading and initializing CrosstalkingState map from file
889  //Extra check:
890  //Should check if there any HVCrosstalking channels in the map that are not listed in the local file!
891  bool MissingChannels = false;
892  for (std::map<std::string, vector<uint32_t> >::iterator it = CrosstalkingPSUs.begin(); it != CrosstalkingPSUs.end();
893  it++) {
894  std::string chan002 = it->first + "channel002";
895  std::string chan003 = it->first + "channel003";
896  std::map<std::string, bool>::iterator iter = CrosstalkingState.find(chan002);
897  if (iter == CrosstalkingState.end()) {
898  std::cout << "ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the "
899  "following unmapped channel voltage status information:"
900  << std::endl;
901  std::cout << chan002 << std::endl;
902  MissingChannels = true;
903  }
904  iter = CrosstalkingState.find(chan003);
905  if (iter == CrosstalkingState.end()) {
906  std::cout << "ERROR! The local file with the channel status for HVCrosstalking channels IS MISSING one of the "
907  "following unmapped channel voltage status information:"
908  << std::endl;
909  std::cout << chan003 << std::endl;
910  MissingChannels = true;
911  }
912  }
913  //Now if any channel WAS missing, exit!
914  if (MissingChannels) {
915  std::cout << "!!!!\n"
916  << "Exiting now... please check the local HVCrosstalkingChannelState.dat and the mapfile you provided ("
917  << psuDetIdMapFile_ << ")" << std::endl;
918  exit(1);
919  }
920  } else { //If the file HVCrosstalkingChannelState.dat does not exist, initialize the map to all OFF.
921  //(see below for creating the file at the end of the execution with the latest state of unmapped channels.
922  for (std::map<std::string, vector<uint32_t> >::iterator it = CrosstalkingPSUs.begin(); it != CrosstalkingPSUs.end();
923  it++) {
924  std::string chan002 = it->first + "channel002";
925  std::string chan003 = it->first + "channel003";
926  CrosstalkingState[chan002] = false;
927  CrosstalkingState[chan003] = false;
928  }
929  }
930 
931  if (debug_) {
932  //print out the UnmappedState map:
933  std::cout << "Printing the UnmappedChannelState initial map:" << std::endl;
934  std::cout << "PSUChannel\t\tHVON?(true or false)" << std::endl;
935  for (std::map<std::string, bool>::iterator it = UnmappedState.begin(); it != UnmappedState.end(); it++) {
936  std::cout << it->first << "\t\t" << it->second << std::endl;
937  }
938  //print out the CrosstalkingState map:
939  std::cout << "Printing the CrosstalkingChannelState initial map:" << std::endl;
940  std::cout << "PSUChannel\t\tHVON?(true or false)" << std::endl;
941  for (std::map<std::string, bool>::iterator it = CrosstalkingState.begin(); it != CrosstalkingState.end(); it++) {
942  std::cout << it->first << "\t\t" << it->second << std::endl;
943  }
944  }
945 
946  //Loop over the psuStruct (DB query results), lopping over the PSUChannels
947  //This will probably change int he future when we will change the query itself
948  //to report directly the detIDs associated with a channel
949  //Probably we will report in the query results the detID, the changeDate
950  //and whether the channel is HV mapped, HV unmapped, HV crosstalking using a flag...
951  for (unsigned int dp = 0; dp < psuStruct.dpname.size(); dp++) {
952  //FIX ME:
953  //Check if the following if condition can EVER be true!
954  std::string PSUChannel = psuStruct.dpname[dp];
955  if (PSUChannel != "UNKNOWN") {
956  // figure out the channel and the PSU individually
958  PSUChannel.substr(PSUChannel.size() - 10); //Channel is the channel, i.e. channel000, channel001 etc
959  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
960 
961  // Get the detIDs corresponding to the given PSU channel using the getDetID function of SiStripPsuDetIdMap.cc
962  //NOTA BENE
963  //Need to make sure the information is treated consistently here:
964  //The map by convention has
965  //detID-> channel002 or channel003 IF the channel is HV mapped,
966  //detID->channel000 if it is not HV mapped
967  //We want to differentiate the behavior depending on the status reported for the channel for channels that are unmapped!
968  //1-if the channel is turning OFF (!=1) then we want to report all detIDs for that channel and all detIDs that are listed as channel000 for that PSU.
969  //2-if the channel is turning ON (==1) then we want to turn on all detIDs for that channel but turn on all detIDs listed as channel000 for that PSU ONLY IF BOTH channel002 and channel003 are BOTH ON!
970  //Need to handle the case of coupled Power supplies (that only turn off when both are turned off).
971 
972  //Fixed SiStripPSUdetidMap.cc to make sure now getDetID gets the correct list of detIDs:
973  //-for channels 000/001 all the detIDs connected to the PSU
974  //-for channels 002/003 HV1/HV2 modules only (exclusively)
975  //UPDATE for HV channels:
976  //actually fixed it to report also detIDs listed as
977  //channel000 on the same supply of channel002 or channel003
978  //and the crosstalking ones (channel999) too..
979 
980  //Get the detIDs associated with the DPNAME (i.e. PSUChannel) reported by the query
981  //Declare the vector to be passed as reference parameters to the getDetID method
982  //std::vector<uint32_t> ids,unmapped_ids,crosstalking_ids;
983  std::vector<uint32_t> ids;
984  //map_.getDetID(PSUChannel, debug_, ids, unmapped_ids, crosstalking_ids);
985  //Actually the method above is a bit of an overkill, we could already use the individual methods:
986  //getLvDetID
987  //getHvDetID
988 
989  //Declaring the two vector needed for the HV case in this scope.
990  std::vector<uint32_t> unmapped_ids, crosstalking_ids;
991  bool LVCase;
992  //LV CASE
993  if (Channel == "channel000" || Channel == "channel001") {
994  LVCase = true;
995  ids = map_.getLvDetID(
996  PSU); //Since in the LV case only 1 list of detids is returned (unmapped and crosstalking are irrelevant for LV) return the vector directly
997  }
998  //HV CASE
999  else { //if (Channel=="channel002" || Channel=="channel003") {
1000  LVCase = false;
1001  map_.getHvDetID(PSUChannel,
1002  ids,
1003  unmapped_ids,
1004  crosstalking_ids); //In the HV case since 3 vectors are filled, use reference parameters
1005  }
1006 
1007  if (debug_) {
1008  cout << "dpname[" << dp << "] = " << PSUChannel << ", for time = " << timeToStream(psuStruct.changeDate[dp])
1009  << endl;
1010  if (!ids.empty()) {
1011  if (Channel == "channel000" || Channel == "channel001") {
1012  cout << "Corresponding to LV (PSU-)matching detids: " << endl;
1013  for (unsigned int i_detid = 0; i_detid < ids.size(); i_detid++) {
1014  cout << ids[i_detid] << std::endl;
1015  }
1016  } else {
1017  cout << "Corresponding to straight HV matching detids: " << endl;
1018  for (unsigned int i_detid = 0; i_detid < ids.size(); i_detid++) {
1019  cout << ids[i_detid] << std::endl;
1020  }
1021  }
1022  }
1023  //The unmapped_ids and crosstalking_ids are only filled for HV channels!
1024  if (!unmapped_ids.empty()) {
1025  cout << "Corresponding to HV unmapped (PSU-)matching detids: " << endl;
1026  for (unsigned int i_detid = 0; i_detid < unmapped_ids.size(); i_detid++) {
1027  cout << unmapped_ids[i_detid] << std::endl;
1028  }
1029  }
1030  if (!crosstalking_ids.empty()) {
1031  cout << "Corresponding to HV crosstalking (PSU-)matching detids: " << endl;
1032  for (unsigned int i_detid = 0; i_detid < crosstalking_ids.size(); i_detid++) {
1033  cout << crosstalking_ids[i_detid] << std::endl;
1034  }
1035  }
1036  }
1037 
1038  //NOW implement the new logic using the detids, unmapped_detids, crosstalking_detids!
1039 
1040  //First check whether the channel we're looking at is turning OFF or turning ON!
1041 
1042  //TURN OFF case:
1043  if (psuStruct.actualStatus[dp] != 1) {
1044  //Behavior is different for LV vs HV channels:
1045  //LV case:
1046  if (LVCase) {
1047  //Turn OFF all:
1048  //-positively matching
1049  //-unmapped matching
1050  //-crosstalking
1051  //for the LV case all the detids are automatically reported in the ids vector
1052  //unmapped and crosstalking are only differentiated (relevant) for HV.
1053  if (!ids.empty()) {
1054  //debug variables increment
1055  ch0bad++;
1056  ch1bad++;
1057 
1058  //Create a pair with the relevant detIDs (vector) and its timestamp
1059  //And put it in the detidV vector of the detIdStruct that will contain all the
1060  //results
1061  detIdStruct.detidV.push_back(std::make_pair(ids, psuStruct.changeDate[dp]));
1062 
1063  //Set the status to OFF
1064  detIdStruct.StatusGood.push_back(false);
1065 
1066  //debug variable population
1067  numLvBad.insert(numLvBad.end(), ids.begin(), ids.end());
1068 
1069  //Set the flag for LV/HV:
1070  detIdStruct.isHV.push_back(0); //LV
1071 
1072  //Set the PSUChannel (I guess for debug purposes?)
1073  detIdStruct.psuName.push_back(PSUChannel);
1074  }
1075  }
1076  //HV case:
1077  else { //if (!LVCase) {
1078  //Debug variables increment:
1079  if (!ids.empty() || !unmapped_ids.empty() || !crosstalking_ids.empty()) {
1080  if (Channel == "channel002") {
1081  ch2bad++;
1082  } else if (Channel == "channel003") {
1083  ch3bad++;
1084  }
1085  }
1086  //First sum the ids (positively matching detids) and the unmapped_ids (since both should be TURNED OFF):
1087  std::vector<uint32_t> OFFids;
1088  OFFids.insert(OFFids.end(), ids.begin(), ids.end()); //Add the ids (if any!)
1089  OFFids.insert(OFFids.end(), unmapped_ids.begin(), unmapped_ids.end()); //Add the unmapped_ids (if any!)
1090  //Now for the cross-talking ids this is a bit more complicated!
1091  if (!crosstalking_ids
1092  .empty()) { //This already means that the PSUChannel is one of the crosstalking ones (even if only a few modules in that PSU are showing crosstalking behavior both its channels have to be considered crosstalking of course!
1093  //Set the channel OFF in the CrosstalkingState map!
1094  CrosstalkingState[PSUChannel] = false; //Turn OFF the channel in the state map!
1095 
1096  //Need to check if both channels (HV1==channel002 or HV2==channel003) are OFF!
1097  if (!CrosstalkingState[PSUChannel.substr(0, PSUChannel.size() - 1) + "2"] &&
1098  !CrosstalkingState[PSUChannel.substr(0, PSUChannel.size() - 1) + "3"]) { //if HV1 & HV2 both OFF (false)
1099  OFFids.insert(
1100  OFFids.end(),
1101  crosstalking_ids.begin(),
1102  crosstalking_ids.end()); //Add the crosstalking_ids (if any!) since both HV1 and HV2 are OFF!
1103  if (debug_) {
1104  std::cout << "Adding the unmapped detids corresponding to (HV1/2 cross-talking) PSU "
1105  << PSUChannel.substr(0, PSUChannel.size() - 10) << " to the list of detids turning OFF"
1106  << std::endl;
1107  }
1108  }
1109  }
1110  //Handle the crosstalking channel by setting it to OFF in the CrosstalkingState map!
1111  if (!unmapped_ids
1112  .empty()) { //This already means that the PSUChannel is one of the unmapped ones (even if only a few modules in that PSU are unmapped both its channels have to be considered crosstalking of course!
1113  UnmappedState[PSUChannel] = false; //Turn OFF the channel in the state map!
1114  }
1115  if (!OFFids.empty()) {
1116  //Create a pair with the relevant detIDs (vector) and its timestamp
1117  //And put it in the detidV vector of the detIdStruct that will contain all the
1118  //results
1119 
1120  //Going OFF HV:
1121  //report not only ids, but also unmapped_ids.
1122  //have to handle crosstalking_ids here... (only OFF if they corresponding PSU HV1/HV2 is off already...
1123  //then add all three vectors to the pair below...
1124  detIdStruct.detidV.push_back(std::make_pair(OFFids, psuStruct.changeDate[dp]));
1125 
1126  //Set the status to OFF
1127  detIdStruct.StatusGood.push_back(false);
1128 
1129  //debug variable population
1130  numHvBad.insert(numHvBad.end(), ids.begin(), ids.end());
1131 
1132  //Set the flag for LV/HV:
1133  detIdStruct.isHV.push_back(1); //HV
1134 
1135  //Set the PSUChannel (I guess for debug purposes?)
1136  detIdStruct.psuName.push_back(PSUChannel);
1137  }
1138  }
1139  }
1140  //TURNING ON CASE
1141  else {
1142  //Implement the rest of the logic!
1143  //Behavior is different for LV vs HV channels:
1144  //LV case:
1145  if (LVCase) {
1146  //Turn ON all (PSU)matching detids:
1147  //for the LV case all the detids are automatically reported in the ids vector
1148  //unmapped and crosstalking are only differentiated (relevant) for HV.
1149  if (!ids.empty()) {
1150  //Create a pair with the relevant detIDs (vector) and its timestamp
1151  //And put it in the detidV vector of the detIdStruct that will contain all the
1152  //results
1153  detIdStruct.detidV.push_back(std::make_pair(ids, psuStruct.changeDate[dp]));
1154 
1155  //Set the status to ON
1156  detIdStruct.StatusGood.push_back(true);
1157 
1158  //Set the flag for LV/HV:
1159  detIdStruct.isHV.push_back(0); //LV
1160 
1161  //Set the PSUChannel (I guess for debug purposes?)
1162  detIdStruct.psuName.push_back(PSUChannel);
1163  }
1164  }
1165  //HV case:
1166  else { //if (!LVCase) {
1167  //First sum the ids (positively matching detids) and the crosstalking_ids (since all ids on a crosstalking PSU should be TURNED ON when at least one HV channel is ON):
1168  std::vector<uint32_t> ONids;
1169  ONids.insert(ONids.end(), ids.begin(), ids.end()); //Add the ids (if any!)
1170  ONids.insert(
1171  ONids.end(), crosstalking_ids.begin(), crosstalking_ids.end()); //Add the crosstalking_ids (if any!)
1172  //Now for the unmapped ids this is a bit more complicated!
1173  if (!unmapped_ids
1174  .empty()) { //This already means that the PSUChannel is one of the unmapped ones (even if only a few modules in that PSU are unmapped both its channels have to be considered unmapped of course!
1175  //Set the HV1 channel on in the UnmappedState map!
1176  UnmappedState[PSUChannel] = true; //Turn ON the channel in the state map!
1177 
1178  //Need to check if BOTH channels (HV1==channel002 or HV2==channel003) are ON!
1179  if (UnmappedState[PSUChannel.substr(0, PSUChannel.size() - 1) + "2"] &&
1180  UnmappedState[PSUChannel.substr(0, PSUChannel.size() - 1) + "3"]) { //if HV1 & HV2 are both ON (true)
1181  ONids.insert(ONids.end(),
1182  unmapped_ids.begin(),
1183  unmapped_ids.end()); //Add the unmapped_ids (if any!) since both HV1 and HV2 are ON!
1184  if (debug_) {
1185  std::cout << "Adding the detids corresponding to HV-unmapped PSU "
1186  << PSUChannel.substr(0, PSUChannel.size() - 10) << " to the list of detids turning ON"
1187  << std::endl;
1188  }
1189  }
1190  }
1191  //Handle the crosstalking channel by setting it to OFF in the CrosstalkingState map!
1192  if (!crosstalking_ids
1193  .empty()) { //This already means that the PSUChannel is one of the crosstalking ones (even if only a few modules in that PSU are showing crosstalking behavior both its channels have to be considered crosstalking of course!
1194  CrosstalkingState[PSUChannel] = true; //Turn ON the channel in the state map!
1195  }
1196  if (!ONids.empty()) {
1197  //Create a pair with the relevant detIDs (vector) and its timestamp
1198  //And put it in the detidV vector of the detIdStruct that will contain all the
1199  //results
1200 
1201  //Going OFF HV:
1202  //report not only ids, but also unmapped_ids.
1203  //have to handle crosstalking_ids here... (only OFF if they corresponding PSU HV1/HV2 is off already...
1204  //then add all three vectors to the pair below...
1205  detIdStruct.detidV.push_back(std::make_pair(ONids, psuStruct.changeDate[dp]));
1206 
1207  //Set the status to ON
1208  detIdStruct.StatusGood.push_back(true);
1209 
1210  //Set the flag for LV/HV:
1211  detIdStruct.isHV.push_back(1); //HV
1212 
1213  //Set the PSUChannel (I guess for debug purposes?)
1214  detIdStruct.psuName.push_back(PSUChannel);
1215  }
1216  }
1217  }
1218  } //End of if dpname not "UNKNOWN"
1219  else {
1220  //if (debug) {
1221  //std::cout<<"PSU Channel name WAS NOT RECOGNIZED"<<std::endl;
1222  //}
1223  detIdStruct.notMatched++;
1224  }
1225  } //End of the loop over all PSUChannels reported by the DB query.
1226  //At this point we need to (over)write the 2 files that will keep the HVUnmapped and HVCrosstalking channels status:
1227  std::ofstream ofsUnmapped("HVUnmappedChannelState.dat");
1228  for (std::map<std::string, bool>::iterator it = UnmappedState.begin(); it != UnmappedState.end(); it++) {
1229  ofsUnmapped << it->first << "\t" << it->second << std::endl;
1230  }
1231  std::ofstream ofsCrosstalking("HVCrosstalkingChannelState.dat");
1232  for (std::map<std::string, bool>::iterator it = CrosstalkingState.begin(); it != CrosstalkingState.end(); it++) {
1233  ofsCrosstalking << it->first << "\t" << it->second << std::endl;
1234  }
1235 
1236  removeDuplicates(numLvBad);
1237  removeDuplicates(numHvBad);
1238 
1239  // useful debugging stuff!
1240  if (debug_) {
1241  std::cout << "Number of channels that turned OFF in this O2O interval" << std::endl;
1242  std::cout << "Channel000 = " << ch0bad << " Channel001 = " << ch1bad << std::endl;
1243  std::cout << "Channel002 = " << ch2bad << " Channel003 = " << ch3bad << std::endl;
1244  std::cout << "Number of LV detIDs that turned OFF in this O2O interval = " << numLvBad.size() << std::endl;
1245  std::cout << "Number of HV detIDs that turned OFF in this O2O interval = " << numHvBad.size() << std::endl;
1246  }
1247 
1248  LogTrace("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__
1249  << "]: Number of PSUs retrieved from DB with map information "
1250  << detIdStruct.detidV.size();
1251  LogTrace("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__
1252  << "]: Number of PSUs retrieved from DB with no map information "
1253  << detIdStruct.notMatched;
1254 
1255  unsigned int dupCount = 0;
1256  for (unsigned int t = 0; t < numLvBad.size(); t++) {
1257  std::vector<unsigned int>::iterator iter = std::find(numHvBad.begin(), numHvBad.end(), numLvBad[t]);
1258  if (iter != numHvBad.end()) {
1259  dupCount++;
1260  }
1261  }
1262  if (debug_)
1263  std::cout << "Number of channels for which LV & HV turned OFF in this O2O interval = " << dupCount << std::endl;
1264 }

References SiStripDetVOffBuilder::TimesAndValues::actualStatus, SiStripPsuDetIdMap::BuildMap(), SiStripDetVOffBuilder::TimesAndValues::changeDate, gather_cfg::cout, debug_, SiStripDetVOffBuilder::DetIdListTimeAndStatus::detidV, Calorimetry_cff::dp, SiStripDetVOffBuilder::TimesAndValues::dpname, relativeConstraints::empty, beamvalidation::exit(), FileExists(), spr::find(), SiStripPsuDetIdMap::getHVCrosstalkingMap(), SiStripPsuDetIdMap::getHvDetID(), SiStripPsuDetIdMap::getHVUnmappedMap(), SiStripPsuDetIdMap::getLvDetID(), SiStripDetVOffBuilder::DetIdListTimeAndStatus::isHV, mps_splice::line, LogTrace, genParticles_cff::map, SiStripDetVOffBuilder::DetIdListTimeAndStatus::notMatched, SiStripPsuDetIdMap::printMap(), psuDetIdMapFile_, SiStripDetVOffBuilder::DetIdListTimeAndStatus::psuName, removeDuplicates(), contentValuesCheck::ss, SiStripDetVOffBuilder::DetIdListTimeAndStatus::StatusGood, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, and timeToStream().

Referenced by BuildDetVOffObj().

◆ discardIOVs()

void SiStripDetVOffBuilder::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 at line 566 of file SiStripDetVOffBuilder.cc.

570  {
571  if (debug_) {
572  cout << "first (1->means the sequence started at the first timestamp in the query results, 0-> that it did not)= "
573  << first << endl;
574  cout << "initial->first (initial SiStripDetVOff object of the IOV sequence)= " << initialIt->first
575  << ", second (initial timestamp of the IOV sequence) = " << initialIt->second << endl;
576  cout << "last (0->means that the sequence is not ending with the last item in the query results, 1-> that it "
577  "DOES!)= "
578  << last << endl;
579  }
580  if (last == true) {
581  resultVec.erase(initialIt + first, it + 1);
582  // Minus 2 because it will be incremented at the end of the loop becoming end()-1.
583  it = resultVec.end() - 2;
584  } else {
585  it = resultVec.erase(initialIt + first, it);
586  }
587 }

References gather_cfg::cout, debug_, first, and dqmdumpme::last.

Referenced by reduce().

◆ extractDetIdVector()

pair< int, int > SiStripDetVOffBuilder::extractDetIdVector ( const unsigned int  i,
SiStripDetVOff modV,
DetIdListTimeAndStatus detIdStruct 
)
private

Definition at line 1274 of file SiStripDetVOffBuilder.cc.

1276  {
1277  // set the LV and HV off flags ready for storing
1278  int lv_off = -1, hv_off = -1;
1279  if (detIdStruct.isHV[i] == 0) {
1280  lv_off = !(detIdStruct.StatusGood[i]);
1281  }
1282  if (detIdStruct.isHV[i] == 1) {
1283  hv_off = !(detIdStruct.StatusGood[i]);
1284 
1285  // TESTING WITHOUT THE FIX
1286  // -----------------------
1287 
1288  if (psuDetIdMapFile_.empty()) {
1289  // temporary fix to handle the fact that we don't know which HV channel the detIDs are associated to
1290  if (i > 0) {
1291  std::string iChannel = detIdStruct.psuName[i].substr((detIdStruct.psuName[i].size() - 3));
1292  std::string iPsu = detIdStruct.psuName[i].substr(0, (detIdStruct.psuName[i].size() - 3));
1293  if (iChannel == "002" || iChannel == "003") {
1294  bool lastStatusOfOtherChannel = true;
1295  for (unsigned int j = 0; j < i; j++) {
1296  std::string jPsu = detIdStruct.psuName[j].substr(0, (detIdStruct.psuName[j].size() - 3));
1297  std::string jChannel = detIdStruct.psuName[j].substr((detIdStruct.psuName[j].size() - 3));
1298  if (iPsu == jPsu && iChannel != jChannel && (jChannel == "002" || jChannel == "003")) {
1299  if (debug_)
1300  cout << "psu[" << i << "] = " << detIdStruct.psuName[i]
1301  << " with status = " << detIdStruct.StatusGood[i] << " and psu[" << j
1302  << "] = " << detIdStruct.psuName[j] << " with status " << detIdStruct.StatusGood[j] << endl;
1303  lastStatusOfOtherChannel = detIdStruct.StatusGood[j];
1304  }
1305  }
1306  if (detIdStruct.StatusGood[i] != lastStatusOfOtherChannel) {
1307  if (debug_)
1308  cout << "turning off hv" << endl;
1309  hv_off = 1;
1310  }
1311  }
1312  }
1313  }
1314 
1315  // -----------------------
1316  }
1317 
1318  return make_pair(hv_off, lv_off);
1319 }

References gather_cfg::cout, debug_, mps_fire::i, SiStripDetVOffBuilder::DetIdListTimeAndStatus::isHV, dqmiolumiharvest::j, psuDetIdMapFile_, SiStripDetVOffBuilder::DetIdListTimeAndStatus::psuName, SiStripDetVOffBuilder::DetIdListTimeAndStatus::StatusGood, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BuildDetVOffObj().

◆ FileExists()

bool SiStripDetVOffBuilder::FileExists ( std::string  filename)

Definition at line 749 of file SiStripDetVOffBuilder.cc.

749  {
750  //Helper method to check if local files exist (needed to handle HVUnmapped, HVCrosstalking modules)
751  struct stat FileInfo;
752  bool Existence;
753  int Stat;
754  //Try to get file attributes
755  Stat = stat(FileName.c_str(), &FileInfo);
756  if (Stat == 0) {
757  Existence = true;
758  } else {
759  Existence = false;
760  }
761  return Existence;
762 }

References tkal_create_file_lists::FileInfo, MonitorAlCaEcalPhisym_cfi::FileName, and edm_modernize_messagelogger::stat.

Referenced by buildPSUdetIdMap().

◆ findMostRecentTimeStamp()

cond::Time_t SiStripDetVOffBuilder::findMostRecentTimeStamp ( const std::vector< coral::TimeStamp > &  coralDate)
private

Definition at line 509 of file SiStripDetVOffBuilder.cc.

509  {
510  cond::Time_t latestDate = getCondTime(coralDate[0]);
511 
512  if (debug_) {
513  std::cout << "latestDate: condTime = " << (latestDate >> 32) << " - "
514  << (latestDate & 0xFFFFFFFF)
515  //<< " coralTime= " << coralDate[0]
516  << std::endl;
517  }
518 
519  for (unsigned int i = 1; i < coralDate.size(); i++) {
520  cond::Time_t testDate = getCondTime(coralDate[i]);
521  if (testDate > latestDate) {
522  latestDate = testDate;
523  }
524  }
525  return latestDate;
526 }

References gather_cfg::cout, debug_, getCondTime(), and mps_fire::i.

Referenced by lastValue(), and lastValueFromFile().

◆ findSetting() [1/2]

int SiStripDetVOffBuilder::findSetting ( std::string  dpname,
const coral::TimeStamp &  changeDate,
const std::vector< std::string > &  settingDpname,
const std::vector< coral::TimeStamp > &  settingDate 
)
private

Returns the PSU channel setting, based on date. Works from PSU channel name. Overloaded.

Definition at line 364 of file SiStripDetVOffBuilder.cc.

367  {
368  int setting = -1;
369  // find out how many channel entries there are
370  std::vector<int> locations;
371  for (unsigned int i = 0; i < settingDpname.size(); i++) {
372  if (settingDpname[i] == dpname) {
373  locations.push_back((int)i);
374  }
375  }
376 
377  // simple cases
378  if (locations.empty()) {
379  setting = -1;
380  } else if (locations.size() == 1) {
381  setting = locations[0];
382  }
383  // more than one entry for this channel
384  // NB. entries ordered by date!
385  else {
386  for (unsigned int j = 0; j < locations.size(); j++) {
387 #ifdef USING_NEW_CORAL
388  const boost::posix_time::ptime& testSec = changeDate.time();
389  const boost::posix_time::ptime& limitSec = settingDate[(unsigned int)locations[j]].time();
390 #else
391  long testSec = changeDate.time().ns();
392  long limitSec = settingDate[(unsigned int)locations[j]].time().ns();
393 #endif
394  if (testSec >= limitSec) {
395  setting = locations[j];
396  }
397  }
398  }
399  return setting;
400 }

References mps_fire::i, createfilelist::int, dqmiolumiharvest::j, and protons_cff::time.

◆ findSetting() [2/2]

int SiStripDetVOffBuilder::findSetting ( uint32_t  id,
const coral::TimeStamp &  changeDate,
const std::vector< uint32_t > &  settingID,
const std::vector< coral::TimeStamp > &  settingDate 
)
private

Returns the PSU channel setting, based on date. Works from DP ID.

Definition at line 326 of file SiStripDetVOffBuilder.cc.

329  {
330  int setting = -1;
331  // find out how many channel entries there are
332  std::vector<int> locations;
333  for (unsigned int i = 0; i < settingID.size(); i++) {
334  if (settingID[i] == id) {
335  locations.push_back((int)i);
336  }
337  }
338 
339  // simple cases
340  if (locations.empty()) {
341  setting = -1;
342  } else if (locations.size() == 1) {
343  setting = locations[0];
344  }
345  // more than one entry for this channel
346  // NB. entries ordered by date!
347  else {
348  for (unsigned int j = 0; j < locations.size(); j++) {
349 #ifdef USING_NEW_CORAL
350  const boost::posix_time::ptime& testSec = changeDate.time();
351  const boost::posix_time::ptime& limitSec = settingDate[(unsigned int)locations[j]].time();
352 #else
353  long testSec = changeDate.time().ns();
354  long limitSec = settingDate[(unsigned int)locations[j]].time().ns();
355 #endif
356  if (testSec >= limitSec) {
357  setting = locations[j];
358  }
359  }
360  }
361  return setting;
362 }

References mps_fire::i, createfilelist::int, dqmiolumiharvest::j, and protons_cff::time.

Referenced by lastValue(), and lastValueFromFile().

◆ getCondTime()

cond::Time_t SiStripDetVOffBuilder::getCondTime ( const coral::TimeStamp &  coralTime)
private

Utility code to convert a coral timestamp to the correct time format for O2O timestamp.

Definition at line 469 of file SiStripDetVOffBuilder.cc.

469  {
470  // const boost::posix_time::ptime& t = coralTime.time();
471  cond::Time_t condTime = cond::time::from_boost(coralTime.time());
472 
473  // cout << "[SiStripDetVOffBuilder::getCondTime] Converting CoralTime into CondTime: "
474  // << " coralTime = (coralTimeInNs) " << coralTime.total_nanoseconds() << " condTime " << (condTime>> 32) << " - " << (condTime & 0xFFFFFFFF) << endl;
475 
476  return condTime;
477 }

References cond::time::from_boost().

Referenced by BuildDetVOffObj(), findMostRecentTimeStamp(), and getCoralTime().

◆ getCoralTime()

coral::TimeStamp SiStripDetVOffBuilder::getCoralTime ( cond::Time_t  iovTime)
private

Utility code to convert an O2O timestamp into a coral timestamp.

Definition at line 479 of file SiStripDetVOffBuilder.cc.

479  {
480  // This method is defined in the TimeConversions header and it does the following:
481  // - takes the seconds part of the iovTime (bit-shifting of 32)
482  // - adds the nanoseconds part (first 32 bits mask)
483  // - adds the time0 that is the time from begin of times (boost::posix_time::from_time_t(0);)
484  coral::TimeStamp coralTime(cond::time::to_boost(iovTime));
485 
486  if (debug_) {
487  unsigned long long iovSec = iovTime >> 32;
488  uint32_t iovNanoSec = uint32_t(iovTime);
489  cond::Time_t testTime = getCondTime(coralTime);
490  cout << "[SiStripDetVOffBuilder::getCoralTime] Converting CondTime into CoralTime: "
491  << " condTime = " << iovSec << " - " << iovNanoSec << " getCondTime(coralTime) = " << (testTime >> 32) << " - "
492  << (testTime & 0xFFFFFFFF) << endl;
493  }
494 
495  return coralTime;
496 }

References gather_cfg::cout, debug_, getCondTime(), and cond::time::to_boost().

Referenced by statusChange().

◆ getModulesVOff()

std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > SiStripDetVOffBuilder::getModulesVOff ( )
inline

Return modules Off vector of objects.

Definition at line 47 of file SiStripDetVOffBuilder.h.

47  {
49  return modulesOff;
50  }

References deltaTmin_, maxIOVlength_, modulesOff, and reduction().

Referenced by SiStripDetVOffHandler::analyze().

◆ getPayloadStats()

std::vector<std::vector<uint32_t> > SiStripDetVOffBuilder::getPayloadStats ( )
inline

Return statistics about payloads transferred for storage in logDB.

Definition at line 52 of file SiStripDetVOffBuilder.h.

52 { return payloadStats; }

References payloadStats.

◆ lastValue()

void SiStripDetVOffBuilder::lastValue ( TimesAndValues tStruct)
private

Definition at line 653 of file SiStripDetVOffBuilder.cc.

653  {
654  coralInterface->doQuery(whichTable, tmin, tmax, tStruct.changeDate, tStruct.actualValue, tStruct.dpname);
655 
656  tStruct.latestTime = findMostRecentTimeStamp(tStruct.changeDate);
657 
658  // preset the size of the status vector
659  tStruct.actualStatus.resize(tStruct.actualValue.size());
660 
661  // retrieve the channel settings from the PVSS DB
662  std::vector<coral::TimeStamp> settingDate;
663  std::vector<float> settingValue;
664  std::vector<std::string> settingDpname;
665  std::vector<uint32_t> settingDpid;
666  coralInterface->doSettingsQuery(tsetmin, tmax, settingDate, settingValue, settingDpname, settingDpid);
667  LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
668  LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: "
669  << settingDpname.size();
670 
671  unsigned int missing = 0;
672  std::stringstream ss;
673  for (unsigned int j = 0; j < tStruct.dpname.size(); j++) {
674  int setting = findSetting(tStruct.dpname[j], tStruct.changeDate[j], settingDpname, settingDate);
675  if (setting >= 0) {
676  if (tStruct.actualValue[j] > (highVoltageOnThreshold_ * (settingValue[setting]))) {
677  tStruct.actualStatus[j] = 1;
678  } else {
679  tStruct.actualStatus[j] = 0;
680  }
681  } else {
682  tStruct.actualStatus[j] = -1;
683  missing++;
684  ss << "Channel = " << tStruct.dpname[j] << std::endl;
685  }
686  }
687  LogDebug("SiStripDetVOffBuilder")
688  << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of channels with no setting information " << missing;
689  LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of entries in dpname vector "
690  << tStruct.dpname.size();
691 }

References SiStripDetVOffBuilder::TimesAndValues::actualStatus, SiStripDetVOffBuilder::TimesAndValues::actualValue, SiStripDetVOffBuilder::TimesAndValues::changeDate, coralInterface, SiStripDetVOffBuilder::TimesAndValues::dpname, findMostRecentTimeStamp(), findSetting(), highVoltageOnThreshold_, dqmiolumiharvest::j, SiStripDetVOffBuilder::TimesAndValues::latestTime, LogDebug, combine::missing, contentValuesCheck::ss, tmax, tmin, tsetmin, and whichTable.

Referenced by BuildDetVOffObj().

◆ lastValueFromFile()

void SiStripDetVOffBuilder::lastValueFromFile ( TimesAndValues tStruct)
private

Definition at line 693 of file SiStripDetVOffBuilder.cc.

693  {
694  readLastValueFromFile(tStruct.dpid, tStruct.actualValue, tStruct.changeDate);
695  tStruct.latestTime = findMostRecentTimeStamp(tStruct.changeDate);
696  LogDebug("SiStripDetVOffBuilder")
697  << "[SiStripDetVOffBuilder::BuildDetVOff]: File access complete \n\t Number of values read from file: "
698  << tStruct.dpid.size();
699 
700  // retrieve the channel settings from the PVSS DB
701  std::vector<coral::TimeStamp> settingDate;
702  std::vector<float> settingValue;
703  std::vector<std::string> settingDpname;
704  std::vector<uint32_t> settingDpid;
705 
706  coralInterface->doSettingsQuery(tsetmin, tmax, settingDate, settingValue, settingDpname, settingDpid);
707  LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Channel settings retrieved";
708  LogDebug("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::BuildDetVOff]: Number of PSU channels: "
709  << settingDpname.size();
710 
711  unsigned int missing = 0;
712  std::stringstream ss;
713  // need to get the PSU channel names from settings
714  tStruct.dpname.clear();
715  tStruct.dpname.resize(tStruct.dpid.size());
716  for (unsigned int j = 0; j < tStruct.dpid.size(); j++) {
717  int setting = findSetting(tStruct.dpid[j], tStruct.changeDate[j], settingDpid, settingDate);
718  if (setting >= 0) {
719  if (tStruct.actualValue[j] > (highVoltageOnThreshold_ * settingValue[setting])) {
720  tStruct.actualStatus[j] = 1;
721  } else {
722  tStruct.actualStatus[j] = 0;
723  }
724  tStruct.dpname[j] = settingDpname[setting];
725  } else {
726  tStruct.actualStatus[j] = -1;
727  tStruct.dpname[j] = "UNKNOWN";
728  missing++;
729  ss << "DP ID = " << tStruct.dpid[j] << std::endl;
730  }
731  }
732  LogDebug("SiStripDetVOffBuilder") << "Number of missing psu channels = " << missing << std::endl;
733  LogDebug("SiStripDetVOffBuilder") << "IDs are: = " << ss.str();
734 }

References SiStripDetVOffBuilder::TimesAndValues::actualStatus, SiStripDetVOffBuilder::TimesAndValues::actualValue, SiStripDetVOffBuilder::TimesAndValues::changeDate, coralInterface, SiStripDetVOffBuilder::TimesAndValues::dpid, SiStripDetVOffBuilder::TimesAndValues::dpname, findMostRecentTimeStamp(), findSetting(), highVoltageOnThreshold_, dqmiolumiharvest::j, SiStripDetVOffBuilder::TimesAndValues::latestTime, LogDebug, combine::missing, readLastValueFromFile(), contentValuesCheck::ss, tmax, and tsetmin.

Referenced by BuildDetVOffObj().

◆ printPar()

void SiStripDetVOffBuilder::printPar ( std::stringstream &  ss,
const std::vector< int > &  par 
)
private

Definition at line 92 of file SiStripDetVOffBuilder.cc.

92  {
93  for (int val : par) {
94  ss << val << " ";
95  }
96 }

References contentValuesCheck::ss, and heppy_batch::val.

Referenced by SiStripDetVOffBuilder().

◆ readLastValueFromFile()

void SiStripDetVOffBuilder::readLastValueFromFile ( std::vector< uint32_t > &  dpIDs,
std::vector< float > &  vmonValues,
std::vector< coral::TimeStamp > &  dateChange 
)
private

Extract the lastValue values from file rather than from the PVSS cond DB.

Definition at line 402 of file SiStripDetVOffBuilder.cc.

404  {
405  std::ifstream lastValueFile(lastValueFileName.c_str());
406  if (lastValueFile.bad()) {
407  edm::LogError("SiStripDetVOffBuilder")
408  << "[SiStripDetVOffBuilder::" << __func__ << "]: last Value file does not exist!";
409  return;
410  }
411 
412  dpIDs.clear();
413  vmonValues.clear();
414  dateChange.clear();
415  std::vector<std::string> changeDates;
416 
418  // remove the first line as it is the title line
419  // std::getline(lastValueFile,line);
420  // line.clear();
421  // now extract data
422  while (std::getline(lastValueFile, line)) {
423  std::istringstream ss(line);
424  uint32_t dpid;
425  float vmon;
426  std::string changeDate;
427  ss >> std::skipws >> dpid >> vmon >> changeDate;
428  dpIDs.push_back(dpid);
429  vmonValues.push_back(vmon);
430  changeDates.push_back(changeDate);
431  }
432  lastValueFile.close();
433 
434  // Now convert dates to coral::TimeStamp
435  for (unsigned int i = 0; i < changeDates.size(); i++) {
436  std::string part = changeDates[i].substr(0, 4);
437  int year = atoi(part.c_str());
438  part.clear();
439 
440  part = changeDates[i].substr(5, 2);
441  int month = atoi(part.c_str());
442  part.clear();
443 
444  part = changeDates[i].substr(8, 2);
445  int day = atoi(part.c_str());
446  part.clear();
447 
448  part = changeDates[i].substr(11, 2);
449  int hour = atoi(part.c_str());
450  part.clear();
451 
452  part = changeDates[i].substr(14, 2);
453  int minute = atoi(part.c_str());
454  part.clear();
455 
456  part = changeDates[i].substr(17, 2);
457  int second = atoi(part.c_str());
458  part.clear();
459 
460  coral::TimeStamp date(year, month, day, hour, minute, second, 0);
461  dateChange.push_back(date);
462  }
463 
464  if (changeDates.size() != dateChange.size()) {
465  edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::" << __func__ << "]: date conversion failed!!";
466  }
467 }

References indexGen::date, util.getRunInfo::day(), mps_fire::i, lastValueFileName, mps_splice::line, edm::second(), contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lastValueFromFile().

◆ reduce()

void SiStripDetVOffBuilder::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 at line 528 of file SiStripDetVOffBuilder.cc.

531  {
532  //const bool last is set to false by default in the header file...
533  int first = 0;
534  // Check if it is the first
535  if (distance(resultVec.begin(), initialIt) == 0) {
536  first = 1;
537  }
538 
539  if (debug_ && (it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() == 0) &&
540  (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() == 0)) {
541  cout << "Same number of LV and HV at start and end of sequence: LV off = " << it->first->getLVoffCounts()
542  << " HV off = " << it->first->getHVoffCounts() << endl;
543  }
544 
545  // if it was going off
546  if ((it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() > 0) ||
547  (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() > 0)) {
548  // Set the time of the current (last) iov as the time of the initial iov of the sequence
549  // replace the first iov with the last one
550  //Naughty use of const bool last... by default it is false (=0), and for the case of the last timestamp in the query results it is set to true(=1) in the call
551  (it + last)->second = (initialIt)->second;
552  discardIOVs(it, initialIt, resultVec, last, 0);
553  if (debug_)
554  cout << "Reducing IOV sequence (going off)" << endl;
555  }
556  // if it was going on
557  else if ((it->first->getLVoffCounts() - initialIt->first->getLVoffCounts() <= 0) ||
558  (it->first->getHVoffCounts() - initialIt->first->getHVoffCounts() <= 0)) {
559  // replace the last minus one iov with the first one
560  discardIOVs(it, initialIt, resultVec, last, first);
561  if (debug_)
562  cout << "Reducing IOV sequence (going on)" << endl;
563  }
564 }

References gather_cfg::cout, debug_, discardIOVs(), HLT_FULL_cff::distance, first, dqmdumpme::last, and edm::second().

Referenced by reduction().

◆ reduction()

void SiStripDetVOffBuilder::reduction ( const uint32_t  deltaTmin,
const uint32_t  maxIOVlength 
)

Definition at line 590 of file SiStripDetVOffBuilder.cc.

590  {
591  int count = 0;
592  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator initialIt;
593 
594  int resultVecSize = modulesOff.size();
595  int resultsIndex = 0;
596 
597  if (resultVecSize > 1) {
598  std::vector<std::pair<SiStripDetVOff*, cond::Time_t> >::iterator it = modulesOff.begin();
599  for (; it != modulesOff.end() - 1; ++it, ++resultsIndex) {
600  unsigned long long deltaT = ((it + 1)->second - it->second) >> 32;
601  unsigned long long deltaTsequence = 0;
602  if (count > 1) {
603  deltaTsequence = ((it + 1)->second - initialIt->second) >> 32;
604  }
605  // Save the initial pair
606  if ((deltaT < deltaTmin) && ((count == 0) || (deltaTsequence < maxIOVlength))) {
607  // If we are not in a the sequence
608  if (count == 0) {
609  initialIt = it;
610  }
611  // Increase the counter in any case.
612  ++count;
613  }
614  // We do it only if the sequence is bigger than two cases
615  else if (count > 1) {
616  reduce(it, initialIt, modulesOff);
617  // reset all
618  count = 0;
619  } else {
620  // reset all
621  count = 0;
622  }
623  // Border case
624  if (resultsIndex == resultVecSize - 2 && count != 0) {
625  reduce(it, initialIt, modulesOff, true);
626  }
627  }
628  }
629 }

References submitPVResolutionJobs::count, modulesOff, reduce(), and edm::second().

Referenced by getModulesVOff().

◆ removeDuplicates()

void SiStripDetVOffBuilder::removeDuplicates ( std::vector< uint32_t > &  vec)
private

Utility code to remove all the duplicates from a vector of uint32_t.

Definition at line 498 of file SiStripDetVOffBuilder.cc.

498  {
499  std::sort(vec.begin(), vec.end());
500  std::vector<uint32_t>::iterator it = std::unique(vec.begin(), vec.end());
501  vec.resize(it - vec.begin());
502 }

References jetUpdater_cfi::sort, and tier0::unique().

Referenced by buildPSUdetIdMap().

◆ setLastSiStripDetVOff()

void SiStripDetVOffBuilder::setLastSiStripDetVOff ( SiStripDetVOff lastPayload,
cond::Time_t  lastTimeStamp 
)

Store the last payload transferred to DB as starting point for creation of new object list. ONLY WORKS FOR STATUSCHANGE OPTION.

Definition at line 504 of file SiStripDetVOffBuilder.cc.

504  {
505  lastStoredCondObj.first = lastPayload;
506  lastStoredCondObj.second = lastTimeStamp;
507 }

References lastStoredCondObj.

Referenced by SiStripDetVOffHandler::analyze().

◆ setPayloadStats()

void SiStripDetVOffBuilder::setPayloadStats ( const uint32_t  afterV,
const uint32_t  numAdded,
const uint32_t  numRemoved 
)
private

Definition at line 1266 of file SiStripDetVOffBuilder.cc.

1266  {
1267  std::vector<uint32_t> pStats(3, 0);
1268  pStats.push_back(afterV);
1269  pStats.push_back(numAdded);
1270  pStats.push_back(numRemoved);
1271  payloadStats.push_back(pStats);
1272 }

References payloadStats.

Referenced by BuildDetVOffObj().

◆ statusChange()

void SiStripDetVOffBuilder::statusChange ( cond::Time_t lastTime,
TimesAndValues tStruct 
)
private

Definition at line 631 of file SiStripDetVOffBuilder.cc.

631  {
632  // Setting tmin to the last value IOV of the database tag
633  if (lastTime > 0) {
634  tmin = getCoralTime(lastTime);
635  }
636 
637  coralInterface->doQuery(whichTable, tmin, tmax, tStruct.changeDate, tStruct.actualValue, tStruct.dpname);
638  //UNIT TEST DEBUG to bypass the query wait time!!!
639  //coral::TimeStamp testtime=getCoralTime(lastTime);
640  //tStruct.changeDate.push_back(testtime);
641  //tStruct.actualValue.push_back(1.);
642  //tStruct.dpname.push_back("cms_trk_dcs_03:CAEN/CMS_TRACKER_SY1527_3/branchController00/easyCrate3/easyBoard17/channel002");
643 
644  // preset the size of the status vector
645  tStruct.actualStatus.resize(tStruct.actualValue.size());
646  tStruct.actualStatus.clear();
647 
648  for (float val : tStruct.actualValue) {
649  tStruct.actualStatus.push_back(static_cast<int>(val));
650  }
651 }

References SiStripDetVOffBuilder::TimesAndValues::actualStatus, SiStripDetVOffBuilder::TimesAndValues::actualValue, SiStripDetVOffBuilder::TimesAndValues::changeDate, coralInterface, SiStripDetVOffBuilder::TimesAndValues::dpname, getCoralTime(), tmax, tmin, heppy_batch::val, and whichTable.

Referenced by BuildDetVOffObj().

◆ timeToStream() [1/2]

string SiStripDetVOffBuilder::timeToStream ( const cond::Time_t condTime,
const string &  comment = "" 
)
private

Definition at line 736 of file SiStripDetVOffBuilder.cc.

736  {
737  stringstream ss;
738  ss << comment << (condTime >> 32) << " - " << (condTime & 0xFFFFFFFF) << std::endl;
739  return ss.str();
740 }

References contentValuesCheck::ss.

◆ timeToStream() [2/2]

string SiStripDetVOffBuilder::timeToStream ( const coral::TimeStamp &  coralTime,
const string &  comment = "" 
)
private

Definition at line 742 of file SiStripDetVOffBuilder.cc.

742  {
743  stringstream ss;
744  ss << "Starting from IOV time in the database : year = " << coralTime.year() << ", month = " << coralTime.month()
745  << ", day = " << coralTime.day() << ", hour = " << coralTime.hour() << ", minute = " << coralTime.minute()
746  << ", second = " << coralTime.second() << ", nanosecond = " << coralTime.nanosecond() << std::endl;
747  return ss.str();
748 }

References contentValuesCheck::ss.

Referenced by buildPSUdetIdMap().

Friends And Related Function Documentation

◆ TestSiStripDetVOffBuilder

friend class TestSiStripDetVOffBuilder
friend

Definition at line 37 of file SiStripDetVOffBuilder.h.

Member Data Documentation

◆ authenticationPath

std::string SiStripDetVOffBuilder::authenticationPath
private

Definition at line 119 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), and SiStripDetVOffBuilder().

◆ coralInterface

std::unique_ptr<SiStripCoralIface> SiStripDetVOffBuilder::coralInterface
private

◆ debug_

bool SiStripDetVOffBuilder::debug_
private

◆ deltaTmin_

uint32_t SiStripDetVOffBuilder::deltaTmin_
private

Definition at line 127 of file SiStripDetVOffBuilder.h.

Referenced by getModulesVOff().

◆ detIdListFile_

std::string SiStripDetVOffBuilder::detIdListFile_
private

Definition at line 129 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj().

◆ excludedDetIdListFile_

std::string SiStripDetVOffBuilder::excludedDetIdListFile_
private

Definition at line 130 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj().

◆ fromFile

bool SiStripDetVOffBuilder::fromFile
private

Definition at line 122 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), and SiStripDetVOffBuilder().

◆ highVoltageOnThreshold_

double SiStripDetVOffBuilder::highVoltageOnThreshold_
private

Definition at line 132 of file SiStripDetVOffBuilder.h.

Referenced by lastValue(), and lastValueFromFile().

◆ lastStoredCondObj

std::pair<SiStripDetVOff*, cond::Time_t> SiStripDetVOffBuilder::lastStoredCondObj
private

◆ lastValueFileName

std::string SiStripDetVOffBuilder::lastValueFileName
private

Definition at line 121 of file SiStripDetVOffBuilder.h.

Referenced by readLastValueFromFile(), and SiStripDetVOffBuilder().

◆ maxIOVlength_

uint32_t SiStripDetVOffBuilder::maxIOVlength_
private

Definition at line 127 of file SiStripDetVOffBuilder.h.

Referenced by getModulesVOff().

◆ modulesOff

std::vector<std::pair<SiStripDetVOff*, cond::Time_t> > SiStripDetVOffBuilder::modulesOff
private

Definition at line 114 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), getModulesVOff(), and reduction().

◆ onlineDbConnectionString

std::string SiStripDetVOffBuilder::onlineDbConnectionString
private

Definition at line 118 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), and SiStripDetVOffBuilder().

◆ payloadStats

std::vector<std::vector<uint32_t> > SiStripDetVOffBuilder::payloadStats
private

Definition at line 113 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), getPayloadStats(), and setPayloadStats().

◆ psuDetIdMapFile_

std::string SiStripDetVOffBuilder::psuDetIdMapFile_
private

◆ tDefault

std::vector<int> SiStripDetVOffBuilder::tDefault
private

Definition at line 126 of file SiStripDetVOffBuilder.h.

◆ tmax

coral::TimeStamp SiStripDetVOffBuilder::tmax
private

◆ tmax_par

std::vector<int> SiStripDetVOffBuilder::tmax_par
private

Definition at line 126 of file SiStripDetVOffBuilder.h.

Referenced by SiStripDetVOffBuilder().

◆ tmin

coral::TimeStamp SiStripDetVOffBuilder::tmin
private

Definition at line 125 of file SiStripDetVOffBuilder.h.

Referenced by lastValue(), SiStripDetVOffBuilder(), and statusChange().

◆ tmin_par

std::vector<int> SiStripDetVOffBuilder::tmin_par
private

Definition at line 126 of file SiStripDetVOffBuilder.h.

Referenced by SiStripDetVOffBuilder().

◆ tset_par

std::vector<int> SiStripDetVOffBuilder::tset_par
private

Definition at line 126 of file SiStripDetVOffBuilder.h.

Referenced by SiStripDetVOffBuilder().

◆ tsetmin

coral::TimeStamp SiStripDetVOffBuilder::tsetmin
private

Definition at line 125 of file SiStripDetVOffBuilder.h.

Referenced by lastValue(), lastValueFromFile(), and SiStripDetVOffBuilder().

◆ whichQuery

bool SiStripDetVOffBuilder::whichQuery
private

Definition at line 77 of file SiStripDetVOffBuilder.h.

Referenced by BuildDetVOffObj(), and SiStripDetVOffBuilder().

◆ whichTable

std::string SiStripDetVOffBuilder::whichTable
private
SiStripDetVOffBuilder::readLastValueFromFile
void readLastValueFromFile(std::vector< uint32_t > &dpIDs, std::vector< float > &vmonValues, std::vector< coral::TimeStamp > &dateChange)
Definition: SiStripDetVOffBuilder.cc:402
SiStripDetVOffBuilder::FileExists
bool FileExists(std::string filename)
Definition: SiStripDetVOffBuilder.cc:749
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
dqm::me_util::Channel
DQMChannel Channel
Definition: MonitorElement.h:58
mps_fire.i
i
Definition: mps_fire.py:428
SiStripDetVOffBuilder::getCoralTime
coral::TimeStamp getCoralTime(cond::Time_t iovTime)
Definition: SiStripDetVOffBuilder.cc:479
cond::time::to_boost
boost::posix_time::ptime to_boost(Time_t iValue)
Definition: TimeConversions.h:39
SiStripPsuDetIdMap::getHvDetID
void getHvDetID(std::string psuchannel, std::vector< uint32_t > &ids, std::vector< uint32_t > &unmapped_ids, std::vector< uint32_t > &crosstalking_ids)
Definition: SiStripPsuDetIdMap.cc:173
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::lastStoredCondObj
std::pair< SiStripDetVOff *, cond::Time_t > lastStoredCondObj
Definition: SiStripDetVOffBuilder.h:115
SiStripDetVOffBuilder::statusChange
void statusChange(cond::Time_t &lastTime, TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:631
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripPsuDetIdMap::getHVUnmappedMap
std::map< std::string, std::vector< uint32_t > > getHVUnmappedMap()
Definition: SiStripPsuDetIdMap.h:70
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
protons_cff.time
time
Definition: protons_cff.py:39
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
SiStripDetVOffBuilder::removeDuplicates
void removeDuplicates(std::vector< uint32_t > &vec)
Definition: SiStripDetVOffBuilder.cc:498
personalPlayback.fp
fp
Definition: personalPlayback.py:523
SiStripPsuDetIdMap::getHVCrosstalkingMap
std::map< std::string, std::vector< uint32_t > > getHVCrosstalkingMap()
Definition: SiStripPsuDetIdMap.h:72
SiStripDetVOffBuilder::lastValueFromFile
void lastValueFromFile(TimesAndValues &tStruct)
Definition: SiStripDetVOffBuilder.cc:693
SiStripPsuDetIdMap::printMap
void printMap()
Definition: SiStripPsuDetIdMap.cc:480
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
SiStripPsuDetIdMap::BuildMap
void BuildMap(const std::string &mapFile, const bool debug)
Definition: SiStripPsuDetIdMap.cc:29
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:64
dqmdumpme.last
last
Definition: dqmdumpme.py:56
part
part
Definition: HCALResponse.h:20
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
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:158
DQM.reader
reader
Definition: DQM.py:105
SiStripPsuDetIdMap::getLvDetID
std::vector< uint32_t > getLvDetID(std::string psu)
Definition: SiStripPsuDetIdMap.cc:162
SiStripPsuDetIdMap
Extension to SiStripConfigDb to map PSU channels to DetIDs using DCU-PSU map and DCU-DetID map.
Definition: SiStripPsuDetIdMap.h:32
SiStripDetVOffBuilder::highVoltageOnThreshold_
double highVoltageOnThreshold_
Definition: SiStripDetVOffBuilder.h:132
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiStripDetVOff::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripDetVOff.cc:64
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
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
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripDetVOffBuilder::authenticationPath
std::string authenticationPath
Definition: SiStripDetVOffBuilder.h:119
cond::time::from_boost
Time_t from_boost(boost::posix_time::ptime bt)
Definition: TimeConversions.h:43
tkal_create_file_lists.FileInfo
FileInfo
Definition: tkal_create_file_lists.py:1119
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
SiStripDetVOffBuilder::tmax
coral::TimeStamp tmax
Definition: SiStripDetVOffBuilder.h:125
createfilelist.int
int
Definition: createfilelist.py:10
SiStripDetVOff::put
bool put(const uint32_t DetId, const int HVoff, const int LVoff)
Insert information for a single detId.
Definition: SiStripDetVOff.cc:24
SiStripDetVOff
Definition: SiStripDetVOff.h:31
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
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripDetVOffBuilder::maxIOVlength_
uint32_t maxIOVlength_
Definition: SiStripDetVOffBuilder.h:127
SiStripDetVOffBuilder::getCondTime
cond::Time_t getCondTime(const coral::TimeStamp &coralTime)
Definition: SiStripDetVOffBuilder.cc:469
util.getRunInfo.day
def day(string)
Definition: getRunInfo.py:11
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
heppy_batch.val
val
Definition: heppy_batch.py:351
SiStripDetVOffBuilder::buildPSUdetIdMap
void buildPSUdetIdMap(TimesAndValues &tStruct, DetIdListTimeAndStatus &dStruct)
Definition: SiStripDetVOffBuilder.cc:764
indexGen.date
date
Definition: indexGen.py:99
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
SiStripDetVOffBuilder::fromFile
bool fromFile
Definition: SiStripDetVOffBuilder.h:122
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
SiStripDetVOffBuilder::tmin_par
std::vector< int > tmin_par
Definition: SiStripDetVOffBuilder.h:126
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
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
combine.missing
missing
Definition: combine.py:5
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
mps_splice.line
line
Definition: mps_splice.py:76
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
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
MonitorAlCaEcalPhisym_cfi.FileName
FileName
Definition: MonitorAlCaEcalPhisym_cfi.py:15
SiStripDetVOffBuilder::tsetmin
coral::TimeStamp tsetmin
Definition: SiStripDetVOffBuilder.h:125
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27