Skip to content

Commit

Permalink
Merge pull request #15527 from alja/ECAL-DV-81-merge
Browse files Browse the repository at this point in the history
81x Fireworks: new version of ECAL detail view
  • Loading branch information
davidlange6 committed Aug 24, 2016
2 parents 8deb31f + 694b064 commit a92a5f2
Show file tree
Hide file tree
Showing 23 changed files with 1,434 additions and 431 deletions.
70 changes: 70 additions & 0 deletions Fireworks/Calo/interface/FWBoxRecHit.h
@@ -0,0 +1,70 @@
#ifndef _FWBOXRECHIT_H_
#define _FWBOXRECHIT_H_

// -*- C++ -*-
//
// Package: ParticleFlow
// Class : FWBoxRecHit
//
// Implementation:
// <Notes on implementation>
//
// Original Author: Simon Harris
//

// System include files
#include "TEveBox.h"
#include "TEveCompound.h"
#include "TEveStraightLineSet.h"

#include "TEveCaloData.h"
#include "TEveChunkManager.h"

// User include files
#include "Fireworks/Core/interface/FWViewContext.h"
#include "Fireworks/Core/interface/FWViewEnergyScale.h"
#include "Fireworks/Core/interface/Context.h"

// Forward declarations
class FWProxyBuilderBase;

//-----------------------------------------------------------------------------
// FWBoxRechHit
//-----------------------------------------------------------------------------
class FWBoxRecHit
{
public:
// ---------------- Constructor(s)/Destructor ----------------------
FWBoxRecHit( const std::vector<TEveVector> &corners, TEveElement *comp,float e , float et);
virtual ~FWBoxRecHit(){}

// --------------------- Member Functions --------------------------
void updateScale( float scale, float maxLogVal, bool plotEt);
void setSquareColor( Color_t c ) { m_ls->SetMarkerColor(c); m_ls->SetLineColor(kBlack); }

TEveBox *getTower() { return m_tower; }
void setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2);
void addLine( float x1, float y1, float z1, float x2, float y2, float z2 );
void addLine( const TEveVector &v1, const TEveVector &v2 );
float getEnergy( bool b ) const { return b ? m_et : m_energy; }
bool isTallest() const { return m_isTallest; }
void setIsTallest( );

private:
FWBoxRecHit( const FWBoxRecHit& ); // Disable default
const FWBoxRecHit& operator=( const FWBoxRecHit& ); // Disable default

// --------------------- Member Functions --------------------------
void setupEveBox( std::vector<TEveVector> &corners, float scale );
void buildTower( const std::vector<TEveVector> &corners);
void buildLineSet( const std::vector<TEveVector> &corners);

// ----------------------- Data Members ----------------------------
TEveBox *m_tower;
TEveStraightLineSet *m_ls;
float m_energy;
float m_et;
bool m_isTallest;
};
#endif
//=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
92 changes: 92 additions & 0 deletions Fireworks/Calo/interface/FWECALCaloDataDetailViewBuilder.h
@@ -0,0 +1,92 @@
#include "Rtypes.h"
#include <map>
#include <vector>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"

namespace edm {
class EventBase;
}

class FWGeometry;
class TEveCaloDataVec;
class TEveCaloLego;
/*
// Less than operator for sorting clusters according to eta
class superClsterEtaLess : public std::binary_function<const reco::CaloCluster&, const reco::CaloCluster&, bool>
{
public:
bool operator()(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
{
return ( lhs.eta() < rhs.eta()) ;
}
};
*/

// builder class for ecal detail view
class FWECALCaloDataDetailViewBuilder {

public:

// construct an ecal detail view builder
// the arguments are the event, a pointer to geometry object,
// the eta and phi position to show,
// the half width of the region (in indices, e.g. iEta) and
// the default color for the hits.
FWECALCaloDataDetailViewBuilder(const edm::EventBase *event, const FWGeometry* geom,
float eta, float phi, int size = 50,
Color_t defaultColor = kMagenta+1)
: m_event(event), m_geom(geom),
m_eta(eta), m_phi(phi), m_size(size),
m_defaultColor(defaultColor){
}

// draw the ecal information with the preset colors
// (if any colors have been preset)
TEveCaloLego* build();

TEveCaloData* buildCaloData(bool xyEE);

// set colors of some predefined detids
void setColor(Color_t color, const std::vector<DetId> &detIds);

// show superclusters using two alternating colors
// to make adjacent clusters visible
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal);

// show a specific supercluster in a specific color
void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow);

// add legends; returns final y
double makeLegend(double x0 = 0.02, double y0 = 0.95,
Color_t clustered1=kGreen+1, Color_t clustered2=kTeal,
Color_t supercluster=kYellow);

private:

// fill data
void fillData(const EcalRecHitCollection *hits,
TEveCaloDataVec *data, bool xyEE);
const edm::EventBase *m_event; // the event
const FWGeometry *m_geom; // the geometry
float m_eta; // eta position view centred on
float m_phi; // phi position view centred on
int m_size; // view half width in number of crystals
Color_t m_defaultColor; // default color for crystals

// for keeping track of what det id goes in what slice
std::map<DetId, int> m_detIdsToColor;

// for keeping track of the colors to use for each slice
std::vector<Color_t> m_colors;

// sorting function to sort super clusters by eta.
static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
{
return ( lhs.eta() < rhs.eta());
}

};
37 changes: 37 additions & 0 deletions Fireworks/Calo/interface/FWECALDetailViewBase.h
@@ -0,0 +1,37 @@
#ifndef Fireworks_Core_FWFWEcalDetailViewBase_h
#define Fireworks_Core_FWFWEcalDetailViewBase_h

// #include "TEveViewer.h"
#include "Fireworks/Core/interface/FWDetailViewGL.h"

class TEveCaloData;
class TEveCaloLego;
class TLegend;
class FWECALDetailViewBuilder;

template <typename T>
class FWECALDetailViewBase : public FWDetailViewGL<T> {
public:
FWECALDetailViewBase ();//: m_data(0), m_builder(0), m_legend(0) {}
virtual ~FWECALDetailViewBase();// { delete m_data; }


protected:
TEveCaloData *m_data;
FWECALDetailViewBuilder *m_builder;
TLegend *m_legend;

private:
using FWDetailView<T>::build;
void build(const FWModelId &id, const T*);

using FWDetailViewGL<T>::setTextInfo;
void setTextInfo(const FWModelId &id, const T*);

};


#include "Fireworks/Calo/src/FWECALDetailViewBase.icc"

#endif

25 changes: 14 additions & 11 deletions Fireworks/Calo/interface/FWECALDetailViewBuilder.h
Expand Up @@ -5,6 +5,7 @@
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
#include "Fireworks/Calo/interface/FWBoxRecHit.h"

namespace edm {
class EventBase;
Expand Down Expand Up @@ -35,12 +36,8 @@ class FWECALDetailViewBuilder {
// the half width of the region (in indices, e.g. iEta) and
// the default color for the hits.
FWECALDetailViewBuilder(const edm::EventBase *event, const FWGeometry* geom,
float eta, float phi, int size = 50,
Color_t defaultColor = kMagenta+1)
: m_event(event), m_geom(geom),
m_eta(eta), m_phi(phi), m_size(size),
m_defaultColor(defaultColor){
}
float eta, float phi, int size = 50 , Color_t defaultColor = kMagenta+1);


// draw the ecal information with the preset colors
// (if any colors have been preset)
Expand All @@ -66,25 +63,31 @@ class FWECALDetailViewBuilder {
private:

// fill data
void fillData(const EcalRecHitCollection *hits,
TEveCaloDataVec *data, bool xyEE);
void fillData(TEveCaloDataVec *data);

void fillEtaPhi(const EcalRecHitCollection *hits, TEveCaloDataVec *data);

const edm::EventBase *m_event; // the event
const FWGeometry *m_geom; // the geometry
float m_eta; // eta position view centred on
float m_phi; // phi position view centred on
int m_size; // view half width in number of crystals
int m_size; // view half width in number of crystals
Color_t m_defaultColor; // default color for crystals


std::vector<FWBoxRecHit*> m_boxes;

// for keeping track of what det id goes in what slice
std::map<DetId, int> m_detIdsToColor;

// for keeping track of the colors to use for each slice
std::vector<Color_t> m_colors;
TEveElement* m_towerList;

// sorting function to sort super clusters by eta.
static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
{
return ( lhs.eta() < rhs.eta());
}

float sizeRad() const;

};

0 comments on commit a92a5f2

Please sign in to comment.