CMS 3D CMS Logo

FWHGTowerSliceSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWHGTowerSliceSelector
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Wed Jun 2 17:39:44 CEST 2010
11 //
12 
13 // system include files
14 
15 // user include files
16 #include "TEveVector.h"
17 #include "TEveCaloData.h"
18 #include "TH2F.h"
19 
27 
28 
29 //
30 // member functions
31 //
32 
33 void
34 FWHGTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell)
35 {
36  if (!m_item) return;
37 
38  const HGCRecHitCollection* hits=nullptr;
39  m_item->get(hits);
40  assert(nullptr!=hits);
41 
42  int index = 0;
43  FWChangeSentry sentry(*(m_item->changeManager()));
44  for(HGCRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
45  {
46  HGCalDetId id ((*it).detid().rawId());
47  if (findBinFromId(id, iCell.fTower) &&
49  !m_item->modelInfo(index).isSelected()) {
50  // std::cout <<" doSelect "<<index<<std::endl;
51  m_item->select(index);
52  }
53  }
54 }
55 
56 void
57 FWHGTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell)
58 {
59  if (!m_item) return;
60 
61  const HGCRecHitCollection* hits=nullptr;
62  m_item->get(hits);
63  assert(nullptr!=hits);
64 
65  int index = 0;
66  FWChangeSentry sentry(*(m_item->changeManager()));
67  for(HGCRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
68  {
69  HGCalDetId id ((*it).detid().rawId());
70  if (findBinFromId(id, iCell.fTower) &&
72  m_item->modelInfo(index).isSelected()) {
73  // std::cout <<" doUnselect "<<index<<std::endl;
74  m_item->unselect(index);
75  }
76  }
77 }
78 
79 bool
81 {
82  TEveCaloData::vCellId_t cellIds;
83  const float* corners = m_item->getGeom()->getCorners( detId.rawId());
84  if( corners == nullptr )
85  {
86  fwLog( fwlog::kInfo ) << "FWHGTowerSliceSelector cannot get geometry for DetId: "<< detId.rawId() << ". Ignored.\n";
87  return false;
88  }
89  std::vector<TEveVector> front( 4 );
90  float eta = 0, phi = 0;
91  int j = 0;
92  for( int i = 0; i < 4; ++i )
93  {
94  front[i] = TEveVector( corners[j], corners[j + 1], corners[j + 2] );
95  j +=3;
96 
97  eta += front[i].Eta();
98  phi += front[i].Phi();
99  }
100  eta /= 4;
101  phi /= 4;
102 
103  const TEveCaloData::CellGeom_t &cg = m_vecData->GetCellGeom()[tower] ;
104  if(( eta >= cg.fEtaMin && eta <= cg.fEtaMax) && (phi >= cg.fPhiMin && phi <= cg.fPhiMax))
105  {
106  return true;
107  }
108 
109  return false;
110 }
void doSelect(const TEveCaloData::CellId_t &) override
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:132
bool isSelected() const
Definition: FWEventItem.h:71
bool findBinFromId(HGCalDetId &id, int tower) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
void doUnselect(const TEveCaloData::CellId_t &) override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
std::vector< HGCRecHit >::const_iterator const_iterator
void unselect(int iIndex) const
Definition: FWEventItem.cc:241
const FWEventItem * m_item
FWDisplayProperties m_displayProperties
Definition: FWEventItem.h:61
const_iterator end() const
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:297
#define fwLog(_level_)
Definition: fwLog.h:50
void select(int iIndex) const
Definition: FWEventItem.cc:252
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683
const_iterator begin() const