CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripCorrelateNoise Class Reference

#include <SiStripCorrelateNoise.h>

Inheritance diagram for SiStripCorrelateNoise:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  Data
 

Public Member Functions

 SiStripCorrelateNoise (const edm::ParameterSet &)
 
 ~SiStripCorrelateNoise () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
void checkGainCache (const edm::EventSetup &es)
 
void DoAnalysis (const edm::EventSetup &, const SiStripNoises &, SiStripNoises &)
 
void DoPlots ()
 
void endJob () override
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

DQM/SiStripMonitorSummary/plugins/SiStripCorrelateNoise.cc

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

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

Definition at line 49 of file SiStripCorrelateNoise.h.

Constructor & Destructor Documentation

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

Definition at line 8 of file SiStripCorrelateNoise.cc.

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

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

Definition at line 27 of file SiStripCorrelateNoise.cc.

27 {}

Member Function Documentation

void SiStripCorrelateNoise::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineoverrideprivate

Definition at line 56 of file SiStripCorrelateNoise.h.

References DoAnalysis(), DoPlots(), endJob(), getHisto(), getHistos(), and plotFactory::histos.

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

Definition at line 31 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.

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

Definition at line 62 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun(), and getGainCache().

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

Definition at line 109 of file SiStripCorrelateNoise.cc.

References universalConfigTemplate::collection, equalGain, TrackerMap::fill(), HcalObjRepresent::Fill(), edm::EventSetup::get(), getGainRatio(), getHistos(), plotFactory::histos, mps_fire::i, SiStripSimParameters_cfi::Noise, edm::ESHandle< T >::product(), refNoise, digitizers_cfi::strip, tkmap, and relativeConstraints::value.

Referenced by analyze(), and beginRun().

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

Definition at line 79 of file SiStripCorrelateNoise.cc.

References patCaloMETCorrections_cff::C, dir, file, mps_fire::i, dataset::outName, TrackerMap::save(), theRun, tkmap, and vTH1.

Referenced by analyze(), and beginRun().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 226 of file SiStripCorrelateNoise.cc.

References file.

Referenced by analyze().

226  {
227  file->Write();
228  file->Close();
229 }
unsigned long long SiStripCorrelateNoise::getGainCache ( const edm::EventSetup eSetup)
inlineprivate

Definition at line 67 of file SiStripCorrelateNoise.h.

References checkGainCache(), plotBeamSpotDB::first, edm::EventSetup::get(), getGainRatio(), and getMeanNoise().

Referenced by checkGainCache().

67  {
68  return eSetup.get<SiStripApvGainRcd>().cacheIdentifier();
69  }
T get() const
Definition: EventSetup.h:71
float SiStripCorrelateNoise::getGainRatio ( const uint32_t &  detid,
const uint16_t &  apv 
)
private

Definition at line 155 of file SiStripCorrelateNoise.cc.

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

Referenced by DoAnalysis(), and getGainCache().

155  {
156  SiStripApvGain::Range oldRange = oldGain->getRange(detid);
157  SiStripApvGain::Range newRange = newGain->getRange(detid);
158 
159  if (oldRange.first == oldRange.second || newRange.first == newRange.second)
160  return 1.;
161 
162  return oldGain->getApvGain(apv, oldRange) / newGain->getApvGain(apv, newRange);
163 }
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 203 of file SiStripCorrelateNoise.cc.

References dataset::name, AlCaHLTBitMon_QueryRunRegistry::string, theRun, and vTH1.

Referenced by analyze(), and getHistos().

203  {
204  if (vTH1.size() < index + 1)
205  vTH1.resize(index + 1, nullptr);
206 
207  if (vTH1[index] == nullptr) {
208  char name[128];
209  std::string SubD;
210  if (index < 200)
211  SubD = "TIB";
212  else if (index < 300)
213  SubD = "TID";
214  else if (index < 400)
215  SubD = "TOB";
216  else
217  SubD = "TEC";
218  sprintf(name, "%d_%lu__%s", theRun, index, SubD.c_str());
219  edm::LogInfo("") << "[getHisto] creating index " << index << std::endl;
220  vTH1[index] = new TH1F(name, name, 200, -0.5, 10.5);
221  }
222 
223  return vTH1[index];
224 }
std::vector< TH1F * > vTH1
void SiStripCorrelateNoise::getHistos ( const uint32_t &  detid,
const TrackerTopology tTopo,
std::vector< TH1F * > &  histos 
)
private

Definition at line 175 of file SiStripCorrelateNoise.cc.

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

Referenced by analyze(), and DoAnalysis().

177  {
178  histos.clear();
179 
180  int subdet = -999;
181  int component = -999;
182  SiStripDetId a(detid);
183  if (a.subdetId() == 3) {
184  subdet = 0;
185  component = tTopo->tibLayer(detid);
186  } else if (a.subdetId() == 4) {
187  subdet = 1;
188  component = tTopo->tidSide(detid) == 2 ? tTopo->tidWheel(detid) : tTopo->tidWheel(detid) + 3;
189  } else if (a.subdetId() == 5) {
190  subdet = 2;
191  component = tTopo->tobLayer(detid);
192  } else if (a.subdetId() == 6) {
193  subdet = 3;
194  component = tTopo->tecSide(detid) == 2 ? tTopo->tecWheel(detid) : tTopo->tecWheel(detid) + 9;
195  }
196 
197  int index = 100 + subdet * 100 + component;
198 
199  histos.push_back(getHisto(100 + 100 * subdet));
200  histos.push_back(getHisto(index));
201 }
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 165 of file SiStripCorrelateNoise.cc.

References SiStripNoises::getNoise(), SiStripPI::mean, and noiseHandle_.

Referenced by getGainCache().

167  {
168  float mean = 0;
169  for (size_t istrip = firstStrip; istrip < firstStrip + range; istrip++) {
170  mean += noiseHandle_->getNoise(istrip, noiseRange);
171  }
172  return mean / (1. * range);
173 }
static float getNoise(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:74
edm::ESHandle< SiStripNoises > noiseHandle_
unsigned long long SiStripCorrelateNoise::getNoiseCache ( const edm::EventSetup eSetup)
inlineprivate

Definition at line 64 of file SiStripCorrelateNoise.h.

References edm::EventSetup::get().

Referenced by beginRun().

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

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 90 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and DoAnalysis().

TFile* SiStripCorrelateNoise::file
private
SiStripDetInfoFileReader* SiStripCorrelateNoise::fr
private

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by SiStripCorrelateNoise().

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

Definition at line 83 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

SiStripApvGain * SiStripCorrelateNoise::newGain
private

Definition at line 89 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

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

Definition at line 84 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and getMeanNoise().

SiStripApvGain* SiStripCorrelateNoise::oldGain
private

Definition at line 89 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

SiStripNoises* SiStripCorrelateNoise::refNoise
private

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and DoAnalysis().

uint32_t SiStripCorrelateNoise::theRun
private

Definition at line 86 of file SiStripCorrelateNoise.h.

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

TrackerMap* SiStripCorrelateNoise::tkmap
private

Definition at line 95 of file SiStripCorrelateNoise.h.

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

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

Definition at line 93 of file SiStripCorrelateNoise.h.

Referenced by DoPlots(), and getHisto().