/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ADETWindowTag.cc
Go to the documentation of this file.
00001 #include "ADETWindowTag.h"
00002 #include "Event/RecHeader.h"
00003 #include "Event/HeaderObject.h"
00004 #include "Event/ReadoutHeader.h"
00005 #include "Event/UserDataHeader.h"
00006 #include "Event/JobInfo.h"
00007 #include "Conventions/JobId.h"
00008 #include "DataSvc/IJobInfoSvc.h"
00009 #include "GaudiKernel/SystemOfUnits.h"
00010 
00011 ADETWindowTag::ADETWindowTag(const string& name, ISvcLocator* svcloc)
00012 : GaudiAlgorithm(name, svcloc)
00013 {
00014   declareProperty("location", m_recHeaderLoc = "/Event/Rec/AdSimple",
00015         "the TES path of target event header location");
00016   declareProperty("LowECut", m_lowECut = 4*Gaudi::Units::MeV,
00017                   "ETWindow low energy cut");
00018   declareProperty("HighECut", m_highECut = 15*Gaudi::Units::MeV,
00019                   "ETWindow high energy cut");
00020   declareProperty("TimeWindow", m_timeWindow = 400*Gaudi::Units::microsecond,
00021                   "ETWindow time window");
00022   m_nTagged = 0;
00023 }
00024 
00025 ADETWindowTag::~ADETWindowTag()
00026 {
00027 }
00028 
00029 StatusCode ADETWindowTag::initialize()
00030 {
00031   info() << "initialize(), lowECut=" << m_lowECut <<", highECut="<<m_highECut<<", timeWindow="<<m_timeWindow<< endreq;
00032 
00033   m_jobInfoSvc = svc<IJobInfoSvc>("JobInfoSvc",true);
00034   if(!m_jobInfoSvc) {
00035     error() << "Failed to initialize JobInfoSvc" << endl;
00036     return StatusCode::FAILURE;
00037   }
00038   
00039   m_inputHeaders.clear();
00040   m_timeStamp.clear();
00041 
00042   return StatusCode::SUCCESS;
00043 }
00044 
00045 StatusCode ADETWindowTag::execute()
00046 {
00047   DayaBay::RecHeader* recHeader = get<DayaBay::RecHeader>(m_recHeaderLoc);
00048   if ( !recHeader ) {
00049         warning() << "Cannot find header at " << m_recHeaderLoc << endreq;
00050         return StatusCode::FAILURE;
00051   }
00052   DetectorId::DetectorId_t detectorId = recHeader->context().GetDetId(); 
00053   if(detectorId != DetectorId::kAD1 && detectorId != DetectorId::kAD2 && detectorId != DetectorId::kAD3 && detectorId != DetectorId::kAD4){
00054      // not a AD recHeader 
00055      return StatusCode::SUCCESS;
00056   }    
00057   TimeStamp nTS = recHeader->context().GetTimeStamp();
00058   double energy = recHeader->recTrigger().energy();
00059 
00060   if(m_inputHeaders.find(detectorId) != m_inputHeaders.end()){
00061     m_inputHeaders[detectorId].push_back(recHeader);
00062     m_timeStamp[detectorId].push_back(nTS);
00063   }
00064   else{
00065     vector<const DayaBay::IHeader*> inputHeaders;
00066     vector<TimeStamp> timeStamp;
00067     inputHeaders.push_back(recHeader);
00068     timeStamp.push_back(nTS);
00069     m_inputHeaders[detectorId] = inputHeaders;
00070     m_timeStamp[detectorId] = timeStamp;
00071   } 
00072 
00073   nTS.Subtract(m_timeStamp[detectorId].at(0));
00074   double deltaT = nTS.GetSeconds()*Gaudi::Units::second;
00075   while(deltaT > m_timeWindow){
00076     m_inputHeaders[detectorId].erase(m_inputHeaders[detectorId].begin());
00077     m_timeStamp[detectorId].erase(m_timeStamp[detectorId].begin());
00078     nTS = recHeader->context().GetTimeStamp();
00079     nTS.Subtract(m_timeStamp[detectorId].at(0));
00080     deltaT = nTS.GetSeconds()*Gaudi::Units::second;
00081   }
00082   
00083   if(energy > m_lowECut && energy < m_highECut){
00084     DayaBay::HeaderObject *ADETWindowTag = new DayaBay::HeaderObject();
00085     ADETWindowTag->setInputHeaders(m_inputHeaders[detectorId]);
00086     // Copy from the recHeader
00087     ADETWindowTag->setExecNumber(recHeader->execNumber());
00088     ADETWindowTag->setContext(recHeader->context());
00089     ADETWindowTag->setEarliest(recHeader->earliest());
00090     ADETWindowTag->setLatest(recHeader->latest());
00091     // Get job id
00092     const DayaBay::JobId &jobId = m_jobInfoSvc->currentJobInfo()->jobId();
00093     ADETWindowTag->setJobId(jobId);
00094   
00095     if(detectorId == DetectorId::kAD1 ||
00096                 detectorId == DetectorId::kAD2 ||
00097                 detectorId == DetectorId::kAD3 ||
00098                 detectorId == DetectorId::kAD4) {
00099       put(ADETWindowTag,"/Event/Tag/Physics/ADETWindow");
00100     }
00101 
00102     /*if(m_inputHeaders[detectorId].size() > 1){
00103       m_inputHeaders[detectorId].clear();
00104       m_timeStamp[detectorId].clear();
00105     }
00106     */
00107     
00108     m_nTagged++;
00109   }
00110   
00111   return StatusCode::SUCCESS;
00112 }
00113 
00114 StatusCode ADETWindowTag::finalize()
00115 {
00116   info() << "finalize(), " <<m_nTagged << " events tagged."<< endreq;
00117 }
00118 
| 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