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

#include <NeutronSpLooseTag.h>

Collaboration diagram for NeutronSpLooseTag:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Private Attributes

IJobInfoSvcm_jobInfoSvc
IDataProviderSvc * m_archiveSvc
string m_recHeaderLoc
string m_tagloc
string m_muonloc
int m_count
float m_eCutLow
float m_eCutHigh
float m_zCut
float m_rCut
float m_timeCutLow
float m_timeCutHigh

Detailed Description

Definition at line 18 of file NeutronSpLooseTag.h.


Constructor & Destructor Documentation

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

Constructor has to be in this form.

Definition at line 21 of file NeutronSpLooseTag.cc.

: GaudiAlgorithm(name, svcloc)
{
  declareProperty("location", m_recHeaderLoc, 
                  "the TES path of target event header location");
  declareProperty("NeutronSpTag_location", m_tagloc, 
                  "tagPath:dataPath for spallation neutron events");
  declareProperty("first_muon_location", m_muonloc,
                  "path for first muon trigger tag");

  declareProperty("low_energy_cut", m_eCutLow, 
                  "low energy cut, units MeV");
  declareProperty("high_energy_cut", m_eCutHigh, 
                  "high energy cut, units MeV");

  declareProperty("zcut", m_zCut, 
                  "vertex cut on z direction, units mm");
  declareProperty("rcut", m_rCut, 
                  "vertex cut on r direction, units mm");

  declareProperty("time_window_start", m_timeCutLow, 
                  "time window start time, units micro second");
  declareProperty("time_window_end", m_timeCutHigh, 
                  "time window end time, units micro second");
}
NeutronSpLooseTag::~NeutronSpLooseTag ( ) [virtual]

Definition at line 47 of file NeutronSpLooseTag.cc.

{
}

Member Function Documentation

StatusCode NeutronSpLooseTag::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 51 of file NeutronSpLooseTag.cc.

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

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

  //Get Archive Svc
  StatusCode status = service("EventDataArchiveSvc", m_archiveSvc);
  if (status.isFailure()) {
    Error("Service [EventDataArchiveSvc] not found", status);
  }

  m_count=0;

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

Definition at line 72 of file NeutronSpLooseTag.cc.

{
  debug() << "executing ... " << endreq;

  //  This part needs rework after framing or event building.
  
  // Get AdSimple
  RecHeader* recHeader = get<RecHeader>(m_recHeaderLoc);
  if(exist<HeaderObject>(m_muonloc))
    {
      HeaderObject* HeaderObj = get<HeaderObject>(m_muonloc);
      if(HeaderObj)
        {
          debug() << "Got Muon Header Obj in TES." << endreq;
        }
    }

  DetectorId::DetectorId_t detectorId = recHeader->context().GetDetId();
  //Only in AD
  if(detectorId == DetectorId::kAD1 || detectorId == DetectorId::kAD2
      || detectorId == DetectorId::kAD3 || detectorId == DetectorId::kAD4)
    {
      bool surroundingActivity = false;
      double E = recHeader->recTrigger().energy()*Gaudi::Units::MeV;
      double Z = fabs(recHeader->recTrigger().position().z())*Gaudi::Units::millimeter;
      double R = sqrt((recHeader->recTrigger().position().x())*(recHeader->recTrigger().position().x())+(recHeader->recTrigger().position().y())*(recHeader->recTrigger().position().y()))*Gaudi::Units::millimeter;
      debug() << "Energy: " << E/Gaudi::Units::MeV << endreq;
      debug() << "Z: " << Z/Gaudi::Units::millimeter << endreq;
      debug() << "R: " << R/Gaudi::Units::millimeter << endreq;

      //Energy Cut & Vertex Cut
      if(E>m_eCutLow && E<m_eCutHigh 
         && Z<m_zCut 
         && R<m_rCut
         && surroundingActivity == false)
        {
          //Get muon list
          SmartDataPtr<DybArchiveList>  muonlist(m_archiveSvc, m_muonloc);
          if(muonlist)
            {
              debug() << "Number of muon in the ArchiveList: " << muonlist->size() << endreq;
            }
          else
            {
              debug() << "No MuonList in AES" << endreq;
              return StatusCode::SUCCESS;
            }
          
          DybArchiveList::const_iterator iter = muonlist->begin();
          for(; iter!=muonlist->end(); iter++)
            {
              HeaderObject* muonTag = dynamic_cast<HeaderObject*>(*iter);
              TimeStamp muonTime(muonTag->timeStamp());
              TimeStamp currentTime(recHeader->timeStamp());
              TimeStamp deltaT = currentTime;
              deltaT.Subtract(muonTime);
              double dt = deltaT.GetSeconds()*Gaudi::Units::second;
              if(dt>m_timeCutLow && dt<m_timeCutHigh)
                {
                  //Make a new Header as a tag
                  HeaderObject *SpalNLooseTag = new HeaderObject();
                  // Use inputHeaders to record the RecHeader which is connect to this tag
                  vector<const IHeader*> inputHeaders;
                  inputHeaders.push_back(recHeader);
                  SpalNLooseTag->setInputHeaders(inputHeaders);
                  // Copy from the ReadoutHeader
                  SpalNLooseTag->setExecNumber(recHeader->execNumber());
                  SpalNLooseTag->setContext(recHeader->context());
                  SpalNLooseTag->setEarliest(recHeader->earliest());
                  SpalNLooseTag->setLatest(recHeader->latest());
                  // Get job id
                  const DayaBay::JobId &m_currentJobId = m_jobInfoSvc->currentJobInfo()->jobId();
                  SpalNLooseTag->setJobId(m_currentJobId);

                  put(SpalNLooseTag, m_tagloc);
                  m_count++;
                }
              debug() << "DeltaT: " << dt << endreq;
              break;
            }
        }
    }

  return StatusCode::SUCCESS;
}
StatusCode NeutronSpLooseTag::finalize ( )

Definition at line 160 of file NeutronSpLooseTag.cc.

{
  debug() << "finalize()" << endreq;
  info() << "Summary: Tagger NeutronSpLooseTag : "<< m_count <<" events tagged at "<< m_tagloc << endreq;
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 31 of file NeutronSpLooseTag.h.

IDataProviderSvc* NeutronSpLooseTag::m_archiveSvc [private]

Definition at line 32 of file NeutronSpLooseTag.h.

Definition at line 33 of file NeutronSpLooseTag.h.

string NeutronSpLooseTag::m_tagloc [private]

Definition at line 34 of file NeutronSpLooseTag.h.

string NeutronSpLooseTag::m_muonloc [private]

Definition at line 35 of file NeutronSpLooseTag.h.

Definition at line 36 of file NeutronSpLooseTag.h.

Definition at line 38 of file NeutronSpLooseTag.h.

Definition at line 39 of file NeutronSpLooseTag.h.

float NeutronSpLooseTag::m_zCut [private]

Definition at line 41 of file NeutronSpLooseTag.h.

float NeutronSpLooseTag::m_rCut [private]

Definition at line 42 of file NeutronSpLooseTag.h.

Definition at line 44 of file NeutronSpLooseTag.h.

Definition at line 45 of file NeutronSpLooseTag.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:37 for SpNeutronTagging by doxygen 1.7.4