Elaborated example of DaVinci algorithm using TriggerTisTos tool

THIS EXAMPLE IS OUT OF DATE AND NEEDS UPDATING PLEASE SEE PYTHON EXAMPLE INSTEAD AND DO EQUIVALENT CALLS IN C++ I WILL TRY TO UPDATE THIS PAGE SOON

cpp file

// from Gaudi
#include "GaudiKernel/AlgFactory.h" 

// local
#include "TisTosDVExample.h"

#include "Event/L0DUReport.h"

#include "Event/HltSummary.h"

using namespace LHCb;

//-----------------------------------------------------------------------------
// Implementation file for class : TisTosDVExample
//
// 2007-09-24 : Tomasz Skwarnicki
//-----------------------------------------------------------------------------

// Declaration of the Algorithm Factory
DECLARE_ALGORITHM_FACTORY( TisTosDVExample );


//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
TisTosDVExample::TisTosDVExample( const std::string& name,
                                  ISvcLocator* pSvcLocator)
  : DVAlgorithm ( name , pSvcLocator )
{

}
//=============================================================================
// Destructor
//=============================================================================
TisTosDVExample::~TisTosDVExample() {} 

//=============================================================================
// Initialization
//=============================================================================
StatusCode TisTosDVExample::initialize() {
  //=== The following two lines should be commented for DC04 algorithms ! ===
  StatusCode sc = DVAlgorithm::initialize(); 
  if ( sc.isFailure() ) return sc;

  debug() << "==> Initialize" << endmsg;

  m_TriggerTisTosTool = tool<ITriggerTisTos>( "TriggerTisTos",this);

  return StatusCode::SUCCESS;
}

//=============================================================================
// Main execution
//=============================================================================
StatusCode TisTosDVExample::execute() {

  debug() << "==> Execute" << endmsg;

  const std::vector<const Particle*> & parts = desktop()->particles();
  if( parts.size() == 0 )  return StatusCode::SUCCESS;

   //  L0 trigger
  if( !exist<L0DUReport>( L0DUReportLocation::Default ) ){ return StatusCode::SUCCESS;  }    
  const L0DUReport* pL0DUReport = get<L0DUReport>( L0DUReportLocation::Default );
  info() << " L0 decision= " << pL0DUReport->decision() << endmsg;

  std::vector<std::string> l0NamesInHlt = m_TriggerTisTosTool->triggerSelectionNames("L0*Decision", 
                                                                                     ITriggerTisTos::kAllTriggerSelections);
  info() << " Names of L0 triggers in Hlt="; dumpvs( l0NamesInHlt );  info() << endmsg;

   //  Hlt overall
  if( !exist<HltSummary>( LHCb::HltSummaryLocation::Default ) ){ return StatusCode::SUCCESS;  }    
  const HltSummary* pHltSummary = get<HltSummary>(LHCb::HltSummaryLocation::Default);
  info() << " Hlt final decision= " << pHltSummary->decision() << endmsg;

  //  Hlt1 (Alleys)
  bool hlt1Decision,dummyTis,dummyTos;
  m_TriggerTisTosTool->setOfflineInput();  
  m_TriggerTisTosTool->triggerTisTos("Hlt1*Decision",hlt1Decision,dummyTis,dummyTos, ITriggerTisTos::kAllTriggerSelections);
  // this also works: m_TriggerTisTosTool->triggerTisTos("*",hlt1Decision,dummyTis,dummyTos);
  info() << " Hlt1 decision= " << hlt1Decision;
  info() << " from OR between "; dumpvs( m_TriggerTisTosTool->triggerSelectionNames() ); info() << endmsg;

  //  Hlt2 (Selections) 
  bool hlt2Decision;
  m_TriggerTisTosTool->triggerTisTos("Hlt2*Decision",hlt2Decision,dummyTis,dummyTos, ITriggerTisTos::kAllTriggerSelections);
  info() << " Hlt2 decision= " << hlt2Decision;
  info() << " from OR between "; dumpvs( m_TriggerTisTosTool->triggerSelectionNames() ); info() << endmsg;

  //     see which Hlt1 triggers were on
  //done m_TriggerTisTosTool->setOfflineInput();   
  std::vector<std::string> hlt1Pass = m_TriggerTisTosTool->triggerSelectionNames(
  "Hlt1*Decision",ITriggerTisTos::kAllTriggerSelections,
  ITriggerTisTos::kTrueRequired, ITriggerTisTos::kAnything, ITriggerTisTos::kAnything);
  info() << " Hlt1 triggers that fired="; dumpvs( hlt1Pass );  info() << endmsg;


  //     see which Hlt2 Selections were on
  //done m_TriggerTisTosTool->setOfflineInput();   
  std::vector<std::string> hlt2Pass = m_TriggerTisTosTool->triggerSelectionNames(
  "Hlt2*Decision",ITriggerTisTos::kAllTriggerSelections,
  ITriggerTisTos::kTrueRequired, ITriggerTisTos::kAnything, ITriggerTisTos::kAnything);
  info() << " Hlt2 Selections that succedded="; dumpvs( hlt2Pass );  info() << endmsg;


  // Tis,Tos with respect to input particles
  for( std::vector<const Particle*>::const_iterator iPart = parts.begin(); iPart!= parts.end(); ++iPart){

    // Particle Info ---------------------------------------------------------------------------

    const std::vector<const Particle*> finals = descendants()->finalStates(*iPart);
    info() << "    Particle " << (*iPart)->particleID().pid() << " Pt " << (*iPart)->pt()
           << " #-of-daughters " << ((*iPart)->daughtersVector()).size()
           << " #-of-final-state-part " << finals.size();
    for( std::vector<const Particle*>::const_iterator pf=finals.begin();pf!=finals.end();++pf){
      info() << " " << (*pf)->particleID().pid() << " Pt " << (*pf)->pt();
    }
    info() << endmsg;

    // L0 Info ---------------------------------------------------------------------------

    bool decisionL0,tisL0,tosL0;
    m_TriggerTisTosTool->triggerTisTos(**iPart,"L0*Decision",decisionL0,tisL0,tosL0, ITriggerTisTos::kAllTriggerSelections);
    if( !decisionL0 )continue;    
    info() << "      L0            TIS= " << tisL0 << " TOS=" << tosL0 << endmsg;

    if( tisL0 ){
      info() << "          L0 TIS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kTrueRequired,
                                                   ITriggerTisTos::kAnything ) );
      info() << endmsg;
    }
    if( tosL0 ){
      info() << "          L0 TOS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kAnything,
                                                   ITriggerTisTos::kTrueRequired ) );
      info() << endmsg;
    }

    // Hlt1 Info ----------------------------------------------------------------------

    bool decisionHlt1,tisHlt1,tosHlt1;
    m_TriggerTisTosTool->triggerTisTos("Hlt1*Decision",decisionHlt1,tisHlt1,tosHlt1, ITriggerTisTos::kAllTriggerSelections);
    if( !decisionHlt1 )continue;    
    info() << "      Hlt1    TIS= " << tisHlt1 << " TOS=" << tosHlt1 << endmsg;
    
    if( tisHlt1 ){
      info() << "          Hlt1 TIS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kTrueRequired,
                                                   ITriggerTisTos::kAnything ) );
      info() << endmsg;
    }
    if( tosHlt1 ){
      info() << "          Hlt1 TOS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kAnything,
                                                   ITriggerTisTos::kTrueRequired ) );
      info() << endmsg;
    }

    // Hlt2 Info --------------------------------------------------------------------

    bool decisionHlt2,tisHlt2,tosHlt2;
    m_TriggerTisTosTool->triggerTisTos("Hlt2*Decision",decisionHlt2,tisHlt2,tosHlt2, ITriggerTisTos::kAllTriggerSelections);
    if( !decisionHlt2 )continue;    
    info() << "      Hlt2 TIS= " << tisHlt2 << " TOS=" << tosHlt2 << endmsg;
    
    if( tisHlt2 ){
      info() << "          Hlt2 TIS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kTrueRequired,
                                                   ITriggerTisTos::kAnything ) );
      info() << endmsg;
    }
    if( tosHlt2 ){
      info() << "          Hlt Hlt2 TOS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kAnything,
                                                   ITriggerTisTos::kTrueRequired ) );
      info() << endmsg;
    }

  } // end particle loop

  // Mandatory. Set to true if event is accepted. 
  setFilterPassed(true);   // Ignore returned status
  return StatusCode::SUCCESS;

  return StatusCode::SUCCESS;

}

//=============================================================================
//  Finalize
//=============================================================================
StatusCode TisTosDVExample::finalize() {

  debug() << "==> Finalize" << endmsg;

  return DVAlgorithm::finalize(); 
}

//=============================================================================

header file

#ifndef TISTOSDVEXAMPLE_H 
#define TISTOSDVEXAMPLE_H 1

// Include files
// from DaVinci, this is a specialized GaudiAlgorithm
#include "Kernel/DVAlgorithm.h"

#include "Kernel/ITriggerTisTos.h"


/** @class TisTosDVExample TisTosDVExample.h
 *  
 *
 *  @author Tomasz Skwarnicki
 *  @date   2007-09-24
 */
class TisTosDVExample : public DVAlgorithm {
public: 
  /// Standard constructor
  TisTosDVExample( const std::string& name, ISvcLocator* pSvcLocator );

  virtual ~TisTosDVExample( ); ///< Destructor

  virtual StatusCode initialize();    ///< Algorithm initialization
  virtual StatusCode execute   ();    ///< Algorithm execution
  virtual StatusCode finalize  ();    ///< Algorithm finalization

  void dumpvs( const std::vector< std::string > & vs )
  { 
    for( std::vector< std::string >::const_iterator s=vs.begin();s != vs.end(); ++s)
    {
      info() << " " << *s;
    }
  }

protected:

private:

  ITriggerTisTos* m_TriggerTisTosTool;

};
#endif // TISTOSDVEXAMPLE_H

Sample output for 1 event in B -> K* mu mu MC

TisTosDVExample                            INFO  L0 decision= 1
TisTosDVExample                            INFO  Names of L0 triggers in Hlt= L0DiMuonDecision L0ElectronDecision L0GlobalPi0Decision L0HadronDecision L0LocalPi0Decision L0MuonDecision L0MuonNoGlobDecision L0PhotonDecision
TisTosDVExample                            INFO  Hlt final decision= 1
TisTosDVExample                            INFO  Hlt1 decision= 1 from OR between  Hlt1ElectronEleTrkDecision Hlt1ElectronSingleDecision Hlt1HadronDiDecision Hlt1HadronSingleDecision Hlt1MuTrackDecision Hlt1MuonDiMuon2L0NoIPDecision Hlt1MuonDiMuon2L0WithIPDecision Hlt1MuonDiMuonMuonSegNoIPDecision Hlt1MuonDiMuonMuonSegWithIPDecision Hlt1MuonDiMuonNoIPDecision Hlt1MuonDiMuonWithIPDecision Hlt1MuonSingleDecision Hlt1MuonSingleNoIPDecision Hlt1PhotonDiTrackDecision
TisTosDVExample                            INFO  Hlt2 decision= 1 from OR between  Hlt2SelB2DplusHDecision Hlt2SelB2DstarMuDecision Hlt2SelB2HHDecision Hlt2SelB2LHCbPhysics.JpsiX_MuMuDecision Hlt2SelB2TwoBodyDecision Hlt2SelBd2D0KstarDecision Hlt2SelBd2D0Kstar_KsHHDecision Hlt2SelBd2DstarPiDecision Hlt2SelBd2MuMuKstarDecision Hlt2SelBd2PiPiPiDecision Hlt2SelBiasedDiElectronDecision Hlt2SelBiasedDiMuonDecision Hlt2SelBs2DsDsDecision Hlt2SelBs2DsHDecision Hlt2SelBs2DsRhoDecision Hlt2SelBs2EtacPhiDecision Hlt2SelBs2JpsiEtaDecision Hlt2SelBs2JpsiEtapDecision Hlt2SelBs2PhiGammaDecision Hlt2SelBs2PhiPhiDecision Hlt2SelBu2D0K_KsDDDecision Hlt2SelBu2D0K_KsHHDecision Hlt2SelBu2LLKDecision Hlt2SelDstarDecision Hlt2SelHidValleyDecision Hlt2SelSingleMuonDecision Hlt2SelUnbiasedDiMuonDecision
TisTosDVExample                            INFO  Hlt1 triggers that fired= Hlt1MuTrackDecision Hlt1MuonDiMuon2L0NoIPDecision Hlt1MuonDiMuon2L0WithIPDecision Hlt1MuonDiMuonMuonSegNoIPDecision Hlt1MuonDiMuonMuonSegWithIPDecision Hlt1MuonDiMuonNoIPDecision Hlt1MuonDiMuonWithIPDecision Hlt1MuonSingleDecision
TisTosDVExample                            INFO  Hlt2 Selections that succedded= Hlt2SelBd2MuMuKstarDecision Hlt2SelBiasedDiMuonDecision Hlt2SelSingleMuonDecision Hlt2SelUnbiasedDiMuonDecision
TisTosDVExample                            INFO     Particle 511 Pt 7568.09 #-of-daughters 2 #-of-final-state-part 4 -13 Pt 3858.22 13 Pt 2239.22 321 Pt 2044.32 -211 Pt 210.724
TisTosDVExample                            INFO       L0            TIS= 0 TOS=1
TisTosDVExample                            INFO           L0 TOS selections=  L0DiMuonDecision L0MuonDecision L0MuonNoGlobDecision
TisTosDVExample                            INFO       Hlt1    TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt1 TOS selections=  Hlt1MuTrackDecision Hlt1MuonDiMuon2L0NoIPDecision Hlt1MuonDiMuon2L0WithIPDecision Hlt1MuonDiMuonMuonSegNoIPDecision Hlt1MuonDiMuonMuonSegWithIPDecision Hlt1MuonDiMuonNoIPDecision Hlt1MuonDiMuonWithIPDecision Hlt1MuonSingleDecision
TisTosDVExample                            INFO       Hlt2 TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt Hlt2 TOS selections=  Hlt2SelBd2MuMuKstarDecision Hlt2SelBiasedDiMuonDecision Hlt2SelSingleMuonDecision Hlt2SelUnbiasedDiMuonDecision

-- TomaszSkwarnicki - 01 Oct 2007, 15 Sep 2008

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2009-12-15 - TomaszSkwarnicki
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback