5 #include "TEveCaloData.h"
6 #include "TEveViewer.h"
9 #include "THLimitsFinder.h"
22 #include "TGeoMatrix.h"
23 #include "TEveTrans.h"
34 if (fabs(
m_eta) < 1.5)
46 "showing crystal location but not energy" << std::endl;
61 "showing crystal location but not energy" << std::endl;
66 TEveCaloDataVec*
data =
new TEveCaloDataVec( 1 +
m_colors.size() );
67 data->RefSliceInfo(0).Setup(
"hits (not clustered)", 0.0,
m_defaultColor );
70 data->RefSliceInfo(
i + 1).Setup(
"hits (clustered)", 0.0,
m_colors[
i] );
82 data->GetPhiLimits(
phiMin, phiMax);
85 THLimitsFinder::Optimize(
etaMin,
etaMax, n, bl, bh, bn, bw);
86 data->SetEtaBins(
new TAxis(bn, bl, bh));
87 THLimitsFinder::Optimize(
phiMin, phiMax, n, bl, bh, bn, bw);
88 data->SetPhiBins(
new TAxis(bn, bl, bh));
91 std::vector<double> etaBinsWithinLimits;
92 etaBinsWithinLimits.push_back(
etaMin);
93 for (
unsigned int i=0;
i<83; ++
i)
96 etaBinsWithinLimits.push_back(
etaMax);
97 Double_t* eta_bins =
new Double_t[etaBinsWithinLimits.size()];
98 for (
unsigned int i=0; i<etaBinsWithinLimits.size(); ++
i)
99 eta_bins[i] = etaBinsWithinLimits[i];
101 std::vector<double> phiBinsWithinLimits;
102 phiBinsWithinLimits.push_back(
phiMin);
105 phiBinsWithinLimits.push_back(
phi);
106 phiBinsWithinLimits.push_back(phiMax);
107 Double_t* phi_bins =
new Double_t[phiBinsWithinLimits.size()];
108 for (
unsigned int i=0; i<phiBinsWithinLimits.size(); ++
i)
109 phi_bins[i] = phiBinsWithinLimits[i];
110 if (fabs(
m_eta) > 1.5) {
111 data->GetEtaBins()->SetTitle(
"X[cm]");
112 data->GetPhiBins()->SetTitle(
"Y[cm]");
113 data->GetPhiBins()->SetTitleSize(0.03);
114 data->GetEtaBins()->SetTitleSize(0.03);
116 data->SetEtaBins(
new TAxis(etaBinsWithinLimits.size()-1,eta_bins));
117 data->SetPhiBins(
new TAxis(phiBinsWithinLimits.size()-1,phi_bins));
118 data->GetEtaBins()->SetTitleFont(122);
119 data->GetEtaBins()->SetTitle(
"h");
120 data->GetPhiBins()->SetTitleFont(122);
121 data->GetPhiBins()->SetTitle(
"f");
122 data->GetPhiBins()->SetTitleSize(0.05);
123 data->GetEtaBins()->SetTitleSize(0.05);
129 TEveCaloLego *lego =
new TEveCaloLego(data);
130 lego->SetDrawNumberCellPixels(100);
133 lego->SetPhiWithRng((
phiMin+phiMax)*0.5, (phiMax-
phiMin)*0.5);
135 lego->InitMainTrans();
136 lego->RefMainTrans().SetScale(legoScale, legoScale, legoScale*0.5);
138 lego->SetAutoRebin(kFALSE);
139 lego->Set2DMode(TEveCaloLego::kValSizeOutline);
140 lego->SetName(
"ECALDetail Lego");
154 for (
size_t i = 0;
i < detIds.size(); ++
i)
161 std::vector<DetId> clusterDetIds;
162 const std::vector<std::pair<DetId, float> > &hitsAndFractions = cluster.
hitsAndFractions();
163 for (
size_t j = 0;
j < hitsAndFractions.size(); ++
j)
165 clusterDetIds.push_back(hitsAndFractions[
j].
first);
177 if( fabs(
m_eta ) < 1.5 ) {
196 unsigned int colorIndex = 0;
200 for(
size_t i = 0;
i < sorted.size(); ++
i )
206 if( colorIndex %2 == 0 )
217 TEveCaloDataVec *
data )
219 const float barrelCR =
m_size*0.0172;
226 double centerEta = 0;
227 double centerPhi = 0;
233 for(
int i = 0;
i < 8; ++
i )
235 v += TEveVector( points[j], points[j + 1], points[j + 2] );
242 fwLog(
fwlog::kInfo ) <<
"cannot get geometry for DetId: "<<
k->id().rawId() <<
". Ignored.\n";
244 double size =
k->energy() / cosh( centerEta );
259 if( !( fabs( centerEta -
m_eta ) < barrelCR
260 && fabs( centerPhi -
m_phi ) < barrelCR ))
continue;
272 for(
unsigned int i = 0;
i < 8; ++
i )
274 TEveVector crystal( points[j], points[j + 1], points[j + 2] );
276 double eta = crystal.Eta();
277 double phi = crystal.Phi();
278 if ( crystal.Perp() > 135 )
continue;
283 if ( minPhi - phi > 0.01) minPhi =
phi;
284 if ( phi - minPhi > 0 && phi - minPhi < 0.01 ) minPhi =
phi;
285 if ( phi - maxPhi > 0.01) maxPhi =
phi;
286 if ( maxPhi - phi > 0 && maxPhi - phi < 0.01 ) maxPhi =
phi;
291 double delta = 0.0172 * 0.5;
294 minPhi = centerPhi -
delta;
295 maxPhi = centerPhi +
delta;
297 if( minPhi >= (
m_phi - barrelCR ) && maxPhi <= (
m_phi + barrelCR ) &&
301 data->FillSlice( slice, size );
308 double crystalSize =
m_size * 0.0172;
309 if( !( fabs( centerEta -
m_eta ) < ( crystalSize )
310 && fabs( centerPhi -
m_phi ) < ( crystalSize )))
317 for(
unsigned int i = 0;
i < 8; ++
i )
319 TEveVector crystal( points[j], points[j + 1], points[j + 2] );
321 double x = crystal.fX;
322 double y = crystal.fY;
323 if( fabs( crystal.fZ ) > 330 )
continue;
327 if( y - maxY > 0.01 ) maxY =
y;
331 data->FillSlice( slice, size );
340 Color_t clustered1, Color_t clustered2,
344 Double_t fontsize = 0.07;
345 TLatex* latex =
new TLatex();
348 Double_t boxH = 0.25*fontsize;
349 Double_t yStep = 0.04;
352 latex->DrawLatex(x, y,
"Energy types:");
359 pos[1] =
y; pos[3] = pos[1] + boxH;
361 latex->DrawLatex(x+0.25, y,
"unclustered");
363 if (clustered1<0)
return y;
365 pos[1] =
y; pos[3] = pos[1] + boxH;
367 latex->DrawLatex(x+0.25, y,
"clustered");
369 if (clustered2<0)
return y;
371 pos[1] =
y; pos[3] = pos[1] + boxH;
373 latex->DrawLatex(x+0.25, y,
"clustered");
375 if (supercluster<0)
return y;
377 pos[1] =
y; pos[3] = pos[1] + boxH;
379 latex->DrawLatex(x+0.25, y,
"super-cluster");
void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow)
double makeLegend(double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow)
std::vector< T >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
bool getByLabel(const InputTag &, Handle< T > &) const
const edm::EventBase * m_event
std::map< DetId, int > m_detIdsToColor
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
const FWGeometry * m_geom
const_iterator end() const
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
const float * getCorners(unsigned int id) const
void fillData(const EcalRecHitCollection *hits, TEveCaloDataVec *data)
void setColor(Color_t color, const std::vector< DetId > &detIds)
T const * product() const
static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
std::vector< Color_t > m_colors
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)