CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::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
 
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,
SiStripApvGainRcd
gainToken_
 
edm::ESWatcher< SiStripApvGainRcdgainWatcher_
 
std::unique_ptr< SiStripApvGainnewGain
 
edm::ESGetToken< SiStripNoises,
SiStripNoisesRcd
noiseToken_
 
edm::ESWatcher< SiStripNoisesRcdnoiseWatcher_
 
std::unique_ptr< SiStripApvGainoldGain
 
std::unique_ptr< SiStripNoisesrefNoise
 
uint32_t theRun
 
TrackerMaptkmap
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (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 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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 48 of file SiStripCorrelateNoise.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file SiStripCorrelateNoise.cc.

References file, gainToken_, newGain, oldGain, refNoise, tkmap, and tTopoToken_.

10  : noiseToken_{esConsumes<edm::Transition::BeginRun>()},
11  gainToken_{esConsumes<edm::Transition::BeginRun>()},
12  tTopoToken_{esConsumes<edm::Transition::BeginRun>()},
13  refNoise(nullptr),
14  oldGain(nullptr),
15  newGain(nullptr) {
16  // now do what ever initialization is needed
17  file = new TFile("correlTest.root", "RECREATE");
18 
19  file->cd();
20  tkmap = new TrackerMap();
21 }
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 ( )
override

Definition at line 23 of file SiStripCorrelateNoise.cc.

23 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 55 of file SiStripCorrelateNoise.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 27 of file SiStripCorrelateNoise.cc.

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

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

Definition at line 47 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

47  {
48  equalGain = true;
49  if (gainWatcher_.check(es)) {
50  if (oldGain) {
51  equalGain = false;
52  }
54  newGain = std::make_unique<SiStripApvGain>(es.getData(gainToken_));
55  }
56 }
edm::ESWatcher< SiStripApvGainRcd > gainWatcher_
std::unique_ptr< SiStripApvGain > oldGain
bool getData(T &iHolder) const
Definition: EventSetup.h:128
std::unique_ptr< SiStripApvGain > newGain
def move
Definition: eostools.py:511
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > gainToken_
void SiStripCorrelateNoise::DoAnalysis ( const edm::EventSetup es,
const SiStripNoises _Noise,
SiStripNoises refNoise 
)
private

Definition at line 88 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

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

Definition at line 58 of file SiStripCorrelateNoise.cc.

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

Referenced by beginRun().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 192 of file SiStripCorrelateNoise.cc.

References file.

192  {
193  file->Write();
194  file->Close();
195 }
float SiStripCorrelateNoise::getGainRatio ( const uint32_t &  detid,
const uint16_t &  apv 
)
private

Definition at line 131 of file SiStripCorrelateNoise.cc.

References newGain, and oldGain.

Referenced by DoAnalysis().

131  {
132  SiStripApvGain::Range oldRange = oldGain->getRange(detid);
133  SiStripApvGain::Range newRange = newGain->getRange(detid);
134 
135  if (oldRange.first == oldRange.second || newRange.first == newRange.second)
136  return 1.;
137 
138  return oldGain->getApvGain(apv, oldRange) / newGain->getApvGain(apv, newRange);
139 }
std::unique_ptr< SiStripApvGain > oldGain
std::unique_ptr< SiStripApvGain > newGain
std::pair< ContainerIterator, ContainerIterator > Range
TH1F * SiStripCorrelateNoise::getHisto ( const long unsigned int &  index)
private

Definition at line 169 of file SiStripCorrelateNoise.cc.

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

Referenced by getHistos().

169  {
170  if (vTH1.size() < index + 1)
171  vTH1.resize(index + 1, nullptr);
172 
173  if (vTH1[index] == nullptr) {
174  char name[128];
175  std::string SubD;
176  if (index < 200)
177  SubD = "TIB";
178  else if (index < 300)
179  SubD = "TID";
180  else if (index < 400)
181  SubD = "TOB";
182  else
183  SubD = "TEC";
184  sprintf(name, "%d_%lu__%s", theRun, index, SubD.c_str());
185  edm::LogInfo("") << "[getHisto] creating index " << index << std::endl;
186  vTH1[index] = new TH1F(name, name, 200, -0.5, 10.5);
187  }
188 
189  return vTH1[index];
190 }
Log< level::Info, false > LogInfo
std::vector< TH1F * > vTH1
void SiStripCorrelateNoise::getHistos ( const uint32_t &  detid,
const TrackerTopology tTopo,
std::vector< TH1F * > &  histos 
)
private

Definition at line 141 of file SiStripCorrelateNoise.cc.

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

Referenced by DoAnalysis().

143  {
144  histos.clear();
145 
146  int subdet = -999;
147  int component = -999;
148  SiStripDetId a(detid);
149  if (a.subdetId() == 3) {
150  subdet = 0;
151  component = tTopo->tibLayer(detid);
152  } else if (a.subdetId() == 4) {
153  subdet = 1;
154  component = tTopo->tidSide(detid) == 2 ? tTopo->tidWheel(detid) : tTopo->tidWheel(detid) + 3;
155  } else if (a.subdetId() == 5) {
156  subdet = 2;
157  component = tTopo->tobLayer(detid);
158  } else if (a.subdetId() == 6) {
159  subdet = 3;
160  component = tTopo->tecSide(detid) == 2 ? tTopo->tecWheel(detid) : tTopo->tecWheel(detid) + 9;
161  }
162 
163  int index = 100 + subdet * 100 + component;
164 
165  histos.push_back(getHisto(100 + 100 * subdet));
166  histos.push_back(getHisto(index));
167 }
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:18
double a
Definition: hdecay.h:119
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const

Member Data Documentation

bool SiStripCorrelateNoise::equalGain
private

Definition at line 83 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and DoAnalysis().

TFile* SiStripCorrelateNoise::file
private
edm::ESGetToken<SiStripApvGain, SiStripApvGainRcd> SiStripCorrelateNoise::gainToken_
private

Definition at line 77 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), and SiStripCorrelateNoise().

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

Definition at line 75 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache().

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

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), getGainRatio(), and SiStripCorrelateNoise().

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

Definition at line 76 of file SiStripCorrelateNoise.h.

Referenced by beginRun().

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

Definition at line 74 of file SiStripCorrelateNoise.h.

Referenced by beginRun().

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

Definition at line 82 of file SiStripCorrelateNoise.h.

Referenced by checkGainCache(), getGainRatio(), and SiStripCorrelateNoise().

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

Definition at line 81 of file SiStripCorrelateNoise.h.

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

uint32_t SiStripCorrelateNoise::theRun
private

Definition at line 80 of file SiStripCorrelateNoise.h.

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

TrackerMap* SiStripCorrelateNoise::tkmap
private

Definition at line 88 of file SiStripCorrelateNoise.h.

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

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

Definition at line 78 of file SiStripCorrelateNoise.h.

Referenced by DoAnalysis(), and SiStripCorrelateNoise().

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

Definition at line 86 of file SiStripCorrelateNoise.h.

Referenced by DoPlots(), and getHisto().