CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Calo/interface/FWECALDetailViewBuilder.h

Go to the documentation of this file.
00001 #include "Rtypes.h"
00002 #include <map>
00003 #include <vector>
00004 #include "DataFormats/DetId/interface/DetId.h"
00005 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00006 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00007 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00008 
00009 namespace edm {
00010    class EventBase;
00011 }
00012 
00013 class FWGeometry;
00014 class TEveCaloDataVec;
00015 class TEveCaloLego;
00016 
00017 // Less than operator for sorting clusters according to eta
00018 class superClsterEtaLess : public std::binary_function<const reco::CaloCluster&, const reco::CaloCluster&, bool>
00019 {
00020 public:
00021    bool operator()(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
00022    {
00023       return ( lhs.eta() < rhs.eta()) ;
00024    }
00025 };
00026 
00027 // builder class for ecal detail view
00028 class FWECALDetailViewBuilder {
00029 
00030 public:
00031 
00032    // construct an ecal detail view builder
00033    // the arguments are the event, a pointer to geometry object,
00034    // the eta and phi position to show,
00035    // the half width of the region (in indices, e.g. iEta) and
00036    // the default color for the hits.
00037    FWECALDetailViewBuilder(const edm::EventBase *event, const FWGeometry* geom,
00038                            float eta, float phi, int size = 50,
00039                            Color_t defaultColor = kMagenta+1)
00040       : m_event(event), m_geom(geom),
00041         m_eta(eta), m_phi(phi), m_size(size),
00042         m_defaultColor(defaultColor){
00043    }
00044 
00045    // draw the ecal information with the preset colors
00046    // (if any colors have been preset)
00047    TEveCaloLego* build();
00048 
00049    // set colors of some predefined detids
00050    void setColor(Color_t color, const std::vector<DetId> &detIds);
00051 
00052    // show superclusters using two alternating colors
00053    // to make adjacent clusters visible
00054    void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal);
00055 
00056    // show a specific supercluster in a specific color
00057    void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow);
00058 
00059    // add legends; returns final y
00060    double makeLegend(double x0 = 0.02, double y0 = 0.95,
00061                      Color_t clustered1=kGreen+1, Color_t clustered2=kTeal,
00062                      Color_t supercluster=kYellow);
00063 
00064 private:
00065 
00066    // fill data
00067    void fillData(const EcalRecHitCollection *hits,
00068                  TEveCaloDataVec *data);
00069    const edm::EventBase *m_event;                               // the event
00070    const FWGeometry     *m_geom;                                // the geometry
00071    float m_eta;                                                 // eta position view centred on
00072    float m_phi;                                                 // phi position view centred on
00073    int m_size;                                                  // view half width in number of crystals
00074    Color_t m_defaultColor;                                      // default color for crystals
00075 
00076    // for keeping track of what det id goes in what slice
00077    std::map<DetId, int> m_detIdsToColor;
00078 
00079    // for keeping track of the colors to use for each slice
00080    std::vector<Color_t> m_colors;
00081 
00082    // sorting function to sort super clusters by eta.
00083    static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs)
00084    {
00085       return ( lhs.eta() < rhs.eta());
00086    }
00087 
00088 };