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::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  Data
 

Public Member Functions

 SiStripCorrelateNoise (const edm::ParameterSet &)
 
 ~SiStripCorrelateNoise () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
 
void endRun (const edm::Run &run, const edm::EventSetup &es) override
 
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)
 

Private Attributes

bool equalGain
 
TFile * file
 
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcdgainToken_
 
edm::ESWatcher< SiStripApvGainRcdgainWatcher_
 
std::unique_ptr< SiStripApvGainnewGain
 
edm::ESGetToken< SiStripNoises, SiStripNoisesRcdnoiseToken_
 
edm::ESWatcher< SiStripNoisesRcdnoiseWatcher_
 
std::unique_ptr< SiStripApvGainoldGain
 
std::unique_ptr< SiStripNoisesrefNoise
 
uint32_t theRun
 
TrackerMaptkmap
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken_
 
std::vector< TH1F * > vTH1
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

DQM/SiStripMonitorSummary/plugins/SiStripCorrelateNoise.cc

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

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

Definition at line 46 of file SiStripCorrelateNoise.h.

Constructor & Destructor Documentation

◆ SiStripCorrelateNoise()

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

Definition at line 8 of file SiStripCorrelateNoise.cc.

9  : noiseToken_{esConsumes<edm::Transition::BeginRun>()},
10  gainToken_{esConsumes<edm::Transition::BeginRun>()},
11  tTopoToken_{esConsumes<edm::Transition::BeginRun>()},
12  refNoise(nullptr),
13  oldGain(nullptr),
14  newGain(nullptr) {
15  // now do what ever initialization is needed
16  file = new TFile("correlTest.root", "RECREATE");
17 
18  file->cd();
19  tkmap = new TrackerMap();
20 }
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
std::unique_ptr< SiStripApvGain > oldGain
std::unique_ptr< SiStripApvGain > newGain
std::unique_ptr< SiStripNoises > refNoise
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > gainToken_

◆ ~SiStripCorrelateNoise()

SiStripCorrelateNoise::~SiStripCorrelateNoise ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 53 of file SiStripCorrelateNoise.h.

53 {};

◆ beginRun()

void SiStripCorrelateNoise::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
overrideprivate

Definition at line 22 of file SiStripCorrelateNoise.cc.

References edm::ESWatcher< T >::check(), checkGainCache(), DeadROC_duringRun::dir, DoAnalysis(), DoPlots(), file, edm::EventSetup::getData(), eostools::move(), noiseToken_, noiseWatcher_, refNoise, writedatasetfile::run, and theRun.

22  {
23  if (noiseWatcher_.check(es)) {
24  auto aNoise = std::make_unique<SiStripNoises>(es.getData(noiseToken_));
25  // Check if gain is the same from one noise iov to the other, otherwise cache
26  // the new gain (and the old one) to rescale
27  checkGainCache(es);
28  if (refNoise) {
29  char dir[128];
30  theRun = run.run();
31  sprintf(dir, "Run_%d", theRun);
32  file->cd("");
33  file->mkdir(dir);
34  file->cd(dir);
35  DoAnalysis(es, *aNoise, *refNoise);
36  DoPlots();
37  }
38  refNoise = std::move(aNoise);
39  }
40 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void DoAnalysis(const edm::EventSetup &, const SiStripNoises &, SiStripNoises &)
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
edm::ESWatcher< SiStripNoisesRcd > noiseWatcher_
std::unique_ptr< SiStripNoises > refNoise
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void checkGainCache(const edm::EventSetup &es)
def move(src, dest)
Definition: eostools.py:511

◆ checkGainCache()

void SiStripCorrelateNoise::checkGainCache ( const edm::EventSetup es)
private

Definition at line 42 of file SiStripCorrelateNoise.cc.

References edm::ESWatcher< T >::check(), equalGain, gainToken_, gainWatcher_, edm::EventSetup::getData(), eostools::move(), newGain, and oldGain.

Referenced by beginRun().

42  {
43  equalGain = true;
44  if (gainWatcher_.check(es)) {
45  if (oldGain) {
46  equalGain = false;
47  }
49  newGain = std::make_unique<SiStripApvGain>(es.getData(gainToken_));
50  }
51 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESWatcher< SiStripApvGainRcd > gainWatcher_
std::unique_ptr< SiStripApvGain > oldGain
std::unique_ptr< SiStripApvGain > newGain
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > gainToken_
def move(src, dest)
Definition: eostools.py:511

◆ DoAnalysis()

void SiStripCorrelateNoise::DoAnalysis ( const edm::EventSetup es,
const SiStripNoises _Noise,
SiStripNoises refNoise 
)
private

Definition at line 83 of file SiStripCorrelateNoise.cc.

References universalConfigTemplate::collection, equalGain, TrackerMap::fill(), HcalObjRepresent::Fill(), edm::EventSetup::getData(), getGainRatio(), getHistos(), combine::histos, mps_fire::i, SiStripCondTypes::Noise, refNoise, nano_mu_digi_cff::strip, tkmap, tTopoToken_, and relativeConstraints::value.

Referenced by beginRun().

85  {
86  SiStripNoises Noise = _Noise;
87  typedef std::vector<SiStripNoises::ratioData> collection;
88  collection divNoise = Noise / refNoise;
89 
90  edm::LogInfo("") << "[Doanalysis]";
91 
92  const auto tTopo = &es.getData(tTopoToken_);
93 
94  std::vector<TH1F *> histos;
95 
96  collection::const_iterator iter = divNoise.begin();
97  collection::const_iterator iterE = divNoise.end();
98 
99  float value;
100  float gainRatio = 1.;
101  // Divide result by d
102  for (; iter != iterE; ++iter) {
103  getHistos(iter->detid, tTopo, histos);
104 
105  size_t strip = 0, stripE = iter->values.size();
106  size_t apvNb = 7;
107 
108  for (; strip < stripE; ++strip) {
109  if (!equalGain && strip / 128 != apvNb) {
110  apvNb = strip / 128;
111  if (apvNb < 6)
112  gainRatio = getGainRatio(iter->detid, apvNb);
113  else
114  edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip " << strip << " apvNb " << apvNb;
115  }
116  // edm::LogInfo("") << "[Doanalysis] detid " << iter->detid << " strip "
117  // << strip << " value " << iter->values[strip];
118  value = iter->values[strip] * gainRatio;
119  tkmap->fill(iter->detid, value);
120  for (size_t i = 0; i < histos.size(); ++i)
121  histos[i]->Fill(value);
122  }
123  }
124 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::unique_ptr< SiStripNoises > refNoise
Definition: value.py:1
float getGainRatio(const uint32_t &detid, const uint16_t &apv)
Log< level::Info, false > LogInfo
histos
Definition: combine.py:4
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3442
void getHistos(const uint32_t &detid, const TrackerTopology *tTopo, std::vector< TH1F *> &histos)

◆ DoPlots()

void SiStripCorrelateNoise::DoPlots ( )
private

Definition at line 53 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

53  {
54  TCanvas *C = new TCanvas();
55  C->Divide(2, 2);
56 
57  char outName[128];
58  sprintf(outName, "Run_%d.png", theRun);
59  for (size_t i = 0; i < vTH1.size(); i++)
60  if (vTH1[i] != nullptr) {
61  if (i % 100 == 0) {
62  C->cd(i / 100);
63  vTH1[i]->SetLineColor(i / 100);
64  vTH1[i]->Draw();
65  C->cd(i / 100)->SetLogy();
66  }
67  vTH1[i]->Write();
68  }
69 
70  C->Print(outName);
71  delete C;
72 
73  vTH1.clear();
74  file->cd("");
75 
76  char dir[128];
77  sprintf(dir, "Run_%d_TkMap.png", theRun);
78  tkmap->save(false, 0, 5, dir);
79  delete tkmap;
80  tkmap = new TrackerMap();
81 }
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:844
std::vector< TH1F * > vTH1

◆ endJob()

void SiStripCorrelateNoise::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 187 of file SiStripCorrelateNoise.cc.

References file.

187  {
188  file->Write();
189  file->Close();
190 }

◆ endRun()

void SiStripCorrelateNoise::endRun ( const edm::Run run,
const edm::EventSetup es 
)
inlineoverrideprivate

Definition at line 54 of file SiStripCorrelateNoise.h.

54 {};

◆ getGainRatio()

float SiStripCorrelateNoise::getGainRatio ( const uint32_t &  detid,
const uint16_t &  apv 
)
private

Definition at line 126 of file SiStripCorrelateNoise.cc.

References newGain, and oldGain.

Referenced by DoAnalysis().

126  {
127  SiStripApvGain::Range oldRange = oldGain->getRange(detid);
128  SiStripApvGain::Range newRange = newGain->getRange(detid);
129 
130  if (oldRange.first == oldRange.second || newRange.first == newRange.second)
131  return 1.;
132 
133  return oldGain->getApvGain(apv, oldRange) / newGain->getApvGain(apv, newRange);
134 }
std::unique_ptr< SiStripApvGain > oldGain
std::unique_ptr< SiStripApvGain > newGain
std::pair< ContainerIterator, ContainerIterator > Range

◆ getHisto()

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

Definition at line 164 of file SiStripCorrelateNoise.cc.

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

Referenced by getHistos().

164  {
165  if (vTH1.size() < index + 1)
166  vTH1.resize(index + 1, nullptr);
167 
168  if (vTH1[index] == nullptr) {
169  char name[128];
170  std::string SubD;
171  if (index < 200)
172  SubD = "TIB";
173  else if (index < 300)
174  SubD = "TID";
175  else if (index < 400)
176  SubD = "TOB";
177  else
178  SubD = "TEC";
179  sprintf(name, "%d_%lu__%s", theRun, index, SubD.c_str());
180  edm::LogInfo("") << "[getHisto] creating index " << index << std::endl;
181  vTH1[index] = new TH1F(name, name, 200, -0.5, 10.5);
182  }
183 
184  return vTH1[index];
185 }
Log< level::Info, false > LogInfo
std::vector< TH1F * > vTH1

◆ getHistos()

void SiStripCorrelateNoise::getHistos ( const uint32_t &  detid,
const TrackerTopology tTopo,
std::vector< TH1F *> &  histos 
)
private

Definition at line 136 of file SiStripCorrelateNoise.cc.

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

Referenced by DoAnalysis().

138  {
139  histos.clear();
140 
141  int subdet = -999;
142  int component = -999;
143  SiStripDetId a(detid);
144  if (a.subdetId() == 3) {
145  subdet = 0;
146  component = tTopo->tibLayer(detid);
147  } else if (a.subdetId() == 4) {
148  subdet = 1;
149  component = tTopo->tidSide(detid) == 2 ? tTopo->tidWheel(detid) : tTopo->tidWheel(detid) + 3;
150  } else if (a.subdetId() == 5) {
151  subdet = 2;
152  component = tTopo->tobLayer(detid);
153  } else if (a.subdetId() == 6) {
154  subdet = 3;
155  component = tTopo->tecSide(detid) == 2 ? tTopo->tecWheel(detid) : tTopo->tecWheel(detid) + 9;
156  }
157 
158  int index = 100 + subdet * 100 + component;
159 
160  histos.push_back(getHisto(100 + 100 * subdet));
161  histos.push_back(getHisto(index));
162 }
TH1F * getHisto(const long unsigned int &index)
unsigned int tobLayer(const DetId &id) const
unsigned int tidSide(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tecSide(const DetId &id) const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
histos
Definition: combine.py:4
double a
Definition: hdecay.h:121
unsigned int tibLayer(const DetId &id) const

Member Data Documentation

◆ equalGain

bool SiStripCorrelateNoise::equalGain
private

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and DoAnalysis().

◆ file

TFile* SiStripCorrelateNoise::file
private

◆ gainToken_

edm::ESGetToken<SiStripApvGain, SiStripApvGainRcd> SiStripCorrelateNoise::gainToken_
private

Definition at line 76 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

◆ gainWatcher_

edm::ESWatcher<SiStripApvGainRcd> SiStripCorrelateNoise::gainWatcher_
private

Definition at line 74 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

◆ newGain

std::unique_ptr<SiStripApvGain> SiStripCorrelateNoise::newGain
private

Definition at line 81 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

◆ noiseToken_

edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> SiStripCorrelateNoise::noiseToken_
private

Definition at line 75 of file SiStripCorrelateNoise.h.

Referenced by beginRun().

◆ noiseWatcher_

edm::ESWatcher<SiStripNoisesRcd> SiStripCorrelateNoise::noiseWatcher_
private

Definition at line 73 of file SiStripCorrelateNoise.h.

Referenced by beginRun().

◆ oldGain

std::unique_ptr<SiStripApvGain> SiStripCorrelateNoise::oldGain
private

Definition at line 81 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and getGainRatio().

◆ refNoise

std::unique_ptr<SiStripNoises> SiStripCorrelateNoise::refNoise
private

Definition at line 80 of file SiStripCorrelateNoise.h.

Referenced by beginRun(), and DoAnalysis().

◆ theRun

uint32_t SiStripCorrelateNoise::theRun
private

Definition at line 79 of file SiStripCorrelateNoise.h.

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

◆ tkmap

TrackerMap* SiStripCorrelateNoise::tkmap
private

Definition at line 87 of file SiStripCorrelateNoise.h.

Referenced by DoAnalysis(), and DoPlots().

◆ tTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripCorrelateNoise::tTopoToken_
private

Definition at line 77 of file SiStripCorrelateNoise.h.

Referenced by DoAnalysis().

◆ vTH1

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

Definition at line 85 of file SiStripCorrelateNoise.h.

Referenced by DoPlots(), and getHisto().