CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CalibFormats/SiPixelObjects/src/PixelConfigurationVerifier.cc

Go to the documentation of this file.
00001 //
00002 // 
00003 //
00004 //
00005 
00006 #include "CalibFormats/SiPixelObjects/interface/PixelConfigurationVerifier.h"
00007 #include "CalibFormats/SiPixelObjects/interface/PixelChannel.h"
00008 #include "CalibFormats/SiPixelObjects/interface/PixelROCStatus.h"
00009 #include <set>
00010 #include <assert.h>
00011 
00012 using namespace pos;
00013 using namespace std;
00014 
00015 
00016 void PixelConfigurationVerifier::checkChannelEnable(PixelFEDCard *theFEDCard,
00017                                                     PixelNameTranslation *theNameTranslation,
00018                                                     PixelDetectorConfig *theDetConfig){
00019   
00020   std::string mthn = "[PixelConfigurationVerifier::checkChannelEnable()]\t\t    " ;
00021   set<PixelChannel> channels=theNameTranslation->getChannels(*theDetConfig);
00022 
00023   unsigned int fedid=theFEDCard->fedNumber;
00024 
00025   //use slots 1-36
00026 
00027   vector<bool> usedChannel(37);
00028   for(unsigned int i=1;i<37;i++){
00029     usedChannel[i]=false;
00030   }
00031 
00032   set<PixelChannel>::const_iterator iChannel=channels.begin();
00033 
00034 
00035   map <int, int> nrocs;
00036   for(;iChannel!=channels.end();++iChannel){
00037     PixelHdwAddress hdw=theNameTranslation->getHdwAddress(*iChannel);
00038     if (fedid==hdw.fednumber()){
00039       unsigned int fedchannel=hdw.fedchannel();
00040       assert(fedchannel>0&&fedchannel<37);
00041       usedChannel[fedchannel]=true;
00042       nrocs[fedchannel] = theNameTranslation->getROCsFromChannel(*iChannel).size();
00043     }
00044   }
00045 
00046   map<PixelROCName, PixelROCStatus> roclistcopy = theDetConfig->getROCsList();
00047   //Now check the channels
00048 
00049   for(unsigned int jChannel=1;jChannel<37;jChannel++){
00050     bool used=theFEDCard->useChannel(jChannel);
00051     //    if (!used) cout << "Channel="<<jChannel<<" is not used"<<endl;
00052     if (used) { 
00053       //            cout << "Channel="<<jChannel<<" is used"<<endl;
00054       //check that nROCs is the same from theNameTranslation and theFEDCard
00055       if (nrocs[jChannel] != theFEDCard->NRocs[jChannel-1]) {
00056         cout<<"[PixelConfigurationVerifier] Warning in FED#"<<fedid<<", channel#"<<jChannel
00057             <<": number of ROCs mismatch: theNameTranslation="<<nrocs[jChannel]<<"; theFEDCard="<<theFEDCard->NRocs[jChannel-1]<<endl;
00058       }
00059     }
00060      
00061     //only do these checks if the channel exists
00062     if (theNameTranslation->FEDChannelExist(fedid,jChannel)) {
00063       
00064       //make sure that all rocs on a channel have the same noAnalogSignal status
00065       vector<PixelROCName> rocsOnThisChannel= theNameTranslation->getROCsFromFEDChannel(fedid,jChannel);
00066       bool onehasNAS=false,onedoesnothaveNAS=false;
00067       vector<PixelROCName>::const_iterator jROC=rocsOnThisChannel.begin();
00068       for (; jROC!= rocsOnThisChannel.end(); ++jROC) {
00069         PixelROCStatus thisROCstatus = roclistcopy[*jROC];
00070         if ( thisROCstatus.get(PixelROCStatus::noAnalogSignal) ) onehasNAS=true;
00071         else onedoesnothaveNAS=true;
00072       }
00073       if (onehasNAS && onedoesnothaveNAS) {
00074         cout<<"[PixelConfigurationVerifier] Error in FED#"<<fedid<<", channel#"<<jChannel
00075             <<": not all ROCs have the same noAnalogSignal state."<<endl;
00076         assert(0);
00077       }
00078       
00079       //now if onehasNAS is true, then all must be noAnalogSignal --> turn off this FED channel!
00080       if (onehasNAS) {
00081         cout<<"[PixelConfigurationVerifier] FEDid="<<fedid<<", channel="<<jChannel
00082             <<": Channel disabled because ROCs are set to noAnalogSignal"<<endl;
00083         theFEDCard->setChannel(jChannel,false); //false should disable the channel
00084       }
00085       
00086       if (!onehasNAS && (used!=usedChannel[jChannel])) {
00087         cout << __LINE__ << "]\t" << mthn << "*******************************************************"     << endl;
00088         cout << __LINE__ << "]\t" << mthn << "WARNING for fedid=" << fedid << " and channel=" << jChannel  <<
00089           " found that fedcard has channel as "                         << endl;
00090         if (used)  cout << __LINE__ << "]\t" << mthn << "used while configuration not using this channel"
00091                         << endl;
00092         if (!used) cout << __LINE__ << "]\t" << mthn << "not used while configuration uses this channel"
00093                         << endl;
00094         cout << __LINE__ << "]\t" << mthn << "The fedcard will be modifed to agree with configuration"   << endl;
00095         cout << __LINE__ << "]\t" << mthn << "*******************************************************"   << endl;
00096         theFEDCard->setChannel(jChannel,usedChannel[jChannel]);
00097       }
00098     }
00099   }
00100 
00101 }