CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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.17 2012/03/23 00:08:29 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 #include "Fireworks/Core/interface/fwLog.h"
00027 
00028 #include "Fireworks/Calo/interface/thetaBins.h"
00029 #include "DataFormats/TauReco/interface/CaloTau.h"
00030 #include "DataFormats/TauReco/interface/CaloTauFwd.h"
00031 
00032 class FWViewContext;
00033 
00034 class FWCaloTauProxyBuilder : public FWTauProxyBuilderBase
00035 {
00036 public:
00037    FWCaloTauProxyBuilder() {}
00038    virtual ~FWCaloTauProxyBuilder() {}
00039   
00040    REGISTER_PROXYBUILDER_METHODS();
00041 
00042 private:
00043    FWCaloTauProxyBuilder(const FWCaloTauProxyBuilder&);    // stop default
00044    const FWCaloTauProxyBuilder& operator=(const FWCaloTauProxyBuilder&);    // stop default
00045 
00046    virtual void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc);
00047 
00048 };
00049 
00050 void
00051 FWCaloTauProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc)
00052 {
00053    reco::CaloTauCollection const * caloTaus = 0;
00054    iItem->get( caloTaus );
00055    if( caloTaus == 0 ) return;
00056 
00057       
00058    Int_t idx = 0;
00059    for( reco::CaloTauCollection::const_iterator it = caloTaus->begin(), itEnd = caloTaus->end(); it != itEnd; ++it, ++idx)
00060    {  
00061       TEveCompound* comp = createCompound();
00062 
00063       if (viewType == FWViewType::kLego)
00064       {
00065          fireworks::addCircle( (*it).eta(), (*it).phi(), 0.5, 20, comp, this );
00066       }
00067       else
00068       {
00069          try {
00070             const reco::CaloTauTagInfo *tauTagInfo = dynamic_cast<const reco::CaloTauTagInfo*>(((*it).caloTauTagInfoRef().get()));
00071             const reco::CaloJet *jet = dynamic_cast<const reco::CaloJet*>((tauTagInfo->calojetRef().get()));
00072 
00073             int min =  100;
00074             int max = -100;
00075             std::vector<double> phis;
00076             std::vector<CaloTowerPtr> towers = jet->getCaloConstituents();
00077             for( std::vector<CaloTowerPtr>::const_iterator tower = towers.begin(), towerEnd = towers.end();
00078                  tower != towerEnd; ++tower )
00079             {
00080                unsigned int ieta = 41 + (*tower)->id().ieta();
00081                if( ieta > 40 ) --ieta;
00082                assert( ieta <= 82 );
00083          
00084                if( int(ieta) > max ) max = ieta;
00085                if( int(ieta) < min ) min = ieta;
00086                m_phis.push_back( (*tower)->phi() );
00087             }
00088             if( min > max ) {   
00089                min = 0; max = 0;
00090             }
00091             const std::vector<std::pair<double, double> > thetaBins = fireworks::thetaBins();
00092             m_minTheta = thetaBins[min].first;
00093             m_maxTheta = thetaBins[max].second;
00094 
00095             buildBaseTau(*it, jet, comp, viewType, vc);
00096             m_phis.clear();
00097          }  
00098          catch (std::exception&  e)
00099          { 
00100             fwLog(fwlog::kInfo) << "FWPFTauProxyBuilder missing PFTauTagInfo. Skip drawing of jets.\n";
00101             buildBaseTau(*it, 0, comp, viewType, vc);
00102          }
00103       }
00104       setupAddElement( comp, product );
00105    }
00106 }
00107 
00108 
00109 REGISTER_FWPROXYBUILDER(FWCaloTauProxyBuilder, reco::CaloTauCollection, "CaloTau", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);