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

#include <TsMultTriggerTool.h>

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

List of all members.

Public Member Functions

 TsMultTriggerTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TsMultTriggerTool ()
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)
unsigned int getThreshold (DayaBay::Detector det)
DayaBay::Trigger::TriggerType_t getTriggerType (DayaBay::Detector det)

Private Attributes

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

Detailed Description

Definition at line 28 of file TsMultTriggerTool.h.


Constructor & Destructor Documentation

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

Definition at line 15 of file TsMultTriggerTool.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_NHitThresholdMap["DayaBayAD1"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["DayaBayAD2"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["DayaBayIWS"]=DayaBay::Trigger::kNearIWSthreshold;
  m_NHitThresholdMap["DayaBayOWS"]=DayaBay::Trigger::kNearOWSthreshold;
  m_NHitThresholdMap["LingAoAD1"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["LingAoAD2"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["LingAoIWS"]=DayaBay::Trigger::kNearIWSthreshold;
  m_NHitThresholdMap["LingAoOWS"]=DayaBay::Trigger::kNearOWSthreshold;
  m_NHitThresholdMap["FarAD1"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["FarAD2"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["FarAD3"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["FarAD4"]=DayaBay::Trigger::kADthreshold;
  m_NHitThresholdMap["FarIWS"]=DayaBay::Trigger::kFarIWSthreshold;
  m_NHitThresholdMap["FarOWS"]=DayaBay::Trigger::kFarOWSthreshold;
  
  
  declareProperty("DetectorsToProcess",m_detectorsToProcess,
                  "List of detectors to process with this tool");
  declareProperty("RecoveryTime",m_recoveryCycles=8,
                  "Number of nhit (80MHz) clock cycles for trigger dead time");
  declareProperty("NHitTriggerThreshold",m_NHitThresholdMap,
                  "Map indexed by detector name with Nhit Thresold");
  
  declareProperty("ADThreshold", 
                  m_ADThreshold = DayaBay::Trigger::kADthreshold,
                                  "DEPRICATED NHit threshold for AD Multiplicty Trigger");       
  declareProperty("FarIWSThreshold",
                  m_FarIWSThreshold=DayaBay::Trigger::kFarIWSthreshold,
                                  "DEPRICATED NHit threshold for FarIWS Multiplicity Trigger");
  declareProperty("FarOWSThreshold",
                   m_FarOWSThreshold=DayaBay::Trigger::kFarOWSthreshold,
                                  "DEPRICATED NHit threshold for FarOWS Multiplicity Trigger");
  declareProperty("NearIWSThreshold",
                  m_NearIWSThreshold=DayaBay::Trigger::kNearIWSthreshold,
                                  "NHit threshold for NearIWS Multiplicity Trigger");
  declareProperty("NearOWSThreshold",
                   m_NearOWSThreshold=DayaBay::Trigger::kNearOWSthreshold,
                              "DEPRICATED NHit threshold for NearOWS Multiplicity Trigger");
}
TsMultTriggerTool::~TsMultTriggerTool ( ) [virtual]

Definition at line 77 of file TsMultTriggerTool.cc.

{}

Member Function Documentation

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

Modify the event.

Implements ITsTriggerTool.

Definition at line 214 of file TsMultTriggerTool.cc.

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

Definition at line 79 of file TsMultTriggerTool.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 threshold " 
                           << getThreshold(det) 
                           << endreq;   
        }
        
        if(m_ADThreshold != (int) DayaBay::Trigger::kADthreshold){
            warning() << "ADThreshold Depricated use NHitTriggerThreshold"
            << endreq;
        }
        if(m_NearIWSThreshold != (int) DayaBay::Trigger::kNearIWSthreshold){
            warning() << "NearIWSThreshold Depricated use NHitTriggerThreshold"
            << endreq;
        }
        if(m_NearOWSThreshold != (int) DayaBay::Trigger::kNearOWSthreshold){
            warning() << "NearOWSThreshold Depricated use NHitTriggerThreshold"
            << endreq;
        }
        if(m_FarIWSThreshold != (int) DayaBay::Trigger::kFarIWSthreshold){
            warning() << "FarIWSThreshold Depricated use NHitTriggerThreshold"
            << endreq;
        }
        if(m_FarOWSThreshold != (int) DayaBay::Trigger::kFarOWSthreshold){
            warning() << "FarOWSThreshold Depricated use NHitTriggerThreshold"
            << endreq;
        }

        return StatusCode::SUCCESS;
}
StatusCode TsMultTriggerTool::finalize ( ) [virtual]

Definition at line 119 of file TsMultTriggerTool.cc.

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

fill new datafields here ... **TODO** args are det,type,clock,nhit,esum,esumcomp

Definition at line 124 of file TsMultTriggerTool.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;
      
      // Only create and add triggers if there is a crate for it...
      
      if(trigCollMap.find(det) == trigCollMap.end()){
          DayaBay::SimTrigCommandCollection *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]);
      
      DayaBay::ElecFeeCrate::DigitalMap hits = crate->nhit();
      DayaBay::ElecFeeCrate::DigitalMap::iterator brIt;
      DayaBay::DigitalSignal bSum; 
      
      // make running sum over all boards
      for(brIt = hits.begin(); brIt != hits.end(); ++brIt){
        if(bSum.empty()) bSum.resize((brIt->second).size(),0);
        DayaBay::DigitalSignal bSig= brIt->second;
        
        for(size_t i = 0; i != bSig.size(); ++i){
          //info() << *it << "\t" << endreq;
          bSum.at(i)+=bSig.at(i);
        }
      } // end make running sum
      
      unsigned int threshold = getThreshold(det);
      verbose() << "Trigger Threshold " << threshold 
                << " Board Sum Size " << bSum.size() << endreq;
      

      int maxNsum = -1;
      for(unsigned int i=0; i < bSum.size(); ++i){      
        if( maxNsum < bSum[i] ) maxNsum = bSum[i];
      }
      debug() << "Max multiplicity for " << det << " is " << maxNsum << endreq; 

      // issue trigger if detector goes over threshold
      for(unsigned int i=0; i < bSum.size(); ++i){
              verbose() << "Board sum entry for cycle #"<< i << "\t is " << bSum[i] << endreq;
          if ( (unsigned int)bSum[i] >= threshold ){ 
              DayaBay::Trigger::TriggerType_t type = getTriggerType(det);
              DayaBay::SimTrigCommand *tc = new DayaBay::SimTrigCommand(det,type,i,bSum[i],0,0);
              debug() << "Adding Trigger at cycle\t" <<  i
                      << " With type " << type <<  endreq;
              verbose() << "Waiting " << m_recoveryCycles << " cycles to recover" << endreq;
              i += m_recoveryCycles;
              trigCH->addCommand(tc);
          }
      }// end issue trigger
    
    }// end if crate exists
  }
  return StatusCode::SUCCESS;                               
}
unsigned int TsMultTriggerTool::getThreshold ( DayaBay::Detector  det) [private]

Definition at line 222 of file TsMultTriggerTool.cc.

                                                               {
      if( m_NHitThresholdMap.find(det.detName()) 
                     != m_NHitThresholdMap.end() ){
          return m_NHitThresholdMap[det.detName()];
      }
      {
          static int count = 10;
          if (count) {
              --count;
              warning() << "Requesting a NHit threshold for " << det.detName() 
                        << " but none was specified in input map "
                        << "Using default value as defined in Conventions/Trigger.h.  Warning you "
                        << count << " more times"
                        << endreq;
          }
      }
    if(det.detectorId() == DetectorId::kAD1 || 
       det.detectorId() == DetectorId::kAD2 ||
       det.detectorId() == DetectorId::kAD3 || 
       det.detectorId() == DetectorId::kAD4 ){
      return DayaBay::Trigger::kADthreshold;
    }
    if(det.detectorId() == DetectorId::kIWS){
      if(det.site() == Site::kFar){
         return DayaBay::Trigger::kFarIWSthreshold;
      }else{
         return DayaBay::Trigger::kNearIWSthreshold;
      }
    }
    if(det.detectorId() == DetectorId::kOWS){
      if(det.site() == Site::kFar){
         return DayaBay::Trigger::kFarOWSthreshold;
      }else{
         return DayaBay::Trigger::kNearOWSthreshold;
      }
    }
  return 0;
}
DayaBay::Trigger::TriggerType_t TsMultTriggerTool::getTriggerType ( DayaBay::Detector  det) [private]

Definition at line 261 of file TsMultTriggerTool.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 TsMultTriggerTool::m_recoveryCycles [private]

Definition at line 45 of file TsMultTriggerTool.h.

unsigned int TsMultTriggerTool::m_ADThreshold [private]

Definition at line 46 of file TsMultTriggerTool.h.

unsigned int TsMultTriggerTool::m_FarIWSThreshold [private]

Definition at line 47 of file TsMultTriggerTool.h.

unsigned int TsMultTriggerTool::m_FarOWSThreshold [private]

Definition at line 48 of file TsMultTriggerTool.h.

unsigned int TsMultTriggerTool::m_NearIWSThreshold [private]

Definition at line 49 of file TsMultTriggerTool.h.

unsigned int TsMultTriggerTool::m_NearOWSThreshold [private]

Definition at line 50 of file TsMultTriggerTool.h.

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

Definition at line 55 of file TsMultTriggerTool.h.

std::map<std::string,int> TsMultTriggerTool::m_NHitThresholdMap [private]

Definition at line 56 of file TsMultTriggerTool.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