CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
DTHVStatusHandler Class Reference

#include <DTHVStatusHandler.h>

Inheritance diagram for DTHVStatusHandler:
popcon::PopConSourceHandler< DTHVStatus >

Public Member Functions

 DTHVStatusHandler (const edm::ParameterSet &ps)
 
void getNewObjects ()
 
std::string id () const
 
virtual ~DTHVStatusHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< DTHVStatus >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (cond::DbSession dbSession, cond::TagInfo const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (cond::DbSession session, cond::TagInfo const &tagInfo, cond::LogDBEntry const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Types

typedef std::pair< int, float > channelValue
 
typedef
DTHVAbstractCheck::timedMeasurement 
timedMeasurement
 

Private Member Functions

int checkForPeriod (cond::Time_t condSince, cond::Time_t condUntil, int &missingChannels, bool copyOffline)
 
void checkNewData ()
 
int checkStatusChange (int type, float oldValue, float newValue)
 
void copyHVData ()
 
void createSnapshot ()
 
void dumpHVAliases ()
 
void dumpSnapshot (const coral::TimeStamp &time)
 
void filterData ()
 
void getChannelMap ()
 
void getChannelSplit ()
 
void getLayerSplit ()
 
void getLayerValues (int rawId, int type, float &valueL, float &valueR, float &valueS, float &valueC)
 
DTHVStatusofflineList ()
 
cond::Time_t recoverLastTime ()
 
int recoverSnapshot ()
 
void setChannelFlag (DTHVStatus *hv, int whe, int sta, int sec, int qua, int lay, int l_p, const DTHVAbstractCheck::flag &flag)
 
void updateHVStatus ()
 

Static Private Member Functions

static cond::Time_t condTime (const coral::TimeStamp &time)
 
static cond::Time_t condTime (long long int time)
 
static coral::TimeStamp coralTime (const cond::Time_t &time)
 
static DTWireId layerId (int rawId, int l_p)
 

Private Attributes

std::map< int, int > aliasMap
 
cond::DbConnection buff_conn
 
cond::DbSession buff_session
 
std::string bufferConnect
 
long long int bwdTime
 
std::map< int, std::vector
< int > * > 
channelSplit
 
std::string dataTag
 
int dSince
 
bool dumpAtEnd
 
bool dumpAtStart
 
int dUntil
 
long long int fwdTime
 
int hSince
 
int hUntil
 
DTHVAbstractCheckhvChecker
 
cond::Time_t lastFound
 
long long int lastStamp
 
DTHVStatuslastStatus
 
std::map< int, int > layerMap
 
std::map< int, int > laySplit
 
std::string mapVersion
 
int maxPayload
 
long long int minTime
 
int mSince
 
int mUntil
 
cond::Time_t nextFound
 
cond::DbConnection omds_conn
 
cond::DbSession omds_session
 
std::string onlineAuthentication
 
std::string onlineConnect
 
cond::Time_t procSince
 
cond::Time_t procUntil
 
int pSince
 
int pUntil
 
std::map< int, timedMeasurementsnapshotValues
 
std::string splitVersion
 
int sSince
 
int sUntil
 
bool switchOff
 
cond::Time_t timeLimit
 
std::vector< std::pair
< DTHVStatus *, cond::Time_t > > 
tmpContainer
 
cond::DbConnection util_conn
 
cond::DbSession util_session
 
std::string utilConnect
 
int ySince
 
int yUntil
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< DTHVStatus >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< DTHVStatus *, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< DTHVStatus
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef DTHVStatus value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< DTHVStatus >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< DTHVStatus >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Description: Class to copy HV status via PopCon

Date:
2010/07/21 16:06:52
Revision:
1.6
Author
Paolo Ronchese INFN Padova

Definition at line 41 of file DTHVStatusHandler.h.

Member Typedef Documentation

typedef std::pair<int,float> DTHVStatusHandler::channelValue
private

Definition at line 62 of file DTHVStatusHandler.h.

Definition at line 61 of file DTHVStatusHandler.h.

Constructor & Destructor Documentation

DTHVStatusHandler::DTHVStatusHandler ( const edm::ParameterSet ps)

Constructor

Definition at line 54 of file DTHVStatusHandler.cc.

References gather_cfg::cout, DTHVAbstractCheck::getInstance(), hvChecker, maxPayload, and onlineAuthentication.

54  :
55  dataTag( ps.getParameter<std::string> ( "tag" ) ),
56  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
57  utilConnect( ps.getParameter<std::string> ( "utilDB" ) ),
58  onlineAuthentication( ps.getParameter<std::string> (
59  "onlineAuthentication" ) ),
60  bufferConnect( ps.getParameter<std::string> ( "bufferDB" ) ),
61  ySince( ps.getParameter<int> ( "sinceYear" ) ),
62  mSince( ps.getParameter<int> ( "sinceMonth" ) ),
63  dSince( ps.getParameter<int> ( "sinceDay" ) ),
64  hSince( ps.getParameter<int> ( "sinceHour" ) ),
65  pSince( ps.getParameter<int> ( "sinceMinute" ) ),
66  sSince( ps.getParameter<int> ( "sinceSecond" ) ),
67  yUntil( ps.getParameter<int> ( "untilYear" ) ),
68  mUntil( ps.getParameter<int> ( "untilMonth" ) ),
69  dUntil( ps.getParameter<int> ( "untilDay" ) ),
70  hUntil( ps.getParameter<int> ( "untilHour" ) ),
71  pUntil( ps.getParameter<int> ( "untilMinute" ) ),
72  sUntil( ps.getParameter<int> ( "untilSecond" ) ),
73  dumpAtStart( ps.getParameter<bool>( "dumpAtStart" ) ),
74  dumpAtEnd( ps.getParameter<bool>( "dumpAtEnd" ) ),
75  bwdTime( ps.getParameter<long long int> ( "bwdTime" ) ),
76  fwdTime( ps.getParameter<long long int> ( "fwdTime" ) ),
77  minTime( ps.getParameter<long long int> ( "minTime" ) ),
78  omds_conn(),
79  util_conn(),
80  buff_conn(),
81  omds_session(),
82  util_session(),
83  buff_session(),
84  mapVersion( ps.getParameter<std::string> ( "mapVersion" ) ),
85  splitVersion( ps.getParameter<std::string> ( "splitVersion" ) ) {
86  std::cout << " PopCon application for DT HV data export "
88  << std::endl;
90  maxPayload = 1000;
91 }
T getParameter(std::string const &) const
long long int minTime
std::string onlineConnect
cond::DbSession buff_session
cond::DbConnection buff_conn
long long int fwdTime
static DTHVAbstractCheck * getInstance()
check HV status
cond::DbConnection util_conn
long long int bwdTime
std::string onlineAuthentication
cond::DbSession util_session
cond::DbSession omds_session
DTHVAbstractCheck * hvChecker
std::string bufferConnect
tuple cout
Definition: gather_cfg.py:41
cond::DbConnection omds_conn
std::string splitVersion
DTHVStatusHandler::~DTHVStatusHandler ( )
virtual

Destructor

Definition at line 96 of file DTHVStatusHandler.cc.

96  {
97 }

Member Function Documentation

int DTHVStatusHandler::checkForPeriod ( cond::Time_t  condSince,
cond::Time_t  condUntil,
int &  missingChannels,
bool  copyOffline 
)
private

Definition at line 880 of file DTHVStatusHandler.cc.

References DTHVStatus::begin(), checkStatusChange(), condTime(), cont, coralTime(), gather_cfg::cout, DTHVStatus::end(), lastFound, lastStamp, maxPayload, minTime, nextFound, cond::DbSession::nominalSchema(), offlineList(), omds_session, procUntil, snapshotValues, timeLimit, and tmpContainer.

Referenced by copyHVData(), and updateHVStatus().

883  {
884 
885  std::map<int,timedMeasurement>::iterator mapIter = snapshotValues.begin();
886  std::map<int,timedMeasurement>::iterator mapIend = snapshotValues.end();
887 
888  std::map<long long int,channelValue> periodBuffer;
889 
890  coral::ITable& fwccTable =
891  omds_session.nominalSchema().tableHandle( "FWCAENCHANNEL" );
892  std::auto_ptr<coral::IQuery> fwccQuery( fwccTable.newQuery() );
893  fwccQuery->addToOutputList( "DPID" );
894  fwccQuery->addToOutputList( "CHANGE_DATE" );
895  fwccQuery->addToOutputList( "ACTUAL_VMON" );
896  fwccQuery->addToOutputList( "ACTUAL_IMON" );
897  fwccQuery->addToOutputList( "ACTUAL_ISON" );
898  fwccQuery->addToOutputList( "ACTUAL_STATUS" );
899  fwccQuery->addToOutputList( "ACTUAL_OVC" );
900  coral::AttributeList timeBindVariableList;
901  timeBindVariableList.extend( "since", typeid(coral::TimeStamp) );
902  timeBindVariableList.extend( "until", typeid(coral::TimeStamp) );
903  coral::TimeStamp coralSince = coralTime( condSince );
904  coral::TimeStamp coralUntil = coralTime( condUntil );
905  std::cout << "look for data since "
906  << coralSince.year( ) << " "
907  << coralSince.month( ) << " "
908  << coralSince.day( ) << " "
909  << coralSince.hour( ) << ":"
910  << coralSince.minute() << ":"
911  << coralSince.second() << " until "
912  << coralUntil.year( ) << " "
913  << coralUntil.month( ) << " "
914  << coralUntil.day( ) << " "
915  << coralUntil.hour( ) << ":"
916  << coralUntil.minute() << ":"
917  << coralUntil.second() << std::endl;
918  timeBindVariableList["since"].data<coral::TimeStamp>() =
919  coralTime( condSince );
920  timeBindVariableList["until"].data<coral::TimeStamp>() =
921  coralTime( condUntil );
922  fwccQuery->setCondition( "CHANGE_DATE>:since and CHANGE_DATE<:until",
923  timeBindVariableList );
924  fwccQuery->addToOrderList( "CHANGE_DATE" );
925  coral::ICursor& fwccCursor = fwccQuery->execute();
926  int nrows = 0;
927  while ( fwccCursor.next() ) {
928  nrows++;
929  const coral::Attribute& dp = fwccCursor.currentRow()["DPID" ];
930  const coral::Attribute& vmon = fwccCursor.currentRow()["ACTUAL_VMON" ];
931  const coral::Attribute& imon = fwccCursor.currentRow()["ACTUAL_IMON" ];
932  coral::TimeStamp changeTime =
933  fwccCursor.currentRow()["CHANGE_DATE"].data<coral::TimeStamp>();
934  long long int cTimeValue = changeTime.total_nanoseconds();
935  if ( !copyOffline ) cTimeValue = -cTimeValue;
936  if ( dp.isNull() ) {
937  std::cout << "------- " << nrows << std::endl;
938  continue;
939  }
940  int dpId = 10 * static_cast<int>( 0.01 +
941  fwccCursor.currentRow()["DPID"].data<float>() );
942  if ( !( vmon.isNull() ) ) {
943  while ( periodBuffer.find( cTimeValue ) !=
944  periodBuffer.end() ) cTimeValue++;
945  int chan = dpId + 1;
946  periodBuffer.insert( std::pair<long long int,channelValue> (
947  cTimeValue, channelValue( chan,
948  vmon.data<float>() ) ) );
949  }
950  if ( !( imon.isNull() ) ) {
951  while ( periodBuffer.find( cTimeValue ) !=
952  periodBuffer.end() ) cTimeValue++;
953  int chan = dpId + 2;
954  periodBuffer.insert( std::pair<long long int,channelValue> (
955  cTimeValue, channelValue( chan,
956  imon.data<float>() ) ) );
957  }
958  }
959 
960  long long int dTime = minTime;
961  dTime <<= 32;
962  std::cout << "data found in period: " << periodBuffer.size() << std::endl;
963  std::map<long long int,channelValue>::const_iterator bufIter =
964  periodBuffer.begin();
965  std::map<long long int,channelValue>::const_iterator bufIend =
966  periodBuffer.end();
967 
968  bool changedStatus = false;
969  while ( bufIter != bufIend ) {
970  const std::pair<long long int,channelValue>& entry = *bufIter++;
971  long long int mTime = entry.first;
972  if ( !copyOffline ) mTime = -mTime;
973  channelValue cValue = entry.second;
974  int chan = cValue.first;
975  float cont = cValue.second;
976  mapIter = snapshotValues.find( chan );
977  if ( ( mapIter != mapIend ) &&
978  ( mapIter->second.first < mTime ) ) {
979  nextFound = condTime( mTime );
980  if ( changedStatus ) {
981  if ( nextFound > timeLimit ) {
982  DTHVStatus* hvStatus = offlineList();
983  std::cout << "new payload "
984  << hvStatus->end() - hvStatus->begin() << std::endl;
985  tmpContainer.push_back( std::make_pair( hvStatus, lastFound ) );
986  changedStatus = false;
987  if ( !( --maxPayload ) ) {
989  std::cout << "max payload number reached" << std::endl;
990  break;
991  }
992  }
993  }
994  if ( copyOffline && !changedStatus &&
995  checkStatusChange( chan, mapIter->second.second, cont ) ) {
996  timeLimit = nextFound + dTime;
997  changedStatus = true;
998  }
999  mapIter->second = timedMeasurement( lastStamp = mTime, cont );
1000  lastFound = nextFound;
1001  missingChannels--;
1002  }
1003  }
1004 
1005  std::cout << nrows << std::endl;
1006  return nrows;
1007 
1008 }
long long int lastStamp
DTHVAbstractCheck::timedMeasurement timedMeasurement
cond::Time_t lastFound
long long int minTime
cond::Time_t procUntil
DTHVStatus * offlineList()
std::vector< std::pair< DTHVStatus *, cond::Time_t > > tmpContainer
static coral::TimeStamp coralTime(const cond::Time_t &time)
int checkStatusChange(int type, float oldValue, float newValue)
cond::Time_t nextFound
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
static cond::Time_t condTime(const coral::TimeStamp &time)
std::map< int, timedMeasurement > snapshotValues
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
int cont
std::pair< int, float > channelValue
cond::DbSession omds_session
const_iterator end() const
Definition: DTHVStatus.cc:522
tuple cout
Definition: gather_cfg.py:41
const_iterator begin() const
Definition: DTHVStatus.cc:517
cond::Time_t timeLimit
void DTHVStatusHandler::checkNewData ( )
private

Definition at line 240 of file DTHVStatusHandler.cc.

References buff_session, coralTime(), gather_cfg::cout, createSnapshot(), getChannelMap(), getChannelSplit(), getLayerSplit(), cond::DbSession::nominalSchema(), omds_session, procSince, procUntil, updateHVStatus(), and util_session.

Referenced by getNewObjects().

240  {
241 
242  //to access the information on last successful log entry for this tag:
243 // cond::LogDBEntry const & lde = logDBEntry();
244 
245  //to access the lastest payload (Ref is a smart pointer)
246 // Ref payload = lastPayload();
247 
248  std::cout << "check for new data since "
249  << procSince << " "
250  << coralTime( procSince ).total_nanoseconds() << " "
251  << coralTime( procSince ).year( ) << " "
252  << coralTime( procSince ).month( ) << " "
253  << coralTime( procSince ).day( ) << " "
254  << coralTime( procSince ).hour( ) << " "
255  << coralTime( procSince ).minute() << " "
256  << coralTime( procSince ).second() << std::endl;
257  std::cout << " until "
258  << procUntil << " "
259  << coralTime( procUntil ).total_nanoseconds() << " "
260  << coralTime( procUntil ).year( ) << " "
261  << coralTime( procUntil ).month( ) << " "
262  << coralTime( procUntil ).day( ) << " "
263  << coralTime( procUntil ).hour( ) << " "
264  << coralTime( procUntil ).minute() << " "
265  << coralTime( procUntil ).second() << std::endl;
266 
267  std::set<std::string> omds_lt( omds_session.nominalSchema().listTables() );
268  std::set<std::string>::const_iterator omds_iter = omds_lt.begin();
269  std::set<std::string>::const_iterator omds_iend = omds_lt.end();
270  while ( omds_iter != omds_iend ) {
271  const std::string& istr = *omds_iter++;
272  std::cout << "TABLE: " << istr << std::endl;
273  }
274 
275  std::set<std::string> util_lt( util_session.nominalSchema().listTables() );
276  std::set<std::string>::const_iterator util_iter = util_lt.begin();
277  std::set<std::string>::const_iterator util_iend = util_lt.end();
278  while ( util_iter != util_iend ) {
279  const std::string& istr = *util_iter++;
280  std::cout << "TABLE: " << istr << std::endl;
281  }
282 
283  getLayerSplit();
284  getChannelMap();
285  getChannelSplit();
286 
287  std::cout << "open buffer db..." << std::endl;
288 
289  if ( !( buff_session.nominalSchema().existsTable( "HVSNAPSHOT" ) ) )
290  createSnapshot();
291  updateHVStatus();
292 
293  return;
294 
295 }
cond::Time_t procUntil
cond::DbSession buff_session
static coral::TimeStamp coralTime(const cond::Time_t &time)
cond::Time_t procSince
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
cond::DbSession util_session
cond::DbSession omds_session
tuple cout
Definition: gather_cfg.py:41
int DTHVStatusHandler::checkStatusChange ( int  type,
float  oldValue,
float  newValue 
)
private

Definition at line 1221 of file DTHVStatusHandler.cc.

References aliasMap, DTHVAbstractCheck::checkCurrentStatus(), DTHVAbstractCheck::compare(), gather_cfg::cout, getLayerValues(), hvChecker, layerId(), layerMap, snapshotValues, and DTWireId::wire().

Referenced by checkForPeriod().

1222  {
1223  int dpId = chan / 10;
1224  int type = chan % 10;
1225  std::map<int,int>::const_iterator aliasIter = aliasMap.find( dpId );
1226  std::map<int,int>::const_iterator aliasIend = aliasMap.end();
1227  if ( aliasIter == aliasIend ) return false;
1228  int rawId = aliasIter->second;
1229  DTWireId chlId( rawId );
1230  int l_p = chlId.wire();
1231  float valueL = 0.0;
1232  float valueR = 0.0;
1233  float valueS = 0.0;
1234  float valueC = 0.0;
1235  getLayerValues( rawId, type, valueL, valueR, valueS, valueC );
1236 // std::cout << "layer values: " << type << " " << valueL << " "
1237 // << valueR << " "
1238 // << valueS << " "
1239 // << valueC << std::endl;
1241  oldStatusL = hvChecker->checkCurrentStatus( layerId( rawId, 0 ).rawId(),
1242  type,
1243  valueL, valueC, valueS,
1245  aliasMap, layerMap );
1247  oldStatusR = hvChecker->checkCurrentStatus( layerId( rawId, 1 ).rawId(),
1248  type,
1249  valueR, valueC, valueS,
1251  aliasMap, layerMap );
1252  switch ( l_p ) {
1253  case 10:
1254  if ( valueL != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1255  << type << " " << l_p << " "
1256  << oldValue << " " << valueL << " "
1257  << std::endl;
1258  valueL = newValue;
1259  break;
1260  case 11:
1261  if ( valueR != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1262  << type << " " << l_p << " "
1263  << oldValue << " " << valueR << " "
1264  << std::endl;
1265  valueR = newValue;
1266  break;
1267  case 12:
1268  if ( valueS != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1269  << type << " " << l_p << " "
1270  << oldValue << " " << valueS << " "
1271  << std::endl;
1272  valueS = newValue;
1273  break;
1274  case 13:
1275  if ( valueC != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1276  << type << " " << l_p << " "
1277  << oldValue << " " << valueC << " "
1278  << std::endl;
1279  valueC = newValue;
1280  break;
1281  default:
1282  break;
1283  }
1285  newStatusL = hvChecker->checkCurrentStatus( layerId( rawId, 0 ).rawId(),
1286  type,
1287  valueL, valueC, valueS,
1289  aliasMap, layerMap );
1291  newStatusR = hvChecker->checkCurrentStatus( layerId( rawId, 1 ).rawId(),
1292  type,
1293  valueR, valueC, valueS,
1295  aliasMap, layerMap );
1296 
1297  if ( DTHVAbstractCheck::compare( newStatusL, oldStatusL ) &&
1298  DTHVAbstractCheck::compare( newStatusR, oldStatusR ) ) return 0;
1299  std::cout << "changed status: " << chan << " from "
1300  << oldValue << " to " << newValue << std::endl;
1301  return 1;
1302 }
type
Definition: HCALResponse.h:22
std::map< int, int > aliasMap
void getLayerValues(int rawId, int type, float &valueL, float &valueR, float &valueS, float &valueC)
static DTWireId layerId(int rawId, int l_p)
virtual DTHVAbstractCheck::flag checkCurrentStatus(int rawId, int type, float valueA, float valueC, float valueS, const std::map< int, timedMeasurement > &snapshotValues, const std::map< int, int > &aliasMap, const std::map< int, int > &layerMap)=0
static bool compare(const DTHVAbstractCheck::flag &fl, const DTHVAbstractCheck::flag &fr)
std::map< int, timedMeasurement > snapshotValues
std::map< int, int > layerMap
DTHVAbstractCheck * hvChecker
tuple cout
Definition: gather_cfg.py:41
cond::Time_t DTHVStatusHandler::condTime ( const coral::TimeStamp &  time)
staticprivate

Definition at line 1409 of file DTHVStatusHandler.cc.

Referenced by checkForPeriod(), getNewObjects(), and recoverLastTime().

1409  {
1410  cond::Time_t cTime = ( ( time.total_nanoseconds() / 1000000000 ) << 32 ) +
1411  ( ( time.total_nanoseconds() % 1000000000 ) / 1000 );
1412  return cTime;
1413 }
unsigned long long Time_t
Definition: Time.h:16
cond::Time_t DTHVStatusHandler::condTime ( long long int  time)
staticprivate

Definition at line 1416 of file DTHVStatusHandler.cc.

1416  {
1417  cond::Time_t cTime = ( ( time / 1000000000 ) << 32 ) +
1418  ( ( time % 1000000000 ) / 1000 );
1419  return cTime;
1420 }
unsigned long long Time_t
Definition: Time.h:16
void DTHVStatusHandler::copyHVData ( )
private

Definition at line 1011 of file DTHVStatusHandler.cc.

References checkForPeriod(), gather_cfg::cout, filterData(), fwdTime, lastFound, lastStatus, popcon::PopConSourceHandler< DTHVStatus >::m_to_transfer, maxPayload, offlineList(), procSince, procUntil, and switchOff.

Referenced by updateHVStatus().

1011  {
1012  long long int dTime = fwdTime;
1013  dTime <<= 32;
1014 
1015  cond::Time_t condSince = procSince;
1016  cond::Time_t condUntil = condSince + dTime;
1017  if ( condUntil > procUntil ) condUntil = procUntil;
1018 
1019  int dum = 0;
1020  lastStatus = 0;
1021  while ( condSince < condUntil ) {
1022  checkForPeriod( condSince, condUntil, dum, true );
1023  condSince = condUntil;
1024  condUntil = condSince + dTime;
1025  if ( condUntil > procUntil ) condUntil = procUntil;
1026  }
1027  std::cout << "call filterData " << std::endl;
1028  filterData();
1029  std::cout << "filterData return "
1030  << switchOff << " "
1031  << lastFound << " "
1032  << maxPayload << " "
1033  << m_to_transfer.size() << std::endl;
1034  if ( switchOff || ( ( lastFound != 0 ) && ( maxPayload > 0 ) ) ) {
1035  DTHVStatus* hvStatus = offlineList();
1036  m_to_transfer.push_back( std::make_pair( hvStatus, lastFound ) );
1037  }
1038 
1039  return;
1040 }
DTHVStatus * lastStatus
cond::Time_t lastFound
cond::Time_t procUntil
DTHVStatus * offlineList()
unsigned long long Time_t
Definition: Time.h:16
cond::Time_t procSince
long long int fwdTime
int checkForPeriod(cond::Time_t condSince, cond::Time_t condUntil, int &missingChannels, bool copyOffline)
tuple cout
Definition: gather_cfg.py:41
coral::TimeStamp DTHVStatusHandler::coralTime ( const cond::Time_t time)
staticprivate

Definition at line 1401 of file DTHVStatusHandler.cc.

Referenced by checkForPeriod(), checkNewData(), getNewObjects(), and updateHVStatus().

1401  {
1402  long long int iTime = ( ( ( ( time >> 32 ) & 0xFFFFFFFF ) * 1000000000 ) +
1403  ( ( time & 0xFFFFFFFF ) * 1000 ) );
1404  coral::TimeStamp cTime( iTime );
1405  return cTime;
1406 }
void DTHVStatusHandler::createSnapshot ( )
private

Definition at line 578 of file DTHVStatusHandler.cc.

References aliasMap, buff_session, gather_cfg::cout, DTLayerId::layer(), cond::DbSession::nominalSchema(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superLayer(), DTChamberId::wheel(), and DTWireId::wire().

Referenced by checkNewData().

578  {
579  std::cout << "create snapshot description..." << std::endl;
580  coral::TableDescription hvssDesc;
581  hvssDesc.setName( "HVSNAPSHOT" );
582  hvssDesc.insertColumn( "TIME",
583  coral::AttributeSpecification::typeNameForId(
584  typeid(coral::TimeStamp) ) );
585  hvssDesc.insertColumn( "WHEEL",
586  coral::AttributeSpecification::typeNameForId(
587  typeid(int) ) );
588  hvssDesc.insertColumn( "STATION",
589  coral::AttributeSpecification::typeNameForId(
590  typeid(int) ) );
591  hvssDesc.insertColumn( "SECTOR",
592  coral::AttributeSpecification::typeNameForId(
593  typeid(int) ) );
594  hvssDesc.insertColumn( "SUPERLAYER",
595  coral::AttributeSpecification::typeNameForId(
596  typeid(int) ) );
597  hvssDesc.insertColumn( "LAYER",
598  coral::AttributeSpecification::typeNameForId(
599  typeid(int) ) );
600  hvssDesc.insertColumn( "CHAN",
601  coral::AttributeSpecification::typeNameForId(
602  typeid(int) ) );
603  hvssDesc.insertColumn( "TYPE",
604  coral::AttributeSpecification::typeNameForId(
605  typeid(int) ) );
606  hvssDesc.insertColumn( "VALUE",
607  coral::AttributeSpecification::typeNameForId(
608  typeid(float) ) );
609  std::cout << "create snapshot table..." << std::endl;
610  buff_session.nominalSchema().createTable( hvssDesc );
611  coral::ITable& bufferTable =
612  buff_session.nominalSchema().tableHandle( "HVSNAPSHOT" );
613  coral::AttributeList newMeas;
614  newMeas.extend( "TIME", typeid(coral::TimeStamp) );
615  newMeas.extend( "WHEEL", typeid(int) );
616  newMeas.extend( "STATION", typeid(int) );
617  newMeas.extend( "SECTOR", typeid(int) );
618  newMeas.extend( "SUPERLAYER", typeid(int) );
619  newMeas.extend( "LAYER", typeid(int) );
620  newMeas.extend( "CHAN", typeid(int) );
621  newMeas.extend( "TYPE", typeid(int) );
622  newMeas.extend( "VALUE", typeid(float) );
623 
624  long long int zeroTime = 0LL;
625  newMeas["TIME" ].data<coral::TimeStamp>() =
626  coral::TimeStamp( zeroTime );
627  newMeas["VALUE" ].data<float>() = -999999.0;
628 
629  std::map<int,int>::const_iterator iter = aliasMap.begin();
630  std::map<int,int>::const_iterator iend = aliasMap.end();
631  while ( iter != iend ) {
632  const std::pair<int,int>& entry= *iter++;
633  int detId = entry.second;
634  DTWireId chlId( detId );
635  newMeas["WHEEL" ].data<int>() = chlId.wheel ();
636  newMeas["STATION" ].data<int>() = chlId.station ();
637  newMeas["SECTOR" ].data<int>() = chlId.sector ();
638  newMeas["SUPERLAYER"].data<int>() = chlId.superLayer();
639  newMeas["LAYER" ].data<int>() = chlId.layer ();
640  newMeas["CHAN" ].data<int>() = chlId.wire () - 10;
641  int itype;
642  for ( itype = 1; itype <= 2; itype++ ) {
643  newMeas["TYPE" ].data<int>() = itype;
644  bufferTable.dataEditor().insertRow( newMeas );
645  }
646  }
647 
648  std::cout << "create logging info..." << std::endl;
649  if ( buff_session.nominalSchema().existsTable( "LOG" ) )
650  buff_session.nominalSchema(). dropTable( "LOG" );
651  coral::TableDescription infoDesc;
652  infoDesc.setName( "LOG" );
653  infoDesc.insertColumn( "EXECTIME",
654  coral::AttributeSpecification::typeNameForId(
655  typeid(coral::TimeStamp) ) );
656  infoDesc.insertColumn( "SNAPSHOT",
657  coral::AttributeSpecification::typeNameForId(
658  typeid(coral::TimeStamp) ) );
659  buff_session.nominalSchema().createTable( infoDesc );
660  coral::AttributeList newInfo;
661  newInfo.extend( "EXECTIME", typeid(coral::TimeStamp) );
662  newInfo.extend( "SNAPSHOT", typeid(coral::TimeStamp) );
663  newInfo["EXECTIME"].data<coral::TimeStamp>() =
664  coral::TimeStamp( zeroTime );
665  newInfo["SNAPSHOT"].data<coral::TimeStamp>() =
666  coral::TimeStamp( zeroTime );
667  coral::ITable& infoTable =
668  buff_session.nominalSchema().tableHandle( "LOG" );
669  infoTable.dataEditor().insertRow( newInfo );
670 
671  return;
672 
673 }
std::map< int, int > aliasMap
cond::DbSession buff_session
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::dumpHVAliases ( )
private

Definition at line 448 of file DTHVStatusHandler.cc.

References aliasMap, buff_session, gather_cfg::cout, layerMap, cond::DbSession::nominalSchema(), omds_session, and DetId::rawId().

Referenced by getChannelMap().

448  {
449 
450  std::cout << "DTHVStatusHandler::dumpHVAliases - begin" << std::endl;
451 
452  std::cout << "create aliases description..." << std::endl;
453  coral::TableDescription hvalDesc;
454  hvalDesc.setName( "HVALIASES" );
455  hvalDesc.insertColumn( "DETID",
456  coral::AttributeSpecification::typeNameForId(
457  typeid(int) ) );
458  hvalDesc.insertColumn( "DPID",
459  coral::AttributeSpecification::typeNameForId(
460  typeid(int) ) );
461  std::cout << "create aliases table..." << std::endl;
462  coral::ITable& hvalTable =
463  buff_session.nominalSchema().createTable( hvalDesc );
464 
465  std::cout << "open DPNAME table..." << std::endl;
466  std::map<int,std::string> idMap;
467  coral::ITable& dpidTable =
468  omds_session.nominalSchema().tableHandle( "DP_NAME2ID" );
469  std::auto_ptr<coral::IQuery> dpidQuery( dpidTable.newQuery() );
470  dpidQuery->addToOutputList( "ID" );
471  dpidQuery->addToOutputList( "DPNAME" );
472  coral::ICursor& dpidCursor = dpidQuery->execute();
473  while( dpidCursor.next() ) {
474  const coral::AttributeList& row = dpidCursor.currentRow();
475  int id = static_cast<int>( 0.01 +
476  row["ID" ].data<float>() );
477  std::string dp = row["DPNAME"].data<std::string>();
478  idMap.insert( std::pair<int,std::string>( id, dp ) );
479  }
480  std::cout << "DPNAME table read... " << idMap.size() << std::endl;
481 
482  std::cout << "open ALIASES table..." << std::endl;
483  std::map<std::string,std::string> cnMap;
484  coral::ITable& nameTable =
485  omds_session.nominalSchema().tableHandle( "ALIASES" );
486  std::auto_ptr<coral::IQuery> nameQuery( nameTable.newQuery() );
487  nameQuery->addToOutputList( "DPE_NAME" );
488  nameQuery->addToOutputList( "ALIAS" );
489  coral::ICursor& nameCursor = nameQuery->execute();
490  while( nameCursor.next() ) {
491  const coral::AttributeList& row = nameCursor.currentRow();
492  std::string dp = row["DPE_NAME"].data<std::string>();
493  std::string an = row["ALIAS" ].data<std::string>();
494  if ( an.length() < 20 ) continue;
495  cnMap.insert( std::pair<std::string,std::string>( dp, an ) );
496  }
497  std::cout << "ALIASES table read... " << cnMap.size() << std::endl;
498 
499  std::map<int,std::string>::const_iterator idIter = idMap.begin();
500  std::map<int,std::string>::const_iterator idIend = idMap.end();
501  std::string outChk( "/outputChannel" );
502  while ( idIter != idIend ) {
503  const std::pair<int,std::string>& ientry = *idIter++;
504  int dpId = ientry.first;
505  std::string dp = ientry.second;
506  int ldp = dp.length();
507  if ( ldp < 20 ) continue;
508  std::string subOut( dp.substr( ldp - 17, 17 ) );
509  std::string subChk( subOut.substr( 0, 14 ) );
510  if ( subChk != outChk ) continue;
511  std::string chName( dp.substr( 0, ldp - 17 ) );
512  chName += ".actual.OvC";
513  int chCode = subOut.c_str()[16] - '0';
514  std::map<std::string,std::string>::const_iterator jter =
515  cnMap.find( chName );
516  if ( jter == cnMap.end() ) continue;
517  const std::pair<std::string,std::string>& jentry = *jter;
518  std::cout << dp << std::endl << chName << " " << chCode << std::endl;
519  std::string an( jentry.second );
520  int al = an.length();
521  int iofw = 7 + an.find( "DT_HV_W", 0 );
522  int iofc = 3 + an.find( "_MB", 0 );
523  int iofs = 2 + an.find( "_S" , 0 );
524  int iofq = 3 + an.find( "_SL", 0 );
525  int iofl = 2 + an.find( "_L" , 0 );
526  if ( ( iofw == al ) ||
527  ( iofc == al ) ||
528  ( iofs == al ) ||
529  ( iofq == al ) ||
530  ( iofl == al ) ) {
531  break;
532  }
533  int ioew = an.find( "_", iofw );
534  int ioec = an.find( "_", iofc );
535  int ioes = an.find( "_", iofs );
536  int ioeq = an.find( "_", iofq );
537  int ioel = an.find( "_", iofl );
538  std::string swhe( an.substr( iofw, ioew - iofw ) );
539  const char* cwhe = swhe.c_str();
540  int whe = cwhe[1] - '0';
541  if ( *cwhe != 'P' ) whe = -whe;
542 
543  std::string scha( an.substr( iofc, ioec - iofc ) );
544  const char* ccha = scha.c_str();
545  int cha = *ccha - '0';
546 
547  std::string ssec( an.substr( iofs, ioes - iofs ) );
548  const char* csec = ssec.c_str();
549  int sec = ( ( *csec - '0' ) * 10 ) + ( csec[1] - '0' );
550  if ( ( csec[2] == 'R' ) && ( sec == 10 ) ) sec = 14;
551  if ( ( csec[2] == 'L' ) && ( sec == 4 ) ) sec = 13;
552 
553  std::string squa( an.substr( iofq, ioeq - iofq ) );
554  const char* cqua = squa.c_str();
555  int qua = *cqua - '0';
556 
557  std::string slay( an.substr( iofl, ioel - iofl ) );
558  const char* clay = slay.c_str();
559  int lay = *clay - '0';
560 
561  DTWireId wireId( whe, cha, sec, qua, lay, 10 + chCode );
562  int chId = wireId.rawId();
563  coral::AttributeList newChan;
564  newChan.extend( "DETID", typeid(int) );
565  newChan.extend( "DPID", typeid(int) );
566  newChan["DETID"].data<int>() = chId;
567  newChan[ "DPID"].data<int>() = dpId;
568  hvalTable.dataEditor().insertRow( newChan );
569  aliasMap.insert( std::pair<int,int>( dpId, chId ) );
570  layerMap.insert( std::pair<int,int>( chId, dpId ) );
571  }
572 
573  std::cout << "DTHVStatusHandler::dumpHVAliases - end" << std::endl;
574  return;
575 }
std::map< int, int > aliasMap
cond::DbSession buff_session
std::map< int, int > layerMap
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
cond::DbSession omds_session
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::dumpSnapshot ( const coral::TimeStamp &  time)
private

Definition at line 800 of file DTHVStatusHandler.cc.

References aliasMap, buff_session, gather_cfg::cout, DTLayerId::layer(), cond::DbSession::nominalSchema(), cmsPerfSuiteHarvest::now, DTChamberId::sector(), snapshotValues, DTChamberId::station(), DTSuperLayerId::superLayer(), DTChamberId::wheel(), and DTWireId::wire().

Referenced by updateHVStatus().

800  {
801 
802  std::cout << "dump snapshot to buffer db..." << std::endl;
803  std::string emptyCondition( "" );
804  coral::AttributeList emptyBindVariableList;
805  std::map<int,int>::const_iterator mapIter = aliasMap.begin();
806  std::map<int,int>::const_iterator mapIend = aliasMap.end();
807  coral::ITable& hvssTable =
808  buff_session.nominalSchema().tableHandle( "HVSNAPSHOT" );
809  coral::ITableDataEditor& hvssEditor( hvssTable.dataEditor() );
810  long nRows = hvssEditor.deleteRows( emptyCondition, emptyBindVariableList );
811  std::cout << nRows << " rows deleted" << std::endl;
812 
813  coral::AttributeList newMeas;
814  newMeas.extend( "TIME", typeid(coral::TimeStamp) );
815  newMeas.extend( "WHEEL", typeid(int) );
816  newMeas.extend( "STATION", typeid(int) );
817  newMeas.extend( "SECTOR", typeid(int) );
818  newMeas.extend( "SUPERLAYER", typeid(int) );
819  newMeas.extend( "LAYER", typeid(int) );
820  newMeas.extend( "CHAN", typeid(int) );
821  newMeas.extend( "TYPE", typeid(int) );
822  newMeas.extend( "VALUE", typeid(float) );
823 
824  nRows = 0;
825  std::map<int,timedMeasurement>::const_iterator ssvIter =
826  snapshotValues.begin();
827  std::map<int,timedMeasurement>::const_iterator ssvIend =
828  snapshotValues.end();
829  while ( ssvIter != ssvIend ) {
830  const std::pair<int,timedMeasurement>& entry = *ssvIter++;
831  int dpty = entry.first;
832  int dpId = dpty / 10;
833  int type = dpty % 10;
834  mapIter = aliasMap.find( dpId );
835  if ( mapIter == mapIend ) continue;
836  DTWireId chlId( mapIter->second );
837  const timedMeasurement& tMeas = entry.second;
838  long long int newTime = tMeas.first;
839  newMeas["TIME" ].data<coral::TimeStamp>() =
840  coral::TimeStamp( newTime );
841  newMeas["WHEEL" ].data<int>() = chlId.wheel ();
842  newMeas["STATION" ].data<int>() = chlId.station ();
843  newMeas["SECTOR" ].data<int>() = chlId.sector ();
844  newMeas["SUPERLAYER"].data<int>() = chlId.superLayer();
845  newMeas["LAYER" ].data<int>() = chlId.layer ();
846  newMeas["CHAN" ].data<int>() = chlId.wire () - 10;
847  newMeas["TYPE" ].data<int>() = type;
848  newMeas["VALUE" ].data<float>() = tMeas.second;
849  hvssEditor.insertRow( newMeas );
850  nRows++;
851  }
852  std::cout << nRows << " rows updated" << std::endl;
853 
854  std::cout << "create logging info..." << std::endl;
855  if ( buff_session.nominalSchema().existsTable( "LOG" ) )
856  buff_session.nominalSchema(). dropTable( "LOG" );
857  coral::TableDescription infoDesc;
858  infoDesc.setName( "LOG" );
859  infoDesc.insertColumn( "EXECTIME",
860  coral::AttributeSpecification::typeNameForId(
861  typeid(coral::TimeStamp) ) );
862  infoDesc.insertColumn( "SNAPSHOT",
863  coral::AttributeSpecification::typeNameForId(
864  typeid(coral::TimeStamp) ) );
865  buff_session.nominalSchema().createTable( infoDesc );
866  coral::AttributeList newInfo;
867  newInfo.extend( "EXECTIME", typeid(coral::TimeStamp) );
868  newInfo.extend( "SNAPSHOT", typeid(coral::TimeStamp) );
869  newInfo["EXECTIME"].data<coral::TimeStamp>() = coral::TimeStamp::now();
870  newInfo["SNAPSHOT"].data<coral::TimeStamp>() = time;
871  coral::ITable& infoTable =
872  buff_session.nominalSchema().tableHandle( "LOG" );
873  infoTable.dataEditor().insertRow( newInfo );
874 
875  return;
876 
877 }
type
Definition: HCALResponse.h:22
std::map< int, int > aliasMap
DTHVAbstractCheck::timedMeasurement timedMeasurement
cond::DbSession buff_session
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
std::map< int, timedMeasurement > snapshotValues
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::filterData ( )
private

Definition at line 1305 of file DTHVStatusHandler.cc.

References DTHVStatus::begin(), gather_cfg::cout, diffTreeTool::diff, DTHVStatus::end(), popcon::PopConSourceHandler< DTHVStatus >::m_to_transfer, switchOff, and tmpContainer.

Referenced by copyHVData().

1305  {
1306 
1307  int maxTime = 100;
1308  int maxTtot = 600;
1309  int minDiff = 88;
1310 
1311  int iTime = 0;
1312  int pTime = 0;
1313  int nTime = 0;
1314  int iSize;
1315  int pSize;
1316  int nSize;
1317 
1318  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator iter =
1319  tmpContainer.begin();
1320  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator iend =
1321  tmpContainer.end();
1322  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator prev;
1323  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator next;
1324 
1325  while ( iter != iend ) {
1326  switchOff = false;
1327  next = iter;
1328  prev = next++;
1329  if ( next == iend ) next = prev;
1330  const DTHVStatus* iPtr = iter->first;
1331  const DTHVStatus* pPtr = prev->first;
1332  const DTHVStatus* nPtr = next->first;
1333  iSize = std::distance( iPtr->begin(), iPtr->end() );
1334  pSize = std::distance( pPtr->begin(), pPtr->end() );
1335  nSize = std::distance( nPtr->begin(), nPtr->end() );
1336  int dtot = nSize - pSize;
1337  prev = next;
1338  while ( ++next != iend ) {
1339  pPtr = prev->first;
1340  nPtr = next->first;
1341  pSize = std::distance( pPtr->begin(), pPtr->end() );
1342  nSize = std::distance( nPtr->begin(), nPtr->end() );
1343  int diff = nSize - pSize;
1344  iTime = static_cast<int>( ( iter->second >> 32 ) & 0xffffffff );
1345  pTime = static_cast<int>( ( prev->second >> 32 ) & 0xffffffff );
1346  nTime = static_cast<int>( ( next->second >> 32 ) & 0xffffffff );
1347  if ( ( nTime - pTime ) > maxTime ) break;
1348  if ( ( nTime - iTime ) > maxTtot ) break;
1349  if ( ( dtot * diff ) < 0 ) break;
1350  prev = next;
1351  }
1352  pPtr = prev->first;
1353  iSize = std::distance( iPtr->begin(), iPtr->end() );
1354  pSize = std::distance( pPtr->begin(), pPtr->end() );
1355  dtot = pSize - iSize;
1356  int dist = pTime - iTime;
1357  if ( ( dtot < -minDiff ) &&
1358  ( dist < maxTtot ) ) {
1359  std::cout << " ******** SWITCH ON "
1360  << std::distance( iter, prev ) << " "
1361  << iTime << " " << pTime << " "
1362  << iSize << " " << pSize << std::endl;
1363  m_to_transfer.push_back( std::make_pair( prev->first, prev->second ) );
1364  while ( iter != prev ) delete ( iter++->first );
1365  }
1366  if ( ( dtot > minDiff ) &&
1367  ( dist < maxTtot ) ) {
1368  std::cout << " ******** SWITCH OFF "
1369  << std::distance( iter, prev ) << " "
1370  << iTime << " " << pTime << " "
1371  << iSize << " " << pSize << std::endl;
1372  m_to_transfer.push_back( std::make_pair( prev->first, iter->second ) );
1373  switchOff = true;
1374  while ( iter != prev ) delete ( iter++->first );
1375  }
1376  if ( ( ( dtot >= -minDiff ) && ( dtot <= minDiff ) ) ||
1377  ( dist >= maxTtot ) ) {
1378  while ( iter != next ) {
1379  const std::pair<DTHVStatus*, cond::Time_t>& entry = *iter++;
1380  m_to_transfer.push_back( std::make_pair( entry.first, entry.second ) );
1381  }
1382  }
1383  iter = next;
1384  }
1385 
1386 }
std::vector< std::pair< DTHVStatus *, cond::Time_t > > tmpContainer
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
const_iterator end() const
Definition: DTHVStatus.cc:522
tuple cout
Definition: gather_cfg.py:41
const_iterator begin() const
Definition: DTHVStatus.cc:517
void DTHVStatusHandler::getChannelMap ( )
private

Definition at line 302 of file DTHVStatusHandler.cc.

References aliasMap, buff_session, gather_cfg::cout, dumpHVAliases(), layerMap, and cond::DbSession::nominalSchema().

Referenced by checkNewData().

302  {
303 
304  if ( !( buff_session.nominalSchema().existsTable( "HVALIASES" ) ) ) {
305  dumpHVAliases();
306  }
307  else {
308  std::cout << "retrieve aliases table..." << std::endl;
309  coral::ITable& hvalTable =
310  buff_session.nominalSchema().tableHandle( "HVALIASES" );
311  std::auto_ptr<coral::IQuery> hvalQuery( hvalTable.newQuery() );
312  hvalQuery->addToOutputList( "DETID" );
313  hvalQuery->addToOutputList( "DPID" );
314  coral::ICursor& hvalCursor = hvalQuery->execute();
315  int chId;
316  int dpId;
317  while ( hvalCursor.next() ) {
318  chId = hvalCursor.currentRow()["DETID"].data<int>();
319  dpId = hvalCursor.currentRow()[ "DPID"].data<int>();
320  aliasMap.insert( std::pair<int,int>( dpId, chId ) );
321  layerMap.insert( std::pair<int,int>( chId, dpId ) );
322  }
323  }
324 
325  return;
326 
327 }
std::map< int, int > aliasMap
cond::DbSession buff_session
std::map< int, int > layerMap
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::getChannelSplit ( )
private

Definition at line 375 of file DTHVStatusHandler.cc.

References channelSplit, gather_cfg::cout, cond::DbSession::nominalSchema(), DetId::rawId(), splitVersion, and util_session.

Referenced by checkNewData().

375  {
376  std::cout << "retrieve channel split table..." << std::endl;
377  int pwhe;
378  int psec;
379  int psta;
380  int pqua;
381  int play;
382  int pl_p;
383  int snum;
384  int swhe;
385  int ssec;
386  int ssta;
387  int squa;
388  int slay;
389  int sl_p;
390  coral::ITable& csplTable =
391  util_session.nominalSchema().tableHandle( "DT_HV_CHANNEL_SPLIT" );
392  std::auto_ptr<coral::IQuery> csplQuery( csplTable.newQuery() );
393  coral::AttributeList versionBindVariableList;
394  versionBindVariableList.extend( "version", typeid(std::string) );
395  versionBindVariableList["version"].data<std::string>() = splitVersion;
396  csplQuery->setCondition( "VERSION=:version", versionBindVariableList );
397  csplQuery->addToOutputList( "P_WHEEL" );
398  csplQuery->addToOutputList( "P_SECTOR" );
399  csplQuery->addToOutputList( "P_STATION" );
400  csplQuery->addToOutputList( "P_SUPERLAYER" );
401  csplQuery->addToOutputList( "P_LAYER" );
402  csplQuery->addToOutputList( "P_PART" );
403  csplQuery->addToOutputList( "S_NUMBER" );
404  csplQuery->addToOutputList( "S_WHEEL" );
405  csplQuery->addToOutputList( "S_SECTOR" );
406  csplQuery->addToOutputList( "S_STATION" );
407  csplQuery->addToOutputList( "S_SUPERLAYER" );
408  csplQuery->addToOutputList( "S_LAYER" );
409  csplQuery->addToOutputList( "S_PART" );
410  coral::ICursor& csplCursor = csplQuery->execute();
411  while ( csplCursor.next() ) {
412  pwhe = csplCursor.currentRow()["P_WHEEL" ].data<int>();
413  psec = csplCursor.currentRow()["P_SECTOR" ].data<int>();
414  psta = csplCursor.currentRow()["P_STATION" ].data<int>();
415  pqua = csplCursor.currentRow()["P_SUPERLAYER"].data<int>();
416  play = csplCursor.currentRow()["P_LAYER" ].data<int>();
417  pl_p = csplCursor.currentRow()["P_PART" ].data<int>();
418  snum = csplCursor.currentRow()["S_NUMBER" ].data<int>();
419  swhe = csplCursor.currentRow()["S_WHEEL" ].data<int>();
420  ssec = csplCursor.currentRow()["S_SECTOR" ].data<int>();
421  ssta = csplCursor.currentRow()["S_STATION" ].data<int>();
422  squa = csplCursor.currentRow()["S_SUPERLAYER"].data<int>();
423  slay = csplCursor.currentRow()["S_LAYER" ].data<int>();
424  sl_p = csplCursor.currentRow()["S_PART" ].data<int>();
425  DTWireId pId( pwhe, psta, psec, pqua, play, 10 + pl_p );
426  DTWireId sId( swhe, ssta, ssec, squa, slay, 10 + sl_p );
427  int pRaw = pId.rawId();
428  int sRaw = sId.rawId();
429  std::vector<int>* splitList = 0;
430  std::map< int,std::vector<int>* >::iterator iter =
431  channelSplit.find( pRaw );
432  std::map< int,std::vector<int>* >::iterator iend =
433  channelSplit.end();
434  if ( iter == iend ) {
435  channelSplit.insert( std::pair< int,
436  std::vector<int>* >( pRaw, splitList =
437  new std::vector<int> ) );
438  }
439  else {
440  splitList = iter->second;
441  }
442  splitList->push_back( sRaw );
443  }
444  return;
445 }
std::map< int, std::vector< int > * > channelSplit
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
cond::DbSession util_session
tuple cout
Definition: gather_cfg.py:41
std::string splitVersion
void DTHVStatusHandler::getLayerSplit ( )
private

Definition at line 330 of file DTHVStatusHandler.cc.

References gather_cfg::cout, laySplit, mapVersion, cond::DbSession::nominalSchema(), and util_session.

Referenced by checkNewData().

330  {
331  std::cout << "retrieve layer split table..." << std::endl;
332  int whe;
333  int sec;
334  int sta;
335  int qua;
336  int lay;
337  int l_p;
338  int f_c;
339  int l_c;
340  coral::ITable& lsplTable =
341  util_session.nominalSchema().tableHandle( "DT_HV_LAYER_SPLIT" );
342  std::cout << " layer split table got..." << std::endl;
343  std::auto_ptr<coral::IQuery> lsplQuery( lsplTable.newQuery() );
344  coral::AttributeList versionBindVariableList;
345  versionBindVariableList.extend( "version", typeid(std::string) );
346  versionBindVariableList["version"].data<std::string>() = mapVersion;
347  lsplQuery->setCondition( "VERSION=:version", versionBindVariableList );
348  lsplQuery->addToOutputList( "WHEEL" );
349  lsplQuery->addToOutputList( "SECTOR" );
350  lsplQuery->addToOutputList( "STATION" );
351  lsplQuery->addToOutputList( "SUPERLAYER" );
352  lsplQuery->addToOutputList( "LAYER" );
353  lsplQuery->addToOutputList( "PART" );
354  lsplQuery->addToOutputList( "FIRST_CELL" );
355  lsplQuery->addToOutputList( "LAST_CELL" );
356  coral::ICursor& lsplCursor = lsplQuery->execute();
357  while ( lsplCursor.next() ) {
358  whe = lsplCursor.currentRow()["WHEEL" ].data<int>();
359  sec = lsplCursor.currentRow()["SECTOR" ].data<int>();
360  sta = lsplCursor.currentRow()["STATION" ].data<int>();
361  qua = lsplCursor.currentRow()["SUPERLAYER"].data<int>();
362  lay = lsplCursor.currentRow()["LAYER" ].data<int>();
363  l_p = lsplCursor.currentRow()["PART" ].data<int>();
364  f_c = lsplCursor.currentRow()["FIRST_CELL"].data<int>();
365  l_c = lsplCursor.currentRow()[ "LAST_CELL"].data<int>();
366  DTWireId wireId( whe, sta, sec, qua, lay, 10 + l_p );
367  laySplit.insert( std::pair<int,int>( wireId.rawId(),
368  ( f_c * 10000 ) + l_c ) );
369  }
370  std::cout << "channel split table retrieved" << std::endl;
371  return;
372 }
std::map< int, int > laySplit
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
cond::DbSession util_session
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::getLayerValues ( int  rawId,
int  type,
float &  valueL,
float &  valueR,
float &  valueS,
float &  valueC 
)
private

Definition at line 1119 of file DTHVStatusHandler.cc.

References gather_cfg::cout, layerId(), layerMap, DetId::rawId(), and snapshotValues.

Referenced by checkStatusChange(), and offlineList().

1121  {
1122  valueL =
1123  valueR =
1124  valueS =
1125  valueC = 0.0;
1126  DTWireId chlId( rawId );
1127  std::map<int,timedMeasurement>::const_iterator snapIter =
1128  snapshotValues.begin();
1129  std::map<int,timedMeasurement>::const_iterator snapIend =
1130  snapshotValues.end();
1131  int rawL = layerId( rawId, 0 ).rawId();
1132  int rawR = layerId( rawId, 1 ).rawId();
1133  int rawS = layerId( rawId, 2 ).rawId();
1134  int rawC = layerId( rawId, 3 ).rawId();
1135  std::map<int,int>::const_iterator layerIter;
1136  std::map<int,int>::const_iterator layerIend = layerMap.end();
1137  if ( ( layerIter = layerMap.find( rawL ) ) != layerIend ) {
1138  const std::pair<int,int>& layerEntry = *layerIter;
1139  int dpId = layerEntry.second;
1140  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1141  if ( snapIter != snapIend ) {
1142  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1143  valueL = snapEntry.second.second;
1144  }
1145  else std::cout << "snapR not found" << std::endl;
1146  }
1147  else std::cout << "rawR not found" << std::endl;
1148  if ( ( layerIter = layerMap.find( rawR ) ) != layerIend ) {
1149  const std::pair<int,int>& layerEntry = *layerIter;
1150  int dpId = layerEntry.second;
1151  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1152  if ( snapIter != snapIend ) {
1153  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1154  valueR = snapEntry.second.second;
1155  }
1156  else std::cout << "snapL not found" << std::endl;
1157  }
1158  else std::cout << "rawL not found" << std::endl;
1159  if ( ( layerIter = layerMap.find( rawS ) ) != layerIend ) {
1160  const std::pair<int,int>& layerEntry = *layerIter;
1161  int dpId = layerEntry.second;
1162  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1163  if ( snapIter != snapIend ) {
1164  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1165  valueS = snapEntry.second.second;
1166  }
1167  else std::cout << "snapS not found" << std::endl;
1168  }
1169  else std::cout << "rawS not found" << std::endl;
1170  if ( ( layerIter = layerMap.find( rawC ) ) != layerIend ) {
1171  const std::pair<int,int>& layerEntry = *layerIter;
1172  int dpId = layerEntry.second;
1173  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1174  if ( snapIter != snapIend ) {
1175  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1176  valueC = snapEntry.second.second;
1177  }
1178  else std::cout << "snapC not found" << std::endl;
1179  }
1180  else std::cout << "rawC not found" << std::endl;
1181 // std::cout << "layer values... " << type << " " << valueL << " "
1182 // << valueR << " "
1183 // << valueS << " "
1184 // << valueC << std::endl;
1185  return;
1186 }
type
Definition: HCALResponse.h:22
static DTWireId layerId(int rawId, int l_p)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::map< int, timedMeasurement > snapshotValues
std::map< int, int > layerMap
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::getNewObjects ( )
virtual

Operations

Implements popcon::PopConSourceHandler< DTHVStatus >.

Definition at line 102 of file DTHVStatusHandler.cc.

References aliasMap, buff_conn, buff_session, bufferConnect, checkNewData(), cond::DbSession::close(), cond::DbTransaction::commit(), condTime(), cond::DbConnection::configuration(), cond::DbConnection::configure(), coralTime(), gather_cfg::cout, cond::DbConnection::createSession(), runTheMatrix::data, dataTag, dSince, dUntil, DTHVStatusData::flagA, DTHVStatusData::flagC, DTHVStatusData::flagS, hSince, hUntil, hvChecker, id(), prof2calltree::last, lastFound, cond::TagInfo::lastInterval, popcon::PopConSourceHandler< DTHVStatus >::lastPayload(), lastStamp, layerId(), layerMap, popcon::PopConSourceHandler< DTHVStatus >::m_to_transfer, mSince, mUntil, nextFound, cmsPerfSuiteHarvest::now, omds_conn, omds_session, onlineAuthentication, onlineConnect, cond::DbSession::open(), procSince, procUntil, pSince, pUntil, DTHVStatusId::sectorId, cond::DbConnectionConfiguration::setAuthenticationPath(), DTHVAbstractCheck::setStatus(), snapshotValues, sSince, cond::DbTransaction::start(), DTHVStatusId::stationId, sUntil, popcon::PopConSourceHandler< DTHVStatus >::tagInfo(), timeLimit, cond::DbSession::transaction(), util_conn, util_session, DTHVStatusId::wheelId, ySince, and yUntil.

102  {
103 
104  std::cout << "get new objects..." << std::endl;
105 
106  // online DB connection - data
107  std::cout << "configure omds DbConnection" << std::endl;
108  // conn->configure( cond::CmsDefaults );
111  std::cout << "create omds DbSession" << std::endl;
113  std::cout << "open omds session" << std::endl;
115  std::cout << "start omds transaction" << std::endl;
117  std::cout << "" << std::endl;
118 
119  // online DB connection - util
120  std::cout << "configure util DbConnection" << std::endl;
121  // conn->configure( cond::CmsDefaults );
124  std::cout << "create util DbSession" << std::endl;
126  std::cout << "open util session" << std::endl;
128  std::cout << "startutil transaction" << std::endl;
130  std::cout << "" << std::endl;
131 
132  // buffer DB connection
133  std::cout << "configure buffer DbConnection" << std::endl;
136  std::cout << "create buffer DbSession" << std::endl;
138  std::cout << "open buffer session" << std::endl;
140  std::cout << "start buffer transaction" << std::endl;
142 
143  // offline info
144 
145  //to access the information on the tag inside the offline database:
146  cond::TagInfo const & ti = tagInfo();
147  cond::Time_t last = ti.lastInterval.first;
148  std::cout << "latest DCS data (HV) already copied until: "
149  << last << std::endl;
150 
151  coral::TimeStamp coralSince( ySince, mSince, dSince,
152  hSince, pSince, sSince, 0 );
153  procSince = condTime( coralSince );
154  coral::TimeStamp coralUntil( yUntil, mUntil, dUntil,
155  hUntil, pUntil, sUntil, 0 );
156  procUntil = condTime( coralUntil );
157  lastFound = 0;
158  nextFound = 0;
159  timeLimit = 0;
160  lastStamp = 0;
161 
162  if ( last == 0 ) {
163  DTHVStatus* dummyStatus = new DTHVStatus( dataTag );
164  cond::Time_t snc = 1;
165  m_to_transfer.push_back( std::make_pair( dummyStatus, snc ) );
166  last = procSince + 1;
167  std::cout << "no old data... " << last << std::endl;
168  }
169  else {
170  Ref payload = lastPayload();
171  DTHVStatus::const_iterator paylIter = payload->begin();
172  DTHVStatus::const_iterator paylIend = payload->end();
173  while ( paylIter != paylIend ) {
174  const std::pair<DTHVStatusId,DTHVStatusData>& entry = *paylIter++;
175  const DTHVStatusId& chan = entry.first;
176  const DTHVStatusData& data = entry.second;
177  DTWireId id( chan.wheelId, chan.stationId, chan.sectorId,
178  chan. slId, chan. layerId, chan. partId + 10 );
179  hvChecker->setStatus( id.rawId(),
180  data.flagA, data.flagC, data.flagS,
182  aliasMap, layerMap );
183  }
184  }
185  coral::TimeStamp coralLast = coralTime( last );
186  coral::TimeStamp coralProc = coral::TimeStamp::now();
187  cond::Time_t condProc = condTime( coralProc );
188 
189  if ( procSince > condProc ) {
190  std::cout << "Required time interval in the future: "
191  << std::endl
192  << " copy since " << ySince << " "
193  << mSince << " "
194  << dSince
195  << " ( " << procSince << " )" << std::endl
196  << " current time " << coralProc.year( ) << " "
197  << coralProc.month() << " "
198  << coralProc.day( ) << std::endl;
199  }
200  if ( procUntil > condProc ) procUntil = condProc;
201  if ( last > procSince ) {
202  if ( last < procUntil ) {
203  procSince = last;
204  checkNewData();
205  }
206  else {
207  std::cout << "Required time interval already copied: "
208  << std::endl
209  << " copy until " << yUntil << " "
210  << mUntil << " "
211  << dUntil
212  << " ( " << procUntil << " )" << std::endl
213  << " data until " << coralLast.year( ) << " "
214  << coralLast.month() << " "
215  << coralLast.day( ) << std::endl;
216  }
217  }
218  else {
219  std::cout << "Required time interval not contiguous with copied data: "
220  << std::endl
221  << " data until " << coralLast.year( ) << " "
222  << coralLast.month() << " "
223  << coralLast.day( ) << std::endl
224  << " copy since " << ySince << " "
225  << mSince << " "
226  << dSince
227  << " ( " << procSince << " )" << std::endl;
228  }
229 
234 
235  return;
236 
237 }
std::string id() const
long long int lastStamp
std::map< int, int > aliasMap
cond::Time_t lastFound
DbTransaction & transaction()
Definition: DbSession.cc:153
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:119
cond::Time_t procUntil
int commit()
commit transaction.
DbConnectionConfiguration & configuration()
Definition: DbConnection.cc:89
std::string onlineConnect
cond::DbSession buff_session
static DTWireId layerId(int rawId, int l_p)
virtual void setStatus(int rawId, int flagA, int flagC, int flagS, const std::map< int, timedMeasurement > &snapshotValues, const std::map< int, int > &aliasMap, const std::map< int, int > &layerMap)
cond::DbConnection buff_conn
static coral::TimeStamp coralTime(const cond::Time_t &time)
int start(bool readOnly=false)
start transaction
cond::Time_t nextFound
unsigned long long Time_t
Definition: Time.h:16
cond::Time_t procSince
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
static cond::Time_t condTime(const coral::TimeStamp &time)
std::map< int, timedMeasurement > snapshotValues
std::map< int, int > layerMap
std::vector< std::pair< DTHVStatusId, DTHVStatusData > >::const_iterator const_iterator
Access methods to data.
Definition: DTHVStatus.h:173
cond::DbConnection util_conn
std::string onlineAuthentication
DbSession createSession() const
Definition: DbConnection.cc:72
cond::DbSession util_session
void setAuthenticationPath(const std::string &p)
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
cond::DbSession omds_session
DTHVAbstractCheck * hvChecker
std::string bufferConnect
tuple cout
Definition: gather_cfg.py:41
cond::Time_t timeLimit
cond::DbConnection omds_conn
std::string DTHVStatusHandler::id ( void  ) const
virtual

Implements popcon::PopConSourceHandler< DTHVStatus >.

Definition at line 297 of file DTHVStatusHandler.cc.

Referenced by getNewObjects().

297  {
298  return "DTHVStatusHandler";
299 }
DTWireId DTHVStatusHandler::layerId ( int  rawId,
int  l_p 
)
staticprivate

Definition at line 1389 of file DTHVStatusHandler.cc.

References DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superLayer(), and DTChamberId::wheel().

Referenced by checkStatusChange(), getLayerValues(), getNewObjects(), and offlineList().

1389  {
1390  DTWireId chlId( rawId );
1391  int whe = chlId.wheel ();
1392  int sta = chlId.station ();
1393  int sec = chlId.sector ();
1394  int qua = chlId.superLayer();
1395  int lay = chlId.layer ();
1396  DTWireId chl( whe, sta, sec, qua, lay, 10 + l_p );
1397  return chl;
1398 }
DTHVStatus * DTHVStatusHandler::offlineList ( )
private

Definition at line 1043 of file DTHVStatusHandler.cc.

References DTHVAbstractCheck::flag::a, aliasMap, DTHVAbstractCheck::flag::c, channelSplit, DTHVAbstractCheck::checkCurrentStatus(), dataTag, getLayerValues(), hvChecker, DTLayerId::layer(), layerId(), layerMap, DetId::rawId(), DTHVAbstractCheck::flag::s, DTChamberId::sector(), setChannelFlag(), snapshotValues, DTChamberId::station(), DTSuperLayerId::superLayer(), DTChamberId::wheel(), and DTWireId::wire().

Referenced by checkForPeriod(), and copyHVData().

1043  {
1044  DTHVStatus* hv = new DTHVStatus( dataTag );
1045  int type;
1046  float valueA = 0.0;
1047  float valueL = 0.0;
1048  float valueR = 0.0;
1049  float valueS = 0.0;
1050  float valueC = 0.0;
1051  std::map<int,int>::const_iterator layerIter = layerMap.begin();
1052  std::map<int,int>::const_iterator layerIend = layerMap.end();
1053  while ( layerIter != layerIend ) {
1054  const std::pair<int,int>& chanEntry = *layerIter++;
1055  int rawId = chanEntry.first;
1056  DTWireId chlId( rawId );
1057  int whe = chlId.wheel ();
1058  int sta = chlId.station ();
1059  int sec = chlId.sector ();
1060  int qua = chlId.superLayer();
1061  int lay = chlId.layer ();
1062  int l_p = chlId.wire();
1063  if ( l_p != 10 ) continue;
1064  for ( type = 1; type <= 2; type++ ) {
1065  getLayerValues( rawId, type, valueL, valueR, valueS, valueC );
1066  for ( l_p = 0; l_p <= 1; l_p++ ) {
1067  int rPart = layerId( rawId, l_p ).rawId();
1068  switch ( l_p ) {
1069  case 0:
1070  valueA = valueL;
1071  break;
1072  case 1:
1073  valueA = valueR;
1074  break;
1075  default:
1076  break;
1077  }
1078 // std::cout << "layer values: " << type << " " << valueA << " "
1079 // << valueS << " "
1080 // << valueC << std::endl;
1082  rPart, type,
1083  valueA, valueC, valueS,
1085  aliasMap, layerMap );
1086  if ( !flag.a && !flag.c && !flag.s ) continue;
1087  setChannelFlag( hv, whe, sta, sec, qua, lay, l_p, flag );
1088  std::map< int,std::vector<int>* >::const_iterator m_iter =
1089  channelSplit.find( rPart );
1090  std::map< int,std::vector<int>* >::const_iterator m_iend =
1091  channelSplit.end();
1092  if ( m_iter != m_iend ) {
1093  std::vector<int>* cList = m_iter->second;
1094  std::vector<int>::const_iterator l_iter = cList->begin();
1095  std::vector<int>::const_iterator l_iend = cList->end();
1096  while ( l_iter != l_iend ) {
1097  DTWireId chlId( *l_iter++ );
1098  int wh2 = chlId.wheel ();
1099  int st2 = chlId.station ();
1100  int se2 = chlId.sector ();
1101  int qu2 = chlId.superLayer();
1102  int la2 = chlId.layer ();
1103  int lp2 = chlId.wire() - 10;
1104 // std::cout << "duplicate "
1105 // << whe << " " << sta << " " << sec << " "
1106 // << qua << " " << lay << " " << l_p << " ---> "
1107 // << wh2 << " " << st2 << " " << se2 << " "
1108 // << qu2 << " " << la2 << " " << lp2 << std::endl;
1109  setChannelFlag( hv, wh2, st2, se2, qu2, la2, lp2, flag );
1110  }
1111  }
1112  }
1113  }
1114  }
1115  return hv;
1116 }
type
Definition: HCALResponse.h:22
long int flag
Definition: mlp_lapack.h:47
std::map< int, int > aliasMap
void getLayerValues(int rawId, int type, float &valueL, float &valueR, float &valueS, float &valueC)
static DTWireId layerId(int rawId, int l_p)
std::map< int, std::vector< int > * > channelSplit
virtual DTHVAbstractCheck::flag checkCurrentStatus(int rawId, int type, float valueA, float valueC, float valueS, const std::map< int, timedMeasurement > &snapshotValues, const std::map< int, int > &aliasMap, const std::map< int, int > &layerMap)=0
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::map< int, timedMeasurement > snapshotValues
std::map< int, int > layerMap
void setChannelFlag(DTHVStatus *hv, int whe, int sta, int sec, int qua, int lay, int l_p, const DTHVAbstractCheck::flag &flag)
DTHVAbstractCheck * hvChecker
cond::Time_t DTHVStatusHandler::recoverLastTime ( )
private

Definition at line 774 of file DTHVStatusHandler.cc.

References condTime(), and snapshotValues.

Referenced by updateHVStatus().

774  {
775  long long int lastTime = 0LL;
776  long long int chanTime = 0LL;
777  std::map<int,timedMeasurement>::iterator mapIter = snapshotValues.begin();
778  std::map<int,timedMeasurement>::iterator mapIend = snapshotValues.end();
779  while ( mapIter != mapIend ) {
780  const std::pair<int,timedMeasurement>& entry = *mapIter++;
781  chanTime = entry.second.first;
782  if ( lastTime < chanTime ) lastTime = chanTime;
783  }
784  return condTime( lastTime );
785 /*
786  coral::ITable& infoTable =
787  buff_session.nominalSchema().tableHandle( "LOG" );
788  std::auto_ptr<coral::IQuery> infoQuery( infoTable.newQuery() );
789  infoQuery->addToOutputList( "SNAPSHOT" );
790  coral::ICursor& infoCursor = infoQuery->execute();
791  coral::TimeStamp time;
792  while ( infoCursor.next() ) {
793  time = infoCursor.currentRow()["SNAPSHOT"].data<coral::TimeStamp>();
794  }
795  return condTime( time );
796 */
797 }
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
static cond::Time_t condTime(const coral::TimeStamp &time)
std::map< int, timedMeasurement > snapshotValues
int DTHVStatusHandler::recoverSnapshot ( )
private

Definition at line 729 of file DTHVStatusHandler.cc.

References buff_session, gather_cfg::cout, layerMap, cond::DbSession::nominalSchema(), DetId::rawId(), snapshotValues, cond::rpcobgas::time, and relativeConstraints::value.

Referenced by updateHVStatus().

729  {
730  int missingChannels = 0;
731  std::map<int,int>::const_iterator layIter = layerMap.begin();
732  std::map<int,int>::const_iterator layIend = layerMap.end();
733  std::cout << "retrieve snapshot table..." << std::endl;
734  coral::ITable& hvssTable =
735  buff_session.nominalSchema().tableHandle( "HVSNAPSHOT" );
736  std::auto_ptr<coral::IQuery> hvssQuery( hvssTable.newQuery() );
737  hvssQuery->addToOutputList( "TIME" );
738  hvssQuery->addToOutputList( "WHEEL" );
739  hvssQuery->addToOutputList( "STATION" );
740  hvssQuery->addToOutputList( "SECTOR" );
741  hvssQuery->addToOutputList( "SUPERLAYER" );
742  hvssQuery->addToOutputList( "LAYER" );
743  hvssQuery->addToOutputList( "CHAN" );
744  hvssQuery->addToOutputList( "TYPE" );
745  hvssQuery->addToOutputList( "VALUE" );
746  coral::ICursor& hvssCursor = hvssQuery->execute();
747  while ( hvssCursor.next() ) {
748  coral::TimeStamp time =
749  hvssCursor.currentRow()["TIME"].data<coral::TimeStamp>();
750  int whe = hvssCursor.currentRow()["WHEEL" ].data<int>();
751  int sta = hvssCursor.currentRow()["STATION" ].data<int>();
752  int sec = hvssCursor.currentRow()["SECTOR" ].data<int>();
753  int qua = hvssCursor.currentRow()["SUPERLAYER"].data<int>();
754  int lay = hvssCursor.currentRow()["LAYER" ].data<int>();
755  int l_p = hvssCursor.currentRow()["CHAN" ].data<int>();
756  int mty = hvssCursor.currentRow()["TYPE" ].data<int>();
757  float value = hvssCursor.currentRow()["VALUE" ].data<float>();
758  if ( mty > 2 ) continue;
759  DTWireId wireId( whe, sta, sec, qua, lay, 10 + l_p );
760  layIter = layerMap.find( wireId.rawId() );
761  if ( layIter == layIend ) {
762  continue;
763  }
764  int dpId = ( layIter->second * 10 ) + mty;
765  snapshotValues.insert( std::pair<int,timedMeasurement>(
766  dpId, timedMeasurement(
767  time.total_nanoseconds(), value ) ) );
768  missingChannels++;
769  }
770  return missingChannels;
771 }
DTHVAbstractCheck::timedMeasurement timedMeasurement
cond::DbSession buff_session
std::map< int, timedMeasurement > snapshotValues
std::map< int, int > layerMap
coral::ISchema & nominalSchema()
Definition: DbSession.cc:175
tuple cout
Definition: gather_cfg.py:41
void DTHVStatusHandler::setChannelFlag ( DTHVStatus hv,
int  whe,
int  sta,
int  sec,
int  qua,
int  lay,
int  l_p,
const DTHVAbstractCheck::flag flag 
)
private

Definition at line 1189 of file DTHVStatusHandler.cc.

References DTHVAbstractCheck::flag::a, DTHVAbstractCheck::flag::c, DTHVStatus::get(), laySplit, DetId::rawId(), DTHVAbstractCheck::flag::s, and DTHVStatus::set().

Referenced by offlineList().

1192  {
1193  int fCell = 0;
1194  int lCell = 99;
1195  int flagA = 0;
1196  int flagC = 0;
1197  int flagS = 0;
1198  int searchStatus = hv->get( whe, sta, sec, qua, lay, l_p,
1199  fCell, lCell, flagA, flagC, flagS );
1200  if ( searchStatus ) {
1201  DTWireId wireId( whe, sta, sec, qua, lay, 10 + l_p );
1202  std::map<int,int>::const_iterator splitIter =
1203  laySplit.find( wireId.rawId() );
1204  std::map<int,int>::const_iterator splitIend =
1205  laySplit.end();
1206  if ( splitIter != splitIend ) {
1207  int code = splitIter->second;
1208  fCell = code / 10000;
1209  lCell = code % 10000;
1210  }
1211  }
1212  flagA |= flag.a;
1213  flagC |= flag.c;
1214  flagS |= flag.s;
1215  hv->set( whe, sta, sec, qua, lay, l_p,
1216  fCell, lCell, flagA, flagC, flagS );
1217  return;
1218 }
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int &fCell, int &lCell, int &flagA, int &flagC, int &flagS) const
get content
Definition: DTHVStatus.cc:88
std::map< int, int > laySplit
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int fCell, int lCell, int flagA, int flagC, int flagS)
Definition: DTHVStatus.cc:283
void DTHVStatusHandler::updateHVStatus ( )
private

Definition at line 676 of file DTHVStatusHandler.cc.

References bwdTime, checkForPeriod(), copyHVData(), coralTime(), gather_cfg::cout, dSince, dumpAtEnd, dumpAtStart, dumpSnapshot(), lastFound, mSince, procSince, recoverLastTime(), recoverSnapshot(), and ySince.

Referenced by checkNewData().

676  {
677  int missingChannels = recoverSnapshot();
678  cond::Time_t snapshotTime = recoverLastTime();
679  std::cout << " snapshot at " << snapshotTime << " ( "
680  << coralTime( snapshotTime )
681  .total_nanoseconds() << " ) "
682  << std::endl;
683  if ( snapshotTime > procSince ) {
684  coral::TimeStamp coralSnap = coralTime( snapshotTime );
685  std::cout << "too recent snapshot: " << std::endl
686  << " snapshot at " << coralSnap.year( ) << " "
687  << coralSnap.month() << " "
688  << coralSnap.day( ) << std::endl
689  << " copy since " << ySince << " "
690  << mSince << " "
691  << dSince
692  << " ( " << procSince << " )" << std::endl;
693  return;
694  }
695  long long int dTime = bwdTime;
696  dTime <<= 32;
697  cond::Time_t condUntil = procSince;
698  cond::Time_t condSince = condUntil - dTime;
699 
700  while ( missingChannels ) {
701  std::cout << "back iteration: "
702  << condSince << " ( " << coralTime( condSince )
703  .total_nanoseconds() << " ) -> "
704  << condUntil << " ( " << coralTime( condUntil )
705  .total_nanoseconds() << " ) "
706  << std::endl;
707  if ( condSince <= snapshotTime ) condSince = snapshotTime;
708  std::cout << "corrected since: "
709  << condSince << " ( " << coralTime( condSince )
710  .total_nanoseconds() << " ) "
711  << std::endl;
712  if ( condSince >= condUntil ) break;
713  std::cout << "missing... " << missingChannels << std::endl;
714  checkForPeriod( condSince, condUntil, missingChannels, false );
715  condUntil = condSince;
716  condSince = condUntil - dTime;
717  }
718 
720 
721  copyHVData();
722 
724 
725  return;
726 }
cond::Time_t lastFound
cond::Time_t recoverLastTime()
static coral::TimeStamp coralTime(const cond::Time_t &time)
unsigned long long Time_t
Definition: Time.h:16
cond::Time_t procSince
void dumpSnapshot(const coral::TimeStamp &time)
int checkForPeriod(cond::Time_t condSince, cond::Time_t condUntil, int &missingChannels, bool copyOffline)
long long int bwdTime
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

std::map<int,int> DTHVStatusHandler::aliasMap
private
cond::DbConnection DTHVStatusHandler::buff_conn
private

Definition at line 136 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

cond::DbSession DTHVStatusHandler::buff_session
private
std::string DTHVStatusHandler::bufferConnect
private

Definition at line 102 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

long long int DTHVStatusHandler::bwdTime
private

Definition at line 119 of file DTHVStatusHandler.h.

Referenced by updateHVStatus().

std::map< int, std::vector<int>* > DTHVStatusHandler::channelSplit
private

Definition at line 146 of file DTHVStatusHandler.h.

Referenced by getChannelSplit(), and offlineList().

std::string DTHVStatusHandler::dataTag
private

Definition at line 98 of file DTHVStatusHandler.h.

Referenced by getNewObjects(), and offlineList().

int DTHVStatusHandler::dSince
private

Definition at line 107 of file DTHVStatusHandler.h.

Referenced by getNewObjects(), and updateHVStatus().

bool DTHVStatusHandler::dumpAtEnd
private

Definition at line 118 of file DTHVStatusHandler.h.

Referenced by updateHVStatus().

bool DTHVStatusHandler::dumpAtStart
private

Definition at line 117 of file DTHVStatusHandler.h.

Referenced by updateHVStatus().

int DTHVStatusHandler::dUntil
private

Definition at line 113 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

long long int DTHVStatusHandler::fwdTime
private

Definition at line 120 of file DTHVStatusHandler.h.

Referenced by copyHVData().

int DTHVStatusHandler::hSince
private

Definition at line 108 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

int DTHVStatusHandler::hUntil
private

Definition at line 114 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

DTHVAbstractCheck* DTHVStatusHandler::hvChecker
private
cond::Time_t DTHVStatusHandler::lastFound
private

Definition at line 128 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), copyHVData(), getNewObjects(), and updateHVStatus().

long long int DTHVStatusHandler::lastStamp
private

Definition at line 131 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), and getNewObjects().

DTHVStatus* DTHVStatusHandler::lastStatus
private

Definition at line 103 of file DTHVStatusHandler.h.

Referenced by copyHVData().

std::map<int,int> DTHVStatusHandler::layerMap
private
std::map<int,int> DTHVStatusHandler::laySplit
private

Definition at line 145 of file DTHVStatusHandler.h.

Referenced by getLayerSplit(), and setChannelFlag().

std::string DTHVStatusHandler::mapVersion
private

Definition at line 141 of file DTHVStatusHandler.h.

Referenced by getLayerSplit().

int DTHVStatusHandler::maxPayload
private

Definition at line 132 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), copyHVData(), and DTHVStatusHandler().

long long int DTHVStatusHandler::minTime
private

Definition at line 121 of file DTHVStatusHandler.h.

Referenced by checkForPeriod().

int DTHVStatusHandler::mSince
private

Definition at line 106 of file DTHVStatusHandler.h.

Referenced by getNewObjects(), and updateHVStatus().

int DTHVStatusHandler::mUntil
private

Definition at line 112 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

cond::Time_t DTHVStatusHandler::nextFound
private

Definition at line 129 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), and getNewObjects().

cond::DbConnection DTHVStatusHandler::omds_conn
private

Definition at line 134 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

cond::DbSession DTHVStatusHandler::omds_session
private

Definition at line 137 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), checkNewData(), dumpHVAliases(), and getNewObjects().

std::string DTHVStatusHandler::onlineAuthentication
private

Definition at line 101 of file DTHVStatusHandler.h.

Referenced by DTHVStatusHandler(), and getNewObjects().

std::string DTHVStatusHandler::onlineConnect
private

Definition at line 99 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

cond::Time_t DTHVStatusHandler::procSince
private

Definition at line 126 of file DTHVStatusHandler.h.

Referenced by checkNewData(), copyHVData(), getNewObjects(), and updateHVStatus().

cond::Time_t DTHVStatusHandler::procUntil
private

Definition at line 127 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), checkNewData(), copyHVData(), and getNewObjects().

int DTHVStatusHandler::pSince
private

Definition at line 109 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

int DTHVStatusHandler::pUntil
private

Definition at line 115 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

std::map<int,timedMeasurement> DTHVStatusHandler::snapshotValues
private
std::string DTHVStatusHandler::splitVersion
private

Definition at line 142 of file DTHVStatusHandler.h.

Referenced by getChannelSplit().

int DTHVStatusHandler::sSince
private

Definition at line 110 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

int DTHVStatusHandler::sUntil
private

Definition at line 116 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

bool DTHVStatusHandler::switchOff
private

Definition at line 148 of file DTHVStatusHandler.h.

Referenced by copyHVData(), and filterData().

cond::Time_t DTHVStatusHandler::timeLimit
private

Definition at line 130 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), and getNewObjects().

std::vector< std::pair<DTHVStatus*, cond::Time_t> > DTHVStatusHandler::tmpContainer
private

Definition at line 147 of file DTHVStatusHandler.h.

Referenced by checkForPeriod(), and filterData().

cond::DbConnection DTHVStatusHandler::util_conn
private

Definition at line 135 of file DTHVStatusHandler.h.

Referenced by getNewObjects().

cond::DbSession DTHVStatusHandler::util_session
private

Definition at line 138 of file DTHVStatusHandler.h.

Referenced by checkNewData(), getChannelSplit(), getLayerSplit(), and getNewObjects().

std::string DTHVStatusHandler::utilConnect
private

Definition at line 100 of file DTHVStatusHandler.h.

int DTHVStatusHandler::ySince
private

Definition at line 105 of file DTHVStatusHandler.h.

Referenced by getNewObjects(), and updateHVStatus().

int DTHVStatusHandler::yUntil
private

Definition at line 111 of file DTHVStatusHandler.h.

Referenced by getNewObjects().