BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcHvDropSvc Class Reference

#include <MdcHvDropSvc.h>

Inheritance diagram for MdcHvDropSvc:

Public Member Functions

 MdcHvDropSvc (const std::string &name, ISvcLocator *svcloc)
 ~MdcHvDropSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
virtual double queryRelativeHvDrop ()
virtual void setRelativeHvDropThreshold (double threshold)
virtual bool queryIsHvDrop ()

Friends

class SvcFactory< MdcHvDropSvc >

Detailed Description

Definition at line 33 of file MdcHvDropSvc.h.

Constructor & Destructor Documentation

◆ MdcHvDropSvc()

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

Definition at line 48 of file MdcHvDropSvc.cxx.

49 : base_class( name, svcloc ) {
50 // declare properties
51 declareProperty( "Host", m_host = std::string( "202.122.33.123" ) );
52 declareProperty( "DbName", m_dbName = std::string( "tof40t_linux" ) );
53 declareProperty( "TableName", m_table = std::string( "MDCLayerVmon" ) );
54 declareProperty( "UserName", m_userName = std::string( "guest" ) );
55 declareProperty( "Password", m_password = std::string( "guestpass" ) );
56 declareProperty( "Port", m_port = 6175 );
57 declareProperty( "IgnoreLayer_21_24", m_ignoreLayer_21_24 = true );
58 declareProperty( "RelativeHvDropThreshold", m_relativeHvDropThreshold = 0.007 );
59 declareProperty( "FetchHvDataLengthInSeconds", m_fetchLength = 5 * 3600 );
60 declareProperty( "UseEtsT1", m_useEtsT1 = 0 ); // whether to use EtsT1, if not, use time().
61 declareProperty( "EtsT1OffSet",
62 m_etsT1Offset = 0 ); // if is 0, and UseEtsT1, will be treated as using
63 // database time from database.. else, acts as
64 // calculating time_override=etsT1+etsT1Offset;
65
66 declareProperty( "Host2", m_host2 = std::string( "bes3db2.ihep.ac.cn" ) );
67 declareProperty( "DbName2", m_dbName2 = std::string( "run" ) );
68 declareProperty( "TableName2", m_table2 = std::string( "RunParams" ) );
69 declareProperty( "UserName2", m_userName2 = std::string( "guest" ) );
70 declareProperty( "Password2", m_password2 = std::string( "guestpass" ) );
71 declareProperty( "Port2", m_port2 = 3306 ); // 3306 is default port for mysql
72}

Referenced by MdcHvDropSvc().

◆ ~MdcHvDropSvc()

MdcHvDropSvc::~MdcHvDropSvc ( )

Definition at line 74 of file MdcHvDropSvc.cxx.

74{}

Member Function Documentation

◆ finalize()

StatusCode MdcHvDropSvc::finalize ( )
virtual

Definition at line 112 of file MdcHvDropSvc.cxx.

112 {
113 MsgStream log( msgSvc(), name() );
114 log << MSG::INFO << "MdcHvDropSvc::finalize()" << endmsg;
115 // if(m_connect_offline) delete m_connect_offline;
116 return StatusCode::SUCCESS;
117}
IMessageSvc * msgSvc()

◆ handle()

void MdcHvDropSvc::handle ( const Incident & inc)

Definition at line 119 of file MdcHvDropSvc.cxx.

119 {
120 MsgStream log( msgSvc(), name() );
121 log << MSG::DEBUG << "handle: " << inc.type() << endmsg;
122 // so currently we do nothing.
123 // if (inc.type() == "NewRun") {
124 // log << MSG::DEBUG << "NewRun" << endmsg;
125 //
126 // SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc, "/Event/EventHeader");
127 // int run = eventHeader->runNumber();
128 // //cout<<"&&&&&&&&&&&&&&:&&&&&&&&&&&&&&&&&&&& MdcHvDropSvc handle,run="<<run<<endl;
129 // if (run < 0) run = -run;
130 // log << MSG::DEBUG << "handle: "
131 // << "Run in handle is: " << run << endmsg;
132 // cout << "-------------in MdcHvDropSvc in the following-----------" << endl;
133 // cout << "handle: "
134 // << "Run in handle is: " << run << endl;
135
136 // if (run >= m_RunFrom && run <= m_RunTo && m_ReadPar == true) {
137 // cout << "do not read the database repeatly in EmcShEnCalibConst" << endl;
138 // cout << "run,RunFrom,runTo=" << run << "," << m_RunFrom << "," << m_RunTo << endl;
139 // } else {
140 //
141 // //cout<<"read the database in EmcShEnCalibConst"<<endl;
142 // if (!getMdcHvDropSvcInfo()) {
143 // log << MSG::ERROR << "can not initilize Shower energy Calib Constants" << endmsg;
144 // } else {
145 // m_ReadPar = true;
146 // std::cout << "in handle of MdcHvDropSvc getPi0CalibFile()= " << getPi0CalibFile()
147 // << std::endl; std::cout << "getSingleGammaCalibFile()= " <<
148 // getSingleGammaCalibFile() << std::endl;
149 // }
150 // }
151 //}
152}

◆ initialize()

StatusCode MdcHvDropSvc::initialize ( )
virtual

Definition at line 83 of file MdcHvDropSvc.cxx.

83 {
84 MsgStream log( msgSvc(), name() );
85 log << MSG::INFO << "MdcHvDropSvc::initialize()" << endmsg;
86
87 StatusCode sc = Service::initialize();
88 if ( sc.isFailure() ) return sc;
89
90 IIncidentSvc* incsvc;
91 sc = service( "IncidentSvc", incsvc );
92 int priority = 100;
93 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
94
95 sc = serviceLocator()->service( "EventDataSvc", m_eventSvc, true );
96 if ( sc.isFailure() )
97 {
98 log << MSG::ERROR << "Unable to find EventDataSvc " << endmsg;
99 return sc;
100 }
101
102 sc = initMySql();
103 if ( sc.isFailure() )
104 {
105 log << MSG::ERROR << "Unable to initialize mysql " << endmsg;
106 return sc;
107 }
108
109 return StatusCode::SUCCESS;
110}

◆ queryIsHvDrop()

virtual bool MdcHvDropSvc::queryIsHvDrop ( )
inlinevirtual

Definition at line 54 of file MdcHvDropSvc.h.

54{ return queryRelativeHvDrop() >= m_relativeHvDropThreshold; }
virtual double queryRelativeHvDrop()

◆ queryRelativeHvDrop()

double MdcHvDropSvc::queryRelativeHvDrop ( )
virtual

Definition at line 334 of file MdcHvDropSvc.cxx.

334 {
335 MsgStream log( msgSvc(), name() );
336 // log << MSG::DEBUG << "MdcHvDropSvc::sqlRow2Item()" << endmsg;
337 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc, "/Event/EventHeader" );
338 Time_t time = eventHeader->time();
339 Time_t fetchBeginTime = time;
340 int run = eventHeader->runNumber();
341 unsigned long time_etsT1 = eventHeader->etsT1();
342 long time_etsT1_timelike32 = ( ( time_etsT1 / 2000000 ) & 0x00000000ffffffffLU );
343
344 // handle etsT1 logic
345 // declareProperty("UseEtsT1",m_useEtsT1=0); // whether to use EtsT1, if not, use time().
346 // declareProperty("EtsT1OffSet",m_etsT1Offset=0);// if is 0, and UseEtsT1, will be treated
347 // as using database time from database.. else, acts as calculating
348 // time_override=etsT1+etsT1Offset;
349
350 if ( m_useEtsT1 )
351 {
352
353 if ( m_etsT1Offset == 0 ) { time = time_etsT1_timelike32 + getRunBeginTime( run ); }
354 else { time = time_etsT1_timelike32 + m_etsT1Offset; }
355 }
356
357 if ( run < 0 ) return 0; // a MC event.
358
359 log << MSG::INFO << "query time " << time << endmsg;
360 log << MSG::INFO << "current boundary " << m_vData.getLowerBoundaryEventTime() << " : "
361 << m_vData.getUpperBoundaryEventTime() << endmsg;
362
363 if ( m_vData.getUpperBoundaryEventTime() < time ||
364 time < m_vData.getLowerBoundaryEventTime() )
365 { // not in cache
366 // 1st time.
367 if ( m_vData.size() == 0 )
368 {
369 char time1str[100];
370 Time_t2str( time, time1str, 100 );
371 log << MSG::INFO << "INFO: MdcHvDropSvc time " << time << " aka " << time1str
372 << " is not in cache yet.\n"
373 << "\tfetching HV info for 1h ago" << time - 3600 << " til fetch Length"
374 << time + m_fetchLength - 3600 << endmsg;
375 fetchBeginTime = time - 3600;
376 }
377 // 2nd time
378 else
379 {
380 Time_t upTimeCachedDBTime =
381 m_vData.getUpperBoundaryEventTime() + m_vData.getOffsetEvt2Db();
382 char time1str[100];
383 Time_t2str( time, time1str, 100 );
384 // time in another fetch interval, thus we choose to fetch new data and append to cache
385 if ( m_vData.getLowerBoundaryEventTime() < time &&
386 time < m_vData.getUpperBoundaryEventTime() + m_fetchLength )
387 {
388
389 log << MSG::INFO << "INFO:MdcHvDropSvc time " << time << " aka " << time1str
390 << " is not in cache yet.\n"
391 << "\tcurrent upperBoundary is " << m_vData.getUpperBoundaryEventTime() << "\n"
392 << "\tfetching HV info for dbTime " << upTimeCachedDBTime
393 << " to fetch Length later" << upTimeCachedDBTime + m_fetchLength << endmsg;
394 fetchBeginTime = upTimeCachedDBTime;
395 }
396 // time not in another fetch interval, and we cannot find a interval to append to cache.
397 else
398 {
399 log << MSG::INFO << "INFO:MdcHvDropSvc time " << time << " aka " << time1str
400 << " is not in cache or canbe fetched in a interval.\n"
401 << "\tcurrent cache boundary is " << m_vData.getLowerBoundaryEventTime() << ":"
402 << m_vData.getUpperBoundaryEventTime() << ".\n"
403 << "\tcurrent fetch interval is " << m_vData.getUpperBoundaryEventTime() << ":"
404 << m_vData.getUpperBoundaryEventTime() + m_fetchLength << endmsg;
405 log << MSG::INFO << "aborted cache and fetching new data.\n"
406 << "\tfetching HV info for 1h ago" << time - 3600 << " til fetch Length"
407 << time + m_fetchLength - 3600 << endmsg;
408 m_vData.clear();
409 fetchBeginTime = time - 3600;
410 }
411 }
412
413 fetchBeginTime += m_vData.getOffsetEvt2Db(); // now db time
414 Time_t time2 = fetchBeginTime + m_fetchLength;
415 if ( !FetchHvInfo( fetchBeginTime - 600, time2 ).isSuccess() )
416 {
417 cout << "ERROR: MdcHvDropSvc failed to fetch HV info\n";
418 return -10000;
419 }
420 }
421 if ( !m_vData.isValid( time ) ) return -9999;
422 if ( m_ignoreLayer_21_24 ) return m_vData.getAvgDropButVeryDrop( time );
423 else return m_vData.getAvgDrop( time );
424}
Double_t time
long Time_t
Definition VData.h:28

Referenced by queryIsHvDrop().

◆ setRelativeHvDropThreshold()

virtual void MdcHvDropSvc::setRelativeHvDropThreshold ( double threshold)
inlinevirtual

Definition at line 51 of file MdcHvDropSvc.h.

51 {
52 m_relativeHvDropThreshold = threshold;
53 };

◆ SvcFactory< MdcHvDropSvc >

friend class SvcFactory< MdcHvDropSvc >
friend

Definition at line 1 of file MdcHvDropSvc.h.


The documentation for this class was generated from the following files: