Elaborated example of DaVinci algorithm using TriggerTisTos tool

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("L0Trigger*", 
                                                                                     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;

  //  Hlt Alleys
  bool hltAlleysDecision,dummyTis,dummyTos;
  m_TriggerTisTosTool->setOfflineInput();  
  m_TriggerTisTosTool->triggerTisTos("*",hltAlleysDecision,dummyTis,dummyTos);
  info() << " Hlt Alleys decision= " << hltAlleysDecision;
  info() << " from OR between "; dumpvs( m_TriggerTisTosTool->triggerSelectionNames() ); info() << endmsg;

  //  Hlt Selections (B and D)
  bool hltSelDecision;
  std::vector< std::string > hltSel;
  hltSel.push_back("HltSelD*");
  hltSel.push_back("HltSelB*");
  //done m_TriggerTisTosTool->setOfflineInput();   
  m_TriggerTisTosTool->triggerTisTos(hltSel,hltSelDecision,dummyTis,dummyTos, ITriggerTisTos::kAllTriggerSelections);
  info() << " HltSelections (B and D) decision= " << hltSelDecision;
  info() << " from OR between "; dumpvs( m_TriggerTisTosTool->triggerSelectionNames() ); info() << endmsg;

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


  //     see which Hlt Selections were on
  //done m_TriggerTisTosTool->setOfflineInput();   
  std::vector<std::string> selPass = m_TriggerTisTosTool->triggerSelectionNames(
  hltSel,ITriggerTisTos::kAllTriggerSelections,
  ITriggerTisTos::kTrueRequired, ITriggerTisTos::kAnything, ITriggerTisTos::kAnything);
  info() << " Hlt Selections that succedded="; dumpvs( selPass );  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,"L0Trigger*",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;
    }

    // Hlt Alley Info ----------------------------------------------------------------------

    bool decisionAlleys,tisAlleys,tosAlleys;
    m_TriggerTisTosTool->triggerTisTos("*",decisionAlleys,tisAlleys,tosAlleys);
    if( !decisionAlleys )continue;    
    info() << "      Hlt Alleys    TIS= " << tisAlleys << " TOS=" << tosAlleys << endmsg;
    
    if( tisAlleys ){
      info() << "          Hlt Alleys TIS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kTrueRequired,
                                                   ITriggerTisTos::kAnything ) );
      info() << endmsg;
    }
    if( tosAlleys ){
      info() << "          Hlt Alleys TOS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kAnything,
                                                   ITriggerTisTos::kTrueRequired ) );
      info() << endmsg;
    }

    // Hlt SelB Info --------------------------------------------------------------------

    bool decisionSelB,tisSelB,tosSelB;
    m_TriggerTisTosTool->triggerTisTos("HltSelB*",decisionSelB,tisSelB,tosSelB, ITriggerTisTos::kAllTriggerSelections);
    if( !decisionSelB )continue;    
    info() << "      Hlt SelB TIS= " << tisSelB << " TOS=" << tosSelB << endmsg;
    
    if( tisSelB ){
      info() << "          Hlt SelB TIS selections= ";
      dumpvs( m_TriggerTisTosTool->triggerSelectionNames( ITriggerTisTos::kAnything, 
                                                   ITriggerTisTos::kTrueRequired,
                                                   ITriggerTisTos::kAnything ) );
      info() << endmsg;
    }
    if( tosSelB ){
      info() << "          Hlt SelB 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;

}

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

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

  return DVAlgorithm::finalize(); //=== For DC04, return StatusCode::SUCCESS;
}

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

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 2 events in B -> K* mu mu MC

TisTosDVExample                            INFO  L0 decision= 1
TisTosDVExample                            INFO  Names of L0 triggers in Hlt= L0TriggerElectron L0TriggerPhoton L0TriggerLocalPi0 L0TriggerGlobalPi0 L0TriggerHadron L0TriggerMuon L0TriggerDiMuon L0TriggerMuonNoGlob
TisTosDVExample                            INFO  Hlt final decision= 1
TisTosDVExample                            INFO  Hlt Alleys decision= 1 from OR between  MuonTriggerSingle MuonTriggerDiMuon MuonTriggerIPDiMuon MuonTriggerPureDiMuon MuonTriggerPureIPDiMuon HadTrigger EleTriggerSingle EleTriggerEleTrk PhoTriggerPhoTrk
TisTosDVExample                            INFO  HltSelections (B and D) decision= 1 from OR between  HltSelDstar HltSelB2DiElectron HltSelBd2MuMuKstar HltSelB2DiMuon HltSelB2JpsiX_MuMu HltSelBu2LLK HltSelB2MuMu HltSelB2HH HltSelBd2DstarPi HltSelBd2D0Kstar HltSelBs2DsH HltSelBs2PhiGamma HltSelBs2PhiPhi HltSelBs2DsDs HltSelB2DstarMu HltSelBd2PiPiPi HltSelBu2D0K_KsHH HltSelBd2D0Kstar_KsHH
TisTosDVExample                            INFO  Hlt Alley triggers that fired= MuonTriggerIPDiMuon
TisTosDVExample                            INFO  Hlt Selections that succedded= HltSelBd2MuMuKstar HltSelB2JpsiX_MuMu
TisTosDVExample                            INFO     Particle -511 Pt 3629.67 #-of-daughters 2 #-of-final-state-part 4 -13 Pt 878.252 13 Pt 1265.15 -321 Pt 1386.07 211 Pt 2758.34
TisTosDVExample                            INFO       L0            TIS= 0 TOS=1
TisTosDVExample                            INFO           L0 TOS selections=  L0TriggerMuon L0TriggerMuonNoGlob
TisTosDVExample                            INFO       Hlt Alleys    TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt Alleys TOS selections=  MuonTriggerIPDiMuon
TisTosDVExample                            INFO       Hlt SelB TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt SelB TOS selections=  HltSelBd2MuMuKstar HltSelB2JpsiX_MuMu

TisTosDVExample                            INFO  L0 decision= 1
TisTosDVExample                            INFO  Names of L0 triggers in Hlt= L0TriggerElectron L0TriggerPhoton L0TriggerLocalPi0 L0TriggerGlobalPi0 L0TriggerHadron L0TriggerMuon L0TriggerDiMuon L0TriggerMuonNoGlob
TisTosDVExample                            INFO  Hlt final decision= 1
TisTosDVExample                            INFO  Hlt Alleys decision= 1 from OR between  MuonTriggerSingle MuonTriggerDiMuon MuonTriggerIPDiMuon MuonTriggerPureDiMuon MuonTriggerPureIPDiMuon HadTrigger EleTriggerSingle EleTriggerEleTrk PhoTriggerPhoTrk
TisTosDVExample                            INFO  HltSelections (B and D) decision= 1 from OR between  HltSelDstar HltSelB2DiElectron HltSelBd2MuMuKstar HltSelB2DiMuon HltSelB2JpsiX_MuMu HltSelBu2LLK HltSelB2MuMu HltSelB2HH HltSelBd2DstarPi HltSelBd2D0Kstar HltSelBs2DsH HltSelBs2PhiGamma HltSelBs2PhiPhi HltSelBs2DsDs HltSelB2DstarMu HltSelBd2PiPiPi HltSelBu2D0K_KsHH HltSelBd2D0Kstar_KsHH
TisTosDVExample                            INFO  Hlt Alley triggers that fired= HadTrigger
TisTosDVExample                            INFO  Hlt Selections that succedded= HltSelBd2MuMuKstar HltSelB2DiMuon HltSelB2JpsiX_MuMu HltSelBd2DstarPi
TisTosDVExample                            INFO     Particle -511 Pt 10235.2 #-of-daughters 2 #-of-final-state-part 4 -13 Pt 674.669 13 Pt 701.803 -321 Pt 6636.12 211 Pt 2244.33
TisTosDVExample                            INFO       L0            TIS= 0 TOS=1
TisTosDVExample                            INFO           L0 TOS selections=  L0TriggerHadron
TisTosDVExample                            INFO       Hlt Alleys    TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt Alleys TOS selections=  HadTrigger
TisTosDVExample                            INFO       Hlt SelB TIS= 0 TOS=1
TisTosDVExample                            INFO           Hlt SelB TOS selections=  HltSelBd2MuMuKstar HltSelB2DiMuon HltSelB2JpsiX_MuMu

-- TomaszSkwarnicki - 01 Oct 2007


This topic: LHCb > LHCbTrigger > TriggerTisTos > TisTosDVExample
Topic revision: r1 - 2007-10-02 - TomaszSkwarnicki
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback