CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCaloTowerSliceSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWCaloTowerSliceSelector
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Wed Jun 2 17:36:23 CEST 2010
11 //
12 
13 // system include files
14 
15 // user include files
16 #include "TH2F.h"
17 #include "TMath.h"
23 
24 
27  m_hist(h)
28 {
29 }
30 
32 {
33 }
34 
35 //
36 // member functions
37 //
38 //
39 
40 bool
41 FWCaloTowerSliceSelector::matchCell(const TEveCaloData::CellId_t& iCell, const CaloTower& tower) const
42 {
43  bool match = false;
44  int idx = m_hist->FindBin(tower.eta(), tower.phi());
45  int nBinsX = m_hist->GetXaxis()->GetNbins() + 2;
46 
47  int etaBin, phiBin, w, newPhiBin;
48  m_hist->GetBinXYZ(idx, etaBin, phiBin, w);
49 
50  if (tower.ietaAbs() > 39)
51  {
52  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
53  if (newPhiBin <= 0) newPhiBin = 71;
54 
55  idx = etaBin + newPhiBin*nBinsX;
56  match |= (idx == iCell.fTower);
57 
58  idx += nBinsX;
59  match |= (idx == iCell.fTower);
60 
61  idx += nBinsX;
62  if (newPhiBin == 71)
63  idx = etaBin + 1*nBinsX;
64  match |= (idx == iCell.fTower);
65 
66  idx += nBinsX;
67  match |= (idx == iCell.fTower);
68  }
69  else if (tower.ietaAbs() > 20)
70  {
71  newPhiBin = ((phiBin + 1) / 2) * 2 -1;
72  idx = etaBin + newPhiBin*nBinsX;
73  match = ( idx == iCell.fTower || idx + nBinsX == iCell.fTower);
74  }
75  else
76  {
77  match = ( idx == iCell.fTower);
78  }
79  return match;
80 }
81 
82 void
83 FWCaloTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell)
84 {
85  if (!m_item) return;
86 
87  const CaloTowerCollection* towers=0;
88  m_item->get(towers);
89  assert(0!=towers);
90  int index = 0;
91 
92  FWChangeSentry sentry(*(m_item->changeManager()));
93  for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
94  {
96  {
97  if (matchCell(iCell, *tower))
98  {
99  m_item->select(index);
100  break;
101  }
102  }
103  }
104 }
105 
106 void
107 FWCaloTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell)
108 {
109  if (!m_item) return;
110 
111  // std::cout <<" doUnselect "<<std::endl;
112 
113  const CaloTowerCollection* towers=0;
114  m_item->get(towers);
115  assert(0!=towers);
116  int index = 0;
117  FWChangeSentry sentry(*(m_item->changeManager()));
118  for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
119  {
121  m_item->modelInfo(index).isSelected()) {
122  if (matchCell(iCell, *tower))
123  {
124  // std::cout <<" doUnselect "<<index<<std::endl;
125  m_item->unselect(index);
126  break;
127  }
128  }
129  }
130 }
virtual void doUnselect(const TEveCaloData::CellId_t &)
int i
Definition: DBlmapReader.cc:9
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:130
bool isSelected() const
Definition: FWEventItem.h:70
void get(const T *&oData) const
Definition: FWEventItem.h:84
std::vector< CaloTower >::const_iterator const_iterator
void unselect(int iIndex) const
Definition: FWEventItem.cc:239
const FWEventItem * m_item
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
bool matchCell(const TEveCaloData::CellId_t &iCell, const CaloTower &tower) const
FWDisplayProperties m_displayProperties
Definition: FWEventItem.h:60
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
const_iterator end() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
FWCaloTowerSliceSelector(TH2F *h, const FWEventItem *i)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual void doSelect(const TEveCaloData::CellId_t &)
int ietaAbs() const
Definition: CaloTower.h:153
void select(int iIndex) const
Definition: FWEventItem.cc:250
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
T w() const
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
const_iterator begin() const