CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWHFTowerSliceSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWHFTowerSliceSelector
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 FWHFTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell)
35 {
36  if (!m_item) return;
37 
38  const HFRecHitCollection* hits=0;
39  m_item->get(hits);
40  assert(0!=hits);
41 
42  int index = 0;
43  FWChangeSentry sentry(*(m_item->changeManager()));
44  for(HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
45  {
46  HcalDetId 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 FWHFTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell)
58 {
59  if (!m_item) return;
60 
61  const HFRecHitCollection* hits=0;
62  m_item->get(hits);
63  assert(0!=hits);
64 
65  int index = 0;
66  FWChangeSentry sentry(*(m_item->changeManager()));
67  for(HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
68  {
69  HcalDetId 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 == 0 )
85  {
86  fwLog( fwlog::kInfo ) << "FWHFTowerSliceSelector 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 }
int i
Definition: DBlmapReader.cc:9
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:130
bool isSelected() const
Definition: FWEventItem.h:70
assert(m_qm.get())
void get(const T *&oData) const
Definition: FWEventItem.h:84
std::vector< HFRecHit >::const_iterator const_iterator
void unselect(int iIndex) const
Definition: FWEventItem.cc:239
const FWEventItem * m_item
virtual void doUnselect(const TEveCaloData::CellId_t &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int j
Definition: DBlmapReader.cc:9
FWDisplayProperties m_displayProperties
Definition: FWEventItem.h:60
const_iterator end() const
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:280
#define fwLog(_level_)
Definition: fwLog.h:50
bool findBinFromId(HcalDetId &id, int tower) const
void select(int iIndex) const
Definition: FWEventItem.cc:250
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
virtual void doSelect(const TEveCaloData::CellId_t &)
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
const_iterator begin() const