CMS 3D CMS Logo

SiStripPlotGain.cc
Go to the documentation of this file.
2 
6 
7 SiStripPlotGain::SiStripPlotGain(const edm::ParameterSet &iConfig) : cacheID(0xFFFFFFFF) {
8  // now do what ever initialization is needed
9  file = new TFile("correlTest.root", "RECREATE");
10  tkmap = new TrackerMap();
11 }
12 
14 
15 //
16 
18  if (getCache(es) == cacheID)
19  return;
20  cacheID = getCache(es);
21 
22  edm::LogInfo("") << "[SiStripPlotGain::beginRun] cacheID " << cacheID << std::endl;
23 
25  DoAnalysis(es, *Handle_.product());
26 }
27 
29  edm::LogInfo("") << "[Doanalysis]";
30 
31  // Retrieve tracker topology from geometry
33  es.get<TrackerTopologyRcd>().get(tTopoHandle);
34  const TrackerTopology *const tTopo = tTopoHandle.product();
35 
36  std::vector<TH1F *> histos;
37 
38  SiStripApvGain::RegistryPointers p = gain.getRegistryPointers();
40  iter = p.detid_begin;
41  iterE = p.detid_end;
42 
43  float value;
44 
45  // Divide result by d
46  for (; iter != iterE; ++iter) {
47  getHistos(*iter, tTopo, histos);
48  SiStripApvGain::Range range = SiStripApvGain::Range(p.getFirstElement(iter), p.getLastElement(iter));
49 
50  edm::LogInfo("") << "[Doanalysis] detid " << *iter << " range " << range.second - range.first;
51  size_t apv = 0, apvE = (range.second - range.first);
52  for (; apv < apvE; apv += 2) {
53  value = gain.getApvGain(apv, range);
54  tkmap->fill(*iter, value);
55  for (size_t i = 0; i < histos.size(); ++i)
56  histos[i]->Fill(value);
57  }
58  }
59 }
60 
61 void SiStripPlotGain::getHistos(const uint32_t &detid, const TrackerTopology *tTopo, std::vector<TH1F *> &histos) {
62  histos.clear();
63 
64  int subdet = -999;
65  int component = -999;
66  SiStripDetId a(detid);
67  if (a.subdetId() == 3) {
68  subdet = 0;
69  component = tTopo->tibLayer(detid);
70  } else if (a.subdetId() == 4) {
71  subdet = 1;
72  component = tTopo->tidSide(detid) == 2 ? tTopo->tidWheel(detid) : tTopo->tidWheel(detid) + 3;
73  } else if (a.subdetId() == 5) {
74  subdet = 2;
75  component = tTopo->tobLayer(detid);
76  } else if (a.subdetId() == 6) {
77  subdet = 3;
78  component = tTopo->tecSide(detid) == 2 ? tTopo->tecWheel(detid) : tTopo->tecWheel(detid) + 9;
79  }
80 
81  int index = 100 + subdet * 100 + component;
82 
83  histos.push_back(getHisto(subdet + 1));
84  histos.push_back(getHisto(index));
85 }
86 
87 TH1F *SiStripPlotGain::getHisto(const long unsigned int &index) {
88  if (vTH1.size() < index + 1)
89  vTH1.resize(index + 1, nullptr);
90 
91  if (vTH1[index] == nullptr) {
92  char name[128];
93  sprintf(name, "%lu", index);
94  edm::LogInfo("") << "[getHisto] creating index " << index << std::endl;
95  vTH1[index] = new TH1F(name, name, 150, 0., 5.);
96  }
97 
98  return vTH1[index];
99 }
100 
102  for (size_t i = 0; i < vTH1.size(); i++)
103  if (vTH1[i] != nullptr)
104  vTH1[i]->Write();
105 
106  file->Write();
107  file->Close();
108 
109  tkmap->save(false, 0, 0, "testTkMap.png");
110 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
SiStripApvGain::RegistryPointers
Definition: SiStripApvGain.h:34
SiStripPlotGain::getHistos
void getHistos(const uint32_t &detid, const TrackerTopology *tTopo, std::vector< TH1F * > &histos)
Definition: SiStripPlotGain.cc:61
edm::Run
Definition: Run.h:45
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripDetId.h
TrackerMap::fill
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3288
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripPlotGain::endJob
void endJob() override
Definition: SiStripPlotGain.cc:101
SiStripApvGain::RegistryConstIterator
Registry::const_iterator RegistryConstIterator
Definition: SiStripApvGain.h:31
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
TrackerTopology.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
edm::ESHandle< TrackerTopology >
SiStripPlotGain.h
SiStripPlotGain::~SiStripPlotGain
~SiStripPlotGain() override
Definition: SiStripPlotGain.cc:13
TrackerMap
Definition: TrackerMap.h:76
SiStripPlotGain::tkmap
TrackerMap * tkmap
Definition: SiStripPlotGain.h:75
SiStripPlotGain::Handle_
edm::ESHandle< SiStripApvGain > Handle_
Definition: SiStripPlotGain.h:70
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
SiStripPlotGain::getCache
unsigned long long getCache(const edm::EventSetup &eSetup)
Definition: SiStripPlotGain.h:62
SiStripPlotGain::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: SiStripPlotGain.cc:17
TrackerTopology::tidSide
unsigned int tidSide(const DetId &id) const
Definition: TrackerTopology.h:190
SiStripPlotGain::getHisto
TH1F * getHisto(const long unsigned int &index)
Definition: SiStripPlotGain.cc:87
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:57
SiStripPlotGain::DoAnalysis
void DoAnalysis(const edm::EventSetup &es, const SiStripApvGain &)
Definition: SiStripPlotGain.cc:28
get
#define get
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
SiStripApvGainRcd
Definition: SiStripCondDataRecords.h:8
combine.histos
histos
Definition: combine.py:4
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
TrackerMap::save
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:810
SiStripPlotGain::file
TFile * file
Definition: SiStripPlotGain.h:72
TrackerTopology::tobLayer
unsigned int tobLayer(const DetId &id) const
Definition: TrackerTopology.h:147
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiStripPlotGain::cacheID
unsigned long long cacheID
Definition: SiStripPlotGain.h:77
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SiStripPlotGain::SiStripPlotGain
SiStripPlotGain(const edm::ParameterSet &)
Definition: SiStripPlotGain.cc:7
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
SiStripPlotGain::vTH1
std::vector< TH1F * > vTH1
Definition: SiStripPlotGain.h:73
SiStripApvGain
Definition: SiStripApvGain.h:25
TrackerTopology::tecWheel
unsigned int tecWheel(const DetId &id) const
Definition: TrackerTopology.h:198
TrackerTopology::tibLayer
unsigned int tibLayer(const DetId &id) const
Definition: TrackerTopology.h:150
TrackerTopology::tecSide
unsigned int tecSide(const DetId &id) const
Definition: TrackerTopology.h:184