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