/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 | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
ADCoincTagging Class Reference

#include <ADCoincTagging.h>

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

List of all members.

Public Member Functions

 ADCoincTagging (const std::string &name, ISvcLocator *svcloc)
 Constructor has to be in this form.
virtual ~ADCoincTagging ()
StatusCode initialize ()
 Three mandatory member functions of any algorithm.
StatusCode execute ()
StatusCode finalize ()
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode

Private Member Functions

void SaveRecData (std::vector< const DayaBay::IHeader * > &inputHeaders, DayaBay::UserDataHeader *dataHeader)
void SaveCalibStatsData (std::vector< const DayaBay::IHeader * > &inputHeaders, DayaBay::UserDataHeader *dataHeader)
void SaveOtherData (std::vector< const DayaBay::IHeader * > &inputHeaders, DayaBay::UserDataHeader *dataHeader)

Private Attributes

std::string m_location
std::string m_tagLocation
std::string m_recHeaderLoc
double m_timeWindow
double m_maxGapWindow
IDaqDetailsSvcm_daqDetailsSvc
std::map
< DetectorId::DetectorId_t,
std::vector< const
DayaBay::IHeader * > > 
m_inputHeaders
std::map
< DetectorId::DetectorId_t,
TimeStamp
m_lastTimeStamp
int m_nTagged
int m_nTaggedTriggers

Detailed Description

Definition at line 16 of file ADCoincTagging.h.


Constructor & Destructor Documentation

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

Constructor has to be in this form.

Definition at line 27 of file ADCoincTagging.cc.

    : DybBaseAlg(name, svcloc),
    m_nTagged(0), m_nTaggedTriggers(0)
{
    declareProperty("RecLocation", m_recHeaderLoc="/Event/Rec/AdSimple",
            "the TES path of target event header location");
    declareProperty("Location", m_location="/Event/Data/Physics/CoincidenceLoose",
            "the TES path of AD Coincidence Data location");
    declareProperty("TagLocation", m_tagLocation="/Event/Tag/Physics/CoincidenceLoose",
            "the TES path of AD Coincidence Tag location");         
    declareProperty("TimeWindow", m_timeWindow=200*Gaudi::Units::microsecond,
        "AD coincidence time window");
    declareProperty("MaxGapWindow", m_maxGapWindow=0.2*Gaudi::Units::second,
        "Maximum Gap between two triggers in one AD");
}
ADCoincTagging::~ADCoincTagging ( ) [virtual]

Definition at line 44 of file ADCoincTagging.cc.

{
}

Member Function Documentation

StatusCode ADCoincTagging::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 49 of file ADCoincTagging.cc.

{
    info() << "initialize: coincidence time window: " << m_timeWindow/Gaudi::Units::microsecond << " microseconds" << endreq;    

    m_daqDetailsSvc = svc<IDaqDetailsSvc>("DetailsFromRecordSvc", true);
    if (!m_daqDetailsSvc) {
        error() << "Failed to load IDaqDetailsSvc" << endreq;
        return StatusCode::FAILURE;
    }
    
    // initialize
    m_inputHeaders[DetectorId::kAD1] = vector<const IHeader*>();
    m_inputHeaders[DetectorId::kAD2] = vector<const IHeader*>();
    m_inputHeaders[DetectorId::kAD3] = vector<const IHeader*>();
    m_inputHeaders[DetectorId::kAD4] = vector<const IHeader*>();
    
    return StatusCode::SUCCESS;
}
StatusCode ADCoincTagging::execute ( )

Definition at line 70 of file ADCoincTagging.cc.

{   
    RecHeader* recHeader = get<RecHeader>(m_recHeaderLoc);
    if ( !recHeader ) {
        warning() << "Cannot find header at " << m_recHeaderLoc << endreq;
        return StatusCode::FAILURE;
    } 
    
    TimeStamp ts = recHeader->context().GetTimeStamp();
    DetectorId::DetectorId_t detectorId = recHeader->context().GetDetId();
    
    TimeStamp lastTS = ts;
    
    if(m_lastTimeStamp.find(detectorId) != m_lastTimeStamp.end()){
        lastTS = m_lastTimeStamp[detectorId];
    }       
    m_lastTimeStamp[detectorId] = ts;
        
    // only look for AD Coincidence
    if (   detectorId == DetectorId::kIWS 
        || detectorId == DetectorId::kOWS 
        || detectorId == DetectorId::kRPC) {
        return StatusCode::SUCCESS; 
    }
    
    TimeStamp dt = TimeStamp(ts);
    dt.Subtract(lastTS);
    double dt_sec = dt.GetSeconds();
    
    if (dt_sec*Gaudi::Units::second > m_timeWindow) {
        int multiplicity = m_inputHeaders[detectorId].size();
        if (multiplicity < 2) {
            m_inputHeaders[detectorId].clear();
        }
        else {
            // found a gap
            
            if (dt_sec*Gaudi::Units::second > m_maxGapWindow) {
                // long gap in DAQ, the previous multiplets not in memory any more
                warning() << "Event gap in AD " << detectorId << ": " << dt_sec << " sec" << endreq;
            } 
            else {
                // found a conincident multiplet
                vector<const IHeader*>& inputHeaders = m_inputHeaders[detectorId];
                                                
                // save a (redundant) tag header object into the tag location                
                HeaderObject *tag = MakeHeader<HeaderObject>(inputHeaders);                
                put(tag, m_tagLocation);
                                
                // make the UserData                
                UserDataHeader* data = MakeHeader<UserDataHeader>(inputHeaders);
                
                // store user-defined data
                SaveRecData(inputHeaders, data);
                SaveCalibStatsData(inputHeaders, data);
                SaveOtherData(inputHeaders, data);
                
                // save UserData to TES
                put(data, m_location);
                
                m_nTagged++;
                m_nTaggedTriggers += multiplicity;
                // info() << "found one: multiplicty " << multiplicity 
                //        << " execNumber: " << execNumber << endreq;
            }
            
            m_inputHeaders[detectorId].clear();
        }
    }
    
    m_inputHeaders[detectorId].push_back(recHeader);
     
    return StatusCode::SUCCESS;
}
StatusCode ADCoincTagging::finalize ( )

Definition at line 146 of file ADCoincTagging.cc.

{
    info() << m_nTagged << " multiplets (" << m_nTaggedTriggers 
           << " triggers) tagged at " << m_location  << endreq;
    return StatusCode::SUCCESS;
}
void ADCoincTagging::SaveRecData ( std::vector< const DayaBay::IHeader * > &  inputHeaders,
DayaBay::UserDataHeader dataHeader 
) [private]
void ADCoincTagging::SaveCalibStatsData ( std::vector< const DayaBay::IHeader * > &  inputHeaders,
DayaBay::UserDataHeader dataHeader 
) [private]
void ADCoincTagging::SaveOtherData ( std::vector< const DayaBay::IHeader * > &  inputHeaders,
DayaBay::UserDataHeader dataHeader 
) [private]

Member Data Documentation

std::string ADCoincTagging::m_location [private]

Reimplemented from DybBaseAlg.

Definition at line 30 of file ADCoincTagging.h.

std::string ADCoincTagging::m_tagLocation [private]

Definition at line 31 of file ADCoincTagging.h.

std::string ADCoincTagging::m_recHeaderLoc [private]

Definition at line 32 of file ADCoincTagging.h.

double ADCoincTagging::m_timeWindow [private]

Definition at line 33 of file ADCoincTagging.h.

Definition at line 34 of file ADCoincTagging.h.

Definition at line 37 of file ADCoincTagging.h.

Reimplemented from DybBaseAlg.

Definition at line 38 of file ADCoincTagging.h.

Definition at line 39 of file ADCoincTagging.h.

Definition at line 40 of file ADCoincTagging.h.

Definition at line 41 of file ADCoincTagging.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:46 for ADCoincTagging by doxygen 1.7.4