CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCaloTauProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWCaloTauProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 // $Id: FWCaloTauProxyBuilder.cc,v 1.17 2012/03/23 00:08:29 amraktad Exp $
12 //
13 
14 // system include files
15 #include "TEveCompound.h"
16 #include "TGeoTube.h"
17 #include "TEveGeoNode.h"
18 #include "TEveStraightLineSet.h"
19 #include "TEveTrack.h"
20 
21 // user include files
27 
31 
32 class FWViewContext;
33 
35 {
36 public:
39 
41 
42 private:
43  FWCaloTauProxyBuilder(const FWCaloTauProxyBuilder&); // stop default
44  const FWCaloTauProxyBuilder& operator=(const FWCaloTauProxyBuilder&); // stop default
45 
46  virtual void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc);
47 
48 };
49 
50 void
51 FWCaloTauProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc)
52 {
53  reco::CaloTauCollection const * caloTaus = 0;
54  iItem->get( caloTaus );
55  if( caloTaus == 0 ) return;
56 
57 
58  Int_t idx = 0;
59  for( reco::CaloTauCollection::const_iterator it = caloTaus->begin(), itEnd = caloTaus->end(); it != itEnd; ++it, ++idx)
60  {
61  TEveCompound* comp = createCompound();
62 
63  if (viewType == FWViewType::kLego)
64  {
65  fireworks::addCircle( (*it).eta(), (*it).phi(), 0.5, 20, comp, this );
66  }
67  else
68  {
69  try {
70  const reco::CaloTauTagInfo *tauTagInfo = dynamic_cast<const reco::CaloTauTagInfo*>(((*it).caloTauTagInfoRef().get()));
71  const reco::CaloJet *jet = dynamic_cast<const reco::CaloJet*>((tauTagInfo->calojetRef().get()));
72 
73  int min = 100;
74  int max = -100;
75  std::vector<double> phis;
76  std::vector<CaloTowerPtr> towers = jet->getCaloConstituents();
77  for( std::vector<CaloTowerPtr>::const_iterator tower = towers.begin(), towerEnd = towers.end();
78  tower != towerEnd; ++tower )
79  {
80  unsigned int ieta = 41 + (*tower)->id().ieta();
81  if( ieta > 40 ) --ieta;
82  assert( ieta <= 82 );
83 
84  if( int(ieta) > max ) max = ieta;
85  if( int(ieta) < min ) min = ieta;
86  m_phis.push_back( (*tower)->phi() );
87  }
88  if( min > max ) {
89  min = 0; max = 0;
90  }
91  const std::vector<std::pair<double, double> > thetaBins = fireworks::thetaBins();
92  m_minTheta = thetaBins[min].first;
93  m_maxTheta = thetaBins[max].second;
94 
95  buildBaseTau(*it, jet, comp, viewType, vc);
96  m_phis.clear();
97  }
98  catch (std::exception& e)
99  {
100  fwLog(fwlog::kInfo) << "FWPFTauProxyBuilder missing PFTauTagInfo. Skip drawing of jets.\n";
101  buildBaseTau(*it, 0, comp, viewType, vc);
102  }
103  }
104  setupAddElement( comp, product );
105  }
106 }
107 
108 
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Jets made from CaloTowers.
Definition: CaloJet.h:30
static const int kAllRPZBits
Definition: FWViewType.h:59
const CaloJetRef & calojetRef() const
const FWCaloTauProxyBuilder & operator=(const FWCaloTauProxyBuilder &)
std::vector< std::pair< double, double > > thetaBins()
Definition: thetaBins.cc:49
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
#define min(a, b)
Definition: mlp_lapack.h:161
virtual void buildViewType(const FWEventItem *iItem, TEveElementList *product, FWViewType::EType viewType, const FWViewContext *vc)
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:94
static const int kAll3DBits
Definition: FWViewType.h:60
std::vector< CaloTau > CaloTauCollection
collection of CaloTau objects
Definition: CaloTauFwd.h:9
void buildBaseTau(const reco::BaseTau &iTau, const reco::Jet *iJet, TEveElement *comp, FWViewType::EType type, const FWViewContext *vc)
const T & max(const T &a, const T &b)
void addCircle(double eta, double phi, double radius, const unsigned int nLineSegments, TEveElement *comp, FWProxyBuilderBase *pb)
#define fwLog(_level_)
Definition: fwLog.h:51
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::vector< double > m_phis
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242