CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Fireworks/Calo/plugins/FWCaloTauProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Calo
00004 // Class  :     FWCaloTauProxyBuilder
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:
00010 //         Created:  Sun Jan  6 23:57:00 EST 2008
00011 // $Id: FWCaloTauProxyBuilder.cc,v 1.16 2010/10/22 14:34:44 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include "TEveCompound.h"
00016 #include "TGeoTube.h"
00017 #include "TEveGeoNode.h"
00018 #include "TEveStraightLineSet.h"
00019 #include "TEveTrack.h"
00020 
00021 // user include files
00022 #include "Fireworks/Calo/interface/FWTauProxyBuilderBase.h"
00023 #include "Fireworks/Core/interface/FWEventItem.h"
00024 #include "Fireworks/Core/interface/FWViewType.h"
00025 #include "Fireworks/Core/interface/BuilderUtils.h"
00026 
00027 #include "Fireworks/Calo/interface/thetaBins.h"
00028 #include "DataFormats/TauReco/interface/CaloTau.h"
00029 #include "DataFormats/TauReco/interface/CaloTauFwd.h"
00030 
00031 class FWViewContext;
00032 
00033 class FWCaloTauProxyBuilder : public FWTauProxyBuilderBase
00034 {
00035 public:
00036    FWCaloTauProxyBuilder() {}
00037    virtual ~FWCaloTauProxyBuilder() {}
00038   
00039    REGISTER_PROXYBUILDER_METHODS();
00040 
00041 private:
00042    FWCaloTauProxyBuilder(const FWCaloTauProxyBuilder&);    // stop default
00043    const FWCaloTauProxyBuilder& operator=(const FWCaloTauProxyBuilder&);    // stop default
00044 
00045    virtual void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc);
00046 
00047 };
00048 
00049 void
00050 FWCaloTauProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc)
00051 {
00052    reco::CaloTauCollection const * caloTaus = 0;
00053    iItem->get( caloTaus );
00054    if( caloTaus == 0 ) return;
00055 
00056       
00057    Int_t idx = 0;
00058    for( reco::CaloTauCollection::const_iterator it = caloTaus->begin(), itEnd = caloTaus->end(); it != itEnd; ++it, ++idx)
00059    {  
00060       TEveCompound* comp = createCompound();
00061 
00062       if (viewType == FWViewType::kLego)
00063       {
00064          fireworks::addCircle( (*it).eta(), (*it).phi(), 0.5, 20, comp, this );
00065       }
00066       else
00067       {
00068          const reco::CaloTauTagInfo *tauTagInfo = dynamic_cast<const reco::CaloTauTagInfo*>(((*it).caloTauTagInfoRef().get()));
00069          const reco::CaloJet *jet = dynamic_cast<const reco::CaloJet*>((tauTagInfo->calojetRef().get()));
00070 
00071          int min =  100;
00072          int max = -100;
00073          std::vector<double> phis;
00074          std::vector<CaloTowerPtr> towers = jet->getCaloConstituents();
00075          for( std::vector<CaloTowerPtr>::const_iterator tower = towers.begin(), towerEnd = towers.end();
00076               tower != towerEnd; ++tower )
00077          {
00078             unsigned int ieta = 41 + (*tower)->id().ieta();
00079             if( ieta > 40 ) --ieta;
00080             assert( ieta <= 82 );
00081          
00082             if( int(ieta) > max ) max = ieta;
00083             if( int(ieta) < min ) min = ieta;
00084             m_phis.push_back( (*tower)->phi() );
00085          }
00086          if( min > max ) {      
00087             min = 0; max = 0;
00088          }
00089          const std::vector<std::pair<double, double> > thetaBins = fireworks::thetaBins();
00090          m_minTheta = thetaBins[min].first;
00091          m_maxTheta = thetaBins[max].second;
00092 
00093          buildBaseTau(*it, *jet, comp, viewType, vc);
00094          m_phis.clear();
00095       }  
00096       setupAddElement( comp, product );
00097    }    
00098 
00099 }
00100 
00101 
00102 REGISTER_FWPROXYBUILDER(FWCaloTauProxyBuilder, reco::CaloTauCollection, "CaloTau", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);