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 edm::EDConsumerBase

Classes

struct  Data
 

Public Member Functions

 SiStripCorrelateNoise (const edm::ParameterSet &)
 
 ~SiStripCorrelateNoise ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 (const edm::EventSetup &, const 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, const TrackerTopology *tTopo, 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
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 9 of file SiStripCorrelateNoise.cc.

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

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

Definition at line 29 of file SiStripCorrelateNoise.cc.

30 {}

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 35 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.

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

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

Referenced by beginRun().

67  {
68  equalGain=true;
69  if(getGainCache(es)!=cacheID_gain ){
71  if(oldGain!=0)
72  delete oldGain;
73 
74  oldGain = newGain;
76 
77  if(cacheID_gain!=0xFFFFFFFF)
78  equalGain=false;
80  edm::LogInfo("") << "[SiStripCorrelateNoise::checkGainCache] cacheID_gain " << cacheID_gain << std::endl;
81  }
82 }
edm::ESHandle< SiStripApvGain > gainHandle_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
unsigned long long cacheID_gain
unsigned long long getGainCache(const edm::EventSetup &eSetup)
void SiStripCorrelateNoise::DoAnalysis ( const edm::EventSetup es,
const SiStripNoises _Noise,
SiStripNoises refNoise 
)
private

Definition at line 116 of file SiStripCorrelateNoise.cc.

References runEdmFileComparison::collection, equalGain, TrackerMap::fill(), HcalObjRepresent::Fill(), edm::EventSetup::get(), getGainRatio(), getHistos(), mergeVDriftHistosByStation::histos, i, getDQMSummary::iter, edm::ESHandle< class >::product(), refNoise, tkmap, and relativeConstraints::value.

Referenced by beginRun().

116  {
117  SiStripNoises Noise = _Noise;
118  typedef std::vector<SiStripNoises::ratioData> collection;
119  collection divNoise=Noise/refNoise;
120 
121  edm::LogInfo("") << "[Doanalysis]";
122 
123  //Retrieve tracker topology from geometry
124  edm::ESHandle<TrackerTopology> tTopoHandle;
125  es.get<IdealGeometryRecord>().get(tTopoHandle);
126  const TrackerTopology* const tTopo = tTopoHandle.product();
127 
128  std::vector<TH1F *>histos;
129 
130  collection::const_iterator iter=divNoise.begin();
131  collection::const_iterator iterE=divNoise.end();
132 
133  float value;
134  float gainRatio=1.;
135  //Divide result by d
136  for(;iter!=iterE;++iter){
137  getHistos(iter->detid, tTopo, histos);
138 
139  size_t strip=0, stripE= iter->values.size();
140  size_t apvNb=7;
141 
142  for (;strip<stripE;++strip){
143  if(!equalGain && strip/128!=apvNb){
144  apvNb=strip/128;
145  if(apvNb<6)
146  gainRatio=getGainRatio(iter->detid,apvNb);
147  else
148  edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " apvNb " << apvNb;
149  }
150  //edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " value " << iter->values[strip];
151  value=iter->values[strip]*gainRatio;
152  tkmap->fill(iter->detid,value);
153  for(size_t i=0;i<histos.size();++i)
154  histos[i]->Fill(value);
155  }
156  }
157 }
int i
Definition: DBlmapReader.cc:9
void getHistos(const uint32_t &detid, const TrackerTopology *tTopo, std::vector< TH1F * > &histos)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
float getGainRatio(const uint32_t &detid, const uint16_t &apv)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:2776
void SiStripCorrelateNoise::DoPlots ( )
private

Definition at line 85 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

85  {
86  TCanvas *C=new TCanvas();
87  C->Divide(2,2);
88 
89  char outName[128];
90  sprintf(outName,"Run_%d.png",theRun);
91  for(size_t i=0;i<vTH1.size();i++)
92  if(vTH1[i]!=0){
93  if(i%100==0){
94  C->cd(i/100);
95  vTH1[i]->SetLineColor(i/100);
96  vTH1[i]->Draw();
97  C->cd(i/100)->SetLogy();
98  }
99  vTH1[i]->Write();
100  }
101 
102  C->Print(outName);
103  delete C;
104 
105  vTH1.clear();
106  file->cd("");
107 
108  char dir[128];
109  sprintf(dir,"Run_%d_TkMap.png",theRun);
110  tkmap->save(false,0,5,dir);
111  delete tkmap;
112  tkmap = new TrackerMap();
113 }
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:698
dbl *** dir
Definition: mlp_gen.cc:35
void SiStripCorrelateNoise::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 237 of file SiStripCorrelateNoise.cc.

References file.

237  {
238  file->Write();
239  file->Close();
240 
241 
242 }
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 160 of file SiStripCorrelateNoise.cc.

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

Referenced by DoAnalysis().

160  {
161 
164 
165  if(oldRange.first==oldRange.second ||
166  newRange.first==newRange.second)
167  return 1.;
168 
169  return oldGain->getApvGain(apv,oldRange)/newGain->getApvGain(apv,newRange);
170 
171 }
static float getApvGain(uint16_t apv, const Range &range)
std::pair< ContainerIterator, ContainerIterator > Range
const Range getRange(const uint32_t detID) const
TH1F * SiStripCorrelateNoise::getHisto ( const long unsigned int &  index)
private

Definition at line 213 of file SiStripCorrelateNoise.cc.

References cmsHarvester::index, mergeVDriftHistosByStation::name, AlCaHLTBitMon_QueryRunRegistry::string, theRun, and vTH1.

Referenced by getHistos().

213  {
214  if(vTH1.size()<index+1)
215  vTH1.resize(index+1,0);
216 
217  if(vTH1[index]==0){
218  char name[128];
219  std::string SubD;
220  if(index<200)
221  SubD="TIB";
222  else if(index<300)
223  SubD="TID";
224  else if(index<400)
225  SubD="TOB";
226  else
227  SubD="TEC";
228  sprintf(name,"%d_%lu__%s",theRun,index,SubD.c_str());
229  edm::LogInfo("")<<"[getHisto] creating index " << index << std::endl;
230  vTH1[index]=new TH1F(name,name,200,-0.5,10.5);
231  }
232 
233  return vTH1[index];
234 }
std::vector< TH1F * > vTH1
void SiStripCorrelateNoise::getHistos ( const uint32_t &  detid,
const TrackerTopology tTopo,
std::vector< TH1F * > &  histos 
)
private

Definition at line 184 of file SiStripCorrelateNoise.cc.

References a, getHisto(), cmsHarvester::index, DetId::subdetId(), TrackerTopology::tecSide(), TrackerTopology::tecWheel(), TrackerTopology::tibLayer(), TrackerTopology::tidSide(), TrackerTopology::tidWheel(), and TrackerTopology::tobLayer().

Referenced by DoAnalysis().

184  {
185 
186  histos.clear();
187 
188  int subdet=-999; int component=-999;
190  if ( a.subdetId() == 3 ){
191  subdet=0;
192  component=tTopo->tibLayer(detid);
193  } else if ( a.subdetId() == 4 ) {
194  subdet=1;
195  component=tTopo->tidSide(detid)==2?tTopo->tidWheel(detid):tTopo->tidWheel(detid)+3;
196  } else if ( a.subdetId() == 5 ) {
197  subdet=2;
198  component=tTopo->tobLayer(detid);
199  } else if ( a.subdetId() == 6 ) {
200  subdet=3;
201  component=tTopo->tecSide(detid)==2?tTopo->tecWheel(detid):tTopo->tecWheel(detid)+9;
202  }
203 
204  int index=100+subdet*100+component;
205 
206 
207  histos.push_back(getHisto(100+100*subdet));
208  histos.push_back(getHisto(index));
209 
210 }
TH1F * getHisto(const long unsigned int &index)
unsigned int tibLayer(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tidSide(const DetId &id) const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
double a
Definition: hdecay.h:121
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const
float SiStripCorrelateNoise::getMeanNoise ( const SiStripNoises::Range noiseRange,
const uint32_t &  first,
const uint32_t &  range 
)
private

Definition at line 174 of file SiStripCorrelateNoise.cc.

References timingPdfMaker::mean, and noiseHandle_.

174  {
175 
176  float mean=0;
177  for (size_t istrip=firstStrip;istrip<firstStrip+range;istrip++){
178  mean+=noiseHandle_->getNoise(istrip,noiseRange);
179  }
180  return mean/(1.*range);
181 }
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
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().