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

#include <ADETWindowTag.h>

Collaboration diagram for ADETWindowTag:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Private Attributes

IJobInfoSvcm_jobInfoSvc
map< DetectorId::DetectorId_t,
vector< const DayaBay::IHeader * > > 
m_inputHeaders
map< DetectorId::DetectorId_t,
vector< TimeStamp > > 
m_timeStamp
string m_recHeaderLoc
float m_lowECut
float m_highECut
int m_timeWindow
int m_nTagged

Detailed Description

Definition at line 18 of file ADETWindowTag.h.


Constructor & Destructor Documentation

ADETWindowTag::ADETWindowTag ( const string &  name,
ISvcLocator *  svcloc 
)

Constructor has to be in this form.

Definition at line 11 of file ADETWindowTag.cc.

: GaudiAlgorithm(name, svcloc)
{
  declareProperty("location", m_recHeaderLoc = "/Event/Rec/AdSimple",
        "the TES path of target event header location");
  declareProperty("LowECut", m_lowECut = 4*Gaudi::Units::MeV,
                  "ETWindow low energy cut");
  declareProperty("HighECut", m_highECut = 15*Gaudi::Units::MeV,
                  "ETWindow high energy cut");
  declareProperty("TimeWindow", m_timeWindow = 400*Gaudi::Units::microsecond,
                  "ETWindow time window");
  m_nTagged = 0;
}
ADETWindowTag::~ADETWindowTag ( ) [virtual]

Definition at line 25 of file ADETWindowTag.cc.

{
}

Member Function Documentation

StatusCode ADETWindowTag::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 29 of file ADETWindowTag.cc.

{
  info() << "initialize(), lowECut=" << m_lowECut <<", highECut="<<m_highECut<<", timeWindow="<<m_timeWindow<< endreq;

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

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

Definition at line 45 of file ADETWindowTag.cc.

{
  DayaBay::RecHeader* recHeader = get<DayaBay::RecHeader>(m_recHeaderLoc);
  if ( !recHeader ) {
        warning() << "Cannot find header at " << m_recHeaderLoc << endreq;
        return StatusCode::FAILURE;
  }
  DetectorId::DetectorId_t detectorId = recHeader->context().GetDetId(); 
  if(detectorId != DetectorId::kAD1 && detectorId != DetectorId::kAD2 && detectorId != DetectorId::kAD3 && detectorId != DetectorId::kAD4){
     // not a AD recHeader 
     return StatusCode::SUCCESS;
  }    
  TimeStamp nTS = recHeader->context().GetTimeStamp();
  double energy = recHeader->recTrigger().energy();

  if(m_inputHeaders.find(detectorId) != m_inputHeaders.end()){
    m_inputHeaders[detectorId].push_back(recHeader);
    m_timeStamp[detectorId].push_back(nTS);
  }
  else{
    vector<const DayaBay::IHeader*> inputHeaders;
    vector<TimeStamp> timeStamp;
    inputHeaders.push_back(recHeader);
    timeStamp.push_back(nTS);
    m_inputHeaders[detectorId] = inputHeaders;
    m_timeStamp[detectorId] = timeStamp;
  } 

  nTS.Subtract(m_timeStamp[detectorId].at(0));
  double deltaT = nTS.GetSeconds()*Gaudi::Units::second;
  while(deltaT > m_timeWindow){
    m_inputHeaders[detectorId].erase(m_inputHeaders[detectorId].begin());
    m_timeStamp[detectorId].erase(m_timeStamp[detectorId].begin());
    nTS = recHeader->context().GetTimeStamp();
    nTS.Subtract(m_timeStamp[detectorId].at(0));
    deltaT = nTS.GetSeconds()*Gaudi::Units::second;
  }
  
  if(energy > m_lowECut && energy < m_highECut){
    DayaBay::HeaderObject *ADETWindowTag = new DayaBay::HeaderObject();
    ADETWindowTag->setInputHeaders(m_inputHeaders[detectorId]);
    // Copy from the recHeader
    ADETWindowTag->setExecNumber(recHeader->execNumber());
    ADETWindowTag->setContext(recHeader->context());
    ADETWindowTag->setEarliest(recHeader->earliest());
    ADETWindowTag->setLatest(recHeader->latest());
    // Get job id
    const DayaBay::JobId &jobId = m_jobInfoSvc->currentJobInfo()->jobId();
    ADETWindowTag->setJobId(jobId);
  
    if(detectorId == DetectorId::kAD1 ||
                detectorId == DetectorId::kAD2 ||
                detectorId == DetectorId::kAD3 ||
                detectorId == DetectorId::kAD4) {
      put(ADETWindowTag,"/Event/Tag/Physics/ADETWindow");
    }

    /*if(m_inputHeaders[detectorId].size() > 1){
      m_inputHeaders[detectorId].clear();
      m_timeStamp[detectorId].clear();
    }
    */
    
    m_nTagged++;
  }
  
  return StatusCode::SUCCESS;
}
StatusCode ADETWindowTag::finalize ( )

Definition at line 114 of file ADETWindowTag.cc.

{
  info() << "finalize(), " <<m_nTagged << " events tagged."<< endreq;
}

Member Data Documentation

Definition at line 31 of file ADETWindowTag.h.

Definition at line 32 of file ADETWindowTag.h.

Definition at line 33 of file ADETWindowTag.h.

Definition at line 34 of file ADETWindowTag.h.

float ADETWindowTag::m_lowECut [private]

Definition at line 35 of file ADETWindowTag.h.

float ADETWindowTag::m_highECut [private]

Definition at line 36 of file ADETWindowTag.h.

Definition at line 37 of file ADETWindowTag.h.

int ADETWindowTag::m_nTagged [private]

Definition at line 38 of file ADETWindowTag.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:19 for ADETWindowTagging by doxygen 1.7.4