CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Calo
00004 // Class  :     FWPFTauProxyBuilder
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:
00010 //         Created:  Sun Jan  6 23:57:00 EST 2008
00011 // $Id: FWPFTauProxyBuilder.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/fwLog.h"
00026 #include "Fireworks/Core/interface/BuilderUtils.h"
00027 
00028 
00029 #include "DataFormats/TauReco/interface/PFTau.h"
00030 #include "DataFormats/TrackReco/interface/Track.h"
00031 
00032 class FWPFTauProxyBuilder : public FWTauProxyBuilderBase
00033 {
00034 public:
00035    FWPFTauProxyBuilder() {}
00036    virtual ~FWPFTauProxyBuilder() {}
00037 
00038    REGISTER_PROXYBUILDER_METHODS();
00039 
00040 private:
00041    FWPFTauProxyBuilder( const FWPFTauProxyBuilder& );    // stop default
00042    const FWPFTauProxyBuilder& operator=( const FWPFTauProxyBuilder& );    // stop default
00043 
00044    virtual void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType type , const FWViewContext*);
00045 };
00046 
00047 void
00048 FWPFTauProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType viewType , const FWViewContext* vc)
00049 {
00050    reco::PFTauCollection const * pfTaus = 0;
00051    iItem->get( pfTaus );
00052    if( pfTaus == 0 ) return;
00053 
00054    for( reco::PFTauCollection::const_iterator it = pfTaus->begin(), itEnd = pfTaus->end(); it != itEnd; ++it)
00055    { 
00056       TEveCompound* comp = createCompound();
00057       if (viewType == FWViewType::kLego)
00058       {
00059          fireworks::addCircle( (*it).eta(), (*it).phi(), 0.5, 20, comp, this );
00060       }
00061       else
00062       {
00063          // prepare phi-list and theta range
00064          try {
00065             const reco::PFTauTagInfo *tauTagInfo = dynamic_cast<const reco::PFTauTagInfo*>( (*it).pfTauTagInfoRef().get() );
00066             const reco::PFJet *jet = dynamic_cast<const reco::PFJet*>( tauTagInfo->pfjetRef().get() );
00067             m_minTheta =  100;
00068             m_maxTheta = -100;
00069             std::vector<double> phis;
00070             std::vector <const reco::Candidate*> candidates = jet->getJetConstituentsQuick();
00071             for( std::vector<const reco::Candidate*>::const_iterator candidate = candidates.begin(), candidateEnd = candidates.end();
00072                  candidate != candidateEnd; ++candidate )
00073             {
00074                double itheta = (*candidate)->theta();
00075                if( itheta > m_maxTheta ) m_maxTheta = itheta;
00076                if( itheta < m_minTheta ) m_minTheta = itheta;
00077 
00078                m_phis.push_back( (*candidate)->phi() );
00079             }
00080             if( m_minTheta > m_maxTheta ) {     
00081                m_minTheta = 0;
00082                m_maxTheta = 0;
00083             }
00084 
00085             buildBaseTau(*it, jet, comp, viewType, vc);
00086             m_phis.clear();
00087          }
00088          catch (std::exception&  e)
00089          { 
00090             fwLog(fwlog::kInfo) << "FWPFTauProxyBuilder missing PFTauTagInfo. Skip drawing of jets.\n";
00091             buildBaseTau(*it, 0, comp, viewType, vc);         
00092          }
00093       }
00094       setupAddElement( comp, product );
00095    }
00096 }
00097 
00098 REGISTER_FWPROXYBUILDER( FWPFTauProxyBuilder, reco::PFTauCollection, "PFTau", FWViewType::kAll3DBits | FWViewType::kAllRPZBits | FWViewType::kAllLegoBits);
00099