![]() |
![]() |
#include <FWECALDetailViewBuilder.h>
Public Member Functions | |
TEveCaloLego * | build () |
FWECALDetailViewBuilder (const edm::EventBase *event, const FWGeometry *geom, float eta, float phi, int size=50, Color_t defaultColor=kMagenta+1) | |
double | makeLegend (double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow) |
void | setColor (Color_t color, const std::vector< DetId > &detIds) |
void | showSuperCluster (const reco::SuperCluster &cluster, Color_t color=kYellow) |
void | showSuperClusters (Color_t color1=kGreen+2, Color_t color2=kTeal) |
Private Member Functions | |
void | fillData (const EcalRecHitCollection *hits, TEveCaloDataVec *data) |
Static Private Member Functions | |
static bool | superClusterEtaLess (const reco::CaloCluster &lhs, const reco::CaloCluster &rhs) |
Private Attributes | |
std::vector< Color_t > | m_colors |
Color_t | m_defaultColor |
std::map< DetId, int > | m_detIdsToColor |
float | m_eta |
const edm::EventBase * | m_event |
const FWGeometry * | m_geom |
float | m_phi |
int | m_size |
Definition at line 28 of file FWECALDetailViewBuilder.h.
FWECALDetailViewBuilder::FWECALDetailViewBuilder | ( | const edm::EventBase * | event, |
const FWGeometry * | geom, | ||
float | eta, | ||
float | phi, | ||
int | size = 50 , |
||
Color_t | defaultColor = kMagenta+1 |
||
) | [inline] |
TEveCaloLego * FWECALDetailViewBuilder::build | ( | ) |
Definition at line 27 of file FWECALDetailViewBuilder.cc.
References runTheMatrix::data, ExpressReco_HICollisions_FallBack::etaMax, ExpressReco_HICollisions_FallBack::etaMin, fillData(), fwLog, edm::EventBase::getByLabel(), i, edm::HandleBase::isValid(), fwlog::kWarning, m_colors, m_defaultColor, m_eta, m_event, M_PI, n, phi, ExpressReco_HICollisions_FallBack::phiMax, ExpressReco_HICollisions_FallBack::phiMin, GlobalPosition_Frontier_DevDB_cff::tag, and fw3dlego::xbins.
Referenced by FWMuonDetailView::build(), FWElectronDetailView::build(), FWPhotonDetailView::build(), and FWCaloTowerDetailView::build().
{ // get the hits from the event edm::Handle<EcalRecHitCollection> handle_hits; const EcalRecHitCollection *hits = 0; if (fabs(m_eta) < 1.5) { try { edm::InputTag tag("ecalRecHit", "EcalRecHitsEB"); m_event->getByLabel(tag, handle_hits); if (handle_hits.isValid()) hits = &*handle_hits; } catch (...) { fwLog(fwlog::kWarning) <<"no barrel ECAL rechits are available, " "showing crystal location but not energy" << std::endl; } } else { try { edm::InputTag tag("ecalRecHit", "EcalRecHitsEE"); m_event->getByLabel(tag, handle_hits); if (handle_hits.isValid()) hits = &*handle_hits; } catch (...) { fwLog(fwlog::kWarning) <<"no endcap ECAL rechits are available, " "showing crystal location but not energy" << std::endl; } } // data TEveCaloDataVec* data = new TEveCaloDataVec( 1 + m_colors.size() ); data->RefSliceInfo(0).Setup("hits (not clustered)", 0.0, m_defaultColor ); for( size_t i = 0; i < m_colors.size(); ++i ) { data->RefSliceInfo(i + 1).Setup( "hits (clustered)", 0.0, m_colors[i] ); } if( handle_hits.isValid() ) // fill fillData( hits, data ); // axis Double_t etaMin(0), etaMax(0), phiMin(0), phiMax(0); // it's hard to define properly visible area in X-Y, // so we rely on auto limits data->GetEtaLimits(etaMin, etaMax); data->GetPhiLimits(phiMin, phiMax); Double_t bl, bh, bw; Int_t bn, n = 20; THLimitsFinder::Optimize(etaMin, etaMax, n, bl, bh, bn, bw); data->SetEtaBins( new TAxis(bn, bl, bh)); THLimitsFinder::Optimize(phiMin, phiMax, n, bl, bh, bn, bw); data->SetPhiBins( new TAxis(bn, bl, bh)); // make tower grid std::vector<double> etaBinsWithinLimits; etaBinsWithinLimits.push_back(etaMin); for (unsigned int i=0; i<83; ++i) if ( fw3dlego::xbins[i] > etaMin && fw3dlego::xbins[i] < etaMax ) etaBinsWithinLimits.push_back(fw3dlego::xbins[i]); etaBinsWithinLimits.push_back(etaMax); Double_t* eta_bins = new Double_t[etaBinsWithinLimits.size()]; for (unsigned int i=0; i<etaBinsWithinLimits.size(); ++i) eta_bins[i] = etaBinsWithinLimits[i]; std::vector<double> phiBinsWithinLimits; phiBinsWithinLimits.push_back(phiMin); for ( double phi = -M_PI; phi < M_PI; phi += M_PI/36 ) if ( phi > phiMin && phi < phiMax ) // it's stupid, I know, but I'm lazy right now phiBinsWithinLimits.push_back(phi); phiBinsWithinLimits.push_back(phiMax); Double_t* phi_bins = new Double_t[phiBinsWithinLimits.size()]; for (unsigned int i=0; i<phiBinsWithinLimits.size(); ++i) phi_bins[i] = phiBinsWithinLimits[i]; if (fabs(m_eta) > 1.5) { data->GetEtaBins()->SetTitle("X[cm]"); data->GetPhiBins()->SetTitle("Y[cm]"); data->GetPhiBins()->SetTitleSize(0.03); data->GetEtaBins()->SetTitleSize(0.03); } else { data->SetEtaBins(new TAxis(etaBinsWithinLimits.size()-1,eta_bins)); data->SetPhiBins(new TAxis(phiBinsWithinLimits.size()-1,phi_bins)); data->GetEtaBins()->SetTitleFont(122); data->GetEtaBins()->SetTitle("h"); data->GetPhiBins()->SetTitleFont(122); data->GetPhiBins()->SetTitle("f"); data->GetPhiBins()->SetTitleSize(0.05); data->GetEtaBins()->SetTitleSize(0.05); } delete [] eta_bins; delete [] phi_bins; // lego TEveCaloLego *lego = new TEveCaloLego(data); lego->SetDrawNumberCellPixels(100); // scale and translate to real world coordinates lego->SetEta(etaMin, etaMax); lego->SetPhiWithRng((phiMin+phiMax)*0.5, (phiMax-phiMin)*0.5); // phi range = 2* phiOffset Double_t legoScale = ((etaMax - etaMin) < (phiMax - phiMin)) ? (etaMax - etaMin) : (phiMax - phiMin); lego->InitMainTrans(); lego->RefMainTrans().SetScale(legoScale, legoScale, legoScale*0.5); lego->RefMainTrans().SetPos((etaMax+etaMin)*0.5, (phiMax+phiMin)*0.5, 0); lego->SetAutoRebin(kFALSE); lego->Set2DMode(TEveCaloLego::kValSizeOutline); lego->SetName("ECALDetail Lego"); return lego; }
void FWECALDetailViewBuilder::fillData | ( | const EcalRecHitCollection * | hits, |
TEveCaloDataVec * | data | ||
) | [private] |
Definition at line 216 of file FWECALDetailViewBuilder.cc.
References edm::SortedCollection< T, SORT >::begin(), delta, EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), eta(), fwLog, FWGeometry::getCorners(), i, j, gen::k, fwlog::kInfo, m_detIdsToColor, m_eta, m_geom, m_phi, M_PI, m_size, maxEta, displayMF_cfg::maxX, displayMF_cfg::maxY, benchmark_cfg::minEta, displayMF_cfg::minX, displayMF_cfg::minY, phi, findQualityFiles::size, v, ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.
Referenced by build().
{ const float barrelCR = m_size*0.0172; // barrel cell range // loop on all the detids for( EcalRecHitCollection::const_iterator k = hits->begin(), kEnd = hits->end(); k != kEnd; ++k ) { // get reco geometry double centerEta = 0; double centerPhi = 0; const float* points = m_geom->getCorners( k->id().rawId()); if( points != 0 ) { TEveVector v; int j = 0; for( int i = 0; i < 8; ++i ) { v += TEveVector( points[j], points[j + 1], points[j + 2] ); j +=3; } centerEta = v.Eta(); centerPhi = v.Phi(); } else fwLog( fwlog::kInfo ) << "cannot get geometry for DetId: "<< k->id().rawId() << ". Ignored.\n"; double size = k->energy() / cosh( centerEta ); // check what slice to put in int slice = 0; std::map<DetId, int>::const_iterator itr = m_detIdsToColor.find(k->id()); if (itr != m_detIdsToColor.end()) slice = itr->second; // if in the EB if( k->id().subdetId() == EcalBarrel ) { // do phi wrapping if( centerPhi > m_phi + M_PI) centerPhi -= 2 * M_PI; if( centerPhi < m_phi - M_PI) centerPhi += 2 * M_PI; // check if the hit is in the window to be drawn if( !( fabs( centerEta - m_eta ) < barrelCR && fabs( centerPhi - m_phi ) < barrelCR )) continue; double minEta(10), maxEta(-10), minPhi(4), maxPhi(-4); if( points != 0 ) { // calorimeter crystalls have slightly non-symetrical form in eta-phi projection // so if we simply get the largest eta and phi, cells will overlap // therefore we get a smaller eta-phi range representing the inner square // we also should use only points from the inner face of the crystal, since // non-projecting direction of crystals leads to large shift in eta on outter // face. int j = 0; for( unsigned int i = 0; i < 8; ++i ) { TEveVector crystal( points[j], points[j + 1], points[j + 2] ); j += 3; double eta = crystal.Eta(); double phi = crystal.Phi(); if ( crystal.Perp() > 135 ) continue; if ( minEta - eta > 0.01) minEta = eta; if ( eta - minEta > 0 && eta - minEta < 0.01 ) minEta = eta; if ( eta - maxEta > 0.01) maxEta = eta; if ( maxEta - eta > 0 && maxEta - eta < 0.01 ) maxEta = eta; if ( minPhi - phi > 0.01) minPhi = phi; if ( phi - minPhi > 0 && phi - minPhi < 0.01 ) minPhi = phi; if ( phi - maxPhi > 0.01) maxPhi = phi; if ( maxPhi - phi > 0 && maxPhi - phi < 0.01 ) maxPhi = phi; } } else { double delta = 0.0172 * 0.5; minEta = centerEta - delta; maxEta = centerEta + delta; minPhi = centerPhi - delta; maxPhi = centerPhi + delta; } if( minPhi >= ( m_phi - barrelCR ) && maxPhi <= ( m_phi + barrelCR ) && minEta >= ( m_eta - barrelCR ) && maxEta <= ( m_eta + barrelCR )) { data->AddTower( minEta, maxEta, minPhi, maxPhi ); data->FillSlice( slice, size ); } // otherwise in the EE } else if( k->id().subdetId() == EcalEndcap ) { // check if the hit is in the window to be drawn double crystalSize = m_size * 0.0172; if( !( fabs( centerEta - m_eta ) < ( crystalSize ) && fabs( centerPhi - m_phi ) < ( crystalSize ))) continue; if( points != 0 ) { double minX(9999), maxX(-9999), minY(9999), maxY(-9999); int j = 0; for( unsigned int i = 0; i < 8; ++i ) { TEveVector crystal( points[j], points[j + 1], points[j + 2] ); j += 3; double x = crystal.fX; double y = crystal.fY; if( fabs( crystal.fZ ) > 330 ) continue; if( minX - x > 0.01 ) minX = x; if( x - maxX > 0.01 ) maxX = x; if( minY - y > 0.01 ) minY = y; if( y - maxY > 0.01 ) maxY = y; } data->AddTower( minX, maxX, minY, maxY ); } data->FillSlice( slice, size ); } } // end loop on hits data->DataChanged(); }
double FWECALDetailViewBuilder::makeLegend | ( | double | x0 = 0.02 , |
double | y0 = 0.95 , |
||
Color_t | clustered1 = kGreen+1 , |
||
Color_t | clustered2 = kTeal , |
||
Color_t | supercluster = kYellow |
||
) |
Definition at line 339 of file FWECALDetailViewBuilder.cc.
References FWDetailViewBase::drawCanvasBox(), m_defaultColor, pos, ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.
Referenced by FWCaloTowerDetailView::setTextInfo(), FWElectronDetailView::setTextInfo(), FWPhotonDetailView::setTextInfo(), and FWMuonDetailView::setTextInfo().
{ Double_t fontsize = 0.07; TLatex* latex = new TLatex(); Double_t x = x0; Double_t y = y0; Double_t boxH = 0.25*fontsize; Double_t yStep = 0.04; y -= yStep; latex->DrawLatex(x, y, "Energy types:"); y -= yStep; Double_t pos[4]; pos[0] = x+0.05; pos[2] = x+0.20; pos[1] = y; pos[3] = pos[1] + boxH; FWDetailViewBase::drawCanvasBox(pos, m_defaultColor); latex->DrawLatex(x+0.25, y, "unclustered"); y -= yStep; if (clustered1<0) return y; pos[1] = y; pos[3] = pos[1] + boxH; FWDetailViewBase::drawCanvasBox(pos, clustered1); latex->DrawLatex(x+0.25, y, "clustered"); y -= yStep; if (clustered2<0) return y; pos[1] = y; pos[3] = pos[1] + boxH; FWDetailViewBase::drawCanvasBox(pos, clustered2); latex->DrawLatex(x+0.25, y, "clustered"); y -= yStep; if (supercluster<0) return y; pos[1] = y; pos[3] = pos[1] + boxH; FWDetailViewBase::drawCanvasBox(pos, supercluster); latex->DrawLatex(x+0.25, y, "super-cluster"); y -= yStep; return y; }
void FWECALDetailViewBuilder::setColor | ( | Color_t | color, |
const std::vector< DetId > & | detIds | ||
) |
Definition at line 145 of file FWECALDetailViewBuilder.cc.
References i, m_colors, and m_detIdsToColor.
Referenced by FWMuonDetailView::build(), and showSuperCluster().
{ m_colors.push_back(color); // get the slice for this group of detIds // note that the zeroth slice is the default one (all else) int slice = m_colors.size(); // take a note of which slice these detids are going to go into for (size_t i = 0; i < detIds.size(); ++i) m_detIdsToColor[detIds[i]] = slice; }
void FWECALDetailViewBuilder::showSuperCluster | ( | const reco::SuperCluster & | cluster, |
Color_t | color = kYellow |
||
) |
Definition at line 159 of file FWECALDetailViewBuilder.cc.
References first, reco::CaloCluster::hitsAndFractions(), j, and setColor().
Referenced by FWElectronDetailView::build(), FWPhotonDetailView::build(), and showSuperClusters().
void FWECALDetailViewBuilder::showSuperClusters | ( | Color_t | color1 = kGreen+2 , |
Color_t | color2 = kTeal |
||
) |
Definition at line 172 of file FWECALDetailViewBuilder.cc.
References runEdmFileComparison::collection, eta(), fwLog, edm::EventBase::getByLabel(), i, edm::HandleBase::isValid(), fwlog::kWarning, m_eta, m_event, m_phi, m_size, phi, edm::Handle< T >::product(), showSuperCluster(), python::multivaluedict::sort(), and superClusterEtaLess().
Referenced by FWMuonDetailView::build(), FWElectronDetailView::build(), FWPhotonDetailView::build(), and FWCaloTowerDetailView::build().
{ // get the superclusters from the event edm::Handle<reco::SuperClusterCollection> collection; if( fabs( m_eta ) < 1.5 ) { try { m_event->getByLabel(edm::InputTag("correctedHybridSuperClusters"), collection); } catch (...) { fwLog(fwlog::kWarning) <<"no barrel superclusters are available" << std::endl; } } else { try { m_event->getByLabel(edm::InputTag("correctedMulti5x5SuperClustersWithPreshower"), collection); } catch (...) { fwLog(fwlog::kWarning) <<"no endcap superclusters are available" << std::endl; } } if( collection.isValid() ) { unsigned int colorIndex = 0; // sort clusters in eta so neighboring clusters have distinct colors reco::SuperClusterCollection sorted = *collection.product(); std::sort( sorted.begin(), sorted.end(), superClusterEtaLess ); for( size_t i = 0; i < sorted.size(); ++i ) { if( !(fabs(sorted[i].eta() - m_eta) < (m_size*0.0172) && fabs(sorted[i].phi() - m_phi) < (m_size*0.0172)) ) continue; if( colorIndex %2 == 0 ) showSuperCluster( sorted[i], color1 ); else showSuperCluster( sorted[i], color2 ); ++colorIndex; } } }
static bool FWECALDetailViewBuilder::superClusterEtaLess | ( | const reco::CaloCluster & | lhs, |
const reco::CaloCluster & | rhs | ||
) | [inline, static, private] |
Definition at line 83 of file FWECALDetailViewBuilder.h.
References reco::CaloCluster::eta().
Referenced by showSuperClusters().
std::vector<Color_t> FWECALDetailViewBuilder::m_colors [private] |
Definition at line 80 of file FWECALDetailViewBuilder.h.
Referenced by build(), and setColor().
Color_t FWECALDetailViewBuilder::m_defaultColor [private] |
Definition at line 74 of file FWECALDetailViewBuilder.h.
Referenced by build(), and makeLegend().
std::map<DetId, int> FWECALDetailViewBuilder::m_detIdsToColor [private] |
Definition at line 77 of file FWECALDetailViewBuilder.h.
Referenced by fillData(), and setColor().
float FWECALDetailViewBuilder::m_eta [private] |
Definition at line 71 of file FWECALDetailViewBuilder.h.
Referenced by build(), fillData(), and showSuperClusters().
const edm::EventBase* FWECALDetailViewBuilder::m_event [private] |
Definition at line 69 of file FWECALDetailViewBuilder.h.
Referenced by build(), and showSuperClusters().
const FWGeometry* FWECALDetailViewBuilder::m_geom [private] |
Definition at line 70 of file FWECALDetailViewBuilder.h.
Referenced by fillData().
float FWECALDetailViewBuilder::m_phi [private] |
Definition at line 72 of file FWECALDetailViewBuilder.h.
Referenced by fillData(), and showSuperClusters().
int FWECALDetailViewBuilder::m_size [private] |
Definition at line 73 of file FWECALDetailViewBuilder.h.
Referenced by fillData(), and showSuperClusters().