1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
#include <memory>
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/CaloTopologyRecord.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
#include <TCanvas.h>
#include <TVirtualPad.h>
#include <TStyle.h>
#include <TROOT.h>
#include <TH2F.h>
#include <TBox.h>
#include <iostream>
class TestEcalGetWindow : public edm::one::EDAnalyzer<> {
public:
explicit TestEcalGetWindow(const edm::ParameterSet&);
~TestEcalGetWindow() override;
void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}
private:
void build(const CaloGeometry& cg, const CaloTopology& etmap, DetId::Detector det, int subdetn, const char* name);
int towerColor(const EcalTrigTowerDetId& theTower);
edm::ESGetToken<CaloTopology, CaloTopologyRecord> topologyToken_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometryToken_;
int pass_;
};
TestEcalGetWindow::TestEcalGetWindow(const edm::ParameterSet& /*iConfig*/)
: topologyToken_{esConsumes<CaloTopology, CaloTopologyRecord>(edm::ESInputTag{})},
geometryToken_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})} {
//now do what ever initialization is needed
pass_ = 0;
// some setup for root
gROOT->SetStyle("Plain"); // white fill colors etc.
gStyle->SetPaperSize(TStyle::kA4);
}
TestEcalGetWindow::~TestEcalGetWindow() {}
void TestEcalGetWindow::build(
const CaloGeometry& /*cg*/, const CaloTopology& ct, DetId::Detector det, int subdetn, const char* name) {
if (det == DetId::Ecal && subdetn == EcalEndcap) {
TCanvas* canv = new TCanvas("c", "", 1000, 1000);
canv->SetLeftMargin(0.15);
canv->SetBottomMargin(0.15);
gStyle->SetOptStat(0);
TH2F* h = new TH2F("", "", 10, 0.5, 100.5, 10, 0.5, 100.5);
h->Draw();
//gPad->SetGridx();
//gPad->SetGridy();
gPad->Update();
h->SetXTitle("x index");
h->SetYTitle("y index");
h->GetXaxis()->SetTickLength(-0.03);
h->GetYaxis()->SetTickLength(-0.03);
h->GetXaxis()->SetLabelOffset(0.03);
h->GetYaxis()->SetLabelOffset(0.03);
h->GetXaxis()->SetLabelSize(0.04);
h->GetYaxis()->SetLabelSize(0.04);
// axis titles
h->GetXaxis()->SetTitleSize(0.04);
h->GetYaxis()->SetTitleSize(0.04);
h->GetXaxis()->SetTitleOffset(1.8);
h->GetYaxis()->SetTitleOffset(1.9);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
const CaloSubdetectorTopology* topology = ct.getSubdetectorTopology(det, subdetn);
std::vector<DetId> eeDetIds;
eeDetIds.emplace_back(EEDetId(1, 50, 1, EEDetId::XYMODE));
eeDetIds.emplace_back(EEDetId(25, 50, 1, EEDetId::XYMODE));
eeDetIds.emplace_back(EEDetId(50, 1, 1, EEDetId::XYMODE));
eeDetIds.emplace_back(EEDetId(50, 25, 1, EEDetId::XYMODE));
eeDetIds.emplace_back(EEDetId(3, 60, 1, EEDetId::XYMODE));
for (const auto& eeDetId : eeDetIds) {
EEDetId myId(eeDetId);
if (myId.zside() == -1)
continue;
std::vector<DetId> myNeighbours = topology->getWindow(myId, 13, 13);
for (const auto& myNeighbour : myNeighbours) {
EEDetId myEEId(myNeighbour);
TBox* box = new TBox(myEEId.ix() - 0.5, myEEId.iy() - 0.5, myEEId.ix() + 0.5, myEEId.iy() + 0.5);
box->SetFillColor(1);
box->Draw();
}
}
gPad->SaveAs(name);
delete canv;
delete h;
}
if (det == DetId::Ecal && subdetn == EcalBarrel) {
TCanvas* canv = new TCanvas("c", "", 1000, 1000);
canv->SetLeftMargin(0.15);
canv->SetBottomMargin(0.15);
gStyle->SetOptStat(0);
TH2F* h = new TH2F("", "", 10, -85.5, 85.5, 10, 0.5, 360.5);
h->Draw();
//gPad->SetGridx();
//gPad->SetGridy();
gPad->Update();
h->SetXTitle("eta index");
h->SetYTitle("phi index");
h->GetXaxis()->SetTickLength(-0.03);
h->GetYaxis()->SetTickLength(-0.03);
h->GetXaxis()->SetLabelOffset(0.03);
h->GetYaxis()->SetLabelOffset(0.03);
h->GetXaxis()->SetLabelSize(0.04);
h->GetYaxis()->SetLabelSize(0.04);
// axis titles
h->GetXaxis()->SetTitleSize(0.04);
h->GetYaxis()->SetTitleSize(0.04);
h->GetXaxis()->SetTitleOffset(1.8);
h->GetYaxis()->SetTitleOffset(1.9);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
const CaloSubdetectorTopology* topology = ct.getSubdetectorTopology(det, subdetn);
std::vector<DetId> ebDetIds;
ebDetIds.emplace_back(EBDetId(1, 1));
ebDetIds.emplace_back(EBDetId(30, 30));
ebDetIds.emplace_back(EBDetId(-1, 120));
ebDetIds.emplace_back(EBDetId(85, 1));
for (const auto& ebDetId : ebDetIds) {
EBDetId myId(ebDetId);
std::vector<DetId> myNeighbours = topology->getWindow(myId, 13, 13);
for (const auto& myNeighbour : myNeighbours) {
EBDetId myEBId(myNeighbour);
TBox* box = new TBox(myEBId.ieta() - 0.5, myEBId.iphi() - 0.5, myEBId.ieta() + 0.5, myEBId.iphi() + 0.5);
box->SetFillColor(1);
box->Draw();
}
}
gPad->SaveAs(name);
delete canv;
delete h;
}
}
// ------------ method called to produce the data ------------
void TestEcalGetWindow::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
edm::LogVerbatim("CaloGeom") << "Here I am ";
const auto& theCaloTopology = iSetup.getData(topologyToken_);
const auto& pG = iSetup.getData(geometryToken_);
if (pass_ == 1) {
build(pG, theCaloTopology, DetId::Ecal, EcalBarrel, "EBGetWindowTest.eps");
}
if (pass_ == 2) {
build(pG, theCaloTopology, DetId::Ecal, EcalEndcap, "EEGetWindowTest.eps");
}
pass_++;
}
//define this as a plug-in
DEFINE_FWK_MODULE(TestEcalGetWindow);
|