CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripPlotGain.cc
Go to the documentation of this file.
2 
4  : gainToken_{esConsumes<edm::Transition::BeginRun>()}, tTopoToken_{esConsumes<edm::Transition::BeginRun>()} {
5  // now do what ever initialization is needed
6  file = new TFile("correlTest.root", "RECREATE");
7  tkmap = new TrackerMap();
8 }
9 
11 
12 //
13 
15  if (gainWatcher_.check(es)) {
16  edm::LogInfo("") << "[SiStripPlotGain::beginRun] cacheID " << es.get<SiStripApvGainRcd>().cacheIdentifier()
17  << std::endl;
19  }
20 }
21 
23  edm::LogInfo("") << "[Doanalysis]";
24 
25  std::vector<TH1F *> histos;
26 
29  iter = p.detid_begin;
30  iterE = p.detid_end;
31 
32  float value;
33 
34  // Divide result by d
35  for (; iter != iterE; ++iter) {
36  getHistos(*iter, tTopo, histos);
38 
39  edm::LogInfo("") << "[Doanalysis] detid " << *iter << " range " << range.second - range.first;
40  size_t apv = 0, apvE = (range.second - range.first);
41  for (; apv < apvE; apv += 2) {
42  value = gain.getApvGain(apv, range);
43  tkmap->fill(*iter, value);
44  for (size_t i = 0; i < histos.size(); ++i)
45  histos[i]->Fill(value);
46  }
47  }
48 }
49 
50 void SiStripPlotGain::getHistos(DetId detid, const TrackerTopology &tTopo, std::vector<TH1F *> &histos) {
51  histos.clear();
52 
53  int subdet = -999;
54  int component = -999;
55  if (detid.subdetId() == 3) {
56  subdet = 0;
57  component = tTopo.tibLayer(detid);
58  } else if (detid.subdetId() == 4) {
59  subdet = 1;
60  component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
61  } else if (detid.subdetId() == 5) {
62  subdet = 2;
63  component = tTopo.tobLayer(detid);
64  } else if (detid.subdetId() == 6) {
65  subdet = 3;
66  component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
67  }
68 
69  int index = 100 + subdet * 100 + component;
70 
71  histos.push_back(getHisto(subdet + 1));
72  histos.push_back(getHisto(index));
73 }
74 
75 TH1F *SiStripPlotGain::getHisto(const long unsigned int &index) {
76  if (vTH1.size() < index + 1)
77  vTH1.resize(index + 1, nullptr);
78 
79  if (vTH1[index] == nullptr) {
80  char name[128];
81  sprintf(name, "%lu", index);
82  edm::LogInfo("") << "[getHisto] creating index " << index << std::endl;
83  vTH1[index] = new TH1F(name, name, 150, 0., 5.);
84  }
85 
86  return vTH1[index];
87 }
88 
90  for (size_t i = 0; i < vTH1.size(); i++)
91  if (vTH1[i] != nullptr)
92  vTH1[i]->Write();
93 
94  file->Write();
95  file->Close();
96 
97  tkmap->save(false, 0, 0, "testTkMap.png");
98 }
ContainerIterator getFirstElement(RegistryConstIterator &idet)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
unsigned int tibLayer(const DetId &id) const
Registry::const_iterator RegistryConstIterator
static float getApvGain(uint16_t apv, const Range &range)
gainToken_(esConsumes())
RegistryConstIterator detid_end
RegistryConstIterator detid_begin
unsigned int tidWheel(const DetId &id) const
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void DoAnalysis(const TrackerTopology &tTopo, const SiStripApvGain &)
unsigned int tidSide(const DetId &id) const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Info, false > LogInfo
Definition: DetId.h:17
ContainerIterator getLastElement(RegistryConstIterator &idet)
TH1F * getHisto(const long unsigned int &index)
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > gainToken_
TrackerMap * tkmap
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void getHistos(DetId detid, const TrackerTopology &tTopo, std::vector< TH1F * > &histos)
T get() const
Definition: EventSetup.h:88
SiStripPlotGain(const edm::ParameterSet &)
std::vector< TH1F * > vTH1
edm::ESWatcher< SiStripApvGainRcd > gainWatcher_
void endJob() override
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
unsigned int tecWheel(const DetId &id) const
RegistryPointers getRegistryPointers() const
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3289
unsigned int tobLayer(const DetId &id) const
Definition: Run.h:45
~SiStripPlotGain() override
unsigned int tecSide(const DetId &id) const