BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcTripSvc.cxx
Go to the documentation of this file.
1#include "GaudiKernel/Bootstrap.h"
2#include "GaudiKernel/PropertyMgr.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/IInterface.h"
6#include "GaudiKernel/StatusCode.h"
7
8#include <time.h>
9
11
12using namespace std;
13
14
15MdcTripSvc::MdcTripSvc(const std::string& name, ISvcLocator* pSvcLocator) :
16 Service(name, pSvcLocator)
17{
18 m_nEvt=0;
19 m_Run=-1;
20 m_isTrip = false;
21}
22
24{
25 vec.clear();
26 vec1.clear();
27}
28
29// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
31 StatusCode status = Service::initialize();
32 MsgStream log( msgSvc(), name() );
33 log << MSG::INFO << "in initialize()" << endreq;
34
35 IService* pSvc = 0;
36 status = serviceLocator()->getService("EventDataSvc", pSvc);
37
38 return status;
39}
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43{
44 MsgStream log(msgSvc(), name());
45 log << MSG::INFO << "in finalize()" << endreq;
46 cout << "the number of tripped events are: " << m_nEvt << endl;
47
48 return StatusCode::SUCCESS;
49}
50
51StatusCode MdcTripSvc::queryInterface (const InterfaceID& riid, void** ppvInterface )
52{
53 if ( IID_IMdcTripSvc.versionMatch(riid) ) {
54 *ppvInterface = static_cast<IMdcTripSvc*> (this);
55 } else {
56 return Service::queryInterface(riid, ppvInterface) ;
57 }
58
59 return StatusCode::SUCCESS;
60}
61
62
63// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
64bool MdcTripSvc::getTripFlag(int iRun, time_t etime)
65{
66 //cout<<"m_Run= "<<m_Run<<" iRun: "<<iRun<<endl;
67 if(m_Run!=iRun)
68 {
69 m_Run=iRun;
70 vec.clear();
71 vec1.clear();
72
73 m_readt.ReadDb(iRun);
74 m_isTrip = m_readt.isRunTripped();
75 //cout<<"m_isTrip= "<<m_isTrip<<endl;
76 if(m_isTrip)
77 {
78 int m = m_readt.getstSize();
79 int n = m_readt.getndSize();
80 char trip_st[255];
81 char trip_nd[255];
82 string m_tStat;
83 string m_tStop;
84 time_t runtripst;
85 time_t runtripnd;
86
87 for(int c = 0;c < m;c++)
88 {
89 m_tStat=m_readt.gettimest(c);
90 strcpy(trip_st, m_tStat.c_str());
91 struct tm tm1;
92 int i = sscanf(trip_st,"%04d-%02d-%02d %02d:%02d:%02d",&(tm1.tm_year),&(tm1.tm_mon),&(tm1.tm_mday),&(tm1.tm_hour),&(tm1.tm_min),&(tm1.tm_sec));
93 tm1.tm_year -= 1900;
94 tm1.tm_mon -= 1;
95 tm1.tm_isdst = 0;
96 tm1.tm_yday = 0;
97 tm1.tm_wday = 0;
98 runtripst = mktime(&tm1);
99 vec.push_back(runtripst);
100
101 m_tStop=m_readt.gettimend(c);
102 strcpy(trip_nd, m_tStop.c_str());
103 struct tm tm2;
104 int j = sscanf(trip_nd,"%04d-%02d-%02d %02d:%02d:%02d",&(tm2.tm_year),&(tm2.tm_mon),&(tm2.tm_mday),&(tm2.tm_hour),&(tm2.tm_min),&(tm2.tm_sec));
105 tm2.tm_year -= 1900;
106 tm2.tm_mon -= 1;
107 tm2.tm_isdst = 0;
108 tm2.tm_yday = 0;
109 tm2.tm_wday = 0;
110 runtripnd = mktime(&tm2);
111 vec1.push_back(runtripnd);
112 //cout<<"m_tStat="<<m_tStat<<"m_tStop="<<m_tStop<<endl;
113 }
114 }
115 }
116
117 bool flag = false;
118 if(m_isTrip)
119 {
120 for(int f = 0;f < vec.size();f++)
121 {
122 if((etime > vec[f])&&(etime < vec1[f])) flag = true;
123 }
124 }
125 if(flag) m_nEvt++;
126 return flag;
127}
128
129void MdcTripSvc::handle(const Incident& inc)
130{
131 MsgStream log( messageService(), name() );
132 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
133}
const Int_t n
IMessageSvc * msgSvc()
virtual StatusCode initialize()
Definition: MdcTripSvc.cxx:30
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
Definition: MdcTripSvc.cxx:51
virtual StatusCode finalize()
Definition: MdcTripSvc.cxx:42
MdcTripSvc(const std::string &name, ISvcLocator *svcloc)
Definition: MdcTripSvc.cxx:15
bool getTripFlag(int iRun, time_t etime)
Definition: MdcTripSvc.cxx:64
void handle(const Incident &inc)
Definition: MdcTripSvc.cxx:129
string gettimest(int i)
dble_vec_t vec[12]
Definition: ranlxd.c:372