CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

SiStripCorrelateNoise Class Reference

#include <DQM/SiStripMonitorSummary/plugins/SiStripCorrelateNoise.cc>

Inheritance diagram for SiStripCorrelateNoise:
edm::EDAnalyzer

List of all members.

Classes

struct  Data

Public Member Functions

 SiStripCorrelateNoise (const edm::ParameterSet &)
 ~SiStripCorrelateNoise ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginRun (const edm::Run &run, const edm::EventSetup &es)
void checkGainCache (const edm::EventSetup &es)
void DoAnalysis (SiStripNoises, SiStripNoises &)
void DoPlots ()
virtual void endJob ()
unsigned long long getGainCache (const edm::EventSetup &eSetup)
float getGainRatio (const uint32_t &detid, const uint16_t &apv)
TH1F * getHisto (const long unsigned int &index)
void getHistos (const uint32_t &detid, std::vector< TH1F * > &histos)
float getMeanNoise (const SiStripNoises::Range &noiseRange, const uint32_t &first, const uint32_t &range)
unsigned long long getNoiseCache (const edm::EventSetup &eSetup)

Private Attributes

unsigned long long cacheID_gain
unsigned long long cacheID_noise
bool equalGain
TFile * file
SiStripDetInfoFileReaderfr
edm::ESHandle< SiStripApvGaingainHandle_
SiStripApvGainnewGain
edm::ESHandle< SiStripNoisesnoiseHandle_
SiStripApvGainoldGain
SiStripNoisesrefNoise
uint32_t theRun
TrackerMaptkmap
std::vector< TH1F * > vTH1

Detailed Description

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

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

Definition at line 50 of file SiStripCorrelateNoise.h.


Constructor & Destructor Documentation

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

Definition at line 11 of file SiStripCorrelateNoise.cc.

References file, fr, cppFunctionSkipper::operator, and tkmap.

                                                                          :
  refNoise(0),oldGain(0),newGain(0),cacheID_noise(0xFFFFFFFF),cacheID_gain(0xFFFFFFFF)
{
  //now do what ever initialization is needed
  if(!edm::Service<SiStripDetInfoFileReader>().isAvailable()){
    edm::LogError("TkLayerMap") << 
      "\n------------------------------------------"
      "\nUnAvailable Service SiStripDetInfoFileReader: please insert in the configuration file an instance like"
      "\n\tprocess.SiStripDetInfoFileReader = cms.Service(\"SiStripDetInfoFileReader\")"
      "\n------------------------------------------";
  }
 
  fr=edm::Service<SiStripDetInfoFileReader>().operator->();
  file = new TFile("correlTest.root","RECREATE");

  file->cd();
  tkmap = new TrackerMap();
}
SiStripCorrelateNoise::~SiStripCorrelateNoise ( )

Definition at line 31 of file SiStripCorrelateNoise.cc.

{}

Member Function Documentation

virtual void SiStripCorrelateNoise::analyze ( const edm::Event ,
const edm::EventSetup  
) [inline, private, virtual]

Implements edm::EDAnalyzer.

Definition at line 58 of file SiStripCorrelateNoise.h.

{};
void SiStripCorrelateNoise::beginRun ( const edm::Run run,
const edm::EventSetup es 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 37 of file SiStripCorrelateNoise.cc.

References cacheID_noise, checkGainCache(), dir, DoAnalysis(), DoPlots(), file, edm::EventSetup::get(), getNoiseCache(), noiseHandle_, edm::ESHandle< T >::product(), refNoise, edm::RunBase::run(), and theRun.

                                                                         {

  if(getNoiseCache(es)==cacheID_noise )
    return;

  
  edm::LogInfo("") << "[SiStripCorrelateNoise::beginRun]  cacheID_noise " << cacheID_noise << std::endl; 
  
  es.get<SiStripNoisesRcd>().get(noiseHandle_);
  SiStripNoises * aNoise= new SiStripNoises(*noiseHandle_.product());
  
  //Check if gain is the same from one noise iov to the other, otherwise cache the new gain (and the old one) to rescale

  checkGainCache(es);

  if(cacheID_noise!=0xFFFFFFFF){
    char dir[128];
    theRun=run.run();
    sprintf(dir,"Run_%d",theRun);
    file->cd("");
    file->mkdir(dir);
    file->cd(dir);
    DoAnalysis(*noiseHandle_.product(),*refNoise);
    DoPlots(); 
  }

  cacheID_noise=getNoiseCache(es);  
  if(refNoise!=0)
    delete refNoise;
  refNoise=aNoise;
}
void SiStripCorrelateNoise::checkGainCache ( const edm::EventSetup es) [private]

Definition at line 70 of file SiStripCorrelateNoise.cc.

References cacheID_gain, equalGain, gainHandle_, edm::EventSetup::get(), getGainCache(), newGain, oldGain, and edm::ESHandle< T >::product().

Referenced by beginRun().

                                                            {
  equalGain=true;
  if(getGainCache(es)!=cacheID_gain ){
    es.get<SiStripApvGainRcd>().get(gainHandle_);
    if(oldGain!=0)
      delete oldGain;
    
    oldGain = newGain;
    newGain = new SiStripApvGain(*gainHandle_.product());

    if(cacheID_gain!=0xFFFFFFFF)
      equalGain=false;
   cacheID_gain=getGainCache(es);
   edm::LogInfo("") << "[SiStripCorrelateNoise::checkGainCache]  cacheID_gain " << cacheID_gain << std::endl; 
  }
}
void SiStripCorrelateNoise::DoAnalysis ( SiStripNoises  Noise,
SiStripNoises refNoise 
) [private]

Definition at line 119 of file SiStripCorrelateNoise.cc.

References runEdmFileComparison::collection, equalGain, HcalObjRepresent::Fill(), TrackerMap::fill(), getGainRatio(), getHistos(), mergeVDriftHistosByStation::histos, i, refNoise, strip(), tkmap, and relativeConstraints::value.

Referenced by beginRun().

                                                                             {
  typedef std::vector<SiStripNoises::ratioData> collection; 
  collection divNoise=Noise/refNoise;

  edm::LogInfo("") << "[Doanalysis]";

  std::vector<TH1F *>histos;

  collection::const_iterator iter=divNoise.begin();
  collection::const_iterator iterE=divNoise.end();

  float value;
  float gainRatio=1.;
  //Divide result by d
  for(;iter!=iterE;++iter){
    getHistos(iter->detid,histos);
    
    size_t strip=0, stripE= iter->values.size();
    size_t apvNb=7;

    for (;strip<stripE;++strip){       
      if(!equalGain && strip/128!=apvNb){
        apvNb=strip/128;
        if(apvNb<6)
          gainRatio=getGainRatio(iter->detid,apvNb);
        else
          edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " apvNb " << apvNb;
      }
      //edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " value " << iter->values[strip];
      value=iter->values[strip]*gainRatio;
      tkmap->fill(iter->detid,value);
      for(size_t i=0;i<histos.size();++i)
        histos[i]->Fill(value);
    }
  }
}
void SiStripCorrelateNoise::DoPlots ( ) [private]

Definition at line 88 of file SiStripCorrelateNoise.cc.

References funct::C, dir, file, i, TrackerMap::save(), theRun, tkmap, and vTH1.

Referenced by beginRun().

                              {
  TCanvas *C=new TCanvas();
  C->Divide(2,2);
  
  char outName[128];
  sprintf(outName,"Run_%d.png",theRun);
  for(size_t i=0;i<vTH1.size();i++)
    if(vTH1[i]!=0){
      if(i%100==0){
        C->cd(i/100);
        vTH1[i]->SetLineColor(i/100);
        vTH1[i]->Draw();
        C->cd(i/100)->SetLogy();
      }
      vTH1[i]->Write();
    }
  
  C->Print(outName);
  delete C;
  
  vTH1.clear();
  file->cd("");

  char dir[128];
  sprintf(dir,"Run_%d_TkMap.png",theRun);
  tkmap->save(false,0,5,dir);
  delete tkmap;
  tkmap = new TrackerMap();
}
void SiStripCorrelateNoise::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file SiStripCorrelateNoise.cc.

References file.

                              {
  file->Write();
  file->Close();


}
unsigned long long SiStripCorrelateNoise::getGainCache ( const edm::EventSetup eSetup) [inline, private]

Definition at line 67 of file SiStripCorrelateNoise.h.

References edm::EventSetup::get().

Referenced by checkGainCache().

{ return eSetup.get<SiStripApvGainRcd>().cacheIdentifier();}
float SiStripCorrelateNoise::getGainRatio ( const uint32_t &  detid,
const uint16_t &  apv 
) [private]

Definition at line 157 of file SiStripCorrelateNoise.cc.

References SiStripApvGain::getApvGain(), SiStripApvGain::getRange(), newGain, and oldGain.

Referenced by DoAnalysis().

                                                                             {

  SiStripApvGain::Range oldRange=oldGain->getRange(detid); 
  SiStripApvGain::Range newRange=newGain->getRange(detid); 

  if(oldRange.first==oldRange.second ||
     newRange.first==newRange.second)
    return 1.;

  return oldGain->getApvGain(apv,oldRange)/newGain->getApvGain(apv,newRange);

}
TH1F * SiStripCorrelateNoise::getHisto ( const long unsigned int &  index) [private]

Definition at line 210 of file SiStripCorrelateNoise.cc.

References getHLTprescales::index, mergeVDriftHistosByStation::name, theRun, and vTH1.

Referenced by getHistos().

                                                             {
  if(vTH1.size()<index+1)
    vTH1.resize(index+1,0);
  
  if(vTH1[index]==0){
    char name[128];
    std::string SubD;
    if(index<200)
      SubD="TIB";
    else if(index<300)
      SubD="TID";
    else if(index<400)
      SubD="TOB";
    else 
      SubD="TEC";
    sprintf(name,"%d_%lu__%s",theRun,index,SubD.c_str());
    edm::LogInfo("")<<"[getHisto] creating index " << index << std::endl;
    vTH1[index]=new TH1F(name,name,200,-0.5,10.5);
  }
  
  return vTH1[index];
}
void SiStripCorrelateNoise::getHistos ( const uint32_t &  detid,
std::vector< TH1F * > &  histos 
) [private]

Definition at line 181 of file SiStripCorrelateNoise.cc.

References a, getHisto(), getHLTprescales::index, TIBDetId::layer(), TOBDetId::layer(), TIDDetId::side(), TECDetId::side(), DetId::subdetId(), TIDDetId::wheel(), and TECDetId::wheel().

Referenced by DoAnalysis().

                                                                              {
  
  histos.clear();
  
  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;
  } 
  
  int index=100+subdet*100+component;
  

  histos.push_back(getHisto(100+100*subdet));
  histos.push_back(getHisto(index));
  
}
float SiStripCorrelateNoise::getMeanNoise ( const SiStripNoises::Range noiseRange,
const uint32_t &  first,
const uint32_t &  range 
) [private]

Definition at line 171 of file SiStripCorrelateNoise.cc.

References timingPdfMaker::mean, and noiseHandle_.

                                                                                                                         {
  
  float mean=0;
  for (size_t istrip=firstStrip;istrip<firstStrip+range;istrip++){
    mean+=noiseHandle_->getNoise(istrip,noiseRange);
  }
  return mean/(1.*range);
}
unsigned long long SiStripCorrelateNoise::getNoiseCache ( const edm::EventSetup eSetup) [inline, private]

Definition at line 66 of file SiStripCorrelateNoise.h.

References edm::EventSetup::get().

Referenced by beginRun().

{ return eSetup.get<SiStripNoisesRcd>().cacheIdentifier();}

Member Data Documentation

unsigned long long SiStripCorrelateNoise::cacheID_gain [private]

Definition at line 98 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

unsigned long long SiStripCorrelateNoise::cacheID_noise [private]

Definition at line 97 of file SiStripCorrelateNoise.h.

Referenced by beginRun().

Definition at line 88 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and DoAnalysis().

TFile* SiStripCorrelateNoise::file [private]

Definition at line 91 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), DoPlots(), endJob(), and SiStripCorrelateNoise().

Definition at line 80 of file SiStripCorrelateNoise.h.

Referenced by SiStripCorrelateNoise().

Definition at line 81 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and getMeanNoise().

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

Definition at line 85 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and DoAnalysis().

uint32_t SiStripCorrelateNoise::theRun [private]

Definition at line 84 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), DoPlots(), and getHisto().

Definition at line 94 of file SiStripCorrelateNoise.h.

Referenced by DoAnalysis(), DoPlots(), and SiStripCorrelateNoise().

std::vector<TH1F*> SiStripCorrelateNoise::vTH1 [private]

Definition at line 92 of file SiStripCorrelateNoise.h.

Referenced by DoPlots(), and getHisto().