CMS 3D CMS Logo

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 
27  SiStripApvGain::RegistryPointers p = gain.getRegistryPointers();
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);
37  SiStripApvGain::Range range = SiStripApvGain::Range(p.getFirstElement(iter), p.getLastElement(iter));
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 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiStripPlotGain::gainToken_
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > gainToken_
Definition: SiStripPlotGain.h:69
mps_fire.i
i
Definition: mps_fire.py:428
SiStripApvGain::RegistryPointers
Definition: SiStripApvGain.h:34
SiStripPlotGain::DoAnalysis
void DoAnalysis(const TrackerTopology &tTopo, const SiStripApvGain &)
Definition: SiStripPlotGain.cc:22
edm::Run
Definition: Run.h:45
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripPlotGain.h:70
SiStripPlotGain::endJob
void endJob() override
Definition: SiStripPlotGain.cc:89
SiStripApvGain::RegistryConstIterator
Registry::const_iterator RegistryConstIterator
Definition: SiStripApvGain.h:31
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
SiStripPlotGain.h
SiStripPlotGain::~SiStripPlotGain
~SiStripPlotGain() override
Definition: SiStripPlotGain.cc:10
TrackerMap
Definition: TrackerMap.h:76
SiStripPlotGain::tkmap
TrackerMap * tkmap
Definition: SiStripPlotGain.h:75
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPlotGain::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: SiStripPlotGain.cc:14
TrackerTopology::tidSide
unsigned int tidSide(const DetId &id) const
Definition: TrackerTopology.h:190
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
SiStripPlotGain::getHisto
TH1F * getHisto(const long unsigned int &index)
Definition: SiStripPlotGain.cc:75
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:58
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiStripApvGainRcd
Definition: SiStripCondDataRecords.h:8
combine.histos
histos
Definition: combine.py:4
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
SiStripPlotGain::gainWatcher_
edm::ESWatcher< SiStripApvGainRcd > gainWatcher_
Definition: SiStripPlotGain.h:68
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
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:3
SiStripPlotGain::getHistos
void getHistos(DetId detid, const TrackerTopology &tTopo, std::vector< TH1F * > &histos)
Definition: SiStripPlotGain.cc:50
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