CMS 3D CMS Logo

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