CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripQualityStatistics Class Reference

#include <CalibTracker/SiStripQuality/plugins/SiStripQualityStatistics.cc>

Inheritance diagram for SiStripQualityStatistics:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
void endJob ()
 SiStripQualityStatistics (const edm::ParameterSet &)
 ~SiStripQualityStatistics ()

Private Member Functions

void SetBadComponents (int, int, SiStripQuality::BadComponent &)

Private Attributes

std::string dataLabel_
edm::FileInPath fp_
unsigned long long m_cacheID_
int NBadComponent [4][19][4]
int NTkBadComponent [4]
SiStripDetInfoFileReaderreader
bool saveTkHistoMap_
std::stringstream ssV [4][19]
TkHistoMaptkhisto
TrackerMaptkMap
std::string TkMapFileName_
TrackerMaptkMapFullIOVs

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 24 of file SiStripQualityStatistics.h.


Constructor & Destructor Documentation

SiStripQualityStatistics::SiStripQualityStatistics ( const edm::ParameterSet iConfig) [explicit]

Definition at line 34 of file SiStripQualityStatistics.cc.

References fp_, edm::FileInPath::fullPath(), reader, python::OfflineSiStripConfigDb_cff::SiStripDetInfoFileReader, tkhisto, TkMapFileName_, and tkMapFullIOVs.

                                                                                  :
  m_cacheID_(0), 
  dataLabel_(iConfig.getUntrackedParameter<std::string>("dataLabel","")),
  TkMapFileName_(iConfig.getUntrackedParameter<std::string>("TkMapFileName","")),
  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
  saveTkHistoMap_(iConfig.getUntrackedParameter<bool>("SaveTkHistoMap",true)),
  tkMap(0),tkMapFullIOVs(0)
{  
  reader = new SiStripDetInfoFileReader(fp_.fullPath());

  tkMapFullIOVs=new TrackerMap( "BadComponents" );
  tkhisto=0;
  if (TkMapFileName_!=""){
    tkhisto   =new TkHistoMap("BadComp","BadComp",-1.); //here the baseline (the value of the empty,not assigned bins) is put to -1 (default is zero)
  }
}
SiStripQualityStatistics::~SiStripQualityStatistics ( ) [inline]

Definition at line 28 of file SiStripQualityStatistics.h.

{};

Member Function Documentation

void SiStripQualityStatistics::analyze ( const edm::Event e,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 66 of file SiStripQualityStatistics.cc.

References a, dataLabel_, cond::rpcobgas::detid, edm::EventID::event(), lut2db_cfg::filename, alcaDQMUpload::filetype(), TrackerMap::fill(), TkHistoMap::fill(), TrackerMap::fillc(), edm::EventSetup::get(), SiStripDetInfoFileReader::getAllDetIds(), SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), i, edm::EventBase::id(), j, gen::k, TIBDetId::layer(), TOBDetId::layer(), LogDebug, edm::EventBase::luminosityBlock(), m_cacheID_, NBadComponent, NTkBadComponent, NULL, TrackerMap::print(), reader, edm::EventID::run(), TrackerMap::save(), SetBadComponents(), TIDDetId::side(), TECDetId::side(), ssV, DetId::subdetId(), sistripsummary::TEC, sistripsummary::TIB, sistripsummary::TID, edm::EventBase::time(), tkhisto, tkMap, TkMapFileName_, tkMapFullIOVs, sistripsummary::TOB, edm::Timestamp::value(), TIDDetId::wheel(), and TECDetId::wheel().

                                                                                     {

  unsigned long long cacheID = iSetup.get<SiStripQualityRcd>().cacheIdentifier();

  std::stringstream ss;

  if (m_cacheID_ == cacheID) 
    return;

  m_cacheID_ = cacheID; 

  edm::ESHandle<SiStripQuality> SiStripQuality_;
  iSetup.get<SiStripQualityRcd>().get(dataLabel_,SiStripQuality_);
    
  for(int i=0;i<4;++i){
    NTkBadComponent[i]=0;
    for(int j=0;j<19;++j){
      ssV[i][j].str("");
      for(int k=0;k<4;++k)
        NBadComponent[i][j][k]=0;
    }
  }

  if (tkMap)
    delete tkMap;
  tkMap=new TrackerMap( "BadComponents" );


  ss.str(""); 
  std::vector<uint32_t> detids=reader->getAllDetIds();
  std::vector<uint32_t>::const_iterator idet=detids.begin();
  for(;idet!=detids.end();++idet){
    ss << "detid " << (*idet) << " IsModuleUsable " << SiStripQuality_->IsModuleUsable((*idet)) << "\n";
    if (SiStripQuality_->IsModuleUsable((*idet)))
      tkMap->fillc(*idet,0x00ff00);
  }
  LogDebug("SiStripQualityStatistics") << ss.str() << std::endl;


  std::vector<SiStripQuality::BadComponent> BC = SiStripQuality_->getBadComponentList();
  
  for (size_t i=0;i<BC.size();++i){
    
    //&&&&&&&&&&&&&
    //Full Tk
    //&&&&&&&&&&&&&

    if (BC[i].BadModule) 
      NTkBadComponent[0]++;
    if (BC[i].BadFibers) 
      NTkBadComponent[1]+= ( (BC[i].BadFibers>>2)&0x1 )+ ( (BC[i].BadFibers>>1)&0x1 ) + ( (BC[i].BadFibers)&0x1 );
    if (BC[i].BadApvs)
      NTkBadComponent[2]+= ( (BC[i].BadApvs>>5)&0x1 )+ ( (BC[i].BadApvs>>4)&0x1 ) + ( (BC[i].BadApvs>>3)&0x1 ) + 
        ( (BC[i].BadApvs>>2)&0x1 )+ ( (BC[i].BadApvs>>1)&0x1 ) + ( (BC[i].BadApvs)&0x1 );

    //&&&&&&&&&&&&&&&&&
    //Single SubSyste
    //&&&&&&&&&&&&&&&&&

    int component;
    SiStripDetId a(BC[i].detid);
    if ( a.subdetId() == SiStripDetId::TIB ){
      //&&&&&&&&&&&&&&&&&
      //TIB
      //&&&&&&&&&&&&&&&&&
      
      component=TIBDetId(BC[i].detid).layer();
      SetBadComponents(0, component, BC[i]);         

    } else if ( a.subdetId() == SiStripDetId::TID ) {
      //&&&&&&&&&&&&&&&&&
      //TID
      //&&&&&&&&&&&&&&&&&

      component=TIDDetId(BC[i].detid).side()==2?TIDDetId(BC[i].detid).wheel():TIDDetId(BC[i].detid).wheel()+3;
      SetBadComponents(1, component, BC[i]);         

    } else if ( a.subdetId() == SiStripDetId::TOB ) {
      //&&&&&&&&&&&&&&&&&
      //TOB
      //&&&&&&&&&&&&&&&&&

      component=TOBDetId(BC[i].detid).layer();
      SetBadComponents(2, component, BC[i]);         

    } else if ( a.subdetId() == SiStripDetId::TEC ) {
      //&&&&&&&&&&&&&&&&&
      //TEC
      //&&&&&&&&&&&&&&&&&

      component=TECDetId(BC[i].detid).side()==2?TECDetId(BC[i].detid).wheel():TECDetId(BC[i].detid).wheel()+9;
      SetBadComponents(3, component, BC[i]);         

    }    
  }

  //&&&&&&&&&&&&&&&&&&
  // Single Strip Info
  //&&&&&&&&&&&&&&&&&&
  float percentage=0;

  SiStripQuality::RegistryIterator rbegin = SiStripQuality_->getRegistryVectorBegin();
  SiStripQuality::RegistryIterator rend   = SiStripQuality_->getRegistryVectorEnd();
  
  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
    uint32_t detid=rp->detid;

    int subdet=-999; int component=-999;
    SiStripDetId a(detid);
    if ( a.subdetId() == 3 ){
      subdet=0;
      component=TIBDetId(detid).layer();
    } else if ( a.subdetId() == 4 ) {
      subdet=1;
      component=TIDDetId(detid).side()==2?TIDDetId(detid).wheel():TIDDetId(detid).wheel()+3;
    } else if ( a.subdetId() == 5 ) {
      subdet=2;
      component=TOBDetId(detid).layer();
    } else if ( a.subdetId() == 6 ) {
      subdet=3;
      component=TECDetId(detid).side()==2?TECDetId(detid).wheel():TECDetId(detid).wheel()+9;
    } 

    SiStripQuality::Range sqrange = SiStripQuality::Range( SiStripQuality_->getDataVectorBegin()+rp->ibegin , SiStripQuality_->getDataVectorBegin()+rp->iend );
        
    percentage=0;
    for(int it=0;it<sqrange.second-sqrange.first;it++){
      unsigned int range=SiStripQuality_->decode( *(sqrange.first+it) ).range;
      NTkBadComponent[3]+=range;
      NBadComponent[subdet][0][3]+=range;
      NBadComponent[subdet][component][3]+=range;
      percentage+=range;
    }
    if(percentage!=0)
      percentage/=128.*reader->getNumberOfApvsAndStripLength(detid).first;
    if(percentage>1)
      edm::LogError("SiStripQualityStatistics") <<  "PROBLEM detid " << detid << " value " << percentage<< std::endl;

    //------- Global Statistics on percentage of bad components along the IOVs ------//
    tkMapFullIOVs->fill(detid,percentage);
    if(tkhisto!=NULL)
      tkhisto->fill(detid,percentage);
  }
  
 
  //&&&&&&&&&&&&&&&&&&
  // printout
  //&&&&&&&&&&&&&&&&&&

  ss.str("");
  ss << "\n-----------------\nNew IOV starting from run " <<   e.id().run() << " event " << e.id().event() << " lumiBlock " << e.luminosityBlock() << " time " << e.time().value() << " chacheID " << m_cacheID_ << "\n-----------------\n";
  ss << "\n-----------------\nGlobal Info\n-----------------";
  ss << "\nBadComponent \t   Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
  ss << "\nTracker:\t\t"<<NTkBadComponent[0]<<"\t"<<NTkBadComponent[1]<<"\t"<<NTkBadComponent[2]<<"\t"<<NTkBadComponent[3];
  ss<< "\n";
  ss << "\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<"\t"<<NBadComponent[0][0][1]<<"\t"<<NBadComponent[0][0][2]<<"\t"<<NBadComponent[0][0][3];
  ss << "\nTID:\t\t\t"<<NBadComponent[1][0][0]<<"\t"<<NBadComponent[1][0][1]<<"\t"<<NBadComponent[1][0][2]<<"\t"<<NBadComponent[1][0][3];
  ss << "\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<"\t"<<NBadComponent[2][0][1]<<"\t"<<NBadComponent[2][0][2]<<"\t"<<NBadComponent[2][0][3];
  ss << "\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<"\t"<<NBadComponent[3][0][1]<<"\t"<<NBadComponent[3][0][2]<<"\t"<<NBadComponent[3][0][3];
  ss << "\n";

  for (int i=1;i<5;++i)
    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];
  ss << "\n";
  for (int i=1;i<4;++i)
    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];
  for (int i=4;i<7;++i)
    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];
  ss << "\n";
  for (int i=1;i<7;++i)
    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];
  ss << "\n";
  for (int i=1;i<10;++i)
    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];
  for (int i=10;i<19;++i)
    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];
  ss<< "\n";

  ss << "\n----------------------------------------------------------------\n\t\t   Detid  \tModules Fibers Apvs\n----------------------------------------------------------------";
  for (int i=1;i<5;++i)
    ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
  ss << "\n";
  for (int i=1;i<4;++i)
    ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
  for (int i=4;i<7;++i)
    ss << "\nTID- Disk " << i-3 << " :" << ssV[1][i].str();
  ss << "\n";
  for (int i=1;i<7;++i)
    ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
  ss << "\n";
  for (int i=1;i<10;++i)
    ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
  for (int i=10;i<19;++i)
    ss << "\nTEC- Disk " << i-9 << " :" << ssV[3][i].str();


  edm::LogInfo("SiStripQualityStatistics") << ss.str() << std::endl;

  std::string filetype=TkMapFileName_,filename=TkMapFileName_;
  std::stringstream sRun; sRun.str("");
  sRun << "_Run_"  << std::setw(6) << std::setfill('0')<< e.id().run() << std::setw(0) ;
    
  if (filename!=""){
    filename.insert(filename.find("."),sRun.str());
    tkMap->save(true,0,0,filename.c_str());
    filename.erase(filename.begin()+filename.find("."),filename.end());
    tkMap->print(true,0,0,filename.c_str());
  }
}
void SiStripQualityStatistics::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file SiStripQualityStatistics.cc.

References lut2db_cfg::filename, TrackerMap::print(), TkHistoMap::save(), TrackerMap::save(), TkHistoMap::saveAsCanvas(), saveTkHistoMap_, tkhisto, TkMapFileName_, and tkMapFullIOVs.

                                     {

  std::string filename=TkMapFileName_;
  if (filename!=""){
    tkMapFullIOVs->save(false,0,0,filename.c_str());
    filename.erase(filename.begin()+filename.find("."),filename.end());
    tkMapFullIOVs->print(false,0,0,filename.c_str());
  
    if(saveTkHistoMap_){
      tkhisto->save(filename+".root");
      tkhisto->saveAsCanvas(filename+"_Canvas.root","E");
    }
  }
}
void SiStripQualityStatistics::SetBadComponents ( int  i,
int  component,
SiStripQuality::BadComponent BC 
) [private]

Definition at line 277 of file SiStripQualityStatistics.cc.

References SiStripQuality::BadComponent::BadApvs, SiStripQuality::BadComponent::BadFibers, SiStripQuality::BadComponent::BadModule, SiStripQuality::BadComponent::detid, TrackerMap::fillc(), SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), i, NBadComponent, reader, ssV, and tkMap.

Referenced by analyze().

                                                                                                  {

  int napv=reader->getNumberOfApvsAndStripLength(BC.detid).first;

  ssV[i][component] << "\n\t\t " 
                    << BC.detid 
                    << " \t " << BC.BadModule << " \t " 
                    << ( (BC.BadFibers)&0x1 ) << " ";
  if (napv==4)
    ssV[i][component] << "x " <<( (BC.BadFibers>>1)&0x1 );
  
  if (napv==6)
    ssV[i][component] << ( (BC.BadFibers>>1)&0x1 ) << " "
                      << ( (BC.BadFibers>>2)&0x1 );
  ssV[i][component] << " \t " 
                    << ( (BC.BadApvs)&0x1 ) << " " 
                    << ( (BC.BadApvs>>1)&0x1 ) << " ";
  if (napv==4) 
    ssV[i][component] << "x x " << ( (BC.BadApvs>>2)&0x1 ) << " " 
                      << ( (BC.BadApvs>>3)&0x1 );
  if (napv==6) 
    ssV[i][component] << ( (BC.BadApvs>>2)&0x1 ) << " " 
                      << ( (BC.BadApvs>>3)&0x1 ) << " " 
                      << ( (BC.BadApvs>>4)&0x1 ) << " " 
                      << ( (BC.BadApvs>>5)&0x1 ) << " "; 

  if (BC.BadApvs){
    NBadComponent[i][0][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) + 
      ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
    NBadComponent[i][component][2]+= ( (BC.BadApvs>>5)&0x1 )+ ( (BC.BadApvs>>4)&0x1 ) + ( (BC.BadApvs>>3)&0x1 ) + 
      ( (BC.BadApvs>>2)&0x1 )+ ( (BC.BadApvs>>1)&0x1 ) + ( (BC.BadApvs)&0x1 );
    tkMap->fillc(BC.detid,0xff0000);
  }
  if (BC.BadFibers){ 
    NBadComponent[i][0][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
    NBadComponent[i][component][1]+= ( (BC.BadFibers>>2)&0x1 )+ ( (BC.BadFibers>>1)&0x1 ) + ( (BC.BadFibers)&0x1 );
    tkMap->fillc(BC.detid,0x0000ff);
  }   
  if (BC.BadModule){
    NBadComponent[i][0][0]++;
    NBadComponent[i][component][0]++;
    tkMap->fillc(BC.detid,0x0);
  }
}

Member Data Documentation

std::string SiStripQualityStatistics::dataLabel_ [private]

Definition at line 38 of file SiStripQualityStatistics.h.

Referenced by analyze().

Definition at line 40 of file SiStripQualityStatistics.h.

Referenced by SiStripQualityStatistics().

unsigned long long SiStripQualityStatistics::m_cacheID_ [private]

Definition at line 37 of file SiStripQualityStatistics.h.

Referenced by analyze().

int SiStripQualityStatistics::NBadComponent[4][19][4] [private]

Definition at line 44 of file SiStripQualityStatistics.h.

Referenced by analyze(), and SetBadComponents().

Definition at line 43 of file SiStripQualityStatistics.h.

Referenced by analyze().

Definition at line 51 of file SiStripQualityStatistics.h.

Referenced by analyze(), SetBadComponents(), and SiStripQualityStatistics().

Definition at line 41 of file SiStripQualityStatistics.h.

Referenced by endJob().

std::stringstream SiStripQualityStatistics::ssV[4][19] [private]

Definition at line 48 of file SiStripQualityStatistics.h.

Referenced by analyze(), and SetBadComponents().

Definition at line 52 of file SiStripQualityStatistics.h.

Referenced by analyze(), endJob(), and SiStripQualityStatistics().

Definition at line 50 of file SiStripQualityStatistics.h.

Referenced by analyze(), and SetBadComponents().

Definition at line 39 of file SiStripQualityStatistics.h.

Referenced by analyze(), endJob(), and SiStripQualityStatistics().

Definition at line 50 of file SiStripQualityStatistics.h.

Referenced by analyze(), endJob(), and SiStripQualityStatistics().