/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 Member Functions | Private Attributes
TsESumTriggerTool Class Reference

#include <TsESumTriggerTool.h>

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

List of all members.

Public Member Functions

 TsESumTriggerTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TsESumTriggerTool ()
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 Member Functions

virtual StatusCode fillTriggers (DayaBay::SimTrigHeader *trigHeader, const DayaBay::ElecHeader &elecHeader)
double getULThreshold (DayaBay::Detector det)
double getDTThreshold (DayaBay::Detector det)
int getDigitalValue (double analogThresh)
DayaBay::Trigger::TriggerType_t getTriggerType (DayaBay::Detector det)

Private Attributes

unsigned int m_recoveryCycles
double m_ADThreshold
double m_FarIWSThreshold
double m_FarOWSThreshold
double m_NearIWSThreshold
double m_NearOWSThreshold
std::map< std::string, double > m_UpperLowerThresholdMap
std::map< std::string, double > m_TotalDigitalThresholdMap
std::vector< std::string > m_detectorsToProcess

Detailed Description

Definition at line 28 of file TsESumTriggerTool.h.


Constructor & Destructor Documentation

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

Definition at line 16 of file TsESumTriggerTool.cc.

    : GaudiTool(type,name,parent)
{
  declareInterface< ITsTriggerTool >(this) ;
  // for now add all but RPC's as default.
  m_detectorsToProcess.push_back("DayaBayAD1");
  m_detectorsToProcess.push_back("DayaBayAD2");
  m_detectorsToProcess.push_back("DayaBayIWS");
  m_detectorsToProcess.push_back("DayaBayOWS");
  m_detectorsToProcess.push_back("LingAoAD1");
  m_detectorsToProcess.push_back("LingAoAD2");
  m_detectorsToProcess.push_back("LingAoIWS");
  m_detectorsToProcess.push_back("LingAoOWS"); 
  m_detectorsToProcess.push_back("FarAD1");
  m_detectorsToProcess.push_back("FarAD2");
  m_detectorsToProcess.push_back("FarAD3");
  m_detectorsToProcess.push_back("FarAD4");
  m_detectorsToProcess.push_back("FarIWS");
  m_detectorsToProcess.push_back("FarOWS");
  
  m_UpperLowerThresholdMap["DayaBayAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["DayaBayAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["DayaBayIWS"]=DayaBay::Trigger::kNearIWSESumThreshold;
  m_UpperLowerThresholdMap["DayaBayOWS"]=DayaBay::Trigger::kNearOWSESumThreshold;
  m_UpperLowerThresholdMap["LingAoAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["LingAoAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["LingAoIWS"]=DayaBay::Trigger::kNearIWSESumThreshold;
  m_UpperLowerThresholdMap["LingAoOWS"]=DayaBay::Trigger::kNearOWSESumThreshold;
  m_UpperLowerThresholdMap["FarAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["FarAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["FarAD3"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["FarAD4"]=DayaBay::Trigger::kADESumThreshold;
  m_UpperLowerThresholdMap["FarIWS"]=DayaBay::Trigger::kFarIWSESumThreshold;
  m_UpperLowerThresholdMap["FarOWS"]=DayaBay::Trigger::kFarOWSESumThreshold;
  
  m_TotalDigitalThresholdMap["DayaBayAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["DayaBayAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["DayaBayIWS"]=DayaBay::Trigger::kNearIWSESumThreshold;
  m_TotalDigitalThresholdMap["DayaBayOWS"]=DayaBay::Trigger::kNearOWSESumThreshold;
  m_TotalDigitalThresholdMap["LingAoAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["LingAoAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["LingAoIWS"]=DayaBay::Trigger::kNearIWSESumThreshold;
  m_TotalDigitalThresholdMap["LingAoOWS"]=DayaBay::Trigger::kNearOWSESumThreshold;
  m_TotalDigitalThresholdMap["FarAD1"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["FarAD2"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["FarAD3"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["FarAD4"]=DayaBay::Trigger::kADESumThreshold;
  m_TotalDigitalThresholdMap["FarIWS"]=DayaBay::Trigger::kFarIWSESumThreshold;
  m_TotalDigitalThresholdMap["FarOWS"]=DayaBay::Trigger::kFarOWSESumThreshold;

  
  declareProperty("DetectorsToProcess",m_detectorsToProcess,
                  "List of detectors to process with this tool");
  declareProperty("RecoveryTime",m_recoveryCycles=20,
               "Number of esum (200 MHz) clock cycles for trigger dead time");
  declareProperty("UpperLowerThresholdMap",m_UpperLowerThresholdMap,
                  "Map indexed by detector name with value of Thrshold in volts");
  declareProperty("DigitalTotalThresholdMap",m_TotalDigitalThresholdMap,
                  "Map indexed by detector name with value of Thrshold in volts");
}
TsESumTriggerTool::~TsESumTriggerTool ( ) [virtual]

Definition at line 79 of file TsESumTriggerTool.cc.

{}

Member Function Documentation

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

Modify the event.

Implements ITsTriggerTool.

Definition at line 287 of file TsESumTriggerTool.cc.

{     
  return fillTriggers(trigHeader,elecHeader);
}
StatusCode TsESumTriggerTool::initialize ( ) [virtual]

Definition at line 81 of file TsESumTriggerTool.cc.

{
  std::vector<std::string>::iterator it;

  // loop over detectors 
  for(it = m_detectorsToProcess.begin(); 
      it != m_detectorsToProcess.end(); 
      ++it){    
        short int detId =  DayaBay::Detector::siteDetPackedFromString(*it);
        DayaBay::Detector det(detId);
        info() << det 
               << " is setup with Upper Lower threshold " 
               << getULThreshold(det) 
               << endreq;
        info() << det 
               << " is setup with Digital Total threshold " 
               << getDTThreshold(det) 
               << endreq;   
    }
      
    return StatusCode::SUCCESS;
}
StatusCode TsESumTriggerTool::finalize ( ) [virtual]

Definition at line 104 of file TsESumTriggerTool.cc.

{
  return StatusCode::SUCCESS;
}
StatusCode TsESumTriggerTool::fillTriggers ( DayaBay::SimTrigHeader trigHeader,
const DayaBay::ElecHeader elecHeader 
) [private, virtual]

Definition at line 109 of file TsESumTriggerTool.cc.

{
  debug() << "running fillTriggers()" << endreq;
  DayaBay::SimTrigCommandHeader* trigCH 
    = const_cast<DayaBay::SimTrigCommandHeader*>(trigHeader->commandHeader());
  
  const DayaBay::ElecCrateHeader* crateHeader = elecHeader.crateHeader();
  DayaBay::ElecCrateHeader::CrateMap cmap = crateHeader->crates();
  DayaBay::ElecCrateHeader::CrateMap::iterator detIterator;
  
  std::vector<std::string>::iterator it;
  debug() << "processing " << m_detectorsToProcess.size() 
          << " detectors." << endreq;
  
  // loop over detectors 
  for(it = m_detectorsToProcess.begin(); 
      it != m_detectorsToProcess.end(); 
      ++it){
    short int detId =  DayaBay::Detector::siteDetPackedFromString(*it);
    DayaBay::Detector det(detId);
    verbose() << "Processing " << *it << " which is " << det << endreq;
    
    const DayaBay::SimTrigCommandHeader::detCollMap trigCollMap = trigCH->collections();
    

    detIterator = cmap.find(det);
    if(detIterator != cmap.end()){
      // A crate was found for this detector
      debug() << "A crate was found for " << det 
              << " processing..." << endreq;
      
      DayaBay::SimTrigCommandCollection *tcc = 0;
      if( trigCollMap.find(det) == trigCollMap.end() ){
          tcc = new DayaBay::SimTrigCommandCollection();
          tcc->setHeader(trigCH);
          tcc->setDetector(det);
          trigCH->addCollection(tcc);
      }
      
      
      // Get the crate from the header object
      DayaBay::ElecFeeCrate *crate 
                        = dynamic_cast<DayaBay::ElecFeeCrate*>(cmap[det]);
      
      // get esum hits...
      DayaBay::AnalogSignal& upperEsum = crate->esumUpper();
      DayaBay::AnalogSignal& lowerEsum = crate->esumLower();
      DayaBay::AnalogSignal& totalEsum = crate->esumTotal();
      DayaBay::DigitalSignal& totalAdc = crate->esumADC();    
                    
      // threshold for upper and lower esums.
      double ULthreshold = getULThreshold(det);
      
      // threshold for digital and total esums.
      double DTthreshold = getDTThreshold(det);
      
      verbose() << "UL Trigger Threshold " << ULthreshold  << endreq;
      verbose() << "DT Trigger Threshold " << DTthreshold  << endreq;
      
      //
      // IN ALL CASES BELOW THE FOLLOWING APPLIES 
      //
      // convert the esum clock to the next Nhit clock cycle 
      // for the trigger command.  by default this will report the 
      // 200MHz esum clock to a 80 MHz adc clock cycle so it's 
      // properly handeled by the readout.
      // 2*(1 + (previous ADC cycle)) --> trigger reported at next 80 MHz
      //                                 clock cycle
      // The Esum Triggers are checked at 40MHz but ReadoutSim expectes them
      // to be reported at 80MHz, so its calculate at 40 then doubled
      // to 80.
      //
      
      // Do upperEsumTriggers
      
      for( unsigned int i = 0; i < upperEsum.size() ; ++i )
      {
          if ( upperEsum[i] >= ULthreshold )
          {
              DayaBay::Trigger::TriggerType_t type = getTriggerType(det);
              type = DayaBay::Trigger::TriggerType_t(type | DayaBay::Trigger::kESumLow);
              
              unsigned int trigcycle = 2* ( 1 + 
                           (i * DayaBay::AdcCycles) / (DayaBay::EsumCycles) );
              DayaBay::SimTrigCommand *tc = 
                             new DayaBay::SimTrigCommand(det,type,trigcycle,0,totalAdc[i],DayaBay::ESumComp::kESumHigh);
              debug() << "Adding Upper Esum Trigger at cycle\t" <<  i
                      << " With type " << type 
                      << " \n\t Nhit clock cycle: " << trigcycle
                      << " \n\t Esum clock cycle: " << i << endreq;
              verbose() << "Waiting " << m_recoveryCycles 
                        << " cycles to recover" << endreq;           
              i += m_recoveryCycles;
              trigCH->addCommand(tc);
              
          }
      }
      
      // Do lowerEsumTriggers
      
      for( unsigned int i = 0; i < lowerEsum.size() ; ++i )
      {
          if ( lowerEsum[i] >= ULthreshold )
          {
              DayaBay::Trigger::TriggerType_t type = getTriggerType(det);
              type = DayaBay::Trigger::TriggerType_t( DayaBay::Trigger::kESumHigh);
              
              unsigned int trigcycle = 2* ( 1 + 
                           (i * DayaBay::AdcCycles) / (DayaBay::EsumCycles) );
              DayaBay::SimTrigCommand *tc = 
                             new DayaBay::SimTrigCommand(det,type,trigcycle,0,totalAdc[i],DayaBay::ESumComp::kESumLow);
              debug() << "Adding Lower Esum Trigger at cycle\t" <<  i
                      << " With type " << type 
                      << " \n\t Nhit clock cycle: " << trigcycle
                      << " \n\t Esum clock cycle: " << i << endreq;
              verbose() << "Waiting " << m_recoveryCycles 
                        << " cycles to recover" << endreq;           
              i += m_recoveryCycles;
              trigCH->addCommand(tc);
              
          }
      }
      
      // Do TotalEsumTriggers
      for( unsigned int i = 0; i < totalEsum.size() ; ++i )
      {
          if ( totalEsum[i] >= DTthreshold )
          {
              DayaBay::Trigger::TriggerType_t type = getTriggerType(det);
              type = DayaBay::Trigger::TriggerType_t(DayaBay::Trigger::kESumAll);

              unsigned int trigcycle = 2* ( 1 + 
                           (i * DayaBay::AdcCycles) / (DayaBay::EsumCycles) );
              DayaBay::SimTrigCommand *tc = 
                             new DayaBay::SimTrigCommand(det,type,trigcycle,0,totalAdc[i],DayaBay::ESumComp::kESumTotal);
              debug() << "Adding Total Esum Trigger at cycle\t" <<  i
                      << " With type " << type 
                      << " \n\t Nhit clock cycle: " << trigcycle
                      << " \n\t Esum clock cycle: " << i << endreq;
              verbose() << "Waiting " << m_recoveryCycles 
                        << " cycles to recover" << endreq;           
              i += m_recoveryCycles;
              trigCH->addCommand(tc);
              
          }
      }
      
      // Do DigitalEsumTriggers
      for( unsigned int i = 0; i < totalAdc.size() ; ++i )
      {
          if ( totalAdc[i] >= getDigitalValue(DTthreshold) )
          {
              DayaBay::Trigger::TriggerType_t type = getTriggerType(det);
              type = DayaBay::Trigger::TriggerType_t(DayaBay::Trigger::kESumADC);

              unsigned int trigcycle = 2* ( 1 + 
                           (i * DayaBay::AdcCycles) / (DayaBay::EsumCycles) );
              DayaBay::SimTrigCommand *tc = 
                             new DayaBay::SimTrigCommand(det,type,trigcycle,0,totalAdc[i],0);
              debug() << "Adding ADC Esum Trigger at cycle\t" <<  i
                      << " With type " << type 
                      << " \n\t Nhit clock cycle: " << trigcycle
                      << " \n\t Esum clock cycle: " << i << endreq;
              verbose() << "Waiting " << m_recoveryCycles 
                        << " cycles to recover" << endreq;           
              i += m_recoveryCycles;
              trigCH->addCommand(tc);
              
          }
      }
        
    }// end if crate exists
  }
  return StatusCode::SUCCESS;                               
}
double TsESumTriggerTool::getULThreshold ( DayaBay::Detector  det) [private]

Definition at line 296 of file TsESumTriggerTool.cc.

                                                           {
    if( m_UpperLowerThresholdMap.find(det.detName()) 
                   != m_UpperLowerThresholdMap.end() ){
        return m_UpperLowerThresholdMap[det.detName()];
    }
    warning() << "Requesting a esum threshold for " << det.detName() 
              << " but none was specified in imput map " << endreq;
    warning() << "Using default value as defined in Conventions/Trigger.h"
              << endreq;
  if(det.detectorId() == DetectorId::kAD1 || 
     det.detectorId() == DetectorId::kAD2 ||
     det.detectorId() == DetectorId::kAD3 || 
     det.detectorId() == DetectorId::kAD4 ){
    return DayaBay::Trigger::kADESumThreshold;
  }
  if(det.detectorId() == DetectorId::kIWS){
    if(det.site() == Site::kFar){
       return DayaBay::Trigger::kFarIWSESumThreshold;
    }else{
       return DayaBay::Trigger::kNearIWSESumThreshold;
    }
  }
  if(det.detectorId() == DetectorId::kOWS){
    if(det.site() == Site::kFar){
       return DayaBay::Trigger::kFarOWSESumThreshold;
    }else{
       return DayaBay::Trigger::kNearOWSESumThreshold;
    }
  }
  return 0.0;
}
double TsESumTriggerTool::getDTThreshold ( DayaBay::Detector  det) [private]

Definition at line 328 of file TsESumTriggerTool.cc.

                                                           {
  if( m_TotalDigitalThresholdMap.find(det.detName()) 
                 != m_TotalDigitalThresholdMap.end() ){
      return m_TotalDigitalThresholdMap[det.detName()];
  }
  
  warning() << "Requesting a esum threshold for " << det.detName() 
            << " but none was specified in imput map " << endreq;
  warning() << "Using default value as defined in Conventions/Trigger.h"
            << endreq;
            
  if(det.detectorId() == DetectorId::kAD1 || 
     det.detectorId() == DetectorId::kAD2 ||
     det.detectorId() == DetectorId::kAD3 || 
     det.detectorId() == DetectorId::kAD4 ){
    return DayaBay::Trigger::kADESumThreshold;
  }
  if(det.detectorId() == DetectorId::kIWS){
    if(det.site() == Site::kFar){
       return DayaBay::Trigger::kFarIWSESumThreshold;
    }else{
       return DayaBay::Trigger::kNearIWSESumThreshold;
    }
  }
  if(det.detectorId() == DetectorId::kOWS){
    if(det.site() == Site::kFar){
       return DayaBay::Trigger::kFarOWSESumThreshold;
    }else{
       return DayaBay::Trigger::kNearOWSESumThreshold;
    }
  }
  return 0.0;
}
int TsESumTriggerTool::getDigitalValue ( double  analogThresh) [private]

Definition at line 366 of file TsESumTriggerTool.cc.

                                                         {
    analogThresh=0; // yes compliler I am used, please don't warn me.
    return 4095; // essentially turn it off right now
    //return (unsigned int) analogThresh;
}
DayaBay::Trigger::TriggerType_t TsESumTriggerTool::getTriggerType ( DayaBay::Detector  det) [private]

Definition at line 362 of file TsESumTriggerTool.cc.

const InterfaceID & ITsTriggerTool::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file ITsTriggerTool.cc.

{ 
    return IID_ITsTriggerTool; 
}

Member Data Documentation

unsigned int TsESumTriggerTool::m_recoveryCycles [private]

Definition at line 45 of file TsESumTriggerTool.h.

Definition at line 47 of file TsESumTriggerTool.h.

Definition at line 48 of file TsESumTriggerTool.h.

Definition at line 49 of file TsESumTriggerTool.h.

Definition at line 50 of file TsESumTriggerTool.h.

Definition at line 51 of file TsESumTriggerTool.h.

std::map<std::string,double> TsESumTriggerTool::m_UpperLowerThresholdMap [private]

Definition at line 53 of file TsESumTriggerTool.h.

std::map<std::string,double> TsESumTriggerTool::m_TotalDigitalThresholdMap [private]

Definition at line 54 of file TsESumTriggerTool.h.

std::vector<std::string> TsESumTriggerTool::m_detectorsToProcess [private]

Definition at line 59 of file TsESumTriggerTool.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