/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Attributes
TsSortTool Class Reference

#include <TsSortTool.h>

Inheritance diagram for TsSortTool:
Inheritance graph
[legend]
Collaboration diagram for TsSortTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TsSortTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TsSortTool ()
virtual StatusCode mutate (DayaBay::SimTrigHeader *trigHeader, const DayaBay::ElecHeader &elecHeader)
 Modify the event.
virtual StatusCode initialize ()
virtual StatusCode finalize ()

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Attributes

bool m_active
unsigned int m_recoveryCycles

Detailed Description

Definition at line 28 of file TsSortTool.h.


Constructor & Destructor Documentation

TsSortTool::TsSortTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 14 of file TsSortTool.cc.

    : GaudiTool(type,name,parent)
{
  declareInterface< ITsTriggerTool >(this) ;
  declareProperty("RecoveryTime",m_recoveryCycles=60,
                  "Number of 80MHz clock cycles for trigger dead time");
  declareProperty("SortTriggers",m_active=true,
                  "If set to true the tool will sort the trigger commands.");
}
TsSortTool::~TsSortTool ( ) [virtual]

Definition at line 26 of file TsSortTool.cc.

{}

Member Function Documentation

StatusCode TsSortTool::mutate ( DayaBay::SimTrigHeader trigHeader,
const DayaBay::ElecHeader elecHeader 
) [virtual]

Modify the event.

Implements ITsTriggerTool.

Definition at line 40 of file TsSortTool.cc.

{     
  if ( !m_active ){
      debug() << "TsSortTool is not active, so doing nothing" << endreq;
      return StatusCode::SUCCESS;
  }
  
  debug() << "running mutate()" << endreq;
  const DayaBay::SimTrigCommandHeader *tch = trigHeader->commandHeader();
  const DayaBay::SimTrigCommandHeader::detCollMap trigCollMap 
                                                          = tch->collections();
  DayaBay::SimTrigCommandHeader::detCollMap::const_iterator trigIt;  
  //Loop over All trigger Collections
  for(trigIt  = trigCollMap.begin(); trigIt != trigCollMap.end(); ++trigIt)
  {
    DayaBay::Detector det(trigIt->first);
    debug() << "found " << (trigIt->second)->commands().size()
            << " commands for " << det.detName() << endreq;

    // Skip sorting if less than 2 triggers exist.
    if( (trigIt->second)->commands().size()<2 ) continue;
    DayaBay::SimTrigCommandCollection *triggerColl = 
               const_cast<DayaBay::SimTrigCommandCollection*>(trigIt->second);

    // sort the trigger commands by clock cycle
    triggerColl->sort();

    DayaBay::SimTrigCommandCollection::CommandContainer& detTriggers = 
        const_cast<DayaBay::SimTrigCommandCollection::CommandContainer&>(triggerColl->commands());

    DayaBay::SimTrigCommandCollection::CommandContainer reducedTriggerColl;
    DayaBay::SimTrigCommand* prevTrigger = detTriggers[0];
    reducedTriggerColl.push_back(prevTrigger);
    for(unsigned int trigIdx=1; trigIdx<detTriggers.size(); trigIdx++){
      unsigned int prevcycle = prevTrigger->clockCycle();
      unsigned int thiscycle = (detTriggers[trigIdx])->clockCycle();
      if( (thiscycle-prevcycle)<m_recoveryCycles ){
        // Remove this trigger since it occurs too soon after previous trigger
        verbose() << "Combining trigger at " << thiscycle << " with trigger at " 
                  << prevcycle << endreq;
        // Update the trigger type
        DayaBay::Trigger::TriggerType_t type = (detTriggers[trigIdx])->type();
        int newtype = (int) (type | prevTrigger->type()); // update its type
        prevTrigger->setType( (DayaBay::Trigger::TriggerType_t) newtype );
        delete detTriggers[trigIdx];
        detTriggers[trigIdx]=0;
      }else{
        prevTrigger = detTriggers[trigIdx];
        reducedTriggerColl.push_back(prevTrigger);
      }
    }
    triggerColl->setCommands( reducedTriggerColl );

    verbose() << "Done Sorting. "  << endreq;
  }

  return StatusCode::SUCCESS;                               
}
StatusCode TsSortTool::initialize ( ) [virtual]

Definition at line 28 of file TsSortTool.cc.

{
  debug() << "Initializing TsSortTool" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode TsSortTool::finalize ( ) [virtual]

Definition at line 34 of file TsSortTool.cc.

{
  debug() << "Finalizing TsSortTool" << endreq;
  return StatusCode::SUCCESS;
}
const InterfaceID & ITsTriggerTool::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file ITsTriggerTool.cc.

{ 
    return IID_ITsTriggerTool; 
}

Member Data Documentation

bool TsSortTool::m_active [private]

Definition at line 44 of file TsSortTool.h.

unsigned int TsSortTool::m_recoveryCycles [private]

Definition at line 45 of file TsSortTool.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:16:52 for TrigSim by doxygen 1.7.4