CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripCorrelateNoise Class Reference

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

Inheritance diagram for SiStripCorrelateNoise:
edm::EDAnalyzer

Classes

struct  Data
 

Public Member Functions

 SiStripCorrelateNoise (const edm::ParameterSet &)
 
 ~SiStripCorrelateNoise ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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, cmsCodeRules.cppFunctionSkipper::operator, and tkmap.

11  :
12  refNoise(0),oldGain(0),newGain(0),cacheID_noise(0xFFFFFFFF),cacheID_gain(0xFFFFFFFF)
13 {
14  //now do what ever initialization is needed
15  if(!edm::Service<SiStripDetInfoFileReader>().isAvailable()){
16  edm::LogError("TkLayerMap") <<
17  "\n------------------------------------------"
18  "\nUnAvailable Service SiStripDetInfoFileReader: please insert in the configuration file an instance like"
19  "\n\tprocess.SiStripDetInfoFileReader = cms.Service(\"SiStripDetInfoFileReader\")"
20  "\n------------------------------------------";
21  }
22 
24  file = new TFile("correlTest.root","RECREATE");
25 
26  file->cd();
27  tkmap = new TrackerMap();
28 }
unsigned long long cacheID_noise
unsigned long long cacheID_gain
SiStripDetInfoFileReader * fr
SiStripCorrelateNoise::~SiStripCorrelateNoise ( )

Definition at line 31 of file SiStripCorrelateNoise.cc.

32 {}

Member Function Documentation

virtual void SiStripCorrelateNoise::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 58 of file SiStripCorrelateNoise.h.

58 {};
void SiStripCorrelateNoise::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
privatevirtual

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< class >::product(), refNoise, edm::RunBase::run(), and theRun.

37  {
38 
40  return;
41 
42 
43  edm::LogInfo("") << "[SiStripCorrelateNoise::beginRun] cacheID_noise " << cacheID_noise << std::endl;
44 
47 
48  //Check if gain is the same from one noise iov to the other, otherwise cache the new gain (and the old one) to rescale
49 
50  checkGainCache(es);
51 
52  if(cacheID_noise!=0xFFFFFFFF){
53  char dir[128];
54  theRun=run.run();
55  sprintf(dir,"Run_%d",theRun);
56  file->cd("");
57  file->mkdir(dir);
58  file->cd(dir);
60  DoPlots();
61  }
62 
64  if(refNoise!=0)
65  delete refNoise;
66  refNoise=aNoise;
67 }
unsigned long long cacheID_noise
RunNumber_t run() const
Definition: RunBase.h:44
unsigned long long getNoiseCache(const edm::EventSetup &eSetup)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void DoAnalysis(SiStripNoises, SiStripNoises &)
edm::ESHandle< SiStripNoises > noiseHandle_
dbl *** dir
Definition: mlp_gen.cc:35
void checkGainCache(const edm::EventSetup &es)
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< class >::product().

Referenced by beginRun().

70  {
71  equalGain=true;
72  if(getGainCache(es)!=cacheID_gain ){
74  if(oldGain!=0)
75  delete oldGain;
76 
77  oldGain = newGain;
79 
80  if(cacheID_gain!=0xFFFFFFFF)
81  equalGain=false;
83  edm::LogInfo("") << "[SiStripCorrelateNoise::checkGainCache] cacheID_gain " << cacheID_gain << std::endl;
84  }
85 }
edm::ESHandle< SiStripApvGain > gainHandle_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
unsigned long long cacheID_gain
unsigned long long getGainCache(const edm::EventSetup &eSetup)
void SiStripCorrelateNoise::DoAnalysis ( SiStripNoises  Noise,
SiStripNoises refNoise 
)
private

Definition at line 119 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

119  {
120  typedef std::vector<SiStripNoises::ratioData> collection;
121  collection divNoise=Noise/refNoise;
122 
123  edm::LogInfo("") << "[Doanalysis]";
124 
125  std::vector<TH1F *>histos;
126 
127  collection::const_iterator iter=divNoise.begin();
128  collection::const_iterator iterE=divNoise.end();
129 
130  float value;
131  float gainRatio=1.;
132  //Divide result by d
133  for(;iter!=iterE;++iter){
134  getHistos(iter->detid,histos);
135 
136  size_t strip=0, stripE= iter->values.size();
137  size_t apvNb=7;
138 
139  for (;strip<stripE;++strip){
140  if(!equalGain && strip/128!=apvNb){
141  apvNb=strip/128;
142  if(apvNb<6)
143  gainRatio=getGainRatio(iter->detid,apvNb);
144  else
145  edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " apvNb " << apvNb;
146  }
147  //edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " value " << iter->values[strip];
148  value=iter->values[strip]*gainRatio;
149  tkmap->fill(iter->detid,value);
150  for(size_t i=0;i<histos.size();++i)
151  histos[i]->Fill(value);
152  }
153  }
154 }
int i
Definition: DBlmapReader.cc:9
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void getHistos(const uint32_t &detid, std::vector< TH1F * > &histos)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
float getGainRatio(const uint32_t &detid, const uint16_t &apv)
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:2548
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().

88  {
89  TCanvas *C=new TCanvas();
90  C->Divide(2,2);
91 
92  char outName[128];
93  sprintf(outName,"Run_%d.png",theRun);
94  for(size_t i=0;i<vTH1.size();i++)
95  if(vTH1[i]!=0){
96  if(i%100==0){
97  C->cd(i/100);
98  vTH1[i]->SetLineColor(i/100);
99  vTH1[i]->Draw();
100  C->cd(i/100)->SetLogy();
101  }
102  vTH1[i]->Write();
103  }
104 
105  C->Print(outName);
106  delete C;
107 
108  vTH1.clear();
109  file->cd("");
110 
111  char dir[128];
112  sprintf(dir,"Run_%d_TkMap.png",theRun);
113  tkmap->save(false,0,5,dir);
114  delete tkmap;
115  tkmap = new TrackerMap();
116 }
int i
Definition: DBlmapReader.cc:9
std::vector< TH1F * > vTH1
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:632
dbl *** dir
Definition: mlp_gen.cc:35
void SiStripCorrelateNoise::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file SiStripCorrelateNoise.cc.

References file.

234  {
235  file->Write();
236  file->Close();
237 
238 
239 }
unsigned long long SiStripCorrelateNoise::getGainCache ( const edm::EventSetup eSetup)
inlineprivate

Definition at line 67 of file SiStripCorrelateNoise.h.

References edm::EventSetup::get().

Referenced by checkGainCache().

67 { return eSetup.get<SiStripApvGainRcd>().cacheIdentifier();}
const T & get() const
Definition: EventSetup.h:55
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().

157  {
158 
161 
162  if(oldRange.first==oldRange.second ||
163  newRange.first==newRange.second)
164  return 1.;
165 
166  return oldGain->getApvGain(apv,oldRange)/newGain->getApvGain(apv,newRange);
167 
168 }
std::pair< ContainerIterator, ContainerIterator > Range
const Range getRange(const uint32_t &detID) const
float getApvGain(const uint16_t &apv, const Range &range) const
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().

210  {
211  if(vTH1.size()<index+1)
212  vTH1.resize(index+1,0);
213 
214  if(vTH1[index]==0){
215  char name[128];
216  std::string SubD;
217  if(index<200)
218  SubD="TIB";
219  else if(index<300)
220  SubD="TID";
221  else if(index<400)
222  SubD="TOB";
223  else
224  SubD="TEC";
225  sprintf(name,"%d_%lu__%s",theRun,index,SubD.c_str());
226  edm::LogInfo("")<<"[getHisto] creating index " << index << std::endl;
227  vTH1[index]=new TH1F(name,name,200,-0.5,10.5);
228  }
229 
230  return vTH1[index];
231 }
std::vector< TH1F * > vTH1
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, TOBDetId::layer(), TIBDetId::layer(), TIDDetId::side(), TECDetId::side(), DetId::subdetId(), TIDDetId::wheel(), and TECDetId::wheel().

Referenced by DoAnalysis().

181  {
182 
183  histos.clear();
184 
185  int subdet=-999; int component=-999;
187  if ( a.subdetId() == 3 ){
188  subdet=0;
189  component=TIBDetId(detid).layer();
190  } else if ( a.subdetId() == 4 ) {
191  subdet=1;
192  component=TIDDetId(detid).side()==2?TIDDetId(detid).wheel():TIDDetId(detid).wheel()+3;
193  } else if ( a.subdetId() == 5 ) {
194  subdet=2;
195  component=TOBDetId(detid).layer();
196  } else if ( a.subdetId() == 6 ) {
197  subdet=3;
198  component=TECDetId(detid).side()==2?TECDetId(detid).wheel():TECDetId(detid).wheel()+9;
199  }
200 
201  int index=100+subdet*100+component;
202 
203 
204  histos.push_back(getHisto(100+100*subdet));
205  histos.push_back(getHisto(index));
206 
207 }
TH1F * getHisto(const long unsigned int &index)
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
unsigned int side() const
positive or negative id
Definition: TECDetId.h:47
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
unsigned int side() const
positive or negative id
Definition: TIDDetId.h:45
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
double a
Definition: hdecay.h:121
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
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 plotscripts::mean(), and noiseHandle_.

171  {
172 
173  float mean=0;
174  for (size_t istrip=firstStrip;istrip<firstStrip+range;istrip++){
175  mean+=noiseHandle_->getNoise(istrip,noiseRange);
176  }
177  return mean/(1.*range);
178 }
edm::ESHandle< SiStripNoises > noiseHandle_
unsigned long long SiStripCorrelateNoise::getNoiseCache ( const edm::EventSetup eSetup)
inlineprivate

Definition at line 66 of file SiStripCorrelateNoise.h.

References edm::EventSetup::get().

Referenced by beginRun().

66 { return eSetup.get<SiStripNoisesRcd>().cacheIdentifier();}
const T & get() const
Definition: EventSetup.h:55

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().

bool SiStripCorrelateNoise::equalGain
private

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().

SiStripDetInfoFileReader* SiStripCorrelateNoise::fr
private

Definition at line 80 of file SiStripCorrelateNoise.h.

Referenced by SiStripCorrelateNoise().

edm::ESHandle<SiStripApvGain> SiStripCorrelateNoise::gainHandle_
private

Definition at line 81 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

SiStripApvGain * SiStripCorrelateNoise::newGain
private

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

edm::ESHandle<SiStripNoises> SiStripCorrelateNoise::noiseHandle_
private

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and getMeanNoise().

SiStripApvGain* SiStripCorrelateNoise::oldGain
private

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

SiStripNoises* SiStripCorrelateNoise::refNoise
private

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().

TrackerMap* SiStripCorrelateNoise::tkmap
private

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().