CMS 3D CMS Logo

SiPixelRawDataErrorModule.cc

Go to the documentation of this file.
00001 #include "DQM/SiPixelMonitorRawData/interface/SiPixelRawDataErrorModule.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00004 // Framework
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 // STL
00007 #include <vector>
00008 #include <memory>
00009 #include <string>
00010 #include <iostream>
00011 #include <stdlib.h>
00012 
00013 // Data Formats
00014 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00015 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00016 #include "DataFormats/DetId/interface/DetId.h"
00017 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00018 
00019 const int SiPixelRawDataErrorModule::LINK_bits = 6;
00020 const int SiPixelRawDataErrorModule::ROC_bits  = 5;
00021 const int SiPixelRawDataErrorModule::DCOL_bits = 5;
00022 const int SiPixelRawDataErrorModule::PXID_bits = 8;
00023 const int SiPixelRawDataErrorModule::ADC_bits  = 8;
00024 const int SiPixelRawDataErrorModule::DataBit_bits = 1;
00025 
00026 const int SiPixelRawDataErrorModule::ADC_shift  = 0;
00027 const int SiPixelRawDataErrorModule::PXID_shift = ADC_shift + ADC_bits;
00028 const int SiPixelRawDataErrorModule::DCOL_shift = PXID_shift + PXID_bits;
00029 const int SiPixelRawDataErrorModule::ROC_shift  = DCOL_shift + DCOL_bits;
00030 const int SiPixelRawDataErrorModule::LINK_shift = ROC_shift + ROC_bits;
00031 const int SiPixelRawDataErrorModule::DB0_shift = 0;
00032 const int SiPixelRawDataErrorModule::DB1_shift = DB0_shift + DataBit_bits;
00033 const int SiPixelRawDataErrorModule::DB2_shift = DB1_shift + DataBit_bits;
00034 const int SiPixelRawDataErrorModule::DB3_shift = DB2_shift + DataBit_bits;
00035 const int SiPixelRawDataErrorModule::DB4_shift = DB3_shift + DataBit_bits;
00036 const int SiPixelRawDataErrorModule::DB5_shift = DB4_shift + DataBit_bits;
00037 const int SiPixelRawDataErrorModule::DB6_shift = DB5_shift + DataBit_bits;
00038 const int SiPixelRawDataErrorModule::DB7_shift = DB6_shift + DataBit_bits;
00039 
00040 const uint32_t SiPixelRawDataErrorModule::LINK_mask = ~(~uint32_t(0) << LINK_bits);
00041 const uint32_t SiPixelRawDataErrorModule::ROC_mask  = ~(~uint32_t(0) << ROC_bits);
00042 const uint32_t SiPixelRawDataErrorModule::DCOL_mask = ~(~uint32_t(0) << DCOL_bits);
00043 const uint32_t SiPixelRawDataErrorModule::PXID_mask = ~(~uint32_t(0) << PXID_bits);
00044 const uint32_t SiPixelRawDataErrorModule::ADC_mask  = ~(~uint32_t(0) << ADC_bits);
00045 const uint32_t SiPixelRawDataErrorModule::DataBit_mask = ~(~uint32_t(0) << DataBit_bits);
00046 
00047 const int SiPixelRawDataErrorModule::TRLRBGN_bits = 32;
00048 const int SiPixelRawDataErrorModule::EVTLGT_bits  = 24;
00049 const int SiPixelRawDataErrorModule::TRLREND_bits = 8;
00050 
00051 const int SiPixelRawDataErrorModule::TRLRBGN_shift = 0;
00052 const int SiPixelRawDataErrorModule::EVTLGT_shift  = TRLRBGN_shift + TRLRBGN_bits;
00053 const int SiPixelRawDataErrorModule::TRLREND_shift = EVTLGT_shift + EVTLGT_bits;
00054 
00055 const long long SiPixelRawDataErrorModule::TRLREND_mask = ~(~(long long)(0) << TRLREND_bits);
00056 const long long SiPixelRawDataErrorModule::EVTLGT_mask  = ~(~(long long)(0) << EVTLGT_bits);
00057 const long long SiPixelRawDataErrorModule::TRLRBGN_mask = ~(~(long long)(0) << TRLRBGN_bits);
00058 //
00059 // Constructors
00060 //
00061 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule() : id_(0),
00062                                          ncols_(416),
00063                                          nrows_(160) { }
00064 //
00065 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule(const uint32_t& id) : 
00066   id_(id),
00067   ncols_(416),
00068   nrows_(160)
00069 { 
00070 }
00071 //
00072 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule(const uint32_t& id, const int& ncols, const int& nrows) : 
00073   id_(id),
00074   ncols_(ncols),
00075   nrows_(nrows)
00076 { 
00077 }
00078 //
00079 // Destructor
00080 //
00081 SiPixelRawDataErrorModule::~SiPixelRawDataErrorModule() {}
00082 //
00083 // Book histograms for errors with detId
00084 //
00085 void SiPixelRawDataErrorModule::book(const edm::ParameterSet& iConfig, bool reducedSet, int type) {
00086   bool barrel = DetId::DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00087   bool endcap = DetId::DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00088   bool isHalfModule = false;
00089   if(barrel){
00090     isHalfModule = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).isHalfModule(); 
00091   }
00092 
00093   std::string hid;
00094   // Get collection name and instantiate Histo Id builder
00095   edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
00096 
00097   // Get DQM interface
00098   DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00099 
00100   if(type==0){
00101     SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
00102     // Types of errors
00103     hid = theHistogramId->setHistoId("errorType",id_);
00104     meErrorType_ = theDMBE->book1D(hid,"Type of errors",15,24.5,39.5);
00105     meErrorType_->setAxisTitle("Type of errors",1);
00106     // Number of errors
00107     hid = theHistogramId->setHistoId("NErrors",id_);
00108     meNErrors_ = theDMBE->book1D(hid,"Number of errors",500,-0.5,499.5);
00109     meNErrors_->setAxisTitle("Number of errors",1);
00110     // For error type 30, the type of problem encoded in the TBM trailer
00111     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00112     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00113     hid = theHistogramId->setHistoId("TBMMessage",id_);
00114     meTBMMessage_ = theDMBE->book1D(hid,"TBM trailer message",8,-0.5,7.5);
00115     meTBMMessage_->setAxisTitle("TBM message",1);
00116     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00117     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00118     hid = theHistogramId->setHistoId("TBMType",id_);
00119     meTBMType_ = theDMBE->book1D(hid,"State Machine message",5,-0.5,4.5);
00120     meTBMType_->setAxisTitle("FSM Type",1);
00121     if(!reducedSet){
00122       // For error type 31, the event number of the TBM header with the error
00123       hid = theHistogramId->setHistoId("EvtNbr",id_);
00124       meEvtNbr_ = theDMBE->book1D(hid,"Event number for error type 31",256,-0.5,255.5);
00125       meEvtNbr_->setAxisTitle("Event number",1);
00126       // For error type 36, the invalid ROC number
00127       hid = theHistogramId->setHistoId("ROCId",id_);
00128       meROCId_ = theDMBE->book1D(hid,"ROC number for error type 36",25,-0.5,24.5);
00129       meROCId_->setAxisTitle("ROC Id",1);
00130       // For error type 37, the invalid dcol values
00131       hid = theHistogramId->setHistoId("DCOLId",id_);
00132       meDCOLId_ = theDMBE->book1D(hid,"DCOL address for error type 37",32,-0.5,31.5);
00133       meDCOLId_->setAxisTitle("DCOL address",1);
00134       // For error type 37, the invalid ROC values
00135       hid = theHistogramId->setHistoId("PXId",id_);
00136       mePXId_ = theDMBE->book1D(hid,"Pixel address for error type 37",256,-0.5,255.5);
00137       mePXId_->setAxisTitle("Pixel address",1);
00138       // For error type 38, the ROC that is being read out of order
00139       hid = theHistogramId->setHistoId("ROCNmbr",id_);
00140       meROCNmbr_ = theDMBE->book1D(hid,"ROC number for error type 38",25,-0.5,24.5);
00141       meROCNmbr_->setAxisTitle("ROC number on DetUnit",1);
00142     }
00143     delete theHistogramId;
00144   }
00145   
00146   if(type==1 && barrel){
00147     uint32_t DBladder = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).ladderName();
00148     char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00149     hid = src.label() + "_" + sladder;
00150     if(isHalfModule) hid += "H";
00151     else hid += "F";
00152     // Types of errors
00153     meErrorTypeLad_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00154     meErrorTypeLad_->setAxisTitle("Type of errors",1);
00155     // Number of errors
00156     meNErrorsLad_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00157     meNErrorsLad_->setAxisTitle("Number of errors",1);
00158     // For error type 30, the type of problem encoded in the TBM trailer
00159     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00160     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00161     meTBMMessageLad_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00162     meTBMMessageLad_->setAxisTitle("TBM message",1);
00163     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00164     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00165     meTBMTypeLad_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00166     meTBMTypeLad_->setAxisTitle("FSM Type",1);
00167     if(!reducedSet){
00168       // For error type 31, the event number of the TBM header with the error
00169       meEvtNbrLad_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00170       meEvtNbrLad_->setAxisTitle("Event number",1);
00171       // For error type 36, the invalid ROC number
00172       meROCIdLad_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00173       meROCIdLad_->setAxisTitle("ROC Id",1);
00174       // For error type 37, the invalid dcol values
00175       meDCOLIdLad_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00176       meDCOLIdLad_->setAxisTitle("DCOL address",1);
00177       // For error type 37, the invalid ROC values
00178       mePXIdLad_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00179       mePXIdLad_->setAxisTitle("Pixel address",1);
00180       // For error type 38, the ROC that is being read out of order
00181       meROCNmbrLad_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00182       meROCNmbrLad_->setAxisTitle("ROC number on DetUnit",1);
00183     }
00184   }
00185   
00186   if(type==2 && barrel){
00187     uint32_t DBlayer = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).layerName();
00188     char slayer[80]; sprintf(slayer,"Layer_%i",DBlayer);
00189     hid = src.label() + "_" + slayer;
00190     // Types of errors
00191     meErrorTypeLay_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00192     meErrorTypeLay_->setAxisTitle("Type of errors",1);
00193     // Number of errors
00194     meNErrorsLay_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00195     meNErrorsLay_->setAxisTitle("Number of errors",1);
00196     // For error type 30, the type of problem encoded in the TBM trailer
00197     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00198     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00199     meTBMMessageLay_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00200     meTBMMessageLay_->setAxisTitle("TBM message",1);
00201     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00202     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00203     meTBMTypeLay_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00204     meTBMTypeLay_->setAxisTitle("FSM Type",1);
00205     if(!reducedSet){
00206       // For error type 31, the event number of the TBM header with the error
00207       meEvtNbrLay_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00208       meEvtNbrLay_->setAxisTitle("Event number",1);
00209       // For error type 36, the invalid ROC number
00210       meROCIdLay_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00211       meROCIdLay_->setAxisTitle("ROC Id",1);
00212       // For error type 37, the invalid dcol values
00213       meDCOLIdLay_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00214       meDCOLIdLay_->setAxisTitle("DCOL address",1);
00215       // For error type 37, the invalid ROC values
00216       mePXIdLay_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00217       mePXIdLay_->setAxisTitle("Pixel address",1);
00218       // For error type 38, the ROC that is being read out of order
00219       meROCNmbrLay_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00220       meROCNmbrLay_->setAxisTitle("ROC number on DetUnit",1);
00221     }
00222   }
00223   
00224   if(type==3 && barrel){
00225     uint32_t DBmodule = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).moduleName();
00226     char smodule[80]; sprintf(smodule,"Ring_%i",DBmodule);
00227     hid = src.label() + "_" + smodule;
00228     // Types of errors
00229     meErrorTypePhi_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00230     meErrorTypePhi_->setAxisTitle("Type of errors",1);
00231     // Number of errors
00232     meNErrorsPhi_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00233     meNErrorsPhi_->setAxisTitle("Number of errors",1);
00234     // For error type 30, the type of problem encoded in the TBM trailer
00235     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00236     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00237     meTBMMessagePhi_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00238     meTBMMessagePhi_->setAxisTitle("TBM message",1);
00239     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00240     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00241     meTBMTypePhi_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00242     meTBMTypePhi_->setAxisTitle("FSM Type",1);
00243     if(!reducedSet){
00244       // For error type 31, the event number of the TBM header with the error
00245       meEvtNbrPhi_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00246       meEvtNbrPhi_->setAxisTitle("Event number",1);
00247       // For error type 36, the invalid ROC number
00248       meROCIdPhi_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00249       meROCIdPhi_->setAxisTitle("ROC Id",1);
00250       // For error type 37, the invalid dcol values
00251       meDCOLIdPhi_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00252       meDCOLIdPhi_->setAxisTitle("DCOL address",1);
00253       // For error type 37, the invalid ROC values
00254       mePXIdPhi_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00255       mePXIdPhi_->setAxisTitle("Pixel address",1);
00256       // For error type 38, the ROC that is being read out of order
00257       meROCNmbrPhi_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00258       meROCNmbrPhi_->setAxisTitle("ROC number on DetUnit",1);
00259     }
00260   }
00261   
00262   if(type==4 && endcap){
00263     uint32_t blade = PixelEndcapName::PixelEndcapName(DetId::DetId(id_)).bladeName();
00264     char sblade[80]; sprintf(sblade,"Blade_%02i",blade);
00265     hid = src.label() + "_" + sblade;
00266     // Types of errors
00267     meErrorTypeBlade_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00268     meErrorTypeBlade_->setAxisTitle("Type of errors",1);
00269     // Number of errors
00270     meNErrorsBlade_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00271     meNErrorsBlade_->setAxisTitle("Number of errors",1);
00272     // For error type 30, the type of problem encoded in the TBM trailer
00273     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00274     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00275     meTBMMessageBlade_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00276     meTBMMessageBlade_->setAxisTitle("TBM message",1);
00277     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00278     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00279     meTBMTypeBlade_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00280     meTBMTypeBlade_->setAxisTitle("FSM Type",1);
00281     if(!reducedSet){
00282       // For error type 31, the event number of the TBM header with the error
00283       meEvtNbrBlade_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00284       meEvtNbrBlade_->setAxisTitle("Event number",1);
00285       // For error type 36, the invalid ROC number
00286       meROCIdBlade_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00287       meROCIdBlade_->setAxisTitle("ROC Id",1);
00288       // For error type 37, the invalid dcol values
00289       meDCOLIdBlade_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00290       meDCOLIdBlade_->setAxisTitle("DCOL address",1);
00291       // For error type 37, the invalid ROC values
00292       mePXIdBlade_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00293       mePXIdBlade_->setAxisTitle("Pixel address",1);
00294       // For error type 38, the ROC that is being read out of order
00295       meROCNmbrBlade_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00296       meROCNmbrBlade_->setAxisTitle("ROC number on DetUnit",1);
00297     }
00298   }
00299   
00300   if(type==5 && endcap){
00301     uint32_t disk = PixelEndcapName::PixelEndcapName(DetId::DetId(id_)).diskName();
00302     char sdisk[80]; sprintf(sdisk,"Disk_%i",disk);
00303     hid = src.label() + "_" + sdisk;
00304     // Types of errors
00305     meErrorTypeDisk_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00306     meErrorTypeDisk_->setAxisTitle("Type of errors",1);
00307     // Number of errors
00308     meNErrorsDisk_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00309     meNErrorsDisk_->setAxisTitle("Number of errors",1);
00310     // For error type 30, the type of problem encoded in the TBM trailer
00311     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00312     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00313     meTBMMessageDisk_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00314     meTBMMessageDisk_->setAxisTitle("TBM message",1);
00315     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00316     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00317     meTBMTypeDisk_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00318     meTBMTypeDisk_->setAxisTitle("FSM Type",1);
00319     if(!reducedSet){
00320       // For error type 31, the event number of the TBM header with the error
00321       meEvtNbrDisk_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00322       meEvtNbrDisk_->setAxisTitle("Event number",1);
00323       // For error type 36, the invalid ROC number
00324       meROCIdDisk_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00325       meROCIdDisk_->setAxisTitle("ROC Id",1);
00326       // For error type 37, the invalid dcol values
00327       meDCOLIdDisk_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00328       meDCOLIdDisk_->setAxisTitle("DCOL address",1);
00329       // For error type 37, the invalid ROC values
00330       mePXIdDisk_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00331       mePXIdDisk_->setAxisTitle("Pixel address",1);
00332       // For error type 38, the ROC that is being read out of order
00333       meROCNmbrDisk_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00334       meROCNmbrDisk_->setAxisTitle("ROC number on DetUnit",1);
00335     }
00336   }
00337   
00338   if(type==6 && endcap){
00339     uint32_t panel = PixelEndcapName::PixelEndcapName(DetId::DetId(id_)).pannelName();
00340     uint32_t module = PixelEndcapName::PixelEndcapName(DetId::DetId(id_)).plaquetteName();
00341     char slab[80]; sprintf(slab,"Panel_%i_Ring_%i",panel, module);
00342     hid = src.label() + "_" + slab;
00343     // Types of errors
00344     meErrorTypeRing_ = theDMBE->book1D("errorType_" + hid,"Type of errors",15,24.5,39.5);
00345     meErrorTypeRing_->setAxisTitle("Type of errors",1);
00346     // Number of errors
00347     meNErrorsRing_ = theDMBE->book1D("NErrors_" + hid,"Number of errors",500,-0.5,499.5);
00348     meNErrorsRing_->setAxisTitle("Number of errors",1);
00349     // For error type 30, the type of problem encoded in the TBM trailer
00350     // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00351     // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00352     meTBMMessageRing_ = theDMBE->book1D("TBMMessage_" + hid,"TBM trailer message",8,-0.5,7.5);
00353     meTBMMessageRing_->setAxisTitle("TBM message",1);
00354     // For error type 30, the type of problem encoded in the FSM bits, 0 = none
00355     // 1 = FSM errors, 2 = invalid # of ROCs, 3 = data stream too long, 4 = multiple
00356     meTBMTypeRing_ = theDMBE->book1D("TBMType_" + hid,"State Machine message",5,-0.5,4.5);
00357     meTBMTypeRing_->setAxisTitle("FSM Type",1);
00358     if(!reducedSet){
00359       // For error type 31, the event number of the TBM header with the error
00360       meEvtNbrRing_ = theDMBE->book1D("EvtNbr_" + hid,"Event number for error type 31",256,-0.5,255.5);
00361       meEvtNbrRing_->setAxisTitle("Event number",1);
00362       // For error type 36, the invalid ROC number
00363       meROCIdRing_ = theDMBE->book1D("ROCId_" + hid,"ROC number for error type 36",25,-0.5,24.5);
00364       meROCIdRing_->setAxisTitle("ROC Id",1);
00365       // For error type 37, the invalid dcol values
00366       meDCOLIdRing_ = theDMBE->book1D("DCOLId_" + hid,"DCOL address for error type 37",32,-0.5,31.5);
00367       meDCOLIdRing_->setAxisTitle("DCOL address",1);
00368       // For error type 37, the invalid ROC values
00369       mePXIdRing_ = theDMBE->book1D("PXId_" + hid,"Pixel address for error type 37",256,-0.5,255.5);
00370       mePXIdRing_->setAxisTitle("Pixel address",1);
00371       // For error type 38, the ROC that is being read out of order
00372       meROCNmbrRing_ = theDMBE->book1D("ROCNmbr_" + hid,"ROC number for error type 38",25,-0.5,24.5);
00373       meROCNmbrRing_->setAxisTitle("ROC number on DetUnit",1);
00374     }
00375   }
00376   
00377   
00378 }
00379 //
00380 // Book histograms for errors with detId
00381 //
00382 void SiPixelRawDataErrorModule::bookFED(const edm::ParameterSet& iConfig) {
00383 
00384   std::string hid;
00385   // Get collection name and instantiate Histo Id builder
00386   edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
00387   SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
00388   // Get DQM interface
00389   DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
00390   // Types of errors
00391   hid = theHistogramId->setHistoId("errorType",id_);
00392   meErrorType_ = theDMBE->book1D(hid,"Type of errors",15,24.5,39.5);
00393   meErrorType_->setAxisTitle("Type of errors",1);
00394   // Number of errors
00395   hid = theHistogramId->setHistoId("NErrors",id_);
00396   meNErrors_ = theDMBE->book1D(hid,"Number of errors",500,-0.5,499.5);
00397   meNErrors_->setAxisTitle("Number of errors",1);
00398   // Type of FIFO full (errorType = 28).  FIFO 1 is 1-5 (where fullType = channel of FIFO 1), 
00399   // fullType = 6 signifies FIFO 2 nearly full, 7 signifies trigger FIFO nearly full, 8 
00400   // indicates an unexpected result
00401   hid = theHistogramId->setHistoId("fullType",id_);
00402   meFullType_ = theDMBE->book1D(hid,"Type of FIFO full",7,0.5,7.5);
00403   meFullType_->setAxisTitle("FIFO type",1);
00404   // For errorType = 29, channel with timeout error (0 indicates unexpected result)
00405   hid = theHistogramId->setHistoId("chanNmbr",id_);
00406   meChanNmbr_ = theDMBE->book1D(hid,"Timeout Channel",37,-0.5,36.5);
00407   meChanNmbr_->setAxisTitle("Channel number",1);
00408   // For error type 30, the type of problem encoded in the TBM trailer
00409   // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger, 
00410   // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
00411   hid = theHistogramId->setHistoId("TBMMessage",id_);
00412   meTBMMessage_ = theDMBE->book1D(hid,"TBM trailer message",8,-0.5,7.5);
00413   meTBMMessage_->setAxisTitle("TBM message",1);
00414   // For error type 30, the type of problem encoded in the TBM error trailer 0 = none
00415   // 1 = data stream too long, 2 = FSM errors, 3 = invalid # of ROCs, 4 = multiple
00416   hid = theHistogramId->setHistoId("TBMType",id_);
00417   meTBMType_ = theDMBE->book1D(hid,"Type of TBM trailer",5,-0.5,4.5);
00418   meTBMType_->setAxisTitle("TBM Type",1);
00419   // For error type 31, the event number of the TBM header with the error
00420   hid = theHistogramId->setHistoId("EvtNbr",id_);
00421   meEvtNbr_ = theDMBE->book1D(hid,"Event number for error type 31",256,-0.5,255.5);
00422   meEvtNbr_->setAxisTitle("Event number",1);
00423   // For errorType = 34, datastream size according to error word
00424   hid = theHistogramId->setHistoId("evtSize",id_);
00425   meEvtSize_ = theDMBE->book1D(hid,"Trailer Datastream Size",500,-0.5,499.5);
00426   meEvtSize_->setAxisTitle("Number of words",1);
00427   // For errorType = 35, the bad channel number
00428   hid = theHistogramId->setHistoId("linkId",id_);
00429   meLinkId_ = theDMBE->book1D(hid,"Invalid Channel Number",35,0.5,35.5);
00430   meLinkId_->setAxisTitle("FED Channel number",1);
00431   // For error type 36, the invalid ROC number matched to FED Channel
00432   hid = theHistogramId->setHistoId("Type36Hitmap",id_);
00433   meInvROC_ = theDMBE->book2D(hid,"Invalid ROC by Channel Number",35,1.,36.,25,0.,25.);
00434   meInvROC_->setAxisTitle("FED Channel Number",1);
00435   meInvROC_->setAxisTitle("ROC Number",2);
00436   
00437   delete theHistogramId;
00438 }
00439 //
00440 // Fill histograms
00441 //
00442 void SiPixelRawDataErrorModule::fill(const edm::DetSetVector<SiPixelRawDataError>& input, bool reducedSet, bool modon, bool ladon, bool layon, bool phion, bool bladeon, bool diskon, bool ringon) {
00443   bool barrel = DetId::DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00444   bool endcap = DetId::DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00445   bool isHalfModule = false;
00446   uint32_t DBladder = 0;
00447   if(barrel){
00448     isHalfModule = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).isHalfModule(); 
00449     DBladder = PixelBarrelName::PixelBarrelName(DetId::DetId(id_)).ladderName();
00450   }
00451   
00452   edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(id_); // search  errors of detid
00453   
00454   if( isearch != input.end() ) {  // Not at empty iterator
00455     
00456     unsigned int numberOfErrors = 0;
00457     
00458     // Look at errors now
00459     edm::DetSet<SiPixelRawDataError>::const_iterator  di;
00460     for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
00461       numberOfErrors++;
00462       int errorType = di->getType();               // type of error
00463       if(modon){
00464         (meErrorType_)->Fill((int)errorType);
00465         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00466           long long errorWord = di->getWord64();     // for 64-bit error words
00467           if(errorType == 34) {
00468             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00469             (meEvtSize_)->Fill((float)evtSize); 
00470           }
00471         } else {
00472           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00473           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00474           case(30) : {
00475             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00476             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00477             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00478             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00479             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00480             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00481             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00482             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00483             int TBMMessage;
00484             if (T0==1) { TBMMessage=0; (meTBMMessage_)->Fill((int)TBMMessage); }
00485             if (T1==1) { TBMMessage=1; (meTBMMessage_)->Fill((int)TBMMessage); }
00486             if (T2==1) { TBMMessage=2; (meTBMMessage_)->Fill((int)TBMMessage); }
00487             if (T3==1) { TBMMessage=3; (meTBMMessage_)->Fill((int)TBMMessage); }
00488             if (T4==1) { TBMMessage=4; (meTBMMessage_)->Fill((int)TBMMessage); }
00489             if (T5==1) { TBMMessage=5; (meTBMMessage_)->Fill((int)TBMMessage); }
00490             if (T6==1) { TBMMessage=6; (meTBMMessage_)->Fill((int)TBMMessage); }
00491             if (T7==1) { TBMMessage=7; (meTBMMessage_)->Fill((int)TBMMessage); }
00492             int StateMach_bits      = 4;
00493             int StateMach_shift     = 8;
00494             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00495             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00496             int TBMType;
00497             switch(StateMach) {
00498             case(0) : {
00499               TBMType = 0;
00500               break; }
00501             case(1) : {
00502               TBMType = 1;
00503               break; }
00504             case(2) : case(4) : case(6) : {
00505               TBMType = 2;
00506               break; }
00507             case(8) : {
00508               TBMType = 3;
00509               break; }
00510             default : TBMType = 4;
00511             };
00512             (meTBMType_)->Fill((int)TBMType);
00513             break; }
00514           case(31) : {
00515             if(!reducedSet){
00516               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00517               (meEvtNbr_)->Fill((int)evtNbr);
00518             }
00519             break; }
00520           case(36) : {
00521             if(!reducedSet){
00522               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00523               (meROCId_)->Fill((float)ROCId);
00524             }
00525             break; }
00526           case(37) : {
00527             if(!reducedSet){
00528               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00529               (meDCOLId_)->Fill((float)DCOLId);
00530               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00531               (mePXId_)->Fill((float)PXId);
00532             }
00533             break; }
00534           case(38) : {
00535             if(!reducedSet){
00536               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00537               (meROCNmbr_)->Fill((float)ROCNmbr);
00538             }
00539             break; }
00540           default : break;
00541           };
00542         }  
00543       }
00544       
00545       if(ladon && barrel){
00546         (meErrorTypeLad_)->Fill((int)errorType);
00547         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00548           long long errorWord = di->getWord64();     // for 64-bit error words
00549           if(errorType == 34) {
00550             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00551             (meEvtSizeLad_)->Fill((float)evtSize); 
00552           }
00553         } else {
00554           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00555           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00556           case(30) : {
00557             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00558             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00559             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00560             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00561             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00562             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00563             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00564             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00565             int TBMMessage;
00566             if (T0==1) { TBMMessage=0; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00567             if (T1==1) { TBMMessage=1; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00568             if (T2==1) { TBMMessage=2; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00569             if (T3==1) { TBMMessage=3; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00570             if (T4==1) { TBMMessage=4; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00571             if (T5==1) { TBMMessage=5; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00572             if (T6==1) { TBMMessage=6; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00573             if (T7==1) { TBMMessage=7; (meTBMMessageLad_)->Fill((int)TBMMessage); }
00574             int StateMach_bits      = 4;
00575             int StateMach_shift     = 8;
00576             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00577             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00578             int TBMType;
00579             switch(StateMach) {
00580             case(0) : {
00581               TBMType = 0;
00582               break; }
00583             case(1) : {
00584               TBMType = 1;
00585               break; }
00586             case(2) : case(4) : case(6) : {
00587               TBMType = 2;
00588               break; }
00589             case(8) : {
00590               TBMType = 3;
00591               break; }
00592             default : TBMType = 4;
00593             };
00594             (meTBMTypeLad_)->Fill((int)TBMType);
00595             break; }
00596           case(31) : {
00597             if(!reducedSet){
00598               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00599               (meEvtNbrLad_)->Fill((int)evtNbr);
00600             }
00601             break; }
00602           case(36) : {
00603             if(!reducedSet){
00604               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00605               (meROCIdLad_)->Fill((float)ROCId);
00606             }
00607             break; }
00608           case(37) : {
00609             if(!reducedSet){
00610               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00611               (meDCOLIdLad_)->Fill((float)DCOLId);
00612               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00613               (mePXIdLad_)->Fill((float)PXId);
00614             }
00615             break; }
00616           case(38) : {
00617             if(!reducedSet){
00618               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00619               (meROCNmbrLad_)->Fill((float)ROCNmbr);
00620             }
00621             break; }
00622           default : break;
00623           };
00624         }
00625       }
00626       
00627       if(layon && barrel){
00628         (meErrorTypeLay_)->Fill((int)errorType);
00629         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00630           long long errorWord = di->getWord64();     // for 64-bit error words
00631           if(errorType == 34) {
00632             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00633             (meEvtSizeLay_)->Fill((float)evtSize); 
00634           }
00635         } else {
00636           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00637           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00638           case(30) : {
00639             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00640             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00641             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00642             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00643             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00644             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00645             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00646             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00647             int TBMMessage;
00648             if (T0==1) { TBMMessage=0; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00649             if (T1==1) { TBMMessage=1; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00650             if (T2==1) { TBMMessage=2; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00651             if (T3==1) { TBMMessage=3; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00652             if (T4==1) { TBMMessage=4; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00653             if (T5==1) { TBMMessage=5; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00654             if (T6==1) { TBMMessage=6; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00655             if (T7==1) { TBMMessage=7; (meTBMMessageLay_)->Fill((int)TBMMessage); }
00656             int StateMach_bits      = 4;
00657             int StateMach_shift     = 8;
00658             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00659             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00660             int TBMType;
00661             switch(StateMach) {
00662             case(0) : {
00663               TBMType = 0;
00664               break; }
00665             case(1) : {
00666               TBMType = 1;
00667               break; }
00668             case(2) : case(4) : case(6) : {
00669               TBMType = 2;
00670               break; }
00671             case(8) : {
00672               TBMType = 3;
00673               break; }
00674             default : TBMType = 4;
00675             };
00676             (meTBMTypeLay_)->Fill((int)TBMType);
00677             break; }
00678           case(31) : {
00679             if(!reducedSet){
00680               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00681               (meEvtNbrLay_)->Fill((int)evtNbr);
00682             }
00683             break; }
00684           case(36) : {
00685             if(!reducedSet){
00686               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00687               (meROCIdLay_)->Fill((float)ROCId);
00688             }
00689             break; }
00690           case(37) : {
00691             if(!reducedSet){
00692               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00693               (meDCOLIdLay_)->Fill((float)DCOLId);
00694               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00695               (mePXIdLay_)->Fill((float)PXId);
00696             }
00697             break; }
00698           case(38) : {
00699             if(!reducedSet){
00700               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00701               (meROCNmbrLay_)->Fill((float)ROCNmbr);
00702             }
00703             break; }
00704           default : break;
00705           };
00706         }
00707       }
00708       
00709       if(phion && barrel){
00710         (meErrorTypePhi_)->Fill((int)errorType);
00711         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00712           long long errorWord = di->getWord64();     // for 64-bit error words
00713           if(errorType == 34) {
00714             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00715             (meEvtSizePhi_)->Fill((float)evtSize); 
00716           }
00717         } else {
00718           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00719           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00720           case(30) : {
00721             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00722             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00723             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00724             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00725             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00726             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00727             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00728             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00729             int TBMMessage;
00730             if (T0==1) { TBMMessage=0; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00731             if (T1==1) { TBMMessage=1; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00732             if (T2==1) { TBMMessage=2; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00733             if (T3==1) { TBMMessage=3; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00734             if (T4==1) { TBMMessage=4; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00735             if (T5==1) { TBMMessage=5; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00736             if (T6==1) { TBMMessage=6; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00737             if (T7==1) { TBMMessage=7; (meTBMMessagePhi_)->Fill((int)TBMMessage); }
00738             int StateMach_bits      = 4;
00739             int StateMach_shift     = 8;
00740             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00741             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00742             int TBMType;
00743             switch(StateMach) {
00744             case(0) : {
00745               TBMType = 0;
00746               break; }
00747             case(1) : {
00748               TBMType = 1;
00749               break; }
00750             case(2) : case(4) : case(6) : {
00751               TBMType = 2;
00752               break; }
00753             case(8) : {
00754               TBMType = 3;
00755               break; }
00756             default : TBMType = 4;
00757             };
00758             (meTBMTypePhi_)->Fill((int)TBMType);
00759             break; }
00760           case(31) : {
00761             if(!reducedSet){
00762               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00763               (meEvtNbrPhi_)->Fill((int)evtNbr);
00764             }
00765             break; }
00766           case(36) : {
00767             if(!reducedSet){
00768               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00769               (meROCIdPhi_)->Fill((float)ROCId);
00770             }
00771             break; }
00772           case(37) : {
00773             if(!reducedSet){
00774               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00775               (meDCOLIdPhi_)->Fill((float)DCOLId);
00776               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00777               (mePXIdPhi_)->Fill((float)PXId);
00778             }
00779             break; }
00780           case(38) : {
00781             if(!reducedSet){
00782               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00783               (meROCNmbrPhi_)->Fill((float)ROCNmbr);
00784             }
00785             break; }
00786           default : break;
00787           };
00788         }
00789       }
00790       
00791       if(bladeon && endcap){
00792         (meErrorTypeBlade_)->Fill((int)errorType);
00793         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00794           long long errorWord = di->getWord64();     // for 64-bit error words
00795           if(errorType == 34) {
00796             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00797             (meEvtSizeBlade_)->Fill((float)evtSize); 
00798           }
00799         } else {
00800           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00801           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00802           case(30) : {
00803             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00804             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00805             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00806             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00807             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00808             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00809             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00810             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00811             int TBMMessage;
00812             if (T0==1) { TBMMessage=0; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00813             if (T1==1) { TBMMessage=1; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00814             if (T2==1) { TBMMessage=2; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00815             if (T3==1) { TBMMessage=3; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00816             if (T4==1) { TBMMessage=4; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00817             if (T5==1) { TBMMessage=5; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00818             if (T6==1) { TBMMessage=6; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00819             if (T7==1) { TBMMessage=7; (meTBMMessageBlade_)->Fill((int)TBMMessage); }
00820             int StateMach_bits      = 4;
00821             int StateMach_shift     = 8;
00822             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00823             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00824             int TBMType;
00825             switch(StateMach) {
00826             case(0) : {
00827               TBMType = 0;
00828               break; }
00829             case(1) : {
00830               TBMType = 1;
00831               break; }
00832             case(2) : case(4) : case(6) : {
00833               TBMType = 2;
00834               break; }
00835             case(8) : {
00836               TBMType = 3;
00837               break; }
00838             default : TBMType = 4;
00839             };
00840             (meTBMTypeBlade_)->Fill((int)TBMType);
00841             break; }
00842           case(31) : {
00843             if(!reducedSet){
00844               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00845               (meEvtNbrBlade_)->Fill((int)evtNbr);
00846             }
00847             break; }
00848           case(36) : {
00849             if(!reducedSet){
00850               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00851               (meROCIdBlade_)->Fill((float)ROCId);
00852             }
00853             break; }
00854           case(37) : {
00855             if(!reducedSet){
00856               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00857               (meDCOLIdBlade_)->Fill((float)DCOLId);
00858               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00859               (mePXIdBlade_)->Fill((float)PXId);
00860             }
00861             break; }
00862           case(38) : {
00863             if(!reducedSet){
00864               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00865               (meROCNmbrBlade_)->Fill((float)ROCNmbr);
00866             }
00867             break; }
00868           default : break;
00869           };
00870         }
00871       }
00872       
00873       if(diskon && endcap){
00874         (meErrorTypeDisk_)->Fill((int)errorType);
00875         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00876           long long errorWord = di->getWord64();     // for 64-bit error words
00877           if(errorType == 34) {
00878             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00879             (meEvtSizeDisk_)->Fill((float)evtSize); 
00880           }
00881         } else {
00882           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00883           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00884           case(30) : {
00885             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00886             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00887             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00888             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00889             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00890             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00891             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00892             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00893             int TBMMessage;
00894             if (T0==1) { TBMMessage=0; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00895             if (T1==1) { TBMMessage=1; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00896             if (T2==1) { TBMMessage=2; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00897             if (T3==1) { TBMMessage=3; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00898             if (T4==1) { TBMMessage=4; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00899             if (T5==1) { TBMMessage=5; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00900             if (T6==1) { TBMMessage=6; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00901             if (T7==1) { TBMMessage=7; (meTBMMessageDisk_)->Fill((int)TBMMessage); }
00902             int StateMach_bits      = 4;
00903             int StateMach_shift     = 8;
00904             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00905             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00906             int TBMType;
00907             switch(StateMach) {
00908             case(0) : {
00909               TBMType = 0;
00910               break; }
00911             case(1) : {
00912               TBMType = 1;
00913               break; }
00914             case(2) : case(4) : case(6) : {
00915               TBMType = 2;
00916               break; }
00917             case(8) : {
00918               TBMType = 3;
00919               break; }
00920             default : TBMType = 4;
00921             };
00922             (meTBMTypeDisk_)->Fill((int)TBMType);
00923             break; }
00924           case(31) : {
00925             if(!reducedSet){
00926               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
00927               (meEvtNbrDisk_)->Fill((int)evtNbr);
00928             }
00929             break; }
00930           case(36) : {
00931             if(!reducedSet){
00932               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
00933               (meROCIdDisk_)->Fill((float)ROCId);
00934             }
00935             break; }
00936           case(37) : {
00937             if(!reducedSet){
00938               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
00939               (meDCOLIdDisk_)->Fill((float)DCOLId);
00940               int PXId = (errorWord >> PXID_shift) & PXID_mask;
00941               (mePXIdDisk_)->Fill((float)PXId);
00942             }
00943             break; }
00944           case(38) : {
00945             if(!reducedSet){
00946               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
00947               (meROCNmbrDisk_)->Fill((float)ROCNmbr);
00948             }
00949             break; }
00950           default : break;
00951           };
00952         }
00953       }
00954       
00955       if(ringon && endcap){
00956         (meErrorTypeRing_)->Fill((int)errorType);
00957         if(!reducedSet && (errorType == 32)||(errorType == 33)||(errorType == 34)) {
00958           long long errorWord = di->getWord64();     // for 64-bit error words
00959           if(errorType == 34) {
00960             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
00961             (meEvtSizeRing_)->Fill((float)evtSize); 
00962           }
00963         } else {
00964           uint32_t errorWord = di->getWord32();      // for 32-bit error words
00965           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
00966           case(30) : {
00967             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
00968             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
00969             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
00970             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
00971             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
00972             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
00973             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
00974             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
00975             int TBMMessage;
00976             if (T0==1) { TBMMessage=0; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00977             if (T1==1) { TBMMessage=1; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00978             if (T2==1) { TBMMessage=2; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00979             if (T3==1) { TBMMessage=3; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00980             if (T4==1) { TBMMessage=4; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00981             if (T5==1) { TBMMessage=5; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00982             if (T6==1) { TBMMessage=6; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00983             if (T7==1) { TBMMessage=7; (meTBMMessageRing_)->Fill((int)TBMMessage); }
00984             int StateMach_bits      = 4;
00985             int StateMach_shift     = 8;
00986             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
00987             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
00988             int TBMType;
00989             switch(StateMach) {
00990             case(0) : {
00991               TBMType = 0;
00992               break; }
00993             case(1) : {
00994               TBMType = 1;
00995               break; }
00996             case(2) : case(4) : case(6) : {
00997               TBMType = 2;
00998               break; }
00999             case(8) : {
01000               TBMType = 3;
01001               break; }
01002             default : TBMType = 4;
01003             };
01004             (meTBMTypeRing_)->Fill((int)TBMType);
01005             break; }
01006           case(31) : {
01007             if(!reducedSet){
01008               int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
01009               (meEvtNbrRing_)->Fill((int)evtNbr);
01010             }
01011             break; }
01012           case(36) : {
01013             if(!reducedSet){
01014               int ROCId = (errorWord >> ROC_shift) & ROC_mask;
01015               (meROCIdRing_)->Fill((float)ROCId);
01016             }
01017             break; }
01018           case(37) : {
01019             if(!reducedSet){
01020               int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
01021               (meDCOLIdRing_)->Fill((float)DCOLId);
01022               int PXId = (errorWord >> PXID_shift) & PXID_mask;
01023               (mePXIdRing_)->Fill((float)PXId);
01024             }
01025             break; }
01026           case(38) : {
01027             if(!reducedSet){
01028               int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
01029               (meROCNmbrRing_)->Fill((float)ROCNmbr);
01030             }
01031             break; }
01032           default : break;
01033           };
01034         }
01035       }
01036     }//for loop
01037     
01038     if(modon) (meNErrors_)->Fill((float)numberOfErrors);
01039     if(ladon && barrel) (meNErrorsLad_)->Fill((float)numberOfErrors);
01040     if(layon && barrel) (meNErrorsLay_)->Fill((float)numberOfErrors);
01041     if(phion && barrel) (meNErrorsPhi_)->Fill((float)numberOfErrors);
01042     if(bladeon && endcap) (meNErrorsBlade_)->Fill((float)numberOfErrors);
01043     if(diskon && endcap) (meNErrorsDisk_)->Fill((float)numberOfErrors);
01044     if(ringon && endcap) (meNErrorsRing_)->Fill((float)numberOfErrors);
01045     //std::cout<<"number of errors="<<numberOfErrors<<std::endl;
01046     
01047   }
01048   
01049   //std::cout<<"number of detector units="<<numberOfDetUnits<<std::endl;
01050   
01051 }
01052 
01053 void SiPixelRawDataErrorModule::fillFED(const edm::DetSetVector<SiPixelRawDataError>& input) {
01054   
01055   edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(0xffffffff); // search  errors of detid
01056   
01057   if( isearch != input.end() ) {  // Not at empty iterator
01058     
01059     unsigned int numberOfErrors = 0;
01060     
01061     // Look at FED errors now
01062     edm::DetSet<SiPixelRawDataError>::const_iterator  di;
01063     for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
01064       int FedId = di->getFedId();                  // FED the error came from
01065 
01066       if(FedId==static_cast<int>(id_)) {
01067         numberOfErrors++;
01068         int errorType = di->getType();               // type of error
01069         (meErrorType_)->Fill((int)errorType);
01070         if((errorType == 32)||(errorType == 33)||(errorType == 34)) {
01071           long long errorWord = di->getWord64();     // for 64-bit error words
01072           if(errorType == 34) {
01073             int evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
01074             (meEvtSize_)->Fill((float)evtSize); }
01075         } else {
01076           uint32_t errorWord = di->getWord32();      // for 32-bit error words
01077           switch(errorType) {  // fill in the appropriate monitorables based on the information stored in the error word
01078           case(28) : {
01079             int NFa = (errorWord >> DB0_shift) & DataBit_mask;
01080             int NFb = (errorWord >> DB1_shift) & DataBit_mask;
01081             int NFc = (errorWord >> DB2_shift) & DataBit_mask;
01082             int NFd = (errorWord >> DB3_shift) & DataBit_mask;
01083             int NFe = (errorWord >> DB4_shift) & DataBit_mask;
01084             int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
01085             int L1A = (errorWord >> DB7_shift) & DataBit_mask;
01086             int fullType;
01087             if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
01088             if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
01089             if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
01090             if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
01091             if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
01092             if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
01093             if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
01094             break; }
01095           case(29) : {
01096             int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
01097             int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
01098             int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
01099             int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
01100             int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
01101             int BLOCK_bits      = 3;
01102             int BLOCK_shift     = 8;
01103             uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
01104             int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
01105             int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
01106             int chanNmbr;
01107             if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
01108             else chanNmbr = (BLOCK-1)/2+4+localCH;
01109             if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0;  // signifies unexpected result
01110             (meChanNmbr_)->Fill((int)chanNmbr);
01111             break; }
01112           case(30) : {
01113             int T0 = (errorWord >> DB0_shift) & DataBit_mask;
01114             int T1 = (errorWord >> DB1_shift) & DataBit_mask;
01115             int T2 = (errorWord >> DB2_shift) & DataBit_mask;
01116             int T3 = (errorWord >> DB3_shift) & DataBit_mask;
01117             int T4 = (errorWord >> DB4_shift) & DataBit_mask;
01118             int T5 = (errorWord >> DB5_shift) & DataBit_mask;
01119             int T6 = (errorWord >> DB6_shift) & DataBit_mask;
01120             int T7 = (errorWord >> DB7_shift) & DataBit_mask;
01121             int TBMMessage;
01122             if (T0==1) { TBMMessage=0; (meTBMMessage_)->Fill((int)TBMMessage); }
01123             if (T1==1) { TBMMessage=1; (meTBMMessage_)->Fill((int)TBMMessage); }
01124             if (T2==1) { TBMMessage=2; (meTBMMessage_)->Fill((int)TBMMessage); }
01125             if (T3==1) { TBMMessage=3; (meTBMMessage_)->Fill((int)TBMMessage); }
01126             if (T4==1) { TBMMessage=4; (meTBMMessage_)->Fill((int)TBMMessage); }
01127             if (T5==1) { TBMMessage=5; (meTBMMessage_)->Fill((int)TBMMessage); }
01128             if (T6==1) { TBMMessage=6; (meTBMMessage_)->Fill((int)TBMMessage); }
01129             if (T7==1) { TBMMessage=7; (meTBMMessage_)->Fill((int)TBMMessage); }
01130             int StateMach_bits      = 4;
01131             int StateMach_shift     = 8;
01132             uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
01133             int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
01134             int TBMType;
01135           switch(StateMach) {
01136           case(0) : {
01137             TBMType = 0;
01138             break; }
01139           case(1) : {
01140             TBMType = 1;
01141             break; }
01142           case(2) : case(4) : case(6) : {
01143             TBMType = 2;
01144             break; }
01145           case(8) : {
01146             TBMType = 3;
01147             break; }
01148             default : TBMType = 4;
01149           };
01150             (meTBMType_)->Fill((int)TBMType);
01151             break; }
01152           case(31) : {
01153             int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
01154             (meEvtNbr_)->Fill((int)evtNbr);
01155             break; }
01156           case(35) : {
01157             int linkId = (errorWord >> LINK_shift) & LINK_mask;
01158             (meLinkId_)->Fill((float)linkId);
01159             break; }
01160           case(36) : {
01161             int ROCId = (errorWord >> ROC_shift) & ROC_mask;
01162             int ChanId = (errorWord >> LINK_shift) & LINK_mask;
01163             (meInvROC_)->Fill((float)ChanId,(float)ROCId);
01164             break; }
01165           default : break;
01166           };
01167         }
01168       }
01169     }
01170     
01171     (meNErrors_)->Fill((float)numberOfErrors);
01172     //std::cout<<"number of errors="<<numberOfErrors<<std::endl;meROCId_
01173     
01174   }
01175   
01176   //std::cout<<"number of detector units="<<numberOfDetUnits<<std::endl;
01177   
01178 }

Generated on Tue Jun 9 17:33:23 2009 for CMSSW by  doxygen 1.5.4