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( *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( 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_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
00127
00128 ModMEs selME_;
00129 if ( selMEsMapIter_ != SummaryMEsMap_.end())
00130 selME_ =selMEsMapIter_->second;
00131
00132 getSummaryMEs(selME_,selDetId_ );
00133
00134
00135 std::vector<uint32_t> sameLayerDetIds_;
00136 sameLayerDetIds_.clear();
00137 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00138
00139
00140
00141
00142
00143
00144 if(std::binary_search(alreadyFilledLayers.begin(),alreadyFilledLayers.end(),sameLayerDetIds_[0]))
00145 return;
00146 alreadyFilledLayers.push_back(sameLayerDetIds_[0]);
00147 sort(alreadyFilledLayers.begin(),alreadyFilledLayers.end());
00148
00149
00150 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00151
00152 SiStripQuality::Range qualityRange = qualityHandle_->getRange(sameLayerDetIds_[i]);
00153 int nStrip = reader->getNumberOfApvsAndStripLength(sameLayerDetIds_[i]).first*128;
00154
00155 numberOfBadStrips=0;
00156
00157 for( int istrip=0;istrip<nStrip;++istrip){
00158 if(qualityHandle_->IsStripBad(qualityRange,istrip)) { numberOfBadStrips++;}
00159 }
00160
00161 float fr=100*float(numberOfBadStrips)/nStrip;
00162 selME_.SummaryDistr->Fill(i+1,fr);
00163 if(fr>20){
00164 char c[9];
00165 sprintf(c,"%d",sameLayerDetIds_[i]);
00166 selME_.SummaryDistr->getTH1()->GetXaxis()->SetBinLabel(i+1,c);
00167 }
00168
00169
00170 if(HistoMaps_On_ ) Tk_HM_->setBinContent(sameLayerDetIds_[i], fr);
00171
00172
00173 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00174 fillTkMap(sameLayerDetIds_[i], fr);
00175 }
00176 }
00177 }
00178 }
00179
00180
00181
00182
00183 void SiStripQualityDQM::fillGrandSummaryMEs(){
00184
00185
00186
00187 std::string hSummary_BadObjects_xTitle = hPSet_.getParameter<std::string>("Summary_BadObjects_histo_xTitle");
00188
00189 std::string hSummary_BadModules_name = hPSet_.getParameter<std::string>("Summary_BadModules_histo_name");
00190 std::string hSummary_BadModules_yTitle = hPSet_.getParameter<std::string>("Summary_BadModules_histo_yTitle");
00191
00192 std::string hSummary_BadFibers_name = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_name");
00193 std::string hSummary_BadFibers_yTitle = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_yTitle");
00194
00195 std::string hSummary_BadApvs_name = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_name");
00196 std::string hSummary_BadApvs_yTitle = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_yTitle");
00197
00198 std::string hSummary_BadStrips_name = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_name");
00199 std::string hSummary_BadStrips_yTitle = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_yTitle");
00200
00201 int NchX = 34;
00202 double LowX = 0.5;
00203 double HighX = 34.5;
00204
00205
00206
00207
00208 MonitorElement *ME[4];
00209
00210 DQMStore* dqmStore_=edm::Service<DQMStore>().operator->();
00211
00212 std::string FolderName=fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
00213
00214 dqmStore_->setCurrentFolder(FolderName);
00215
00216 ME[0] = dqmStore_->book1D(hSummary_BadModules_name,hSummary_BadModules_name,NchX,LowX,HighX);
00217 ME[0]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00218 ME[0]->setAxisTitle(hSummary_BadModules_yTitle,2);
00219
00220 ME[1] = dqmStore_->book1D(hSummary_BadFibers_name,hSummary_BadFibers_name,NchX,LowX,HighX);
00221 ME[1]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00222 ME[1]->setAxisTitle(hSummary_BadFibers_yTitle,2);
00223
00224 ME[2] = dqmStore_->book1D(hSummary_BadApvs_name,hSummary_BadApvs_name,NchX,LowX,HighX);
00225 ME[2]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00226 ME[2]->setAxisTitle(hSummary_BadApvs_yTitle,2);
00227
00228 ME[3] = dqmStore_->book1D(hSummary_BadStrips_name,hSummary_BadStrips_name,NchX,LowX,HighX);
00229 ME[3]->setAxisTitle(hSummary_BadObjects_xTitle,1);
00230 ME[3]->setAxisTitle(hSummary_BadStrips_yTitle,2);
00231
00232
00233
00234
00235 for(int i=0;i<4;++i){
00236 NTkBadComponent[i]=0;
00237 for(int j=0;j<19;++j){
00238 ssV[i][j].str("");
00239 for(int k=0;k<4;++k)
00240 NBadComponent[i][j][k]=0;
00241 }
00242 }
00243
00244 std::stringstream ss;
00245 ss.str("");
00246 std::vector<uint32_t> detids=reader->getAllDetIds();
00247 std::vector<uint32_t>::const_iterator idet=detids.begin();
00248 for(;idet!=detids.end();++idet){
00249 ss << "detid " << (*idet) << " IsModuleUsable " << qualityHandle_->IsModuleUsable((*idet)) << "\n";
00250 }
00251 LogDebug("SiStripQualityStatistics") << ss.str() << std::endl;
00252
00253
00254 std::vector<SiStripQuality::BadComponent> BC = qualityHandle_->getBadComponentList();
00255
00256 for (size_t i=0;i<BC.size();++i){
00257
00258
00259
00260
00261
00262 if (BC[i].BadModule)
00263 NTkBadComponent[0]++;
00264 if (BC[i].BadFibers)
00265 NTkBadComponent[1]+= ( (BC[i].BadFibers>>2)&0x1 )+ ( (BC[i].BadFibers>>1)&0x1 ) + ( (BC[i].BadFibers)&0x1 );
00266 if (BC[i].BadApvs)
00267 NTkBadComponent[2]+= ( (BC[i].BadApvs>>5)&0x1 )+ ( (BC[i].BadApvs>>4)&0x1 ) + ( (BC[i].BadApvs>>3)&0x1 ) +
00268 ( (BC[i].BadApvs>>2)&0x1 )+ ( (BC[i].BadApvs>>1)&0x1 ) + ( (BC[i].BadApvs)&0x1 );
00269
00270
00271
00272
00273
00274 int component;
00275 SiStripDetId a(BC[i].detid);
00276 if ( a.subdetId() == SiStripDetId::TIB ){
00277
00278
00279
00280
00281 component=TIBDetId(BC[i].detid).layer();
00282 SetBadComponents(0, component, BC[i]);
00283
00284 } else if ( a.subdetId() == SiStripDetId::TID ) {
00285
00286
00287
00288
00289 component=TIDDetId(BC[i].detid).side()==2?TIDDetId(BC[i].detid).wheel():TIDDetId(BC[i].detid).wheel()+3;
00290 SetBadComponents(1, component, BC[i]);
00291
00292 } else if ( a.subdetId() == SiStripDetId::TOB ) {
00293
00294
00295
00296
00297 component=TOBDetId(BC[i].detid).layer();
00298 SetBadComponents(2, component, BC[i]);
00299
00300 } else if ( a.subdetId() == SiStripDetId::TEC ) {
00301
00302
00303
00304
00305 component=TECDetId(BC[i].detid).side()==2?TECDetId(BC[i].detid).wheel():TECDetId(BC[i].detid).wheel()+9;
00306 SetBadComponents(3, component, BC[i]);
00307
00308 }
00309 }
00310
00311
00312
00313
00314
00315 SiStripQuality::RegistryIterator rbegin = qualityHandle_->getRegistryVectorBegin();
00316 SiStripQuality::RegistryIterator rend = qualityHandle_->getRegistryVectorEnd();
00317
00318 for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
00319 uint32_t detid=rp->detid;
00320
00321 int subdet=0;
00322 int component=0;
00323 SiStripDetId a(detid);
00324 if ( a.subdetId() == 3 ){
00325 subdet=0;
00326 component=TIBDetId(detid).layer();
00327 } else if ( a.subdetId() == 4 ) {
00328 subdet=1;
00329 component=TIDDetId(detid).side()==2?TIDDetId(detid).wheel():TIDDetId(detid).wheel()+3;
00330 } else if ( a.subdetId() == 5 ) {
00331 subdet=2;
00332 component=TOBDetId(detid).layer();
00333 } else if ( a.subdetId() == 6 ) {
00334 subdet=3;
00335 component=TECDetId(detid).side()==2?TECDetId(detid).wheel():TECDetId(detid).wheel()+9;
00336 }
00337
00338 SiStripQuality::Range sqrange = SiStripQuality::Range( qualityHandle_->getDataVectorBegin()+rp->ibegin , qualityHandle_->getDataVectorBegin()+rp->iend );
00339
00340 for(int it=0;it<sqrange.second-sqrange.first;it++){
00341 unsigned int range=qualityHandle_->decode( *(sqrange.first+it) ).range;
00342 NTkBadComponent[3]+=range;
00343 NBadComponent[subdet][0][3]+=range;
00344 NBadComponent[subdet][component][3]+=range;
00345 }
00346 }
00347
00348
00349
00350
00351
00352
00353 ss.str("");
00354 ss << "\n-----------------\nGlobal Info\n-----------------";
00355 ss << "\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
00356 ss << "\nTracker:\t\t"<<NTkBadComponent[0]<<"\t"<<NTkBadComponent[1]<<"\t"<<NTkBadComponent[2]<<"\t"<<NTkBadComponent[3];
00357 ss<< "\n";
00358 ss << "\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<"\t"<<NBadComponent[0][0][1]<<"\t"<<NBadComponent[0][0][2]<<"\t"<<NBadComponent[0][0][3];
00359 ss << "\nTID:\t\t\t"<<NBadComponent[1][0][0]<<"\t"<<NBadComponent[1][0][1]<<"\t"<<NBadComponent[1][0][2]<<"\t"<<NBadComponent[1][0][3];
00360 ss << "\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<"\t"<<NBadComponent[2][0][1]<<"\t"<<NBadComponent[2][0][2]<<"\t"<<NBadComponent[2][0][3];
00361 ss << "\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<"\t"<<NBadComponent[3][0][1]<<"\t"<<NBadComponent[3][0][2]<<"\t"<<NBadComponent[3][0][3];
00362 ss << "\n";
00363
00364 for (int i=1;i<5;++i){
00365 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];
00366 std::stringstream binlabel;
00367 binlabel<<"TIB L "<<i;
00368
00369 for(int j=0;j<4;j++){
00370 ME[j]->Fill(i,NBadComponent[0][i][j]);
00371 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i,binlabel.str().c_str());
00372 }
00373 }
00374 ss << "\n";
00375 for (int i=1;i<4;++i){
00376 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];
00377 std::stringstream binlabel;
00378 binlabel<<"TID+ D "<<i;
00379
00380 for(int j=0;j<4;j++){
00381 ME[j]->Fill(i+4,NBadComponent[1][i][j]);
00382 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+4,binlabel.str().c_str());
00383 }
00384 }
00385 for (int i=4;i<7;++i){
00386 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];
00387 std::stringstream binlabel;
00388 binlabel<<"TID- D "<<i-3;
00389
00390 for(int j=0;j<4;j++){
00391 ME[j]->Fill(i+4,NBadComponent[1][i][j]);
00392 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+4,binlabel.str().c_str());
00393 }
00394 }
00395 ss << "\n";
00396 for (int i=1;i<7;++i){
00397 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];
00398 std::stringstream binlabel;
00399 binlabel<<"TOB L "<<i;
00400
00401 for(int j=0;j<4;j++){
00402 ME[j]->Fill(i+10,NBadComponent[2][i][j]);
00403 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+10,binlabel.str().c_str());
00404 }
00405 }
00406 ss << "\n";
00407 for (int i=1;i<10;++i){
00408 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];
00409 std::stringstream binlabel;
00410 binlabel<<"TEC+ D "<<i;
00411
00412 for(int j=0;j<4;j++){
00413 ME[j]->Fill(i+16,NBadComponent[3][i][j]);
00414 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+16,binlabel.str().c_str());
00415 }
00416 }
00417 for (int i=10;i<19;++i){
00418 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];
00419 std::stringstream binlabel;
00420 binlabel<<"TEC- D "<<i-9;
00421
00422 for(int j=0;j<4;j++){
00423 ME[j]->Fill(i+16,NBadComponent[3][i][j]);
00424 ME[j]->getTH1()->GetXaxis()->SetBinLabel(i+16,binlabel.str().c_str());
00425 }
00426 }
00427 ss<< "\n";
00428
00429 ss << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers Apvs\n----------------------------------------------------------------";
00430 for (int i=1;i<5;++i)
00431 ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
00432 ss << "\n";
00433 for (int i=1;i<4;++i)
00434 ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
00435 for (int i=4;i<7;++i)
00436 ss << "\nTID- Disk " << i-3 << " :" << ssV[1][i].str();
00437 ss << "\n";
00438 for (int i=1;i<7;++i)
00439 ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
00440 ss << "\n";
00441 for (int i=1;i<10;++i)
00442 ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
00443 for (int i=10;i<19;++i)
00444 ss << "\nTEC- Disk " << i-9 << " :" << ssV[3][i].str();
00445
00446
00447 edm::LogInfo("SiStripQualityStatistics") << ss.str() << std::endl;
00448
00449 for (int i=0; i<4; i++){
00450 TCanvas c1("c1");
00451 ME[i]->getTH1()->Draw();
00452 std::string name (ME[i]->getTH1()->GetTitle());
00453 name+=".png";
00454 c1.Print(name.c_str());
00455 }
00456
00457
00458 }
00459
00460
00461 void SiStripQualityDQM::SetBadComponents(int i, int component,SiStripQuality::BadComponent& BC){
00462
00463 int napv=reader->getNumberOfApvsAndStripLength(BC.detid).first;
00464
00465 ssV[i][component] << "\n\t\t "
00466 << BC.detid
00467 << " \t " << BC.BadModule << " \t "
00468 << ( (BC.BadFibers)&0x1 ) << " ";
00469 if (napv==4)
00470 ssV[i][component] << "x " <<( (BC.BadFibers>>1)&0x1 );
00471
00472 if (napv==6)
00473 ssV[i][component] << ( (BC.BadFibers>>1)&0x1 ) << " "
00474 << ( (BC.BadFibers>>2)&0x1 );
00475 ssV[i][component] << " \t "
00476 << ( (BC.BadApvs)&0x1 ) << " "
00477 << ( (BC.BadApvs>>1)&0x1 ) << " ";
00478 if (napv==4)
00479 ssV[i][component] << "x x " << ( (BC.BadApvs>>2)&0x1 ) << " "
00480 << ( (BC.BadApvs>>3)&0x1 );
00481 if (napv==6)
00482 ssV[i][component] << ( (BC.BadApvs>>2)&0x1 ) << " "
00483 << ( (BC.BadApvs>>3)&0x1 ) << " "
00484 << ( (BC.BadApvs>>4)&0x1 ) << " "
00485 << ( (BC.BadApvs>>5)&0x1 ) << " ";
00486
00487 if (BC.BadApvs){
00488 NBadComponent[i][0][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) +
00489 ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
00490 NBadComponent[i][component][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) +
00491 ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
00492
00493 }
00494 if (BC.BadFibers){
00495 NBadComponent[i][0][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
00496 NBadComponent[i][component][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
00497
00498 }
00499 if (BC.BadModule){
00500 NBadComponent[i][0][0]++;
00501 NBadComponent[i][component][0]++;
00502
00503 }
00504 }
00505