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/09/14 13:54:04
Revision:
1.7
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:121
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 879 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().

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

Definition at line 1220 of file DTHVStatusHandler.cc.

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

Referenced by checkForPeriod().

1221  {
1222  int dpId = chan / 10;
1223  int type = chan % 10;
1224  std::map<int,int>::const_iterator aliasIter = aliasMap.find( dpId );
1225  std::map<int,int>::const_iterator aliasIend = aliasMap.end();
1226  if ( aliasIter == aliasIend ) return false;
1227  int rawId = aliasIter->second;
1228  DTWireId chlId( rawId );
1229  int l_p = chlId.wire();
1230  float valueL = 0.0;
1231  float valueR = 0.0;
1232  float valueS = 0.0;
1233  float valueC = 0.0;
1234  getLayerValues( rawId, type, valueL, valueR, valueS, valueC );
1235 // std::cout << "layer values: " << type << " " << valueL << " "
1236 // << valueR << " "
1237 // << valueS << " "
1238 // << valueC << std::endl;
1240  oldStatusL = hvChecker->checkCurrentStatus( layerId( rawId, 0 ).rawId(),
1241  type,
1242  valueL, valueC, valueS,
1244  aliasMap, layerMap );
1246  oldStatusR = hvChecker->checkCurrentStatus( layerId( rawId, 1 ).rawId(),
1247  type,
1248  valueR, valueC, valueS,
1250  aliasMap, layerMap );
1251  switch ( l_p ) {
1252  case 10:
1253  if ( valueL != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1254  << type << " " << l_p << " "
1255  << oldValue << " " << valueL << " "
1256  << std::endl;
1257  valueL = newValue;
1258  break;
1259  case 11:
1260  if ( valueR != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1261  << type << " " << l_p << " "
1262  << oldValue << " " << valueR << " "
1263  << std::endl;
1264  valueR = newValue;
1265  break;
1266  case 12:
1267  if ( valueS != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1268  << type << " " << l_p << " "
1269  << oldValue << " " << valueS << " "
1270  << std::endl;
1271  valueS = newValue;
1272  break;
1273  case 13:
1274  if ( valueC != oldValue ) std::cout << "*** INCONSISTENT DATA!!!!! "
1275  << type << " " << l_p << " "
1276  << oldValue << " " << valueC << " "
1277  << std::endl;
1278  valueC = newValue;
1279  break;
1280  default:
1281  break;
1282  }
1284  newStatusL = hvChecker->checkCurrentStatus( layerId( rawId, 0 ).rawId(),
1285  type,
1286  valueL, valueC, valueS,
1288  aliasMap, layerMap );
1290  newStatusR = hvChecker->checkCurrentStatus( layerId( rawId, 1 ).rawId(),
1291  type,
1292  valueR, valueC, valueS,
1294  aliasMap, layerMap );
1295 
1296  if ( DTHVAbstractCheck::compare( newStatusL, oldStatusL ) &&
1297  DTHVAbstractCheck::compare( newStatusR, oldStatusR ) ) return 0;
1298  std::cout << "changed status: " << chan << " from "
1299  << oldValue << " to " << newValue << std::endl;
1300  return 1;
1301 }
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:121
cond::Time_t DTHVStatusHandler::condTime ( const coral::TimeStamp &  time)
staticprivate

Definition at line 1408 of file DTHVStatusHandler.cc.

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

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

Definition at line 1415 of file DTHVStatusHandler.cc.

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

Definition at line 1010 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().

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

Definition at line 1400 of file DTHVStatusHandler.cc.

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

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

Definition at line 577 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().

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

Definition at line 447 of file DTHVStatusHandler.cc.

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

Referenced by getChannelMap().

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

Definition at line 799 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().

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

Definition at line 1304 of file DTHVStatusHandler.cc.

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

Referenced by copyHVData().

1304  {
1305 
1306  int maxTime = 100;
1307  int maxTtot = 600;
1308  int minDiff = 88;
1309 
1310  int iTime = 0;
1311  int pTime = 0;
1312  int nTime = 0;
1313  int iSize;
1314  int pSize;
1315  int nSize;
1316 
1317  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator iter =
1318  tmpContainer.begin();
1319  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator iend =
1320  tmpContainer.end();
1321  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator prev;
1322  std::vector< std::pair<DTHVStatus*, cond::Time_t> >::const_iterator next;
1323 
1324  while ( iter != iend ) {
1325  switchOff = false;
1326  next = iter;
1327  prev = next++;
1328  if ( next == iend ) next = prev;
1329  const DTHVStatus* iPtr = iter->first;
1330  const DTHVStatus* pPtr = prev->first;
1331  const DTHVStatus* nPtr = next->first;
1332  iSize = std::distance( iPtr->begin(), iPtr->end() );
1333  pSize = std::distance( pPtr->begin(), pPtr->end() );
1334  nSize = std::distance( nPtr->begin(), nPtr->end() );
1335  int dtot = nSize - pSize;
1336  prev = next;
1337  while ( ++next != iend ) {
1338  pPtr = prev->first;
1339  nPtr = next->first;
1340  pSize = std::distance( pPtr->begin(), pPtr->end() );
1341  nSize = std::distance( nPtr->begin(), nPtr->end() );
1342  int diff = nSize - pSize;
1343  iTime = static_cast<int>( ( iter->second >> 32 ) & 0xffffffff );
1344  pTime = static_cast<int>( ( prev->second >> 32 ) & 0xffffffff );
1345  nTime = static_cast<int>( ( next->second >> 32 ) & 0xffffffff );
1346  if ( ( nTime - pTime ) > maxTime ) break;
1347  if ( ( nTime - iTime ) > maxTtot ) break;
1348  if ( ( dtot * diff ) < 0 ) break;
1349  prev = next;
1350  }
1351  pPtr = prev->first;
1352  iSize = std::distance( iPtr->begin(), iPtr->end() );
1353  pSize = std::distance( pPtr->begin(), pPtr->end() );
1354  dtot = pSize - iSize;
1355  int dist = pTime - iTime;
1356  if ( ( dtot < -minDiff ) &&
1357  ( dist < maxTtot ) ) {
1358  std::cout << " ******** SWITCH ON "
1359  << std::distance( iter, prev ) << " "
1360  << iTime << " " << pTime << " "
1361  << iSize << " " << pSize << std::endl;
1362  m_to_transfer.push_back( std::make_pair( prev->first, prev->second ) );
1363  while ( iter != prev ) delete ( iter++->first );
1364  }
1365  if ( ( dtot > minDiff ) &&
1366  ( dist < maxTtot ) ) {
1367  std::cout << " ******** SWITCH OFF "
1368  << std::distance( iter, prev ) << " "
1369  << iTime << " " << pTime << " "
1370  << iSize << " " << pSize << std::endl;
1371  m_to_transfer.push_back( std::make_pair( prev->first, iter->second ) );
1372  switchOff = true;
1373  while ( iter != prev ) delete ( iter++->first );
1374  }
1375  if ( ( ( dtot >= -minDiff ) && ( dtot <= minDiff ) ) ||
1376  ( dist >= maxTtot ) ) {
1377  while ( iter != next ) {
1378  const std::pair<DTHVStatus*, cond::Time_t>& entry = *iter++;
1379  m_to_transfer.push_back( std::make_pair( entry.first, entry.second ) );
1380  }
1381  }
1382  iter = next;
1383  }
1384 
1385 }
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:121
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:228
tuple cout
Definition: gather_cfg.py:121
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 swhe;
384  int ssec;
385  int ssta;
386  int squa;
387  int slay;
388  int sl_p;
389  coral::ITable& csplTable =
390  util_session.nominalSchema().tableHandle( "DT_HV_CHANNEL_SPLIT" );
391  std::auto_ptr<coral::IQuery> csplQuery( csplTable.newQuery() );
392  coral::AttributeList versionBindVariableList;
393  versionBindVariableList.extend( "version", typeid(std::string) );
394  versionBindVariableList["version"].data<std::string>() = splitVersion;
395  csplQuery->setCondition( "VERSION=:version", versionBindVariableList );
396  csplQuery->addToOutputList( "P_WHEEL" );
397  csplQuery->addToOutputList( "P_SECTOR" );
398  csplQuery->addToOutputList( "P_STATION" );
399  csplQuery->addToOutputList( "P_SUPERLAYER" );
400  csplQuery->addToOutputList( "P_LAYER" );
401  csplQuery->addToOutputList( "P_PART" );
402  csplQuery->addToOutputList( "S_NUMBER" );
403  csplQuery->addToOutputList( "S_WHEEL" );
404  csplQuery->addToOutputList( "S_SECTOR" );
405  csplQuery->addToOutputList( "S_STATION" );
406  csplQuery->addToOutputList( "S_SUPERLAYER" );
407  csplQuery->addToOutputList( "S_LAYER" );
408  csplQuery->addToOutputList( "S_PART" );
409  coral::ICursor& csplCursor = csplQuery->execute();
410  while ( csplCursor.next() ) {
411  pwhe = csplCursor.currentRow()["P_WHEEL" ].data<int>();
412  psec = csplCursor.currentRow()["P_SECTOR" ].data<int>();
413  psta = csplCursor.currentRow()["P_STATION" ].data<int>();
414  pqua = csplCursor.currentRow()["P_SUPERLAYER"].data<int>();
415  play = csplCursor.currentRow()["P_LAYER" ].data<int>();
416  pl_p = csplCursor.currentRow()["P_PART" ].data<int>();
417  csplCursor.currentRow()["S_NUMBER" ].data<int>();
418  swhe = csplCursor.currentRow()["S_WHEEL" ].data<int>();
419  ssec = csplCursor.currentRow()["S_SECTOR" ].data<int>();
420  ssta = csplCursor.currentRow()["S_STATION" ].data<int>();
421  squa = csplCursor.currentRow()["S_SUPERLAYER"].data<int>();
422  slay = csplCursor.currentRow()["S_LAYER" ].data<int>();
423  sl_p = csplCursor.currentRow()["S_PART" ].data<int>();
424  DTWireId pId( pwhe, psta, psec, pqua, play, 10 + pl_p );
425  DTWireId sId( swhe, ssta, ssec, squa, slay, 10 + sl_p );
426  int pRaw = pId.rawId();
427  int sRaw = sId.rawId();
428  std::vector<int>* splitList = 0;
429  std::map< int,std::vector<int>* >::iterator iter =
430  channelSplit.find( pRaw );
431  std::map< int,std::vector<int>* >::iterator iend =
432  channelSplit.end();
433  if ( iter == iend ) {
434  channelSplit.insert( std::pair< int,
435  std::vector<int>* >( pRaw, splitList =
436  new std::vector<int> ) );
437  }
438  else {
439  splitList = iter->second;
440  }
441  splitList->push_back( sRaw );
442  }
443  return;
444 }
std::map< int, std::vector< int > * > channelSplit
coral::ISchema & nominalSchema()
Definition: DbSession.cc:228
cond::DbSession util_session
tuple cout
Definition: gather_cfg.py:121
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:228
cond::DbSession util_session
tuple cout
Definition: gather_cfg.py:121
void DTHVStatusHandler::getLayerValues ( int  rawId,
int  type,
float &  valueL,
float &  valueR,
float &  valueS,
float &  valueC 
)
private

Definition at line 1118 of file DTHVStatusHandler.cc.

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

Referenced by checkStatusChange(), and offlineList().

1120  {
1121  valueL =
1122  valueR =
1123  valueS =
1124  valueC = 0.0;
1125  DTWireId chlId( rawId );
1126  std::map<int,timedMeasurement>::const_iterator snapIter =
1127  snapshotValues.begin();
1128  std::map<int,timedMeasurement>::const_iterator snapIend =
1129  snapshotValues.end();
1130  int rawL = layerId( rawId, 0 ).rawId();
1131  int rawR = layerId( rawId, 1 ).rawId();
1132  int rawS = layerId( rawId, 2 ).rawId();
1133  int rawC = layerId( rawId, 3 ).rawId();
1134  std::map<int,int>::const_iterator layerIter;
1135  std::map<int,int>::const_iterator layerIend = layerMap.end();
1136  if ( ( layerIter = layerMap.find( rawL ) ) != layerIend ) {
1137  const std::pair<int,int>& layerEntry = *layerIter;
1138  int dpId = layerEntry.second;
1139  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1140  if ( snapIter != snapIend ) {
1141  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1142  valueL = snapEntry.second.second;
1143  }
1144  else std::cout << "snapR not found" << std::endl;
1145  }
1146  else std::cout << "rawR not found" << std::endl;
1147  if ( ( layerIter = layerMap.find( rawR ) ) != layerIend ) {
1148  const std::pair<int,int>& layerEntry = *layerIter;
1149  int dpId = layerEntry.second;
1150  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1151  if ( snapIter != snapIend ) {
1152  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1153  valueR = snapEntry.second.second;
1154  }
1155  else std::cout << "snapL not found" << std::endl;
1156  }
1157  else std::cout << "rawL not found" << std::endl;
1158  if ( ( layerIter = layerMap.find( rawS ) ) != layerIend ) {
1159  const std::pair<int,int>& layerEntry = *layerIter;
1160  int dpId = layerEntry.second;
1161  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1162  if ( snapIter != snapIend ) {
1163  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1164  valueS = snapEntry.second.second;
1165  }
1166  else std::cout << "snapS not found" << std::endl;
1167  }
1168  else std::cout << "rawS not found" << std::endl;
1169  if ( ( layerIter = layerMap.find( rawC ) ) != layerIend ) {
1170  const std::pair<int,int>& layerEntry = *layerIter;
1171  int dpId = layerEntry.second;
1172  snapIter = snapshotValues.find( ( dpId * 10 ) + type );
1173  if ( snapIter != snapIend ) {
1174  const std::pair<int,timedMeasurement>& snapEntry = *snapIter;
1175  valueC = snapEntry.second.second;
1176  }
1177  else std::cout << "snapC not found" << std::endl;
1178  }
1179  else std::cout << "rawC not found" << std::endl;
1180 // std::cout << "layer values... " << type << " " << valueL << " "
1181 // << valueR << " "
1182 // << valueS << " "
1183 // << valueC << std::endl;
1184  return;
1185 }
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:121
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(), 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:189
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:144
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)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
cond::DbSession omds_session
DTHVAbstractCheck * hvChecker
std::string bufferConnect
tuple cout
Definition: gather_cfg.py:121
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 1388 of file DTHVStatusHandler.cc.

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

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

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

Definition at line 1042 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().

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

References condTime(), and snapshotValues.

Referenced by updateHVStatus().

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

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

1191  {
1192  int fCell = 0;
1193  int lCell = 99;
1194  int flagA = 0;
1195  int flagC = 0;
1196  int flagS = 0;
1197  int searchStatus = hv->get( whe, sta, sec, qua, lay, l_p,
1198  fCell, lCell, flagA, flagC, flagS );
1199  if ( searchStatus ) {
1200  DTWireId wireId( whe, sta, sec, qua, lay, 10 + l_p );
1201  std::map<int,int>::const_iterator splitIter =
1202  laySplit.find( wireId.rawId() );
1203  std::map<int,int>::const_iterator splitIend =
1204  laySplit.end();
1205  if ( splitIter != splitIend ) {
1206  int code = splitIter->second;
1207  fCell = code / 10000;
1208  lCell = code % 10000;
1209  }
1210  }
1211  flagA |= flag.a;
1212  flagC |= flag.c;
1213  flagS |= flag.s;
1214  hv->set( whe, sta, sec, qua, lay, l_p,
1215  fCell, lCell, flagA, flagC, flagS );
1216  return;
1217 }
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 675 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().

675  {
676  int missingChannels = recoverSnapshot();
677  cond::Time_t snapshotTime = recoverLastTime();
678  std::cout << " snapshot at " << snapshotTime << " ( "
679  << coralTime( snapshotTime )
680  .total_nanoseconds() << " ) "
681  << std::endl;
682  if ( snapshotTime > procSince ) {
683  coral::TimeStamp coralSnap = coralTime( snapshotTime );
684  std::cout << "too recent snapshot: " << std::endl
685  << " snapshot at " << coralSnap.year( ) << " "
686  << coralSnap.month() << " "
687  << coralSnap.day( ) << std::endl
688  << " copy since " << ySince << " "
689  << mSince << " "
690  << dSince
691  << " ( " << procSince << " )" << std::endl;
692  return;
693  }
694  long long int dTime = bwdTime;
695  dTime <<= 32;
696  cond::Time_t condUntil = procSince;
697  cond::Time_t condSince = condUntil - dTime;
698 
699  while ( missingChannels ) {
700  std::cout << "back iteration: "
701  << condSince << " ( " << coralTime( condSince )
702  .total_nanoseconds() << " ) -> "
703  << condUntil << " ( " << coralTime( condUntil )
704  .total_nanoseconds() << " ) "
705  << std::endl;
706  if ( condSince <= snapshotTime ) condSince = snapshotTime;
707  std::cout << "corrected since: "
708  << condSince << " ( " << coralTime( condSince )
709  .total_nanoseconds() << " ) "
710  << std::endl;
711  if ( condSince >= condUntil ) break;
712  std::cout << "missing... " << missingChannels << std::endl;
713  checkForPeriod( condSince, condUntil, missingChannels, false );
714  condUntil = condSince;
715  condSince = condUntil - dTime;
716  }
717 
719 
720  copyHVData();
721 
723 
724  return;
725 }
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:121

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().