CMS 3D CMS Logo

SiStripPsuDetIdMap.cc
Go to the documentation of this file.
7 
11 #include <cstdlib>
12 #include <iostream>
13 #include <iomanip>
14 #include <sstream>
15 #include <string>
16 
17 using namespace sistrip;
18 
19 // only one constructor
21  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] Constructing ...";
22 }
23 // destructor
25  LogTrace("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] Destructing ...";
26 }
27 
28 // Build PSU-DETID map
29 void SiStripPsuDetIdMap::BuildMap(const std::string& mapFile, const bool debug) {
30  BuildMap(mapFile, debug, LVMap, HVMap, HVUnmapped_Map, HVCrosstalking_Map);
31 }
32 
33 void SiStripPsuDetIdMap::BuildMap(const std::string& mapFile, std::vector<std::pair<uint32_t, std::string> >& rawmap) {
34  //This method is a remnant of the old method, that provided a vector type of map, based on the
35  //raw reading of a file, with no processing.
36  //FIXME:
37  //This is not currently used, but I think we could slim this down to just a vector with
38  //the detIDs since the PSUChannel part of the excludedlist (if it ever is in a file) is never used!
39  edm::FileInPath file(mapFile.c_str());
40  std::ifstream ifs(file.fullPath().c_str());
41  string line;
42  while (getline(ifs, line)) {
43  if (!line.empty()) {
44  // split the line and insert in the map
45  stringstream ss(line);
46  string PSUChannel;
47  uint32_t detId;
48  ss >> detId;
49  ss >> PSUChannel;
50  rawmap.push_back(std::make_pair(detId, PSUChannel));
51  }
52  }
53 }
54 
55 //The following is the currently used method (called from SiStripDetVOffBuilder::buildPSUdetIdMap)
57  const std::string& mapFile,
58  const bool debug,
59  PsuDetIdMap& LVmap,
60  PsuDetIdMap& HVmap,
61  PsuDetIdMap& HVUnmappedmap,
62  PsuDetIdMap& HVCrosstalkingmap) //Maybe it would be nicer to return the map instead of using a reference...
63 {
64  //This method reads the map from the mapfile indicated in the cfg
65  //It populates the 4 maps (private data members of the SiStripPSUDetIdMap in question) (all maps are std::map<std::string,uint32_t > ):
66  //LVMap
67  //HVMap
68  //HVUnmapped_Map
69  //HVCrosstalking_Map
70  //These maps are accessed, based on the LV/HV case, to extract the detIDs connected to a given PSUChannel...
71  //see the getDetIDs method...
72  edm::FileInPath file(mapFile.c_str());
73  std::ifstream ifs(file.fullPath().c_str());
74  string line;
75  while (getline(ifs, line)) {
76  if (!line.empty()) {
77  // split the line and insert in the map
78  stringstream ss(line);
79  string PSUChannel;
80  uint32_t detId;
81  ss >> detId;
82  ss >> PSUChannel;
83  //Old "vector of pairs" map!
84  //map.push_back( std::make_pair(detId, dpName) );//This "map" is normally the pgMap of the map of which we are executing BuildMap()...
85  //Using a map to make the look-up easy and avoid lots of lookup loops.
86  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
87  std::string Channel = PSUChannel.substr(PSUChannel.size() - 10);
88  LVmap[PSU].push_back(detId); // LVmap uses simply the PSU since there is no channel distinction necessary
89  if (Channel == "channel000") {
90  HVUnmappedmap[PSU].push_back(
91  detId); //Populate HV Unmapped map, by PSU listing all detids unmapped in that PSU (not necessarily all will be unmapped)
92  } else if (Channel == "channel999") {
93  HVCrosstalkingmap[PSU].push_back(
94  detId); //Populate HV Crosstalking map, by PSU listing all detids crosstalking in that PSU (usually all will be unmapped)
95  } else {
96  HVmap[PSUChannel].push_back(detId); //HV map for HV mapped channels, populated by PSU channel!
97  }
98  }
99  }
100 
101  //Remove duplicates for all 4 maps
102  for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
103  RemoveDuplicateDetIDs(psu->second);
104  }
105  for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
106  RemoveDuplicateDetIDs(psuchan->second);
107  }
108  for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
109  RemoveDuplicateDetIDs(psu->second);
110  }
111  for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
112  RemoveDuplicateDetIDs(psu->second);
113  }
114  if (debug) {
115  //Print out all the 4 maps:
116  std::cout << "Dumping the LV map" << std::endl;
117  std::cout << "PSU->detids" << std::endl;
118  for (PsuDetIdMap::iterator psu = LVMap.begin(); psu != LVMap.end(); psu++) {
119  std::cout << psu->first << " corresponds to following detids" << endl;
120  for (unsigned int i = 0; i < psu->second.size(); i++) {
121  std::cout << "\t\t" << psu->second[i] << std::endl;
122  }
123  }
124  std::cout << "Dumping the HV map for HV mapped channels" << std::endl;
125  std::cout << "PSUChannel->detids" << std::endl;
126  for (PsuDetIdMap::iterator psuchan = HVMap.begin(); psuchan != HVMap.end(); psuchan++) {
127  std::cout << psuchan->first << " corresponds to following detids" << endl;
128  for (unsigned int i = 0; i < psuchan->second.size(); i++) {
129  std::cout << "\t\t" << psuchan->second[i] << std::endl;
130  }
131  }
132  std::cout << "Dumping the HV map for HV UNmapped channels" << std::endl;
133  std::cout << "PSU->detids" << std::endl;
134  for (PsuDetIdMap::iterator psu = HVUnmapped_Map.begin(); psu != HVUnmapped_Map.end(); psu++) {
135  std::cout << psu->first << " corresponds to following detids" << endl;
136  for (unsigned int i = 0; i < psu->second.size(); i++) {
137  std::cout << "\t\t" << psu->second[i] << std::endl;
138  }
139  }
140  std::cout << "Dumping the HV map for HV Crosstalking channels" << std::endl;
141  std::cout << "PSU->detids" << std::endl;
142  for (PsuDetIdMap::iterator psu = HVCrosstalking_Map.begin(); psu != HVCrosstalking_Map.end(); psu++) {
143  std::cout << psu->first << " corresponds to following detids" << endl;
144  for (unsigned int i = 0; i < psu->second.size(); i++) {
145  std::cout << "\t\t" << psu->second[i] << std::endl;
146  }
147  }
148  //Could add here consistency checks against the list of detIDs for Strip or Pixels
149  //Number of total detIDs LVMapped, HV Mapped, HVunmapped, HV crosstalking...
150  }
151 }
152 
153 void SiStripPsuDetIdMap::RemoveDuplicateDetIDs(std::vector<uint32_t>& detids) {
154  //Function to remove duplicates from a vector of detids
155  if (!detids.empty()) { //Leave empty vector alone ;)
156  std::sort(detids.begin(), detids.end());
157  std::vector<uint32_t>::iterator it = std::unique(detids.begin(), detids.end());
158  detids.resize(it - detids.begin());
159  }
160 }
161 
162 std::vector<uint32_t> SiStripPsuDetIdMap::getLvDetID(std::string PSU) {
163  //Function that returns a vector with all detids associated with a PSU
164  //(no channel information is saved in the map since it is not relevant for LV!)
165  if (LVMap.find(PSU) != LVMap.end()) {
166  return LVMap[PSU];
167  } else {
168  std::vector<uint32_t> detids;
169  return detids;
170  }
171 }
172 
174  std::vector<uint32_t>& ids,
175  std::vector<uint32_t>& unmapped_ids,
176  std::vector<uint32_t>& crosstalking_ids) {
177  //Function that (via reference parameters) populates ids, unmapped_ids, crosstalking_ids vectors of detids associated with a given PSU *HV* channel.
178  if (HVMap.find(PSUChannel) != HVMap.end()) {
179  ids = HVMap[PSUChannel];
180  }
181  //Extract the PSU to check the unmapped and crosstalking maps too corresponding to this channel
182  std::string PSU = PSUChannel.substr(0, PSUChannel.size() - 10);
183  if (HVUnmapped_Map.find(PSU) != HVUnmapped_Map.end()) {
184  unmapped_ids = HVUnmapped_Map[PSU];
185  }
186  if (HVCrosstalking_Map.find(PSU) != HVCrosstalking_Map.end()) {
187  crosstalking_ids = HVCrosstalking_Map[PSU];
188  }
189 }
190 
191 // This method needs to be updated once HV channel mapping is known
192 // Currently, channel number is ignored for mapping purposes
193 // check both PG and CG as the channels should be unique
194 
196  const bool debug,
197  std::vector<uint32_t>& detids,
198  std::vector<uint32_t>& unmapped_detids,
199  std::vector<uint32_t>& crosstalking_detids) {
200  //This function takes as argument the PSUChannel (i.e. the dpname as it comes from the PVSS query, e.g. cms_trk_dcs_02:CAEN/CMS_TRACKER_SY1527_2/branchController05/easyCrate0/easyBoard12/channel001)
201  //And it returns 3 vectors:
202  //1-detids->all the detids positively matching the PSUChannel in question
203  //2-unmapped_detids->the detids that are matching the PSU in question but that are not HV mapped
204  //3-crosstalking_detids->the detids that are matching the PSU in question but exhibit the HV channel cross-talking behavior (they are ON as long as ANY of the 2 HV channels of the supply is ON, so they only go OFF when both channels are OFF)
205  //The second and third vectors are only relevant for the HV case, when unmapped and cross-talking channels need further processing before being turned ON and OFF.
206 
207  const std::string& PSUChannelFromQuery = PSUChannel;
208 
209  //Get the channel to see if it is LV or HV, they will be treated differently
210  std::string ChannelFromQuery = PSUChannelFromQuery.substr(PSUChannelFromQuery.size() - 10);
211  //Get the PSU from Query, to be used for LVMap and for the HVUnmapped and HVCrosstalking maps:
212  std::string PSUFromQuery = PSUChannelFromQuery.substr(0, PSUChannelFromQuery.size() - 10);
213  if (debug) {
214  //FIXME:
215  //Should handle all the couts with MessageLogger!
216  std::cout << "DPNAME from QUERY: " << PSUChannelFromQuery << ", Channel: " << ChannelFromQuery
217  << "PSU: " << PSUFromQuery << std::endl;
218  }
219 
220  //First prepare the strings needed to do the matching of the PSUChannel from the query to the ones in the map
221 
222  //Handle the LV case first:
223  if (ChannelFromQuery == "channel000" or ChannelFromQuery == "channel001") {
224  //For LV channels we need to look for any detID that is reported either as channel000 (not HV mapped)
225  //but also as channel002 and channel003 (if they are HV mapped), or as channel999 (if they are in a crosstalking PSU)
226  //Get the PSU to do a PSU-only matching to get all detIDs connected to the LV channel:
227  //Now loop over the map!
228  //for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
229  // std::string PSUFromMap = iter->second.substr(0,iter->second.size()-10);
230  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
231  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
232  // if (PSUFromQuery == PSUFromMap) {
233  // detids.push_back(iter->first); //And fill the detids vector with the all detids matching the PSU from the query!
234  // }
235  //}
236  //No need to loop over if we use an actual map!
237 
238  if (LVMap.find(PSUFromQuery) != LVMap.end()) {
239  detids = LVMap[PSUFromQuery];
240  }
241  }
242  //Handle the HV case too:
243  else if (ChannelFromQuery == "channel002" or ChannelFromQuery == "channel003") {
244  //For the HV channel we need to look at the actual positive matching detIDs,
245  //but also to the unmapped one (channel000) and the crosstalking ones (channel999).
246  //Assemble the corresponding channel000 (unmapped channels) replacing the last character in PSUChannelFromQuery:
247  // std::string ZeroedPSUChannelFromQuery= PSUChannelFromQuery;
248  // ZeroedPSUChannelFromQuery.replace(ZeroedPSUChannelFromQuery.size()-1,1,"0");
249  // //Same for channel999 for the crosstalking channels:
250  // //std::string NineNineNine='999';
251  // std::string NinedPSUChannelFromQuery= PSUChannelFromQuery;
252  // NinedPSUChannelFromQuery.replace(NinedPSUChannelFromQuery.size()-3,3,"999");
253  // //std::string NinedPSUChannelFromQuery= PSUChannelFromQuery.substr(0,PSUChannelFromQuery.size()-3);// + '999';
254  // //Now loop over the map!
255  // for (PsuDetIdMap::iterator iter = pgMap.begin(); iter != pgMap.end(); iter++) {
256  // std::string PSUChannelFromMap = iter->second;
257  // //Careful if you uncomment this cout: it prints 15148 lines when checking for 1 psu name match! (meant for debugging of course)
258  // //std::cout<<"Truncated DPNAME from MAP: "<<PSUFromMap<<std::endl;
259  // if (PSUChannelFromMap==PSUChannelFromQuery) {
260  // detids.push_back(iter->first); //Fill the detids vector with the all detids matching the PSUChannel from the query!
261  // }
262  // if (PSUChannelFromMap==ZeroedPSUChannelFromQuery) {
263  // unmapped_detids.push_back(iter->first); //Fill the unmapped_detids vector with the all detids matching the channel000 for the PSU from the query!
264  // if (debug) { //BEWARE: this debug printouts can become very heavy! 1 print out per detID matched!
265  // std::cout<<"Matched one of the HV-UNMAPPED channels: "<<ZeroedPSUChannelFromQuery<<std::endl;
266  // std::cout<<"Corresponding to detID: "<<iter->first<<std::endl;
267  // //for (unsigned int i_nohvmap_detid=0;i_nohvmap_detid < iter->first.size();i_nohvmap_detid++) {
268  // // cout<< iter->first[i_nohvmap_detid] << std::endl;
269  // }
270  // }
271  // if (PSUChannelFromMap==NinedPSUChannelFromQuery) {
272  // crosstalking_detids.push_back(iter->first); //Fill the crosstalking_detids vector with the all detids matching the channel999 for the PSU from the query!
273  // }
274  // }
275  if (HVMap.find(PSUChannelFromQuery) != HVMap.end()) {
276  detids = HVMap[PSUChannelFromQuery];
277  } else if (HVUnmapped_Map.find(PSUFromQuery) != HVUnmapped_Map.end()) {
278  unmapped_detids = HVUnmapped_Map[PSUFromQuery];
279  } else if (HVCrosstalking_Map.find(PSUFromQuery) != HVCrosstalking_Map.end()) {
280  crosstalking_detids = HVCrosstalking_Map[PSUFromQuery];
281  }
282  }
283  //
284  //
285  // //With the new code above that makes use of the channel00X information in the map
286  // //we should no more need to remove duplicates by construction.
287  // //The following code was used when there was no channel information in the map,
288  // //to elegantly eliminate duplicates.
289  // //We can now use it as a cross-check (still removing duplicates in case they happen, but writing a message out)
290  //
291  // // remove duplicates
292  //
293  // //First sort detIDs vector, so that duplicates will be consecutive
294  // if (!detids.empty()) {
295  // std::sort(detids.begin(),detids.end());
296  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
297  // //and reports a forward iterator pointing to the new end of the sequence
298  // std::vector<uint32_t>::iterator it = std::unique(detids.begin(),detids.end());
299  // if (it!=detids.end()) {
300  // std::cout<<"ARGH! It seems we found duplicate detIDs in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
301  // detids.resize( it - detids.begin() );
302  // }
303  // if (debug) {
304  // std::cout<<"Matched the following detIDs to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
305  // for (std::vector<uint32_t>::iterator i_detid=detids.begin();i_detid!=detids.end(); i_detid++) {
306  // std::cout<<*i_detid<<std::endl;;
307  // }
308  // }
309  // }
310  // //Same for unmapped detIDs:
311  // if (!unmapped_detids.empty()) {
312  // std::sort(unmapped_detids.begin(),unmapped_detids.end());
313  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
314  // //and reports a forward iterator pointing to the new end of the sequence
315  // std::vector<uint32_t>::iterator it = std::unique(unmapped_detids.begin(),unmapped_detids.end());
316  // if (it!=unmapped_detids.end()) {
317  // std::cout<<"ARGH! It seems we found duplicate unmapped_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
318  // unmapped_detids.resize( it - unmapped_detids.begin() );
319  // }
320  // if (debug) {
321  // std::cout<<"Matched the following unmapped_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
322  // for (std::vector<uint32_t>::iterator i_detid=unmapped_detids.begin();i_detid!=unmapped_detids.end(); i_detid++) {
323  // std::cout<<*i_detid<<std::endl;;
324  // }
325  // }
326  // }
327  // //Finally, same for crosstalking detIDs:
328  // if (!crosstalking_detids.empty()) {
329  // std::sort(crosstalking_detids.begin(),crosstalking_detids.end());
330  // //Then use the forward iterator unique from STD that basically removes all consecutive duplicates from the vector
331  // //and reports a forward iterator pointing to the new end of the sequence
332  // std::vector<uint32_t>::iterator it = std::unique(crosstalking_detids.begin(),crosstalking_detids.end());
333  // if (it!=crosstalking_detids.end()) {
334  // std::cout<<"ARGH! It seems we found duplicate crosstalking_detids in the map corresponding to this PSUChannel: "<<PSUChannelFromQuery<<std::endl;
335  // crosstalking_detids.resize( it - crosstalking_detids.begin() );
336  // }
337  // if (debug) {
338  // std::cout<<"Matched the following crosstalking_detids to PSU channel from query "<<PSUChannelFromQuery <<":"<<std::endl;
339  // for (std::vector<uint32_t>::iterator i_detid=crosstalking_detids.begin();i_detid!=crosstalking_detids.end(); i_detid++) {
340  // std::cout<<*i_detid<<std::endl;;
341  // }
342  // }
343  // }
344  //
345  // //Using reference parameters since we are returning multiple objects.
346  // //return detids;
347 }
348 
349 // returns PSU channel name for a given DETID
351  std::vector<std::pair<uint32_t, std::string> >::iterator iter;
352  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
353  if (iter->first && iter->first == detid) {
354  return iter->second;
355  }
356  }
357  // if we reach here, then we didn't find the detid in the map
358  return "UNKNOWN";
359 }
360 
362  std::vector<std::pair<uint32_t, std::string> >::iterator iter;
363  if (group == "PG") {
364  for (iter = pgMap.begin(); iter != pgMap.end(); iter++) {
365  if (iter->first && iter->first == detid) {
366  return iter->second;
367  }
368  }
369  }
370  if (group == "CG") {
371  for (iter = cgMap.begin(); iter != cgMap.end(); iter++) {
372  if (iter->first && iter->first == detid) {
373  return iter->second;
374  }
375  }
376  }
377  // if we reach here, then we didn't find the detid in the map
378  return "UNKNOWN";
379 }
380 
381 // returns the PVSS name for a given DETID
383  for (unsigned int i = 0; i < pgMap.size(); i++) {
384  if (pgMap[i].first == detid) {
385  return detectorLocations[i];
386  }
387  }
388  return "UNKNOWN";
389 }
390 
391 // returns the PVSS name for a given DETID, depending on specified map
393  if (group == "PG") {
394  for (unsigned int i = 0; i < pgMap.size(); i++) {
395  if (pgMap[i].first == detid) {
396  return detectorLocations[i];
397  }
398  }
399  }
400  if (group == "CG") {
401  for (unsigned int i = 0; i < cgMap.size(); i++) {
402  if (cgMap[i].first == detid) {
403  return controlLocations[i];
404  }
405  }
406  }
407  return "UNKNOWN";
408 }
409 
410 // returns the PVSS name for a given PSU channel
412  for (unsigned int i = 0; i < pgMap.size(); i++) {
413  if (pgMap[i].second == PSUChannel) {
414  return detectorLocations[i];
415  }
416  }
417  for (unsigned int i = 0; i < cgMap.size(); i++) {
418  if (cgMap[i].second == PSUChannel) {
419  return controlLocations[i];
420  }
421  }
422  return "UNKNOWN";
423 }
424 
425 // returns the DCU ID for a given PSU channel
427  for (unsigned int i = 0; i < pgMap.size(); i++) {
428  if (pgMap[i].second == PSUChannel) {
429  return dcuIds[i];
430  }
431  }
432  for (unsigned int i = 0; i < cgMap.size(); i++) {
433  if (cgMap[i].second == PSUChannel) {
434  return cgDcuIds[i];
435  }
436  }
437  return 0;
438 }
439 
440 uint32_t SiStripPsuDetIdMap::getDcuId(uint32_t detid) {
441  for (unsigned int i = 0; i < pgMap.size(); i++) {
442  if (pgMap[i].first == detid) {
443  return dcuIds[i];
444  }
445  }
446  return 0;
447 }
448 
449 // determine if a given PSU channel is HV or not
451  // isHV = 0 means LV, = 1 means HV, = -1 means error
452  int isHV = 0;
453  std::string::size_type loc = PSUChannel.find("channel", 0);
454  if (loc != std::string::npos) {
455  std::string chNumber = PSUChannel.substr(loc + 7, 3);
456  if (chNumber == "002" || chNumber == "003") {
457  isHV = 1;
458  } else if (chNumber == "000" || chNumber == "001") {
459  isHV = 0;
460  } else {
461  edm::LogWarning("SiStripPsuDetIdMap")
462  << "[SiStripPsuDetIdMap::" << __func__ << "] channel number of unexpected format, setting error flag!";
463  isHV = -1;
464  }
465  } else {
466  edm::LogWarning("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__
467  << "] channel number not located in PSU channel name, setting error flag!";
468  isHV = -1;
469  }
470  return isHV;
471 }
472 
474  output.clear();
475  for (unsigned int i = 0; i < input.size(); i++) {
476  output.push_back(new TkDcuPsuMap(*(input[i])));
477  }
478 }
479 
481  stringstream pg;
482  pg << "Map of power supplies to DET IDs: " << std::endl << "-- PSU name -- -- Det Id --" << std::endl;
483  for (unsigned int p = 0; p < pgMap.size(); p++) {
484  pg << pgMap[p].first << " " << pgMap[p].second << std::endl;
485  }
486  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << pg.str();
487 }
488 
490  stringstream cg;
491  cg << "Map of control power supplies to DET IDs: " << std::endl
492  << "-- PSU name -- -- Det Id --" << std::endl;
493  for (unsigned int p = 0; p < cgMap.size(); p++) {
494  cg << cgMap[p].first << " " << cgMap[p].second << std::endl;
495  }
496  edm::LogInfo("SiStripPsuDetIdMap") << "[SiStripPsuDetIdMap::" << __func__ << "] " << cg.str();
497 }
498 
499 std::vector<std::pair<uint32_t, std::string> > SiStripPsuDetIdMap::getDcuPsuMap() {
500  if (!pgMap.empty()) {
501  return pgMap;
502  }
503  std::vector<std::pair<uint32_t, std::string> > emptyVec;
504  return emptyVec;
505 }
506 
508  const DcuPsuVector& dcuPsus_) {
509  std::cout << "Number of entries in DCU-PSU map: " << dcuPsus_.size() << std::endl;
510  std::cout << "Number of entries in DCU-DETID map: " << dcuDetIds_.size() << std::endl;
511  std::cout << std::endl;
512 
513  std::vector<bool> ddUsed(dcuDetIds_.size(), false);
514  std::vector<bool> dpUsed(dcuPsus_.size(), false);
515 
516  for (unsigned int dp = 0; dp < dcuPsus_.size(); dp++) {
517  for (unsigned int dd = 0; dd < dcuDetIds_.size(); dd++) {
518  if (dcuPsus_[dp]->getDcuHardId() == dcuDetIds_[dd].second->getDcuHardId()) {
519  dpUsed[dp] = true;
520  ddUsed[dd] = true;
521  }
522  }
523  }
524  unsigned int numDpUsed = 0, numDpNotUsed = 0;
525  for (unsigned int dp = 0; dp < dpUsed.size(); dp++) {
526  if (dpUsed[dp]) {
527  numDpUsed++;
528  } else {
529  numDpNotUsed++;
530  }
531  }
532 
533  std::cout << "Number of used DCU-PSU entries: " << numDpUsed << std::endl;
534  std::cout << "Number of unused DCU-PSU entries: " << numDpNotUsed << std::endl;
535 
536  unsigned int numDdUsed = 0, numDdNotUsed = 0;
537  for (unsigned int dd = 0; dd < ddUsed.size(); dd++) {
538  if (ddUsed[dd]) {
539  numDdUsed++;
540  } else {
541  numDdNotUsed++;
542  }
543  }
544 
545  std::cout << "Number of used DCU-DETID entries: " << numDdUsed << std::endl;
546  std::cout << "Number of unused DCU-DETID entries: " << numDdNotUsed << std::endl;
547  std::cout << std::endl;
548  std::cout << "Size of PSU-DETID map: " << pgMap.size() << std::endl;
549  std::cout << "Size of detectorLocations: " << detectorLocations.size() << std::endl;
550 }
551 
552 //std::vector< std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > SiStripPsuDetIdMap::retrieveDcuDeviceAddresses(std::string partition) {
553 std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > > SiStripPsuDetIdMap::retrieveDcuDeviceAddresses(
554  std::string partition) {
555  // get the DB parameters
556  SiStripDbParams dbParams_ = db_->dbParams();
557  SiStripDbParams::SiStripPartitions::const_iterator iter;
558 
559  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> > resultVec;
560 
562  SiStripConfigDb::DeviceType device_ = DCU;
563 
564  for (iter = dbParams_.partitions().begin(); iter != dbParams_.partitions().end(); ++iter) {
565  if (partition.empty() || partition == iter->second.partitionName()) {
566  if (iter->second.partitionName() == SiStripPartition::defaultPartitionName_) {
567  continue;
568  }
569  if (iter->second.dcuVersion().first > 0 && iter->second.fecVersion().first > 0) {
571  db_->getDeviceDescriptions(device_, iter->second.partitionName());
572  if (!range.empty()) {
573  SiStripConfigDb::DeviceDescriptionsV nextVec(range.begin(), range.end());
574  for (unsigned int i = 0; i < nextVec.size(); i++) {
575  dcuDescription* desc = dynamic_cast<dcuDescription*>(nextVec[i]);
576  resultVec.push_back(std::make_pair(desc->getDcuHardId(), db_->deviceAddress(*(nextVec[i]))));
577  }
578  }
579  }
580  }
581  }
582 
583  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > > testVec;
584  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator reorg_iter = resultVec.begin();
585 
586  for (; reorg_iter != resultVec.end(); reorg_iter++) {
587  std::vector<uint16_t> fecInfo(4, 0);
588  fecInfo[0] = reorg_iter->second.fecCrate_;
589  fecInfo[1] = reorg_iter->second.fecSlot_;
590  fecInfo[2] = reorg_iter->second.fecRing_;
591  fecInfo[3] = reorg_iter->second.ccuAddr_;
592  std::vector<uint32_t> dcuids;
593  std::vector<std::pair<uint32_t, SiStripConfigDb::DeviceAddress> >::iterator jter = reorg_iter;
594  for (; jter != resultVec.end(); jter++) {
595  if (reorg_iter->second.fecCrate_ == jter->second.fecCrate_ &&
596  reorg_iter->second.fecSlot_ == jter->second.fecSlot_ &&
597  reorg_iter->second.fecRing_ == jter->second.fecRing_ &&
598  reorg_iter->second.ccuAddr_ == jter->second.ccuAddr_) {
599  dcuids.push_back(jter->first);
600  }
601  }
602  // handle duplicates
603  bool isDup = false;
604  for (unsigned int i = 0; i < testVec.size(); i++) {
605  if (fecInfo == testVec[i].first) {
606  isDup = true;
607  dcuids.insert(dcuids.end(), (testVec[i].second).begin(), (testVec[i].second).end());
608  std::sort(dcuids.begin(), dcuids.end());
609  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(), dcuids.end());
610  dcuids.resize(it - dcuids.begin());
611  testVec[i].second = dcuids;
612  }
613  }
614  if (!isDup) {
615  std::sort(dcuids.begin(), dcuids.end());
616  std::vector<uint32_t>::iterator it = std::unique(dcuids.begin(), dcuids.end());
617  dcuids.resize(it - dcuids.begin());
618  testVec.push_back(std::make_pair(fecInfo, dcuids));
619  }
620  }
621  // return resultVec;
622  return testVec;
623 }
624 
625 std::vector<uint32_t> SiStripPsuDetIdMap::findDcuIdFromDeviceAddress(uint32_t dcuid_) {
626  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > >::iterator iter =
627  dcu_device_addr_vector.begin();
628  std::vector<std::pair<std::vector<uint16_t>, std::vector<uint32_t> > >::iterator res_iter =
629  dcu_device_addr_vector.end();
630  std::vector<uint32_t> pgDcu;
631 
632  for (; iter != dcu_device_addr_vector.end(); iter++) {
633  std::vector<uint32_t> dcuids = iter->second;
634  std::vector<uint32_t>::iterator dcu_iter = std::find(dcuids.begin(), dcuids.end(), dcuid_);
635  bool alreadyFound = false;
636  if (res_iter != dcu_device_addr_vector.end()) {
637  alreadyFound = true;
638  }
639  if (dcu_iter != dcuids.end()) {
640  res_iter = iter;
641  if (!alreadyFound) {
642  for (unsigned int i = 0; i < dcuids.size(); i++) {
643  if (dcuids[i] != dcuid_) {
644  pgDcu.push_back(dcuids[i]);
645  }
646  }
647  } else {
648  std::cout << "Oh oh ... we have a duplicate :-(" << std::endl;
649  }
650  }
651  }
652  return pgDcu;
653 }
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
dqm::me_util::Channel
DQMChannel Channel
Definition: MonitorElement.h:58
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
SiStripPsuDetIdMap::findDcuIdFromDeviceAddress
std::vector< uint32_t > findDcuIdFromDeviceAddress(uint32_t dcuid_)
Definition: SiStripPsuDetIdMap.cc:625
SiStripConfigDb::DeviceDescriptionsRange
DeviceDescriptions::range DeviceDescriptionsRange
Definition: SiStripConfigDb.h:110
SiStripPsuDetIdMap::getDetID
void getDetID(std::string pvss, bool, std::vector< uint32_t > &detids, std::vector< uint32_t > &unmapped_detids, std::vector< uint32_t > &crosstalking_detids)
Definition: SiStripPsuDetIdMap.cc:195
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
SiStripConfigDb::DcuDetIdsV
std::vector< DcuDetId > DcuDetIdsV
Definition: SiStripConfigDb.h:128
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
SiStripPsuDetIdMap::retrieveDcuDeviceAddresses
std::vector< std::pair< std::vector< uint16_t >, std::vector< uint32_t > > > retrieveDcuDeviceAddresses(std::string partition)
Definition: SiStripPsuDetIdMap.cc:553
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripConfigDb::DeviceDescriptionsV
std::vector< DeviceDescription * > DeviceDescriptionsV
Definition: SiStripConfigDb.h:111
SiStripPsuDetIdMap.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
SiStripPsuDetIdMap::printMap
void printMap()
Definition: SiStripPsuDetIdMap.cc:480
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
dqmdumpme.first
first
Definition: dqmdumpme.py:55
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiStripPsuDetIdMap::BuildMap
void BuildMap(const std::string &mapFile, const bool debug)
Definition: SiStripPsuDetIdMap.cc:29
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripPsuDetIdMap::getDcuId
uint32_t getDcuId(std::string pvss)
Definition: SiStripPsuDetIdMap.cc:426
edm::FileInPath
Definition: FileInPath.h:64
SiStripPsuDetIdMap::getDetectorLocation
std::string getDetectorLocation(uint32_t detid)
Definition: SiStripPsuDetIdMap.cc:382
debug
#define debug
Definition: HDRShower.cc:19
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:157
Service.h
SiStripPsuDetIdMap::IsHVChannel
int IsHVChannel(std::string pvss)
Definition: SiStripPsuDetIdMap.cc:450
SiStripPsuDetIdMap::getLvDetID
std::vector< uint32_t > getLvDetID(std::string psu)
Definition: SiStripPsuDetIdMap.cc:162
SiStripConfigDb::DeviceType
enumDeviceType DeviceType
Definition: SiStripConfigDb.h:107
mps_fire.end
end
Definition: mps_fire.py:242
SiStripPsuDetIdMap::printControlMap
void printControlMap()
Definition: SiStripPsuDetIdMap.cc:489
createTree.dd
string dd
Definition: createTree.py:154
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripPsuDetIdMap::checkMapInputValues
void checkMapInputValues(const SiStripConfigDb::DcuDetIdsV &dcuDetIds_, const DcuPsuVector &dcuPsus_)
Definition: SiStripPsuDetIdMap.cc:507
SiStripConstants.h
SiStripPsuDetIdMap::clone
void clone(DcuPsuVector &input, DcuPsuVector &output)
Definition: SiStripPsuDetIdMap.cc:473
SiStripPsuDetIdMap::SiStripPsuDetIdMap
SiStripPsuDetIdMap()
Definition: SiStripPsuDetIdMap.cc:20
SiStripDbParams::partitions
const_iterator_range partitions() const
Definition: SiStripDbParams.h:178
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SiStripPsuDetIdMap::getDcuPsuMap
std::vector< std::pair< uint32_t, std::string > > getDcuPsuMap()
Definition: SiStripPsuDetIdMap.cc:499
SiStripConfigDb.h
SiStripPsuDetIdMap::RemoveDuplicateDetIDs
void RemoveDuplicateDetIDs(std::vector< uint32_t > &detids)
Definition: SiStripPsuDetIdMap.cc:153
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SiStripDbParams
Container class for database connection parameters.
Definition: SiStripDbParams.h:25
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
SiStripEnumsAndStrings.h
ParameterSetfwd.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Exception.h
SiStripPsuDetIdMap::~SiStripPsuDetIdMap
~SiStripPsuDetIdMap()
Definition: SiStripPsuDetIdMap.cc:24
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
ParameterSet.h
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
SiStripPsuDetIdMap::DcuPsuVector
std::vector< TkDcuPsuMap * > DcuPsuVector
Definition: SiStripPsuDetIdMap.h:123
SiStripPartition::defaultPartitionName_
static const std::string defaultPartitionName_
Definition: SiStripPartition.h:40
mps_splice.line
line
Definition: mps_splice.py:76
SiStripPsuDetIdMap::getPSUName
std::string getPSUName(uint32_t detid)
Definition: SiStripPsuDetIdMap.cc:350
watchdog.group
group
Definition: watchdog.py:82