5 #include "TEveCaloData.h"
6 #include "TEveViewer.h"
10 #include "THLimitsFinder.h"
23 #include "TGeoMatrix.h"
24 #include "TEveTrans.h"
35 if (fabs(
m_eta) < 1.5)
48 fwLog(
fwlog::kWarning) <<
"FWECALDetailViewBuilder::build():: Failed to access EcalRecHitsEB collection." << std::endl;
62 fwLog(
fwlog::kWarning) <<
"FWECALDetailViewBuilder::build():: Failed to access reducedEcalRecHitsEB collection." << std::endl;
77 fwLog(
fwlog::kWarning) <<
"FWECALDetailViewBuilder::build():: Failed to access ecalRecHitsEE collection." << std::endl;
92 fwLog(
fwlog::kWarning) <<
"FWECALDetailViewBuilder::build():: Failed to access reducedEcalRecHitsEE collection." << std::endl;
98 TEveCaloDataVec*
data =
new TEveCaloDataVec( 1 +
m_colors.size() );
99 data->RefSliceInfo(0).Setup(
"hits (not clustered)", 0.0,
m_defaultColor );
102 data->RefSliceInfo(
i + 1).Setup(
"hits (clustered)", 0.0,
m_colors[
i] );
114 fwLog(
fwlog::kWarning) <<
"FWECALDetailViewBuilder::build():: No hits found in " << Form(
"FWECALDetailViewBuilder::build():: No hits found in eta[%f] phi[%f] region",
m_eta,
m_phi)<<
".\n";
117 float x =
m_size*TMath::DegToRad();
118 if (fabs(
m_eta) < 1.5 || xyEE ==
false) {
127 float theta = TEveCaloData::EtaToTheta(
m_eta);
128 float r = TMath::Tan(theta) * 290;
130 phiMax = r * TMath::Cos(
m_phi + x) + 300;
137 data->FillSlice(0, 0.1);
144 data->GetPhiLimits(
phiMin, phiMax);
147 if (fabs(
m_eta) > 1.5 && xyEE ) {
149 phi_axis =
new TAxis(10,
phiMin, phiMax);
150 eta_axis->SetTitle(
"X[cm]");
151 phi_axis->SetTitle(
"Y[cm]");
152 phi_axis->SetTitleSize(0.05);
153 eta_axis->SetTitleSize(0.05);
155 std::vector<double> etaBinsWithinLimits;
156 etaBinsWithinLimits.push_back(
etaMin);
157 for (
unsigned int i=0;
i<83; ++
i)
160 etaBinsWithinLimits.push_back(
etaMax);
162 std::vector<double> phiBinsWithinLimits;
163 phiBinsWithinLimits.push_back(
phiMin);
166 phiBinsWithinLimits.push_back(
phi);
167 phiBinsWithinLimits.push_back(phiMax);
169 eta_axis =
new TAxis((
int)etaBinsWithinLimits.size() -1, &etaBinsWithinLimits[0]);
170 phi_axis =
new TAxis((
int)phiBinsWithinLimits.size() -1, &phiBinsWithinLimits[0]);
172 eta_axis->SetTitleFont(122);
173 eta_axis->SetTitle(
"h");
174 eta_axis->SetTitleSize(0.07);
175 phi_axis->SetTitleFont(122);
176 phi_axis->SetTitle(
"f");
177 phi_axis->SetTitleSize(0.07);
179 eta_axis->SetNdivisions(510);
180 phi_axis->SetNdivisions(510);
181 data->SetEtaBins(eta_axis);
182 data->SetPhiBins(phi_axis);
192 data->GetEtaLimits(etaMin, etaMax);
193 data->GetPhiLimits(phiMin, phiMax);
196 TEveCaloLego *lego =
new TEveCaloLego(data);
197 lego->SetDrawNumberCellPixels(100);
199 lego->SetEta(etaMin, etaMax);
200 lego->SetPhiWithRng((phiMin+phiMax)*0.5, (phiMax-phiMin)*0.5);
201 Double_t legoScale = ((etaMax -
etaMin) < (phiMax - phiMin)) ? (etaMax - etaMin) : (phiMax -
phiMin);
202 lego->InitMainTrans();
203 lego->RefMainTrans().SetScale(legoScale, legoScale, legoScale*0.5);
204 lego->RefMainTrans().SetPos((etaMax+etaMin)*0.5, (phiMax+phiMin)*0.5, 0);
205 lego->SetAutoRebin(kFALSE);
206 lego->Set2DMode(TEveCaloLego::kValSizeOutline);
207 lego->SetName(
"ECALDetail Lego");
221 for (
size_t i = 0;
i < detIds.size(); ++
i)
228 std::vector<DetId> clusterDetIds;
229 const std::vector<std::pair<DetId, float> > &hitsAndFractions = cluster.
hitsAndFractions();
230 for (
size_t j = 0;
j < hitsAndFractions.size(); ++
j)
232 clusterDetIds.push_back(hitsAndFractions[
j].
first);
244 if( fabs(
m_eta ) < 1.5 ) {
263 unsigned int colorIndex = 0;
267 for(
size_t i = 0;
i < sorted.size(); ++
i )
273 if( colorIndex %2 == 0 )
284 TEveCaloDataVec *
data,
bool xyEE )
286 const float barrelCR =
m_size*0.0172;
293 double centerEta = 0;
294 double centerPhi = 0;
300 for(
int i = 0;
i < 8; ++
i )
302 v += TEveVector( points[j], points[j + 1], points[j + 2] );
309 fwLog(
fwlog::kInfo ) <<
"cannot get geometry for DetId: "<<
k->id().rawId() <<
". Ignored.\n";
311 double size =
k->energy() / cosh( centerEta );
326 if( !( fabs( centerEta -
m_eta ) < barrelCR
327 && fabs( centerPhi -
m_phi ) < barrelCR ))
continue;
340 for(
unsigned int i = 0;
i < 8; ++
i )
342 TEveVector crystal( points[j], points[j + 1], points[j + 2] );
344 double eta = crystal.Eta();
345 double phi = crystal.Phi();
346 if ( ((
k->id().subdetId() ==
EcalBarrel) && (crystal.Perp() > 135) )|| ((
k->id().subdetId() ==
EcalEndcap) && (crystal.Perp() > 155)))
continue;
351 if ( minPhi - phi > eps) minPhi =
phi;
352 if ( phi - minPhi > 0 && phi - minPhi < eps ) minPhi =
phi;
353 if ( phi - maxPhi > eps) maxPhi =
phi;
354 if ( maxPhi - phi > 0 && maxPhi - phi < eps ) maxPhi =
phi;
359 double delta = 0.0172 * 0.5;
362 minPhi = centerPhi -
delta;
363 maxPhi = centerPhi +
delta;
365 if( minPhi >= (
m_phi - barrelCR ) && maxPhi <= (
m_phi + barrelCR ) &&
370 data->FillSlice( slice, size );
377 double crystalSize =
m_size * 0.0172;
378 if( !( fabs( centerEta -
m_eta ) < ( crystalSize )
379 && fabs( centerPhi -
m_phi ) < ( crystalSize )))
386 for(
unsigned int i = 0;
i < 8; ++
i )
388 TEveVector crystal( points[j], points[j + 1], points[j + 2] );
390 double x = crystal.fX;
391 double y = crystal.fY;
392 if( fabs( crystal.fZ ) > 330 )
continue;
396 if( y - maxY > 0.01 ) maxY =
y;
401 data->FillSlice( slice, size );
410 Color_t clustered1, Color_t clustered2,
414 Double_t fontsize = 0.07;
415 TLatex* latex =
new TLatex();
418 Double_t boxH = 0.25*fontsize;
419 Double_t yStep = 0.04;
422 latex->DrawLatex(x, y,
"Energy types:");
429 pos[1] =
y; pos[3] = pos[1] + boxH;
431 latex->DrawLatex(x+0.25, y,
"unclustered");
433 if (clustered1<0)
return y;
435 pos[1] =
y; pos[3] = pos[1] + boxH;
437 latex->DrawLatex(x+0.25, y,
"clustered");
439 if (clustered2<0)
return y;
441 pos[1] =
y; pos[3] = pos[1] + boxH;
443 latex->DrawLatex(x+0.25, y,
"clustered");
445 if (supercluster<0)
return y;
447 pos[1] =
y; pos[3] = pos[1] + boxH;
449 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)
void fillData(const EcalRecHitCollection *hits, TEveCaloDataVec *data, bool xyEE)
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
const edm::EventBase * m_event
std::map< DetId, int > m_detIdsToColor
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
const FWGeometry * m_geom
TEveCaloData * buildCaloData(bool xyEE)
const_iterator end() const
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
const float * getCorners(unsigned int id) const
void setColor(Color_t color, const std::vector< DetId > &detIds)
T const * product() const
bool getByLabel(InputTag const &, Handle< T > &) const
char data[epos_bytes_allocation]
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)