Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:26

0001 #include "Rtypes.h"
0002 #include "DataFormats/DetId/interface/DetId.h"
0003 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0004 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0005 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0006 
0007 #include <map>
0008 #include <vector>
0009 
0010 namespace edm {
0011   class EventBase;
0012 }
0013 
0014 class FWGeometry;
0015 class TEveCaloData;
0016 class TEveCaloDataVec;
0017 class TEveCaloLego;
0018 
0019 // builder class for ecal detail view
0020 class FWECALCaloDataDetailViewBuilder {
0021 public:
0022   // construct an ecal detail view builder
0023   // the arguments are the event, a pointer to geometry object,
0024   // the eta and phi position to show,
0025   // the half width of the region (in indices, e.g. iEta) and
0026   // the default color for the hits.
0027   FWECALCaloDataDetailViewBuilder(const edm::EventBase *event,
0028                                   const FWGeometry *geom,
0029                                   float eta,
0030                                   float phi,
0031                                   int size = 50,
0032                                   Color_t defaultColor = kMagenta + 1)
0033       : m_event(event), m_geom(geom), m_eta(eta), m_phi(phi), m_size(size), m_defaultColor(defaultColor) {}
0034 
0035   // draw the ecal information with the preset colors
0036   // (if any colors have been preset)
0037   TEveCaloLego *build();
0038 
0039   TEveCaloData *buildCaloData(bool xyEE);
0040 
0041   // set colors of some predefined detids
0042   void setColor(Color_t color, const std::vector<DetId> &detIds);
0043 
0044   // show superclusters using two alternating colors
0045   // to make adjacent clusters visible
0046   void showSuperClusters(Color_t color1 = kGreen + 2, Color_t color2 = kTeal);
0047 
0048   // show a specific supercluster in a specific color
0049   void showSuperCluster(const reco::SuperCluster &cluster, Color_t color = kYellow);
0050 
0051   // add legends; returns final y
0052   double makeLegend(double x0 = 0.02,
0053                     double y0 = 0.95,
0054                     Color_t clustered1 = kGreen + 1,
0055                     Color_t clustered2 = kTeal,
0056                     Color_t supercluster = kYellow);
0057 
0058 private:
0059   // fill data
0060   void fillData(const EcalRecHitCollection *hits, TEveCaloDataVec *data, bool xyEE);
0061   const edm::EventBase *m_event;  // the event
0062   const FWGeometry *m_geom;       // the geometry
0063   float m_eta;                    // eta position view centred on
0064   float m_phi;                    // phi position view centred on
0065   int m_size;                     // view half width in number of crystals
0066   Color_t m_defaultColor;         // default color for crystals
0067 
0068   // for keeping track of what det id goes in what slice
0069   std::map<DetId, int> m_detIdsToColor;
0070 
0071   // for keeping track of the colors to use for each slice
0072   std::vector<Color_t> m_colors;
0073 
0074   // sorting function to sort super clusters by eta.
0075   static bool superClusterEtaLess(const reco::CaloCluster &lhs, const reco::CaloCluster &rhs) {
0076     return (lhs.eta() < rhs.eta());
0077   }
0078 };