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

#include <ADETWindowData.h>

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

List of all members.

Public Member Functions

 ADETWindowData (const string &name, ISvcLocator *svcloc)
virtual ~ADETWindowData ()
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
DayaBay::UserDataHeaderGetCurrentHeaderObject () const
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

DayaBay::UserDataHeaderMakeHeaderObject ()
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
std::string m_location

Private Member Functions

void SaveRecData (DayaBay::HeaderObject *tagHeader, DayaBay::UserDataHeader *dataHeader)
void SaveCalibStatsData (DayaBay::HeaderObject *tagHeader, DayaBay::UserDataHeader *dataHeader)
void SaveOtherData (DayaBay::HeaderObject *tagHeader, DayaBay::UserDataHeader *dataHeader)

Private Attributes

int m_nTagged
string m_tagLoc
string m_dataLoc
string m_muonLoc
IDaqDetailsSvcm_daqDetailsSvc
IDataProviderSvc * m_archiveSvc

Detailed Description

Definition at line 13 of file ADETWindowData.h.


Constructor & Destructor Documentation

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

Definition at line 11 of file ADETWindowData.cc.

   : DybAlgorithm<UserDataHeader>(name, svcloc),
   m_nTagged(0)
{
   // default data location
   m_tagLoc = "/Event/Tag/Physics/ADETWindow";
   m_dataLoc = "/Event/Data/Physics/ADETWindow";
   m_muonLoc = "/Event/Tag/Muon/MuonAll";
}
ADETWindowData::~ADETWindowData ( ) [virtual]

Definition at line 22 of file ADETWindowData.cc.

{
}

Member Function Documentation

StatusCode ADETWindowData::initialize ( )

Definition at line 27 of file ADETWindowData.cc.

{
   StatusCode sc = this->GaudiAlgorithm::initialize();
   if (sc.isFailure()) return sc;
   info() << "initialize" << endreq;   
   
   m_daqDetailsSvc = svc<IDaqDetailsSvc>("DetailsFromRecordSvc", true);
   if (!m_daqDetailsSvc) {
      error() << "Failed to load IDaqDetailsSvc" << endreq;
      return StatusCode::FAILURE;
   }

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

Definition at line 51 of file ADETWindowData.cc.

{   
   if (!exist<HeaderObject>("/Event/Tag/Physics/ADETWindow")) {
      // not a ADETWindowTag 
      return StatusCode::SUCCESS;
   }
   m_location = m_dataLoc; // set the output location
   
   HeaderObject *tagHeader = getTES<HeaderObject>(m_tagLoc);
   UserDataHeader* dataHeader = MakeHeaderObject();
   dataHeader->setContext(tagHeader->context());
   dataHeader->setEarliest(tagHeader->earliest());
   dataHeader->setLatest(tagHeader->latest());

   SaveRecData(tagHeader, dataHeader);
   SaveCalibStatsData(tagHeader, dataHeader);
   SaveOtherData(tagHeader, dataHeader);
   
   m_nTagged++;
   return StatusCode::SUCCESS;
}
StatusCode ADETWindowData::finalize ( )

Definition at line 74 of file ADETWindowData.cc.

{
   info() << m_nTagged << " events tagged at " << m_dataLoc << endreq;
   return this->GaudiAlgorithm::finalize();
}
void ADETWindowData::SaveRecData ( DayaBay::HeaderObject tagHeader,
DayaBay::UserDataHeader dataHeader 
) [private]

Definition at line 82 of file ADETWindowData.cc.

{
   // initialize data vectors
   vector<float> e, x, y, z;
   vector<int> triggerNumber, triggerType, t_s, t_ns, dt_ns, energyStatus, positionStatus;
   float dtLastAD1_Muon_ms = 0; 
   float dtLastAD2_Muon_ms = 0; 
   float dtLastAD3_Muon_ms = 0; 
   float dtLastAD4_Muon_ms = 0; 
   float dtLastIWS_Muon_ms = 0; 
   float dtLastOWS_Muon_ms = 0; 
   float dtLastRPC_Muon_ms = 0;
   
   vector<const IHeader*> inputHeaders = tagHeader->inputHeaders();
   int t0_s = 0; 
   int t0_ns = 0; 
   for (size_t i=0; i<inputHeaders.size(); i++) {
      const RecHeader* recHeader = dynamic_cast<const RecHeader*>(inputHeaders[i]);
      RecTrigger result = recHeader->recTrigger();
      e.push_back(result.energy()/Gaudi::Units::MeV);
      x.push_back(result.position().x()/Gaudi::Units::mm);
      y.push_back(result.position().y()/Gaudi::Units::mm);
      z.push_back(result.position().z()/Gaudi::Units::mm);
      triggerNumber.push_back(result.triggerNumber());
      triggerType.push_back(result.triggerType());

      energyStatus.push_back(result.energyStatus());
      positionStatus.push_back(result.positionStatus());
      int thisT_s = recHeader->timeStamp().GetSec();
      int thisT_ns = recHeader->timeStamp().GetNanoSec();
      if (0 == i) {
         t0_s = thisT_s;
         t0_ns = thisT_ns;
      }
      t_s.push_back(thisT_s);
      t_ns.push_back(thisT_ns);
      dt_ns.push_back( int((thisT_s-t0_s)*1e9 + thisT_ns - t0_ns));
   }
   
   dataHeader->set("e", e);
   dataHeader->set("x", x);
   dataHeader->set("y", y);
   dataHeader->set("z", z);
   dataHeader->set("triggerNumber", triggerNumber);
   dataHeader->set("triggerType", triggerType);
   dataHeader->set("t_s", t_s);
   dataHeader->set("t_ns", t_ns);
   dataHeader->set("dt_ns", dt_ns);
   dataHeader->set("energyStatus", energyStatus);
   dataHeader->set("positionStatus", positionStatus);

   SmartDataPtr<DybArchiveList>  muonlist(m_archiveSvc, m_muonLoc);
   if(muonlist) {
      debug() << "Number of muon in the ArchiveList: " << muonlist->size() << endreq;
   }
   else{
      warning() << "No MuonList found at /Event/Tag/Muon/MuonAll" << endreq;
      dataHeader->set("dtLastAD1_Muon_ms", dtLastAD1_Muon_ms);
      dataHeader->set("dtLastAD2_Muon_ms", dtLastAD2_Muon_ms);
      dataHeader->set("dtLastAD3_Muon_ms", dtLastAD3_Muon_ms);
      dataHeader->set("dtLastAD4_Muon_ms", dtLastAD4_Muon_ms);
      dataHeader->set("dtLastIWS_Muon_ms", dtLastIWS_Muon_ms);
      dataHeader->set("dtLastOWS_Muon_ms", dtLastOWS_Muon_ms);
      dataHeader->set("dtLastRPC_Muon_ms", dtLastRPC_Muon_ms);
      return;
   }

   DybArchiveList::const_iterator iter = muonlist->begin();
   for(; iter!=muonlist->end(); iter++) {
      HeaderObject* muonAllTag = dynamic_cast<HeaderObject*>(*iter);
      const std::vector<const IHeader*> &crhs = muonAllTag->findHeaders(CalibReadoutHeader::classID());
      for (size_t i=0; i<crhs.size(); i++) {
         HeaderObject* muonTagHeader = dynamic_cast<HeaderObject*>(const_cast<IHeader*>(crhs[i]));
         if(!muonTagHeader){
            warning() <<"No muonTagHeader found."<<endreq;
         }
         int muonDetId = muonTagHeader->context().GetDetId();
         TimeStamp muonTime(muonTagHeader->timeStamp());
         TimeStamp currentTime(dataHeader->timeStamp());
         currentTime.Subtract(muonTime);
         if(muonDetId == DetectorId::kAD1 && dtLastAD1_Muon_ms == 0) {
            dtLastAD1_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kAD2 && dtLastAD2_Muon_ms == 0) {
            dtLastAD2_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kAD3 && dtLastAD3_Muon_ms == 0) {
            dtLastAD3_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kAD4 && dtLastAD4_Muon_ms == 0) {
            dtLastAD4_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kIWS && dtLastIWS_Muon_ms == 0) {
            dtLastIWS_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kOWS && dtLastOWS_Muon_ms == 0) {
            dtLastOWS_Muon_ms = currentTime.GetSeconds()*1e3;
         }
         if(muonDetId == DetectorId::kRPC && dtLastRPC_Muon_ms == 0) {
            dtLastRPC_Muon_ms = currentTime.GetSeconds()*1e3;
         }
      }
   }
   dataHeader->set("dtLastAD1_Muon_ms", dtLastAD1_Muon_ms);
   dataHeader->set("dtLastAD2_Muon_ms", dtLastAD2_Muon_ms);
   dataHeader->set("dtLastAD3_Muon_ms", dtLastAD3_Muon_ms);
   dataHeader->set("dtLastAD4_Muon_ms", dtLastAD4_Muon_ms);
   dataHeader->set("dtLastIWS_Muon_ms", dtLastIWS_Muon_ms);
   dataHeader->set("dtLastOWS_Muon_ms", dtLastOWS_Muon_ms);
   dataHeader->set("dtLastRPC_Muon_ms", dtLastRPC_Muon_ms);
}
void ADETWindowData::SaveCalibStatsData ( DayaBay::HeaderObject tagHeader,
DayaBay::UserDataHeader dataHeader 
) [private]

Definition at line 194 of file ADETWindowData.cc.

{
   int nDataInt = 1;
   int nDataFloat = 29;
   string dataStrInt[] = { "nHit" };
   string dataStrFloat[] = { 
      "nPESum", "nPEMedian", "nPERMS", "nPEMax", "nPulseSum", "nPulseMedian", "nPulseRMS",
      "tEarliest", "tLatest", "tMean", "tMedian", "tRMS", "EarlyCharge", "MiddleCharge", "LateCharge",
      "dtLastAD1_ms", "dtLastAD2_ms", "dtLastAD3_ms", "dtLastAD4_ms", "dtLastIWS_ms", "dtLastOWS_ms", "dtLastRPC_ms",
      "dtNextAD1_ms", "dtNextAD2_ms", "dtNextAD3_ms", "dtNextAD4_ms", "dtNextIWS_ms", "dtNextOWS_ms", "dtNextRPC_ms"
   };
   
   vector< vector<int> > dataInt(nDataInt);
   vector< vector<float> > dataFloat(nDataFloat);

   vector<const IHeader*> inputHeaders = tagHeader->inputHeaders();
   for (size_t i=0; i<inputHeaders.size(); i++) {
      const RecHeader* recHeader = dynamic_cast<const RecHeader*>(inputHeaders[i]);
      vector<const IHeader*> inputHeaders = recHeader->findHeaders("/Event/Data/CalibStats");
      if ( 1 == inputHeaders.size() ) {
         // Fix:: UserDataHeader class need to make getBlahBlah() methods const. 
         UserDataHeader* calibStats =  const_cast<UserDataHeader*>(dynamic_cast<const UserDataHeader*>(inputHeaders[0]));
         for (int j=0; j<nDataInt; j++ ) {
            int value = calibStats->getInt(dataStrInt[j]);
            dataInt[j].push_back(value);
         }
         for (int j=0; j<nDataFloat; j++ ) {
            float value = calibStats->getFloat(dataStrFloat[j]);
            dataFloat[j].push_back(value);
         }
      }
      else {
         warning() << inputHeaders.size() << " Data at /Event/Data/CalibStats" << endreq;
     }
   }
   for (int j=0; j<nDataInt; j++ ) {
      dataHeader->set( string("calib_")+dataStrInt[j], dataInt[j] );
   }
   for (int j=0; j<nDataFloat; j++ ) {
      dataHeader->set( string("calib_")+dataStrFloat[j], dataFloat[j] );
   }
}
void ADETWindowData::SaveOtherData ( DayaBay::HeaderObject tagHeader,
DayaBay::UserDataHeader dataHeader 
) [private]

Definition at line 238 of file ADETWindowData.cc.

{
   // initialize data vectors
   vector<int> I, J;
   
   int multiplicity = tagHeader->inputHeaders().size();
   for (int i=0; i<multiplicity-1; i++) {
         I.push_back(i);
         J.push_back(multiplicity-1);
   }
   
   dataHeader->set("multiplicity", multiplicity);
   dataHeader->set("I", I);
   dataHeader->set("J", J);
   
   int runNo = 0;
   int fileNo = 0;
   ServiceMode svcMode = ServiceMode(tagHeader->context(), 0);
   const DaqRunDetails& runDetails = m_daqDetailsSvc->runDetails(svcMode);
   if (&runDetails) {
      runNo = runDetails.runNumber();
   }
   const DaqFileDetails& fileDetails = m_daqDetailsSvc->fileDetails(svcMode);
   if (&fileDetails) {
      fileNo = fileDetails.fileNumber();
   }
   dataHeader->set("runNo", runNo);
   dataHeader->set("fileNo", fileNo);
}
DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::UserDataHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::UserDataHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::UserDataHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::UserDataHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

Definition at line 24 of file ADETWindowData.h.

string ADETWindowData::m_tagLoc [private]

Definition at line 25 of file ADETWindowData.h.

string ADETWindowData::m_dataLoc [private]

Definition at line 26 of file ADETWindowData.h.

string ADETWindowData::m_muonLoc [private]

Definition at line 27 of file ADETWindowData.h.

Definition at line 28 of file ADETWindowData.h.

IDataProviderSvc* ADETWindowData::m_archiveSvc [private]

Definition at line 29 of file ADETWindowData.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::UserDataHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


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