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 // $Id: FWCaloTowerSliceSelector.cc,v 1.3 2010/12/01 21:40:31 amraktad Exp $
12 //
13 
14 // system include files
15 
16 // user include files
17 #include "TH2F.h"
18 #include "TMath.h"
24 
25 
28  m_hist(h)
29 {
30 }
31 
33 {
34 }
35 
36 //
37 // member functions
38 //
39 //
40 
41 bool
42 FWCaloTowerSliceSelector::matchCell(const TEveCaloData::CellId_t& iCell, const CaloTower& tower) const
43 {
44  bool match = false;
45  int idx = m_hist->FindBin(tower.eta(), tower.phi());
46  int nBinsX = m_hist->GetXaxis()->GetNbins() + 2;
47 
48  int etaBin, phiBin, w, newPhiBin;
49  m_hist->GetBinXYZ(idx, etaBin, phiBin, w);
50 
51  if (tower.ietaAbs() > 39)
52  {
53  newPhiBin = ((phiBin + 1) / 4) * 4 - 1;
54  if (newPhiBin <= 0) newPhiBin = 71;
55 
56  idx = etaBin + newPhiBin*nBinsX;
57  match |= (idx == iCell.fTower);
58 
59  idx += nBinsX;
60  match |= (idx == iCell.fTower);
61 
62  idx += nBinsX;
63  if (newPhiBin == 71)
64  idx = etaBin + 1*nBinsX;
65  match |= (idx == iCell.fTower);
66 
67  idx += nBinsX;
68  match |= (idx == iCell.fTower);
69  }
70  else if (tower.ietaAbs() > 20)
71  {
72  newPhiBin = ((phiBin + 1) / 2) * 2 -1;
73  idx = etaBin + newPhiBin*nBinsX;
74  match = ( idx == iCell.fTower || idx + nBinsX == iCell.fTower);
75  }
76  else
77  {
78  match = ( idx == iCell.fTower);
79  }
80  return match;
81 }
82 
83 void
84 FWCaloTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell)
85 {
86  if (!m_item) return;
87 
88  const CaloTowerCollection* towers=0;
89  m_item->get(towers);
90  assert(0!=towers);
91  int index = 0;
92 
93  FWChangeSentry sentry(*(m_item->changeManager()));
94  for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
95  {
97  {
98  if (matchCell(iCell, *tower))
99  {
100  m_item->select(index);
101  break;
102  }
103  }
104  }
105 }
106 
107 void
108 FWCaloTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell)
109 {
110  if (!m_item) return;
111 
112  // std::cout <<" doUnselect "<<std::endl;
113 
114  const CaloTowerCollection* towers=0;
115  m_item->get(towers);
116  assert(0!=towers);
117  int index = 0;
118  FWChangeSentry sentry(*(m_item->changeManager()));
119  for(CaloTowerCollection::const_iterator tower = towers->begin(); tower != towers->end(); ++tower,++index)
120  {
122  m_item->modelInfo(index).isSelected()) {
123  if (matchCell(iCell, *tower))
124  {
125  // std::cout <<" doUnselect "<<index<<std::endl;
126  m_item->unselect(index);
127  break;
128  }
129  }
130  }
131 }
virtual void doUnselect(const TEveCaloData::CellId_t &)
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< CaloTower >::const_iterator const_iterator
void unselect(int iIndex) const
Definition: FWEventItem.cc:240
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:61
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:155
void select(int iIndex) const
Definition: FWEventItem.cc:251
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:536
const_iterator begin() const