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
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
00027 edm::ESHandle<TrackerTopology> tTopoHandle;
00028 eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00029 const TrackerTopology* const tTopo = tTopoHandle.product();
00030
00031
00032 getConditionObject(eSetup);
00033 if(!cablingHandle_.isValid()) {
00034 edm::LogError("InvalidCablingHandle") << "Invalid Cabling Handle";
00035 return;
00036 }
00037 cablingHandle_->addActiveDetectorsRawIds(activeDetIds);
00038 cablingHandle_->addAllDetectorsRawIds(activeDetIds);
00039
00040
00041
00042 int counterTIB[4];
00043 for(int i=0;i<4;i++) counterTIB[i]=0;
00044 int counterTID[2][3];
00045 for(int i=0;i<2;i++){
00046 for(int j=0;j<3;j++)counterTID[i][j]=0;
00047 }
00048 int counterTOB[6];
00049 for(int i=0;i<6;i++)counterTOB[i]=0;
00050 int counterTEC[2][9];
00051 for(int i=0;i<2;i++){
00052 for(int j=0;j<9;j++)counterTEC[i][j]=0;
00053 }
00054
00055
00056
00057 std::vector<uint32_t>::const_iterator idet=activeDetIds.begin();
00058
00059
00060 for(;idet!=activeDetIds.end();++idet){
00061 uint32_t detId = *idet;
00062 StripSubdetector subdet(detId);
00063
00064 if(HistoMaps_On_ ) {Tk_HM_->fill(detId, cablingHandle_->nApvPairs(detId)*2);}
00065 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00066
00067 int32_t n_conn = 0;
00068 for(uint32_t connDet_i=0; connDet_i<cablingHandle_->getConnections(detId).size(); connDet_i++){
00069 if(cablingHandle_->getConnections(detId)[connDet_i]!=0 && cablingHandle_->getConnections(detId)[connDet_i]->isConnected()!=0) n_conn++;
00070 }
00071 fillTkMap(detId,n_conn*2.);
00072 }
00073 switch (subdet.subdetId())
00074 {
00075 case StripSubdetector::TIB:
00076 {
00077 int i = tTopo->tibLayer(detId) - 1;
00078 counterTIB[i]++;
00079 break;
00080 }
00081 case StripSubdetector::TID:
00082 {
00083 int j = tTopo->tidWheel(detId) - 1;
00084 int side = tTopo->tidSide(detId);
00085 if (side == 2) {
00086 counterTID[0][j]++;
00087 } else if (side == 1) {
00088 counterTID[1][j]++;
00089 }
00090 break;
00091 }
00092 case StripSubdetector::TOB:
00093 {
00094 int i = tTopo->tobLayer(detId) - 1;
00095 counterTOB[i]++;
00096 break;
00097 }
00098 case StripSubdetector::TEC:
00099 {
00100 int j = tTopo->tecWheel(detId) - 1;
00101 int side = tTopo->tecSide(detId);
00102 if (side == 2) {
00103 counterTEC[0][j]++;
00104 } else if (side == 1) {
00105 counterTEC[1][j]++;
00106 }
00107 break;
00108 }
00109 }
00110
00111 }
00112
00113
00114 int TIBDetIds[4]={672,864,540,648};
00115 int TIDDetIds[2][3]={{136,136,136},{136,136,136}};
00116 int TOBDetIds[6]={1008,1152,648,720,792,888};
00117 int TECDetIds[2][9]={{408,408,408,360,360,360,312,312,272},{408,408,408,360,360,360,312,312,272}};
00118
00119
00120
00121 DQMStore* dqmStore_=edm::Service<DQMStore>().operator->();
00122
00123 std::string FolderName=fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
00124
00125 dqmStore_->setCurrentFolder(FolderName);
00126
00127
00128 MonitorElement *ME;
00129 ME = dqmStore_->book2D("SummaryOfCabling","SummaryOfCabling",6,0.5,6.5,9,0.5,9.5);
00130 ME->setAxisTitle("Sub Det",1);
00131 ME->setAxisTitle("Layer",2);
00132
00133
00134 ME->getTH1()->GetXaxis()->SetBinLabel(1,"TIB");
00135 ME->getTH1()->GetXaxis()->SetBinLabel(2,"TID F");
00136 ME->getTH1()->GetXaxis()->SetBinLabel(3,"TID B");
00137 ME->getTH1()->GetXaxis()->SetBinLabel(4,"TOB");
00138 ME->getTH1()->GetXaxis()->SetBinLabel(5,"TEC F");
00139 ME->getTH1()->GetXaxis()->SetBinLabel(6,"TEC B");
00140
00141 for(int i=0;i<4;i++){
00142 ME->Fill(1,i+1,float(counterTIB[i])/TIBDetIds[i]);
00143 }
00144
00145 for(int i=0;i<2;i++){
00146 for(int j=0;j<3;j++){
00147 ME->Fill(i+2,j+1,float(counterTID[i][j])/TIDDetIds[i][j]);
00148 }
00149 }
00150
00151 for(int i=0;i<6;i++){
00152 ME->Fill(4,i+1,float(counterTOB[i])/TOBDetIds[i]);
00153 }
00154
00155 for(int i=0;i<2;i++){
00156 for(int j=0;j<9;j++){
00157 ME->Fill(i+5,j+1,float(counterTEC[i][j])/TECDetIds[i][j]);
00158 }
00159 }
00160
00161 if (fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
00162
00163 TCanvas c1("c1");
00164 ME->getTH1()->Draw("TEXT");
00165 ME->getTH1()->SetStats(kFALSE);
00166 std::string name (ME->getTH1()->GetTitle());
00167 name+=".png";
00168 c1.Print(name.c_str());
00169 }
00170
00171 }
00172
00173