5 #include "TEveCaloData.h"
6 #include "TEveViewer.h"
10 #include "THLimitsFinder.h"
23 #include "TGeoMatrix.h"
24 #include "TEveTrans.h"
34 if (fabs(
m_eta) < 1.5) {
42 fwLog(
fwlog::kWarning) <<
"FWECALCaloDataDetailViewBuilder::build():: Failed to access EcalRecHitsEB collection."
55 <<
"FWECALCaloDataDetailViewBuilder::build():: Failed to access reducedEcalRecHitsEB collection."
66 fwLog(
fwlog::kWarning) <<
"FWECALCaloDataDetailViewBuilder::build():: Failed to access ecalRecHitsEE collection."
80 <<
"FWECALCaloDataDetailViewBuilder::build():: Failed to access reducedEcalRecHitsEE collection."
87 TEveCaloDataVec*
data =
new TEveCaloDataVec(1 +
m_colors.size());
88 data->RefSliceInfo(0).Setup(
"hits (not clustered)", 0.0,
m_defaultColor);
90 data->RefSliceInfo(
i + 1).Setup(
"hits (clustered)", 0.0,
m_colors[
i]);
101 << Form(
"FWECALCaloDataDetailViewBuilder::build():: No hits found in eta[%f] phi[%f] region",
107 float x =
m_size * TMath::DegToRad();
108 if (fabs(
m_eta) < 1.5 || xyEE ==
false) {
115 float theta = TEveCaloData::EtaToTheta(
m_eta);
116 float r = TMath::Tan(theta) * 290;
118 phiMax = r * TMath::Cos(
m_phi + x) + 300;
126 data->FillSlice(0, 0.1);
129 TAxis* eta_axis =
nullptr;
130 TAxis* phi_axis =
nullptr;
132 data->GetPhiLimits(
phiMin, phiMax);
135 if (fabs(
m_eta) > 1.5 && xyEE) {
137 phi_axis =
new TAxis(10,
phiMin, phiMax);
138 eta_axis->SetTitle(
"X[cm]");
139 phi_axis->SetTitle(
"Y[cm]");
140 phi_axis->SetTitleSize(0.05);
141 eta_axis->SetTitleSize(0.05);
143 std::vector<double> etaBinsWithinLimits;
144 etaBinsWithinLimits.push_back(
etaMin);
145 for (
unsigned int i = 0;
i < 83; ++
i)
148 etaBinsWithinLimits.push_back(
etaMax);
150 std::vector<double> phiBinsWithinLimits;
151 phiBinsWithinLimits.push_back(
phiMin);
154 phiBinsWithinLimits.push_back(
phi);
155 phiBinsWithinLimits.push_back(phiMax);
157 eta_axis =
new TAxis((
int)etaBinsWithinLimits.size() - 1, &etaBinsWithinLimits[0]);
158 phi_axis =
new TAxis((
int)phiBinsWithinLimits.size() - 1, &phiBinsWithinLimits[0]);
160 eta_axis->SetTitleFont(122);
161 eta_axis->SetTitle(
"h");
162 eta_axis->SetTitleSize(0.07);
163 phi_axis->SetTitleFont(122);
164 phi_axis->SetTitle(
"f");
165 phi_axis->SetTitleSize(0.07);
167 eta_axis->SetNdivisions(510);
168 phi_axis->SetNdivisions(510);
169 data->SetEtaBins(eta_axis);
170 data->SetPhiBins(phi_axis);
179 data->GetEtaLimits(etaMin, etaMax);
180 data->GetPhiLimits(phiMin, phiMax);
183 TEveCaloLego* lego =
new TEveCaloLego(data);
184 lego->SetDrawNumberCellPixels(100);
186 lego->SetEta(etaMin, etaMax);
187 lego->SetPhiWithRng((phiMin + phiMax) * 0.5, (phiMax - phiMin) * 0.5);
188 Double_t legoScale = ((etaMax -
etaMin) < (phiMax - phiMin)) ? (etaMax - etaMin) : (phiMax -
phiMin);
189 lego->InitMainTrans();
190 lego->RefMainTrans().SetScale(legoScale, legoScale, legoScale * 0.5);
191 lego->RefMainTrans().SetPos((etaMax + etaMin) * 0.5, (phiMax + phiMin) * 0.5, 0);
192 lego->SetAutoRebin(kFALSE);
193 lego->Set2DMode(TEveCaloLego::kValSizeOutline);
194 lego->SetName(
"ECALDetail Lego");
205 for (
size_t i = 0;
i < detIds.size(); ++
i)
210 std::vector<DetId> clusterDetIds;
211 const std::vector<std::pair<DetId, float> >& hitsAndFractions = cluster.
hitsAndFractions();
212 for (
size_t j = 0;
j < hitsAndFractions.size(); ++
j) {
213 clusterDetIds.push_back(hitsAndFractions[
j].
first);
223 if (fabs(
m_eta) < 1.5) {
237 unsigned int colorIndex = 0;
241 for (
size_t i = 0;
i < sorted.size(); ++
i) {
245 if (colorIndex % 2 == 0)
255 const float barrelCR =
m_size * 0.0172;
260 double centerEta = 0;
261 double centerPhi = 0;
263 if (points !=
nullptr) {
266 for (
int i = 0;
i < 8; ++
i) {
267 v += TEveVector(points[j], points[j + 1], points[j + 2]);
273 fwLog(
fwlog::kInfo) <<
"cannot get geometry for DetId: " <<
k->id().rawId() <<
". Ignored.\n";
275 double size =
k->energy() / cosh(centerEta);
287 centerPhi -= 2 *
M_PI;
289 centerPhi += 2 *
M_PI;
292 if (!(fabs(centerEta -
m_eta) < barrelCR && fabs(centerPhi -
m_phi) < barrelCR))
296 if (points !=
nullptr) {
305 for (
unsigned int i = 0;
i < 8; ++
i) {
306 TEveVector crystal(points[j], points[j + 1], points[j + 2]);
308 double eta = crystal.Eta();
309 double phi = crystal.Phi();
310 if (((
k->id().subdetId() ==
EcalBarrel) && (crystal.Perp() > 135)) ||
311 ((
k->id().subdetId() ==
EcalEndcap) && (crystal.Perp() > 155)))
313 if (minEta - eta > eps)
315 if (eta - minEta > 0 && eta - minEta < eps)
325 if (phi - maxPhi > eps)
327 if (maxPhi - phi > 0 && maxPhi - phi < eps)
331 double delta = 0.0172 * 0.5;
332 minEta = centerEta -
delta;
335 maxPhi = centerPhi +
delta;
337 if (
minPhi >= (
m_phi - barrelCR) && maxPhi <= (m_phi + barrelCR) && minEta >= (
m_eta - barrelCR) &&
341 data->FillSlice(slice, size);
346 double crystalSize =
m_size * 0.0172;
347 if (!(fabs(centerEta -
m_eta) < (crystalSize) && fabs(centerPhi -
m_phi) < (crystalSize)))
350 if (points !=
nullptr) {
351 double minX(9999), maxX(-9999), minY(9999), maxY(-9999);
353 for (
unsigned int i = 0;
i < 8; ++
i) {
354 TEveVector crystal(points[j], points[j + 1], points[j + 2]);
356 double x = crystal.fX;
357 double y = crystal.fY;
358 if (fabs(crystal.fZ) > 330)
369 data->AddTower(minX, maxX, minY, maxY);
372 data->FillSlice(slice, size);
380 double x0,
double y0, Color_t clustered1, Color_t clustered2, Color_t supercluster) {
381 Double_t fontsize = 0.07;
382 TLatex* latex =
new TLatex();
385 Double_t boxH = 0.25 * fontsize;
386 Double_t
yStep = 0.04;
389 latex->DrawLatex(x, y,
"Energy types:");
397 pos[3] = pos[1] + boxH;
399 latex->DrawLatex(x + 0.25, y,
"unclustered");
405 pos[3] = pos[1] + boxH;
407 latex->DrawLatex(x + 0.25, y,
"clustered");
413 pos[3] = pos[1] + boxH;
415 latex->DrawLatex(x + 0.25, y,
"clustered");
417 if (supercluster < 0)
421 pos[3] = pos[1] + boxH;
423 latex->DrawLatex(x + 0.25, y,
"super-cluster");
const FWGeometry * m_geom
std::vector< Color_t > m_colors
void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow)
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
TEveCaloData * buildCaloData(bool xyEE)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
if(conf_.getParameter< bool >("UseStripCablingDB"))
double makeLegend(double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow)
const edm::EventBase * m_event
void setColor(Color_t color, const std::vector< DetId > &detIds)
const_iterator end() const
void fillData(const EcalRecHitCollection *hits, TEveCaloDataVec *data, bool xyEE)
const float * getCorners(unsigned int id) const
T const * product() const
std::map< DetId, int > m_detIdsToColor
bool getByLabel(InputTag const &, Handle< T > &) const
char data[epos_bytes_allocation]
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
tuple size
Write out results.
const_iterator begin() const
static void drawCanvasBox(Double_t *pos, Color_t fillCol, Int_t fillType=0, bool bg=kTRUE)