/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 | Private Attributes
MuonTimingAlg Class Reference

#include <MuonTimingAlg.h>

Collaboration diagram for MuonTimingAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MuonTimingAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~MuonTimingAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()

Private Attributes

std::string m_readoutLocation
 Property ReadoutLocation - location in TES where the input ReadoutHeader is to be found.
ICableSvcm_cableSvc
IPmtGeomInfoSvcm_pmtGeomSvc
IStatisticsSvcm_statsSvc

Detailed Description

Definition at line 23 of file MuonTimingAlg.h.


Constructor & Destructor Documentation

MuonTimingAlg::MuonTimingAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 28 of file MuonTimingAlg.cc.

    : GaudiAlgorithm(name,pSvcLocator)
    , m_cableSvc(0)
    , m_pmtGeomSvc(0)
    , m_statsSvc(0)
{
    declareProperty("ReadoutLocation",
                    m_readoutLocation=DayaBay::ReadoutHeaderLocation::Default,
                    "Location in the TES where the input ReadoutHeader is to be found.");
}
MuonTimingAlg::~MuonTimingAlg ( ) [virtual]

Definition at line 39 of file MuonTimingAlg.cc.

{
}

Member Function Documentation

StatusCode MuonTimingAlg::initialize ( ) [virtual]

Definition at line 43 of file MuonTimingAlg.cc.

{
  StatusCode sc = this->GaudiAlgorithm::initialize();
  if( sc != StatusCode::SUCCESS ) return sc;

  // Get Cable Service
  m_cableSvc = svc<ICableSvc>("CableSvc",true);
  if(!m_cableSvc){
    error() << "Failed to access cable service." << endreq;
    return StatusCode::FAILURE;
  }
  
  //Get PMT geometry service
  m_pmtGeomSvc = svc<IPmtGeomInfoSvc>("PmtGeomInfoSvc", true);
  if(!m_pmtGeomSvc ){
    error() << "Failed to access PMT geometry service." << endreq;
    return StatusCode::FAILURE;
  }
  
  // Get the histogram service
  m_statsSvc = svc<IStatisticsSvc>("StatisticsSvc",true);
  if(!m_statsSvc) {
    error() << "Failed to access Statistics service." << endreq;
    return StatusCode::FAILURE;
  }
  
  return StatusCode::SUCCESS;
}
StatusCode MuonTimingAlg::execute ( ) [virtual]

Definition at line 72 of file MuonTimingAlg.cc.

{
  // Get input header
  DayaBay::ReadoutHeader* readoutHeader = 
    get<DayaBay::ReadoutHeader>(m_readoutLocation);

  DayaBay::Detector detector(readoutHeader->context().GetSite(),
                             readoutHeader->context().GetDetId());

  // Skip non-water pool events
  if(!detector.isWaterShield()) return StatusCode::SUCCESS; 

  // Get raw event data
  const DayaBay::DaqCrate* daqCrate = readoutHeader->daqCrate();
  if(!daqCrate){
    error() << "Failed to get DAQ crate from header" << endreq;
    return StatusCode::FAILURE;
  }
  const DayaBay::DaqPmtCrate* pmtCrate = daqCrate->asPmtCrate();
  if(!pmtCrate){
    error() << "Failed to convert to PMT readout!" << endreq;
    return StatusCode::FAILURE;
  }

  // Get trigger type
  DayaBay::Trigger::TriggerType_t trigType = daqCrate->triggerType();
  if (trigType == 268435472){
     return StatusCode::SUCCESS;
  }      
  info()<<"<-------------------------line---------------------------->"<<endreq;
  info()<<"trigger type:"<<trigType<<endreq;
  // FIXME: Add any selection on trigger type here
  // if( ... ) return StatusCode::SUCCESS;  // skip this trigger

  //event number shows the event sequence
  int Event=daqCrate->eventNumber();
  info()<<"Event:"<<Event<<endreq;
  
  // Get context for database calls
  Context context = readoutHeader->context();
  ServiceMode svcMode(context, 0);

  // Loop over hits in water pool event, and collect data
  const DayaBay::DaqPmtCrate::PmtChannelPtrList& channels
    = pmtCrate->channelReadouts();    
  DayaBay::DaqPmtCrate::PmtChannelPtrList::const_iterator channelIter, 
    channelEnd = channels.end();
  for(channelIter = channels.begin(); channelIter!=channelEnd; channelIter++) { 
    // Process data from each FEE channel
    // Det,Board and Channel
    const DayaBay::DaqPmtChannel& channel = *(*channelIter);
    const DayaBay::FeeChannelId& chanId = channel.channelId();
    const DayaBay::DetectorSensor& sensDetId 
      = m_cableSvc->sensor(chanId, svcMode);
    //get the wall number and wall spot info
    const DayaBay::PoolPmtSensor pmtId = m_cableSvc->poolPmtSensor(chanId, svcMode);

    //get PMT geometry info, coordinator
    float pmtx = 0;
    float pmty = 0;
    float pmtz = 0;

    const CLHEP::Hep3Vector pos = m_pmtGeomSvc->get(pmtId.fullPackedData())->localPosition();
    pmtx = pos.x();
    pmty = pos.y();
    pmtz = pos.z();
    info()<<"x:"<<pmtx<<",y:"<<pmty<<",z:"<<pmtz<<endreq;
    float distance = sqrt(pow((pmtx-LED[0][0]),2)+pow((pmty-LED[0][1]),2)+pow((pmtz-LED[0][2]),2));
    info()<<"distance(mm):"<<distance<<endreq;    
    float tof = distance*1e6/c; 
    info()<<"time of flight(ns):"<<tof<<endreq;    
    if (sensDetId.bogus()) {
      warning() << "Got bogus PMT: \"" << sensDetId
                << "\" using channelId: \"" << chanId
                << "\" and context \"" << context.AsString() << "\""
                << endreq;
      continue;
    }
    int wall = pmtId.wallNumber();
    int spot = pmtId.wallSpot();
    bool inwardFacing = pmtId.inwardFacing();
    info()<<"wall number:"<<wall<<","<<"spot:"<<spot<<"inwardfacing:"<<inwardFacing<<endreq;

    // Process all hits on this channel
    //for(unsigned int i=0; i<channel.hitCount(); i++) {
    //just loop the first hit to get the direct light, no reflection
    for(unsigned int i=0; i<1; i++) {     
      int adcClock = channel.peakCycle(i);
      int adc = channel.adc(i);
      float preAdc = channel.preAdcAvg(i);
      int tdc = channel.tdc(i);  //tdc trigger time offset
      bool isHighGain = channel.isHighGainAdc(i);
      
      if(isHighGain = 1){adc = adc-preAdc;}
      else {adc = (adc-preAdc)*20;}
       
      // FIXME: Insert code here to process data from each hit
      float tdcns = 1.5625*tdc;
      info()<<"adc-preAdc:"<<adc-preAdc<<","<<"tdc(ns):"<<tdcns<<endreq;//add isHighGain selection
      info()<<"Tdc-TOF with unknown trigger time offset:"<<tdcns-tof<<endreq;
      info()<<"<--------------hit end line-------------------->"<<endreq;
    }

  }

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

Definition at line 180 of file MuonTimingAlg.cc.

{
  // After processing all events, run calibration calculation to
  // determine timing offsets.
  
  // FIXME: insert timing calibration calculation here
  // Write output to statistics svc or directly to text file

  return this->GaudiAlgorithm::finalize();
}

Member Data Documentation

std::string MuonTimingAlg::m_readoutLocation [private]

Property ReadoutLocation - location in TES where the input ReadoutHeader is to be found.

Default is DayaBay::ReadoutHeader::Default

Definition at line 41 of file MuonTimingAlg.h.

Definition at line 44 of file MuonTimingAlg.h.

Definition at line 47 of file MuonTimingAlg.h.

Definition at line 50 of file MuonTimingAlg.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:04:28 for CalibParam by doxygen 1.7.4