/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
ROsTriggerDataPackerTool Class Reference

#include <ROsTriggerDataPackerTool.h>

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

List of all members.

Public Member Functions

 ROsTriggerDataPackerTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ROsTriggerDataPackerTool ()
virtual StatusCode fillDataPackages (std::vector< DayaBay::ReadoutTriggerDataPkg * > &dataPkgs, const DayaBay::SimTrigHeader &trigHeader)
 Modify the event.
virtual StatusCode initialize ()
virtual StatusCode finalize ()

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Attributes

unsigned int m_recoveryCycles

Detailed Description

Definition at line 30 of file ROsTriggerDataPackerTool.h.


Constructor & Destructor Documentation

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

Definition at line 16 of file ROsTriggerDataPackerTool.cc.

  : GaudiTool(type,name,parent)
{
  declareInterface< IROsTriggerDataPackerTool >(this) ;
  declareProperty("RecoveryTime",m_recoveryCycles=12,
                  "Number of (80 MHz) clock cycles for trigger recovery time");
  //declareProperty("ReadoutCycles",m_roCycles,
  //                "Clock Cycles to readout relative to reference");
}
ROsTriggerDataPackerTool::~ROsTriggerDataPackerTool ( ) [virtual]

Definition at line 28 of file ROsTriggerDataPackerTool.cc.

{}

Member Function Documentation

StatusCode ROsTriggerDataPackerTool::fillDataPackages ( std::vector< DayaBay::ReadoutTriggerDataPkg * > &  ,
const DayaBay::SimTrigHeader  
) [virtual]

Modify the event.

get command collections from trigger header

Loop over All trigger Collections

Create and fill new trigger data frame

Decide if trigger should be masked or not.

Trigger Should not be masked, create a data package for it.

This trigger should be masked, add it to the previous Trigger data pacakge.

Implements IROsTriggerDataPackerTool.

Definition at line 42 of file ROsTriggerDataPackerTool.cc.

{
  debug() << "Packing Trigger Data" << endreq;

  const DayaBay::SimTrigCommandHeader *tch = trigHeader.commandHeader();
  const DayaBay::SimTrigCommandHeader::detCollMap trigCollMap = tch->collections();

  DayaBay::SimTrigCommandHeader::detCollMap::const_iterator trigIt;

  for(trigIt  = trigCollMap.begin(); trigIt != trigCollMap.end(); ++trigIt)
  {
    DayaBay::Detector det(trigIt->first);
    debug() << "found " << (trigIt->second)->commands().size() << " commands for " << det.detName() << endreq;

    DayaBay::SimTrigCommandCollection *triggerColl = trigIt->second ;
    const DayaBay::SimTrigCommandCollection::CommandContainer& detTriggers = triggerColl->commands();
    DayaBay::SimTrigCommandCollection::CommandContainer::const_iterator tcIt;

    DayaBay::ReadoutTriggerDataPkg *tdpkg = 0;
    int prevCycle=0;

    if (!det.isRPC()) { // treat RPC triggers separately
        for(tcIt=detTriggers.begin();tcIt!=detTriggers.end();++tcIt){
             verbose() << "Trigger: " << **tcIt << endreq;
             verbose() << "Creating Trigger Data Frame" << endreq;

             DayaBay::ReadoutTriggerDataFrame *tdf = new DayaBay::ReadoutTriggerDataFrame();
             tdf->setCycle((*tcIt)->clockCycle());
             TimeStamp triggerTime( trigHeader.earliest() );
             triggerTime.Add((*tcIt)->clockCycle() / double(DayaBay::NhitFrequencyHz));
             tdf->setTriggerTime(triggerTime);
             tdf->setTriggerType((*tcIt)->type());
             tdf->setNhit((*tcIt)->nhit());
             tdf->setEsumAdc((*tcIt)->esumAdc());
             tdf->setEsumComp((*tcIt)->esumComp());

             //tdf->setReadoutType();
             //tdf->setCrossSource();
             //tdf->setSeqNumber();

             // done by addFrame() so don't set package here
             // tdf->setPackage()

             int thiscycle = (*tcIt)->clockCycle();
             unsigned int dt = (unsigned int) (thiscycle-prevCycle);
             bool shouldBeMasked =  dt < m_recoveryCycles;

             if ( ! tdpkg || ! shouldBeMasked ){
                 verbose() << "Creating a new trigger data package" << endreq;
                 tdpkg = new DayaBay::ReadoutTriggerDataPkg();
                 tdpkg->setDetector(det);
                 tdpkg->addFrame(tdf);
                 dataPkgs.push_back(tdpkg);
                 prevCycle=thiscycle;
             }else{
                 debug() << "Adding a masked trigger" << endreq;
                 if(!tdpkg){
                     fatal() << "This should never happen!!!\n"
                         << "A trigger frame was produced "
                         << "with not package to put it in"
                         << endreq;
                     return StatusCode::FAILURE;
                 }
                 tdpkg->addFrame(tdf);
             }
        verbose() << "Done Packing Detector " << *tdpkg << endreq;
        }
    } else { // we do RPC stuff
        // Q: is any RPC command masked?
        // A: don't think so
        // Q: how to treat different clock frequencies?
        // A: simply implement it.

        // Loop over trigger commands for RPCs
        for(tcIt=detTriggers.begin();tcIt!=detTriggers.end();++tcIt){
            const DayaBay::SimRpcTrigCommand* rtc = dynamic_cast<const DayaBay::SimRpcTrigCommand*>(*tcIt);
            if (!rtc) {
                return StatusCode::FAILURE;
                // FIXME: treat case when the trigger command is not RPC,
                // but still in the RPC detector. (Which should never happen)
            }

            // Create and fill trigger data frame
            DayaBay::ReadoutRpcTriggerDataFrame *tdf = new DayaBay::ReadoutRpcTriggerDataFrame();
            tdf->setIsRpc(true);
            tdf->setCycle(rtc->clockCycle());

            TimeStamp triggerTime( trigHeader.earliest() );
            triggerTime.Add(rtc->clockCycle() / double(DayaBay::BaseFrequencyHz));

            tdf->setTriggerTime(triggerTime);
            tdf->setTriggerType((*tcIt)->type());
            tdf->setInTriggers(rtc->inTriggers());
            tdf->setOutTriggers(rtc->outTriggers());

            // create, fill, and register trigger data package
            tdpkg = new DayaBay::ReadoutTriggerDataPkg();
            tdpkg->setDetector(det);
            tdpkg->addFrame(tdf);
            dataPkgs.push_back(tdpkg);
            tdpkg = 0;
        }
    }
    debug() << "Done Packing Triggers. " <<  endreq;
  }

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

Definition at line 30 of file ROsTriggerDataPackerTool.cc.

{
  debug() << "Initializing Trigger Data Packer" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode ROsTriggerDataPackerTool::finalize ( ) [virtual]

Definition at line 36 of file ROsTriggerDataPackerTool.cc.

{
  debug() << "Finalizing Trigger Data Packer" << endreq;
  return StatusCode::SUCCESS;
}
const InterfaceID & IROsTriggerDataPackerTool::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file IROsTriggerDataPackerTool.cc.

{ 
    return IID_IROsTriggerDataPackerTool; 
}

Member Data Documentation

Definition at line 47 of file ROsTriggerDataPackerTool.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:17:06 for ReadoutSim by doxygen 1.7.4