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

#include <Co60Tag.h>

Collaboration diagram for Co60Tag:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Co60Tag (const std::string &name, ISvcLocator *svcloc)
 Constructor has to be in this form.
virtual ~Co60Tag ()
StatusCode initialize ()
 Three mandatory member functions of any algorithm.
StatusCode execute ()
StatusCode finalize ()

Private Attributes

IJobInfoSvcm_jobInfoSvc
std::string m_recHeaderLocation
std::string m_calibStatsLocation
std::string m_muonLooseLocation
std::string m_Co60Location
float m_vertexCut
float m_muonVetoTime
TimeStamp m_lastMuonTime
float m_freshStart
int m_tagged

Detailed Description

Definition at line 22 of file Co60Tag.h.


Constructor & Destructor Documentation

Co60Tag::Co60Tag ( const std::string &  name,
ISvcLocator *  svcloc 
)

Constructor has to be in this form.

Definition at line 13 of file Co60Tag.cc.

: GaudiAlgorithm(name, svcloc)
{
  declareProperty("CalibStatsLocation", m_calibStatsLocation="/Event/Data/CalibStats",
                  "Location of CalibStats User data");
  declareProperty("RecHeaderLocation", m_recHeaderLocation="/Event/Rec/AdSimple",
                  "Location of RecHeader");
  declareProperty("MuonLooseLocation", m_muonLooseLocation="/Event/Tag/Physics/MuonLoose",
                  "Location of Muon Loose Tags");
  declareProperty("Co60Location", m_Co60Location="/Event/Tag/Calib/Co60",
                  "Location of Co60 Tag");

  declareProperty("VertexCut", m_vertexCut = 0.5 * Gaudi::Units::m,
                  "Radius of the spherical vertex cut");
  declareProperty("MuonVetoTime", m_muonVetoTime = 1.0 * Gaudi::Units::ms,
                  "Duration of muon veto after a \" loose muon\".");
}
Co60Tag::~Co60Tag ( ) [virtual]

Definition at line 31 of file Co60Tag.cc.

{
}

Member Function Documentation

StatusCode Co60Tag::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 35 of file Co60Tag.cc.

{
  debug() << "initialize()" << endreq;

  m_jobInfoSvc = svc<IJobInfoSvc>("JobInfoSvc",true);
  if(!m_jobInfoSvc) {
    error() << "Failed to initialize JobInfoSvc" << endreq;
    return StatusCode::FAILURE;
  }
  m_tagged = 0;
  m_freshStart = true;

  return StatusCode::SUCCESS;
}
StatusCode Co60Tag::execute ( )

Definition at line 50 of file Co60Tag.cc.

{
  debug() << "execute() ______________________________ start" << endreq;

  //----------------------------------------
  // Get all necessary headers
  //----------------------------------------

  const DayaBay::RecHeader * recHdr = 0;  
  DayaBay::UserDataHeader *calibStatsHdr = 0;  //
  
  // Get CalibStats Header
  if (!exist<DayaBay::UserDataHeader>(evtSvc(), m_calibStatsLocation)) {
    warning() << "Cannot find header at " << m_calibStatsLocation << endreq;
    return StatusCode::FAILURE;
  } else {
    calibStatsHdr = get<DayaBay::UserDataHeader>(m_calibStatsLocation);
  }

  // Get Rec Header
  if ( !exist<DayaBay::RecHeader>(evtSvc(), m_recHeaderLocation)) {
    warning() << "Cannot find header at " << m_recHeaderLocation << endreq;
    return StatusCode::FAILURE;
  } else {
    recHdr = get<DayaBay::RecHeader>(m_recHeaderLocation);
  } 
  const DayaBay::RecTrigger& recTrigger = recHdr->recTrigger();
       
  DetectorId::DetectorId_t detectorId = recHdr->context().GetDetId(); 
  TimeStamp triggerTime = recTrigger.triggerTime();

  //----------------------------------------
  // Actual checking
  //----------------------------------------

  // Fresh start! Assume it is muon event and skip.
  if(m_freshStart){
    debug() << "Fresh start! Assume it is muon event and skip." << endreq;
    m_lastMuonTime = triggerTime;
    m_freshStart = false;
    return StatusCode::SUCCESS;
  }

  // Check if it is a muon, if so, start veto and skip.
  bool isMuon = exist<DayaBay::HeaderObject>(evtSvc(), m_muonLooseLocation);
  if (isMuon){
    debug() << "Muon found! Start veto and skip." << endreq;
    m_lastMuonTime = triggerTime;
    return StatusCode::SUCCESS;
  }
  
  // Only consider AD triggers
  if (!(detectorId == DetectorId::kAD1 || detectorId == DetectorId::kAD2
   || detectorId == DetectorId::kAD3 || detectorId == DetectorId::kAD4)) {
    debug() << "Non-AD trigger. Skip." << endreq;
    return StatusCode::SUCCESS;
  }

  // Apply muon veto
  TimeStamp timeSinceLastMuon = TimeStamp(triggerTime);
  timeSinceLastMuon.Subtract(m_lastMuonTime);
  debug() << "Current trigger time: " << triggerTime.AsString() << endreq;
  debug() << "Last muon time      : " << m_lastMuonTime.AsString() << endreq;
  debug() << "Time since last muon: " << timeSinceLastMuon.GetSeconds() << endreq;
  if (timeSinceLastMuon.GetSeconds() * Gaudi::Units::s < m_muonVetoTime){
    //Muon veto on!
    debug() << "Muon veto on! Skip." << endreq;
    return StatusCode::SUCCESS;
  }

  // Skip if recon has failed
  float recES = recTrigger.energyStatus();
  float recPS = recTrigger.positionStatus();
  if (recES != 1  || recPS != 1){ 
    debug() << "Recon failed. Skip." << endreq;
    return StatusCode::SUCCESS;
  }

  // Apply spherical position cut  
  // FIXME: Source position is hard-coded to be AD center!
  float recX = recTrigger.position().x() / Gaudi::Units::mm;
  float recY = recTrigger.position().y() / Gaudi::Units::mm;
  float recZ = recTrigger.position().z() / Gaudi::Units::mm;
  float posX = 0;
  float posY = 0;
  float posZ = 0;
  float delX = recX - posX;
  float delY = recY - posY;
  float delZ = recZ - posZ;
  float delR2 = delX*delX + delY*delY + delZ*delZ;
  debug() << "Source position: ("<< posX << ", " << posY << ", " << posZ << ")" << endreq;
  debug() << "Recon position : ("<< recX << ", " << recY << ", " << recZ << ")" << endreq;
  if (delR2 > m_vertexCut * m_vertexCut){
    debug() << "Recon position lies outside of the vertex cut! Skip." << endreq;
    return StatusCode::SUCCESS;
  }

  //----------------------------------------
  // Got a candidate, let's tag it!
  //----------------------------------------

  // Tag as Co60 event
  DayaBay::HeaderObject *header = new DayaBay::HeaderObject();
  std::vector<const DayaBay::IHeader*> inputHeaders;
  inputHeaders.push_back(recHdr);
  inputHeaders.push_back(calibStatsHdr);
  header->setInputHeaders(inputHeaders);
  header->setExecNumber(recHdr->execNumber());
  header->setContext(recHdr->context());
  header->setEarliest(recHdr->earliest());
  header->setLatest(recHdr->latest());
  m_tagged++;

  const DayaBay::JobId &m_currentJobId = m_jobInfoSvc->currentJobInfo()->jobId();
  header->setJobId(m_currentJobId);

  put(header, m_Co60Location);

  debug() << "execute() ______________________________ end" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode Co60Tag::finalize ( )

Definition at line 172 of file Co60Tag.cc.

{
  debug() << "finalize()" << endreq;
  switch(m_tagged){
    case 0: info () << "No trigger was tagged as Co60 event." << endreq; break;
    case 1: info () << "Only one trigger was tagged as Co60 event." << endreq; break;
    default: info () << m_tagged << " triggers were tagged as Co60 events." << endreq;
  }
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 35 of file Co60Tag.h.

std::string Co60Tag::m_recHeaderLocation [private]

Definition at line 37 of file Co60Tag.h.

std::string Co60Tag::m_calibStatsLocation [private]

Definition at line 38 of file Co60Tag.h.

std::string Co60Tag::m_muonLooseLocation [private]

Definition at line 39 of file Co60Tag.h.

std::string Co60Tag::m_Co60Location [private]

Definition at line 40 of file Co60Tag.h.

float Co60Tag::m_vertexCut [private]

Definition at line 42 of file Co60Tag.h.

float Co60Tag::m_muonVetoTime [private]

Definition at line 43 of file Co60Tag.h.

Definition at line 45 of file Co60Tag.h.

float Co60Tag::m_freshStart [private]

Definition at line 46 of file Co60Tag.h.

int Co60Tag::m_tagged [private]

Definition at line 47 of file Co60Tag.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:10:08 for CalibrationTagging by doxygen 1.7.4