CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/SiStripMonitorSummary/src/SiStripCablingDQM.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripMonitorSummary/interface/SiStripCablingDQM.h"
00002 #include "DQMServices/Core/interface/MonitorElement.h"
00003 #include "TCanvas.h"
00004 using namespace std;
00005 // -----
00006 
00007 SiStripCablingDQM::SiStripCablingDQM(const edm::EventSetup & eSetup,
00008                                      edm::ParameterSet const& hPSet,
00009                                      edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
00010 
00011   // Build the Histo_TkMap:
00012   if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","Cabling_TkMap",0.);
00013 
00014 }
00015 // -----
00016 
00017 // -----
00018 SiStripCablingDQM::~SiStripCablingDQM(){}
00019 // -----
00020 
00021 
00022 
00023 // -----
00024 void SiStripCablingDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00025   
00026   // Get active and total detIds
00027   getConditionObject(eSetup);
00028   if(!cablingHandle_.isValid()) {
00029     edm::LogError("InvalidCablingHandle") << "Invalid Cabling Handle";
00030     return;
00031   }
00032   cablingHandle_->addActiveDetectorsRawIds(activeDetIds);
00033   cablingHandle_->addAllDetectorsRawIds(activeDetIds);
00034 
00035 
00036   //Initialize arrays for counting:
00037   int counterTIB[4];
00038   for(int i=0;i<4;i++) counterTIB[i]=0;
00039   int counterTID[2][3];
00040   for(int i=0;i<2;i++){
00041     for(int j=0;j<3;j++)counterTID[i][j]=0;
00042   }
00043   int counterTOB[6];
00044   for(int i=0;i<6;i++)counterTOB[i]=0;
00045   int counterTEC[2][9];
00046   for(int i=0;i<2;i++){
00047     for(int j=0;j<9;j++)counterTEC[i][j]=0;
00048   }
00049 
00050 
00051  
00052   std::vector<uint32_t>::const_iterator idet=activeDetIds.begin();
00053 
00054   //fill arrays for counting and fill Histo_Map with value for connected : 
00055   for(;idet!=activeDetIds.end();++idet){
00056     uint32_t detId = *idet;
00057     StripSubdetector subdet(detId);
00058 
00059     if(HistoMaps_On_ ) {Tk_HM_->fill(detId, cablingHandle_->nApvPairs(detId)*2);}
00060     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00061 
00062     int32_t n_conn = 0;
00063       for(uint32_t connDet_i=0; connDet_i<cablingHandle_->getConnections(detId).size(); connDet_i++){
00064         if(cablingHandle_->getConnections(detId)[connDet_i]!=0 &&  cablingHandle_->getConnections(detId)[connDet_i]->isConnected()!=0) n_conn++;
00065       }
00066       fillTkMap(detId,n_conn*2.); 
00067     }
00068     switch (subdet.subdetId()) 
00069       {
00070       case StripSubdetector::TIB:
00071         {
00072           TIBDetId tibId(detId);
00073           int i = tibId.layer() - 1;
00074           counterTIB[i]++;
00075           break;       
00076         }
00077       case StripSubdetector::TID:
00078         {
00079           TIDDetId tidId(detId);
00080           if (tidId.side() == 2) {
00081             int j = tidId.wheel() - 1;
00082             counterTID[0][j]++;
00083           }  else if (tidId.side() == 1) {
00084             int j = tidId.wheel() - 1;
00085             counterTID[1][j]++;
00086           }
00087           break;       
00088         }
00089       case StripSubdetector::TOB:
00090         {
00091           TOBDetId tobId(detId);
00092           int i = tobId.layer() - 1;
00093           counterTOB[i]++;
00094           break;       
00095         }
00096       case StripSubdetector::TEC:
00097         {
00098           TECDetId tecId(detId);
00099           if (tecId.side() == 2) {
00100             int j = tecId.wheel() - 1;
00101             counterTEC[0][j]++;
00102           }  else if (tecId.side() == 1) {
00103             int j = tecId.wheel() - 1;
00104             counterTEC[1][j]++;
00105           }
00106           break;       
00107         }
00108       }
00109 
00110   } // idet
00111 
00112   //obtained from tracker.dat and hard-coded
00113   int TIBDetIds[4]={672,864,540,648};
00114   int TIDDetIds[2][3]={{136,136,136},{136,136,136}};
00115   int TOBDetIds[6]={1008,1152,648,720,792,888};
00116   int TECDetIds[2][9]={{408,408,408,360,360,360,312,312,272},{408,408,408,360,360,360,312,312,272}};
00117 
00118 
00119 
00120   DQMStore* dqmStore_=edm::Service<DQMStore>().operator->();
00121 
00122   std::string FolderName=fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
00123 
00124   dqmStore_->setCurrentFolder(FolderName);
00125 
00126   //  dqmStore_->cd("SiStrip/MechanicalView/");
00127   MonitorElement *ME;
00128   ME = dqmStore_->book2D("SummaryOfCabling","SummaryOfCabling",6,0.5,6.5,9,0.5,9.5);
00129   ME->setAxisTitle("Sub Det",1);
00130   ME->setAxisTitle("Layer",2);
00131 
00132 
00133   ME->getTH1()->GetXaxis()->SetBinLabel(1,"TIB");
00134   ME->getTH1()->GetXaxis()->SetBinLabel(2,"TID F");
00135   ME->getTH1()->GetXaxis()->SetBinLabel(3,"TID B");
00136   ME->getTH1()->GetXaxis()->SetBinLabel(4,"TOB");
00137   ME->getTH1()->GetXaxis()->SetBinLabel(5,"TEC F");
00138   ME->getTH1()->GetXaxis()->SetBinLabel(6,"TEC B");
00139 
00140   for(int i=0;i<4;i++){
00141     ME->Fill(1,i+1,float(counterTIB[i])/TIBDetIds[i]);
00142   }
00143   
00144   for(int i=0;i<2;i++){
00145     for(int j=0;j<3;j++){
00146       ME->Fill(i+2,j+1,float(counterTID[i][j])/TIDDetIds[i][j]);
00147     }
00148   }
00149 
00150   for(int i=0;i<6;i++){
00151     ME->Fill(4,i+1,float(counterTOB[i])/TOBDetIds[i]);
00152   }
00153   
00154   for(int i=0;i<2;i++){
00155     for(int j=0;j<9;j++){
00156       ME->Fill(i+5,j+1,float(counterTEC[i][j])/TECDetIds[i][j]);
00157     }
00158   }
00159 
00160   if (fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
00161 
00162     TCanvas c1("c1");
00163     ME->getTH1()->Draw("TEXT");
00164     ME->getTH1()->SetStats(kFALSE);
00165     std::string name (ME->getTH1()->GetTitle());
00166     name+=".png";
00167     c1.Print(name.c_str());
00168   }
00169 
00170 }
00171 
00172