00001 #include "DQM/SiStripMonitorSummary/interface/SiStripQualityDQM.h"
00002 #include "DQMServices/Core/interface/MonitorElement.h"
00003 #include "TCanvas.h"
00004
00005
00006 SiStripQualityDQM::SiStripQualityDQM(const edm::EventSetup & eSetup,
00007 edm::ParameterSet const& hPSet,
00008 edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
00009 qualityLabel_ = fPSet.getParameter<std::string>("StripQualityLabel");
00010
00011
00012 if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","Quality_TkMap",0.);
00013
00014 }
00015
00016
00017
00018
00019
00020 SiStripQualityDQM::~SiStripQualityDQM(){}
00021
00022
00023
00024
00025 void SiStripQualityDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00026 getConditionObject(eSetup);
00027 qualityHandle_->getDetIds(activeDetIds);
00028
00029 }
00030
00031
00032
00033
00034 void SiStripQualityDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
00035
00036 ModMEs CondObj_ME;
00037
00038 for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00039 detIter_!= selectedDetIds.end();detIter_++){
00040 fillMEsForDet(CondObj_ME,*detIter_);
00041
00042 }
00043 }
00044
00045
00046
00047
00048
00049
00050 void SiStripQualityDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
00051
00052 getModMEs(selModME_,selDetId_);
00053
00054 SiStripQuality::Range qualityRange = qualityHandle_->getRange(selDetId_);
00055 int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00056
00057 for( int istrip=0;istrip<nStrip;++istrip){
00058 selModME_.ProfileDistr->Fill(istrip+1,qualityHandle_->IsStripBad(qualityRange,istrip)?0.:1.);
00059
00060 }
00061
00062 }
00063
00064
00065
00066
00067 void SiStripQualityDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
00068
00069 for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00070 detIter_!= selectedDetIds.end();detIter_++){
00071 fillMEsForLayer(SummaryMEsMap_, *detIter_);
00072
00073 }
00074
00075 for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
00076
00077 ModMEs selME;
00078 selME = iter->second;
00079
00080 if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
00081
00082 TCanvas c1("c1");
00083 selME.SummaryDistr->getTH1()->Draw();
00084 std::string name (selME.SummaryDistr->getTH1()->GetTitle());
00085 name+=".png";
00086 c1.Print(name.c_str());
00087 }
00088 }
00089
00090 }
00091
00092
00093
00094
00095
00096 void SiStripQualityDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00097
00098 float numberOfBadStrips=0;
00099
00100 SiStripHistoId hidmanager;
00101
00102 if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00103
00104 std::string hSummary_description;
00105 hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
00106
00107 std::string hSummary_name;
00108
00109
00110 int subDetId_ = ((selDetId_>>25)&0x7);
00111
00112 if( subDetId_<3 || subDetId_>6 ){
00113 edm::LogError("SiStripQualityDQM")
00114 << "[SiStripQualityDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00115 << subDetId_ << " no folder set!"
00116 << std::endl;
00117 return;
00118 }
00119
00120
00121 hSummary_name = hidmanager.createHistoLayer(hSummary_description,
00122 "layer",
00123 getLayerNameAndId(selDetId_).first,
00124 "") ;
00125
00126 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00127
00128 ModMEs selME_;
00129 selME_ =selMEsMapIter_->second;
00130
00131 getSummaryMEs(selME_,selDetId_ );
00132
00133
00134 std::vector<uint32_t> sameLayerDetIds_;
00135 sameLayerDetIds_.clear();
00136 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00137
00138
00139
00140
00141
00142
00143 if(std::binary_search(alreadyFilledLayers.begin(),alreadyFilledLayers.end(),sameLayerDetIds_[0]))
00144 return;
00145 alreadyFilledLayers.push_back(sameLayerDetIds_[0]);
00146 sort(alreadyFilledLayers.begin(),alreadyFilledLayers.end());
00147
00148
00149 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00150
00151 SiStripQuality::Range qualityRange = qualityHandle_->getRange(sameLayerDetIds_[i]);
00152 int nStrip = reader->getNumberOfApvsAndStripLength(sameLayerDetIds_[i]).first*128;
00153
00154 numberOfBadStrips=0;
00155
00156 for( int istrip=0;istrip<nStrip;++istrip){
00157 if(qualityHandle_->IsStripBad(qualityRange,istrip)) { numberOfBadStrips++;}
00158 }
00159
00160 float fr=100*float(numberOfBadStrips)/nStrip;
00161 selME_.SummaryDistr->Fill(i+1,fr);
00162 if(fr>20){
00163 char c[9];
00164 sprintf(c,"%d",sameLayerDetIds_[i]);
00165 selME_.SummaryDistr->getTH1()->GetXaxis()->SetBinLabel(i+1,c);
00166 }
00167
00168
00169 if(HistoMaps_On_ ) Tk_HM_->setBinContent(sameLayerDetIds_[i], fr);
00170
00171
00172 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00173 fillTkMap(sameLayerDetIds_[i], fr);
00174 }
00175 }
00176 }
00177 }
00178
00179
00180
00181
00182 void SiStripQualityDQM::fillGrandSummaryMEs(){
00183
00184
00185
00186 std::string hSummary_BadObjects_xTitle = hPSet_.getParameter<std::string>("Summary_BadObjects_histo_xTitle");
00187
00188 std::string hSummary_BadModules_name = hPSet_.getParameter<std::string>("Summary_BadModules_histo_name");
00189 std::string hSummary_BadModules_yTitle = hPSet_.getParameter<std::string>("Summary_BadModules_histo_yTitle");
00190
00191 std::string hSummary_BadFibers_name = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_name");
00192 std::string hSummary_BadFibers_yTitle = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_yTitle");
00193
00194 std::string hSummary_BadApvs_name = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_name");
00195 std::string hSummary_BadApvs_yTitle = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_yTitle");
00196
00197 std::string hSummary_BadStrips_name = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_name");
00198 std::string hSummary_BadStrips_yTitle = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_yTitle");
00199
00200 int NchX = 34;
00201 double LowX = 0.5;
00202 double HighX = 34.5;
00203
00204
00205
00206
00207 MonitorElement *ME[4];
00208
00209 DQMStore* dqmStore_=edm::Service<DQMStore>().operator->();
00210
00211 std::string FolderName=fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
00212
00213 dqmStore_->setCurrentFolder(FolderName);
00214
00215 ME[0] = dqmStore_->book1D(hSummary_BadModules_name,hSummary_BadModules_name,NchX,LowX,HighX);
00216 ME[0]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00217 ME[0]->setAxisTitle(hSummary_BadModules_yTitle,2);
00218
00219 ME[1] = dqmStore_->book1D(hSummary_BadFibers_name,hSummary_BadFibers_name,NchX,LowX,HighX);
00220 ME[1]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00221 ME[1]->setAxisTitle(hSummary_BadFibers_yTitle,2);
00222
00223 ME[2] = dqmStore_->book1D(hSummary_BadApvs_name,hSummary_BadApvs_name,NchX,LowX,HighX);
00224 ME[2]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00225 ME[2]->setAxisTitle(hSummary_BadApvs_yTitle,2);
00226
00227 ME[3] = dqmStore_->book1D(hSummary_BadStrips_name,hSummary_BadStrips_name,NchX,LowX,HighX);
00228 ME[3]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00229 ME[3]->setAxisTitle(hSummary_BadStrips_yTitle,2);
00230
00231
00232
00233
00234 for(int i=0;i<4;++i){
00235 NTkBadComponent[i]=0;
00236 for(int j=0;j<19;++j){
00237 ssV[i][j].str("");
00238 for(int k=0;k<4;++k)
00239 NBadComponent[i][j][k]=0;
00240 }
00241 }
00242
00243 std::stringstream ss;
00244 ss.str("");
00245 std::vector<uint32_t> detids=reader->getAllDetIds();
00246 std::vector<uint32_t>::const_iterator idet=detids.begin();
00247 for(;idet!=detids.end();++idet){
00248 ss << "detid " << (*idet) << " IsModuleUsable " << qualityHandle_->IsModuleUsable((*idet)) << "\n";
00249 }
00250 LogDebug("SiStripQualityStatistics") << ss.str() << std::endl;
00251
00252
00253 std::vector<SiStripQuality::BadComponent> BC = qualityHandle_->getBadComponentList();
00254
00255 for (size_t i=0;i<BC.size();++i){
00256
00257
00258
00259
00260
00261 if (BC[i].BadModule)
00262 NTkBadComponent[0]++;
00263 if (BC[i].BadFibers)
00264 NTkBadComponent[1]+= ( (BC[i].BadFibers>>2)&0x1 )+ ( (BC[i].BadFibers>>1)&0x1 ) + ( (BC[i].BadFibers)&0x1 );
00265 if (BC[i].BadApvs)
00266 NTkBadComponent[2]+= ( (BC[i].BadApvs>>5)&0x1 )+ ( (BC[i].BadApvs>>4)&0x1 ) + ( (BC[i].BadApvs>>3)&0x1 ) +
00267 ( (BC[i].BadApvs>>2)&0x1 )+ ( (BC[i].BadApvs>>1)&0x1 ) + ( (BC[i].BadApvs)&0x1 );
00268
00269
00270
00271
00272
00273 int component;
00274 SiStripDetId a(BC[i].detid);
00275 if ( a.subdetId() == SiStripDetId::TIB ){
00276
00277
00278
00279
00280 component=TIBDetId(BC[i].detid).layer();
00281 SetBadComponents(0, component, BC[i]);
00282
00283 } else if ( a.subdetId() == SiStripDetId::TID ) {
00284
00285
00286
00287
00288 component=TIDDetId(BC[i].detid).side()==2?TIDDetId(BC[i].detid).wheel():TIDDetId(BC[i].detid).wheel()+3;
00289 SetBadComponents(1, component, BC[i]);
00290
00291 } else if ( a.subdetId() == SiStripDetId::TOB ) {
00292
00293
00294
00295
00296 component=TOBDetId(BC[i].detid).layer();
00297 SetBadComponents(2, component, BC[i]);
00298
00299 } else if ( a.subdetId() == SiStripDetId::TEC ) {
00300
00301
00302
00303
00304 component=TECDetId(BC[i].detid).side()==2?TECDetId(BC[i].detid).wheel():TECDetId(BC[i].detid).wheel()+9;
00305 SetBadComponents(3, component, BC[i]);
00306
00307 }
00308 }
00309
00310
00311
00312
00313
00314 SiStripQuality::RegistryIterator rbegin = qualityHandle_->getRegistryVectorBegin();
00315 SiStripQuality::RegistryIterator rend = qualityHandle_->getRegistryVectorEnd();
00316
00317 for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
00318 uint32_t detid=rp->detid;
00319
00320 int subdet=0;
00321 int component=0;
00322 SiStripDetId a(detid);
00323 if ( a.subdetId() == 3 ){
00324 subdet=0;
00325 component=TIBDetId(detid).layer();
00326 } else if ( a.subdetId() == 4 ) {
00327 subdet=1;
00328 component=TIDDetId(detid).side()==2?TIDDetId(detid).wheel():TIDDetId(detid).wheel()+3;
00329 } else if ( a.subdetId() == 5 ) {
00330 subdet=2;
00331 component=TOBDetId(detid).layer();
00332 } else if ( a.subdetId() == 6 ) {
00333 subdet=3;
00334 component=TECDetId(detid).side()==2?TECDetId(detid).wheel():TECDetId(detid).wheel()+9;
00335 }
00336
00337 SiStripQuality::Range sqrange = SiStripQuality::Range( qualityHandle_->getDataVectorBegin()+rp->ibegin , qualityHandle_->getDataVectorBegin()+rp->iend );
00338
00339 for(int it=0;it<sqrange.second-sqrange.first;it++){
00340 unsigned int range=qualityHandle_->decode( *(sqrange.first+it) ).range;
00341 NTkBadComponent[3]+=range;
00342 NBadComponent[subdet][0][3]+=range;
00343 NBadComponent[subdet][component][3]+=range;
00344 }
00345 }
00346
00347
00348
00349
00350
00351
00352 ss.str("");
00353 ss << "\n-----------------\nGlobal Info\n-----------------";
00354 ss << "\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
00355 ss << "\nTracker:\t\t"<<NTkBadComponent[0]<<"\t"<<NTkBadComponent[1]<<"\t"<<NTkBadComponent[2]<<"\t"<<NTkBadComponent[3];
00356 ss<< "\n";
00357 ss << "\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<"\t"<<NBadComponent[0][0][1]<<"\t"<<NBadComponent[0][0][2]<<"\t"<<NBadComponent[0][0][3];
00358 ss << "\nTID:\t\t\t"<<NBadComponent[1][0][0]<<"\t"<<NBadComponent[1][0][1]<<"\t"<<NBadComponent[1][0][2]<<"\t"<<NBadComponent[1][0][3];
00359 ss << "\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<"\t"<<NBadComponent[2][0][1]<<"\t"<<NBadComponent[2][0][2]<<"\t"<<NBadComponent[2][0][3];
00360 ss << "\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<"\t"<<NBadComponent[3][0][1]<<"\t"<<NBadComponent[3][0][2]<<"\t"<<NBadComponent[3][0][3];
00361 ss << "\n";
00362
00363 for (int i=1;i<5;++i){
00364 ss << "\nTIB Layer " << i << " :\t\t"<<NBadComponent[0][i][0]<<"\t"<<NBadComponent[0][i][1]<<"\t"<<NBadComponent[0][i][2]<<"\t"<<NBadComponent[0][i][3];
00365 std::stringstream binlabel;
00366 binlabel<<"TIB L "<<i;
00367
00368 for(int j=0;j<4;j++){
00369 ME[j]->Fill(i,NBadComponent[0][i][j]);
00370 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i,binlabel.str().c_str());
00371 }
00372 }
00373 ss << "\n";
00374 for (int i=1;i<4;++i){
00375 ss << "\nTID+ Disk " << i << " :\t\t"<<NBadComponent[1][i][0]<<"\t"<<NBadComponent[1][i][1]<<"\t"<<NBadComponent[1][i][2]<<"\t"<<NBadComponent[1][i][3];
00376 std::stringstream binlabel;
00377 binlabel<<"TID+ D "<<i;
00378
00379 for(int j=0;j<4;j++){
00380 ME[j]->Fill(i+4,NBadComponent[1][i][j]);
00381 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+4,binlabel.str().c_str());
00382 }
00383 }
00384 for (int i=4;i<7;++i){
00385 ss << "\nTID- Disk " << i-3 << " :\t\t"<<NBadComponent[1][i][0]<<"\t"<<NBadComponent[1][i][1]<<"\t"<<NBadComponent[1][i][2]<<"\t"<<NBadComponent[1][i][3];
00386 std::stringstream binlabel;
00387 binlabel<<"TID- D "<<i-3;
00388
00389 for(int j=0;j<4;j++){
00390 ME[j]->Fill(i+4,NBadComponent[1][i][j]);
00391 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+4,binlabel.str().c_str());
00392 }
00393 }
00394 ss << "\n";
00395 for (int i=1;i<7;++i){
00396 ss << "\nTOB Layer " << i << " :\t\t"<<NBadComponent[2][i][0]<<"\t"<<NBadComponent[2][i][1]<<"\t"<<NBadComponent[2][i][2]<<"\t"<<NBadComponent[2][i][3];
00397 std::stringstream binlabel;
00398 binlabel<<"TOB L "<<i;
00399
00400 for(int j=0;j<4;j++){
00401 ME[j]->Fill(i+10,NBadComponent[2][i][j]);
00402 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+10,binlabel.str().c_str());
00403 }
00404 }
00405 ss << "\n";
00406 for (int i=1;i<10;++i){
00407 ss << "\nTEC+ Disk " << i << " :\t\t"<<NBadComponent[3][i][0]<<"\t"<<NBadComponent[3][i][1]<<"\t"<<NBadComponent[3][i][2]<<"\t"<<NBadComponent[3][i][3];
00408 std::stringstream binlabel;
00409 binlabel<<"TEC+ D "<<i;
00410
00411 for(int j=0;j<4;j++){
00412 ME[j]->Fill(i+16,NBadComponent[3][i][j]);
00413 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+16,binlabel.str().c_str());
00414 }
00415 }
00416 for (int i=10;i<19;++i){
00417 ss << "\nTEC- Disk " << i-9 << " :\t\t"<<NBadComponent[3][i][0]<<"\t"<<NBadComponent[3][i][1]<<"\t"<<NBadComponent[3][i][2]<<"\t"<<NBadComponent[3][i][3];
00418 std::stringstream binlabel;
00419 binlabel<<"TEC- D "<<i-9;
00420
00421 for(int j=0;j<4;j++){
00422 ME[j]->Fill(i+16,NBadComponent[3][i][j]);
00423 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+16,binlabel.str().c_str());
00424 }
00425 }
00426 ss<< "\n";
00427
00428 ss << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
00429 for (int i=1;i<5;++i)
00430 ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
00431 ss << "\n";
00432 for (int i=1;i<4;++i)
00433 ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
00434 for (int i=4;i<7;++i)
00435 ss << "\nTID- Disk " << i-3 << " :" << ssV[1][i].str();
00436 ss << "\n";
00437 for (int i=1;i<7;++i)
00438 ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
00439 ss << "\n";
00440 for (int i=1;i<10;++i)
00441 ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
00442 for (int i=10;i<19;++i)
00443 ss << "\nTEC- Disk " << i-9 << " :" << ssV[3][i].str();
00444
00445
00446 edm::LogInfo("SiStripQualityStatistics") << ss.str() << std::endl;
00447
00448 for (int i=0; i<4; i++){
00449 TCanvas c1("c1");
00450 ME[i]->getTH1()->Draw();
00451 std::string name (ME[i]->getTH1()->GetTitle());
00452 name+=".png";
00453 c1.Print(name.c_str());
00454 }
00455
00456
00457 }
00458
00459
00460 void SiStripQualityDQM::SetBadComponents(int i, int component,SiStripQuality::BadComponent& BC){
00461
00462 int napv=reader->getNumberOfApvsAndStripLength(BC.detid).first;
00463
00464 ssV[i][component] << "\n\t\t "
00465 << BC.detid
00466 << " \t " << BC.BadModule << " \t "
00467 << ( (BC.BadFibers)&0x1 ) << " ";
00468 if (napv==4)
00469 ssV[i][component] << "x " <<( (BC.BadFibers>>1)&0x1 );
00470
00471 if (napv==6)
00472 ssV[i][component] << ( (BC.BadFibers>>1)&0x1 ) << " "
00473 << ( (BC.BadFibers>>2)&0x1 );
00474 ssV[i][component] << " \t "
00475 << ( (BC.BadApvs)&0x1 ) << " "
00476 << ( (BC.BadApvs>>1)&0x1 ) << " ";
00477 if (napv==4)
00478 ssV[i][component] << "x x " << ( (BC.BadApvs>>2)&0x1 ) << " "
00479 << ( (BC.BadApvs>>3)&0x1 );
00480 if (napv==6)
00481 ssV[i][component] << ( (BC.BadApvs>>2)&0x1 ) << " "
00482 << ( (BC.BadApvs>>3)&0x1 ) << " "
00483 << ( (BC.BadApvs>>4)&0x1 ) << " "
00484 << ( (BC.BadApvs>>5)&0x1 ) << " ";
00485
00486 if (BC.BadApvs){
00487 NBadComponent[i][0][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) +
00488 ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
00489 NBadComponent[i][component][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) +
00490 ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
00491
00492 }
00493 if (BC.BadFibers){
00494 NBadComponent[i][0][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
00495 NBadComponent[i][component][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
00496
00497 }
00498 if (BC.BadModule){
00499 NBadComponent[i][0][0]++;
00500 NBadComponent[i][component][0]++;
00501
00502 }
00503 }
00504