CMS 3D CMS Logo

PixelConfigurationVerifier.cc
Go to the documentation of this file.
1 //
2 //
3 //
4 //
5 
9 #include <set>
10 #include <cassert>
11 
12 using namespace pos;
13 using namespace std;
14 
16  PixelNameTranslation *theNameTranslation,
17  PixelDetectorConfig *theDetConfig) {
18  std::string mthn = "[PixelConfigurationVerifier::checkChannelEnable()]\t\t ";
19  set<PixelChannel> channels = theNameTranslation->getChannels(*theDetConfig);
20 
21  unsigned int fedid = theFEDCard->fedNumber;
22 
23  //use slots 1-36
24 
25  vector<bool> usedChannel(37);
26  for (unsigned int i = 1; i < 37; i++) {
27  usedChannel[i] = false;
28  }
29 
30  set<PixelChannel>::const_iterator iChannel = channels.begin();
31 
32  map<int, int> nrocs;
33  for (; iChannel != channels.end(); ++iChannel) {
34  PixelHdwAddress hdw = theNameTranslation->getHdwAddress(*iChannel);
35  if (fedid == hdw.fednumber()) {
36  unsigned int fedchannel = hdw.fedchannel();
37  assert(fedchannel > 0 && fedchannel < 37);
38  usedChannel[fedchannel] = true;
39  nrocs[fedchannel] = theNameTranslation->getROCsFromChannel(*iChannel).size();
40  }
41  }
42 
43  map<PixelROCName, PixelROCStatus> roclistcopy = theDetConfig->getROCsList();
44  //Now check the channels
45 
46  for (unsigned int jChannel = 1; jChannel < 37; jChannel++) {
47  bool used = theFEDCard->useChannel(jChannel);
48  // if (!used) cout << "Channel="<<jChannel<<" is not used"<<endl;
49  if (used) {
50  // cout << "Channel="<<jChannel<<" is used"<<endl;
51  //check that nROCs is the same from theNameTranslation and theFEDCard
52  if (nrocs[jChannel] != theFEDCard->NRocs[jChannel - 1]) {
53  cout << "[PixelConfigurationVerifier] Warning in FED#" << fedid << ", channel#" << jChannel
54  << ": number of ROCs mismatch: theNameTranslation=" << nrocs[jChannel]
55  << "; theFEDCard=" << theFEDCard->NRocs[jChannel - 1] << endl;
56  }
57  }
58 
59  //only do these checks if the channel exists
60  if (theNameTranslation->FEDChannelExist(fedid, jChannel)) {
61  //make sure that all rocs on a channel have the same noAnalogSignal status
62  vector<PixelROCName> rocsOnThisChannel = theNameTranslation->getROCsFromFEDChannel(fedid, jChannel);
63  bool onehasNAS = false, onedoesnothaveNAS = false;
64  vector<PixelROCName>::const_iterator jROC = rocsOnThisChannel.begin();
65  for (; jROC != rocsOnThisChannel.end(); ++jROC) {
66  PixelROCStatus thisROCstatus = roclistcopy[*jROC];
67  if (thisROCstatus.get(PixelROCStatus::noAnalogSignal))
68  onehasNAS = true;
69  else
70  onedoesnothaveNAS = true;
71  }
72  if (onehasNAS && onedoesnothaveNAS) {
73  cout << "[PixelConfigurationVerifier] Error in FED#" << fedid << ", channel#" << jChannel
74  << ": not all ROCs have the same noAnalogSignal state." << endl;
75  assert(0);
76  }
77 
78  //now if onehasNAS is true, then all must be noAnalogSignal --> turn off this FED channel!
79  if (onehasNAS) {
80  cout << "[PixelConfigurationVerifier] FEDid=" << fedid << ", channel=" << jChannel
81  << ": Channel disabled because ROCs are set to noAnalogSignal" << endl;
82  theFEDCard->setChannel(jChannel, false); //false should disable the channel
83  }
84 
85  if (!onehasNAS && (used != usedChannel[jChannel])) {
86  cout << __LINE__ << "]\t" << mthn << "*******************************************************" << endl;
87  cout << __LINE__ << "]\t" << mthn << "WARNING for fedid=" << fedid << " and channel=" << jChannel
88  << " found that fedcard has channel as " << endl;
89  if (used)
90  cout << __LINE__ << "]\t" << mthn << "used while configuration not using this channel" << endl;
91  if (!used)
92  cout << __LINE__ << "]\t" << mthn << "not used while configuration uses this channel" << endl;
93  cout << __LINE__ << "]\t" << mthn << "The fedcard will be modifed to agree with configuration" << endl;
94  cout << __LINE__ << "]\t" << mthn << "*******************************************************" << endl;
95  theFEDCard->setChannel(jChannel, usedChannel[jChannel]);
96  }
97  }
98  }
99 }
bool FEDChannelExist(unsigned int fednumber, unsigned int fedchannel) const
const std::vector< PixelROCName > & getROCsFromChannel(const PixelChannel &aChannel) const
unsigned int fedchannel() const
This class implements...
assert(be >=bs)
const std::vector< PixelROCName > & getROCsFromFEDChannel(unsigned int fednumber, unsigned int fedchannel) const
bool useChannel(unsigned int iChannel)
void checkChannelEnable(PixelFEDCard *theFEDCard, PixelNameTranslation *theNameTranslation, PixelDetectorConfig *theDetConfig)
std::set< PixelChannel > getChannels() const
This is the documentation about PixelDetectorConfig...
Store mfec, mfecchannel etc.
const std::map< PixelROCName, PixelROCStatus > & getROCsList() const
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
This class performs various tests to make sure that configurations are consistent.
This is the documentation about PixelNameTranslation...
This class implements..
void setChannel(unsigned int iChannel, bool mode)
This is the documentation about PixelFEDCard...
Definition: PixelFEDCard.h:27
unsigned long fedNumber
Definition: PixelFEDCard.h:146
bool get(ROCstatus stat) const
unsigned int fednumber() const
This class keeps the possible non-standard status a ROC can have.