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 // $Id: FWHFTowerSliceSelector.cc,v 1.9 2010/09/07 15:46:45 yana Exp $
12 //
13 
14 // system include files
15 
16 // user include files
17 #include "TEveVector.h"
18 #include "TEveCaloData.h"
19 #include "TH2F.h"
20 
28 
29 
30 //
31 // member functions
32 //
33 
34 void
35 FWHFTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell)
36 {
37  if (!m_item) return;
38 
39  const HFRecHitCollection* hits=0;
40  m_item->get(hits);
41  assert(0!=hits);
42 
43  int index = 0;
44  FWChangeSentry sentry(*(m_item->changeManager()));
45  for(HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
46  {
47  HcalDetId id ((*it).detid().rawId());
48  if (findBinFromId(id, iCell.fTower) &&
50  !m_item->modelInfo(index).isSelected()) {
51  // std::cout <<" doSelect "<<index<<std::endl;
52  m_item->select(index);
53  }
54  }
55 }
56 
57 void
58 FWHFTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell)
59 {
60  if (!m_item) return;
61 
62  const HFRecHitCollection* hits=0;
63  m_item->get(hits);
64  assert(0!=hits);
65 
66  int index = 0;
67  FWChangeSentry sentry(*(m_item->changeManager()));
68  for(HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it,++index)
69  {
70  HcalDetId id ((*it).detid().rawId());
71  if (findBinFromId(id, iCell.fTower) &&
73  m_item->modelInfo(index).isSelected()) {
74  // std::cout <<" doUnselect "<<index<<std::endl;
75  m_item->unselect(index);
76  }
77  }
78 }
79 
80 bool
82 {
83  TEveCaloData::vCellId_t cellIds;
84  const float* corners = m_item->getGeom()->getCorners( detId.rawId());
85  if( corners == 0 )
86  {
87  fwLog( fwlog::kInfo ) << "FWHFTowerSliceSelector cannot get geometry for DetId: "<< detId.rawId() << ". Ignored.\n";
88  return false;
89  }
90  std::vector<TEveVector> front( 4 );
91  float eta = 0, phi = 0;
92  int j = 0;
93  for( int i = 0; i < 4; ++i )
94  {
95  front[i] = TEveVector( corners[j], corners[j + 1], corners[j + 2] );
96  j +=3;
97 
98  eta += front[i].Eta();
99  phi += front[i].Phi();
100  }
101  eta /= 4;
102  phi /= 4;
103 
104  const TEveCaloData::CellGeom_t &cg = m_vecData->GetCellGeom()[tower] ;
105  if(( eta >= cg.fEtaMin && eta <= cg.fEtaMax) && (phi >= cg.fPhiMin && phi <= cg.fPhiMax))
106  {
107  return true;
108  }
109 
110  return false;
111 }
int i
Definition: DBlmapReader.cc:9
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:131
bool isSelected() const
Definition: FWEventItem.h:71
void get(const T *&oData) const
Definition: FWEventItem.h:85
std::vector< T >::const_iterator const_iterator
void unselect(int iIndex) const
Definition: FWEventItem.cc:240
T eta() const
const FWEventItem * m_item
virtual void doUnselect(const TEveCaloData::CellId_t &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int j
Definition: DBlmapReader.cc:9
FWDisplayProperties m_displayProperties
Definition: FWEventItem.h:61
const_iterator end() const
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:278
#define fwLog(_level_)
Definition: fwLog.h:51
bool findBinFromId(HcalDetId &id, int tower) const
void select(int iIndex) const
Definition: FWEventItem.cc:251
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
Definition: DDAxes.h:10