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 (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t 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 53 of file DTHVStatusHandler.cc.

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

53  :
54  dataTag( ps.getParameter<std::string> ( "tag" ) ),
55  onlineConnect( ps.getParameter<std::string> ( "onlineDB" ) ),
56  utilConnect( ps.getParameter<std::string> ( "utilDB" ) ),
58  "onlineAuthentication" ) ),
59  bufferConnect( ps.getParameter<std::string> ( "bufferDB" ) ),
60  ySince( ps.getParameter<int> ( "sinceYear" ) ),
61  mSince( ps.getParameter<int> ( "sinceMonth" ) ),
62  dSince( ps.getParameter<int> ( "sinceDay" ) ),
63  hSince( ps.getParameter<int> ( "sinceHour" ) ),
64  pSince( ps.getParameter<int> ( "sinceMinute" ) ),
65  sSince( ps.getParameter<int> ( "sinceSecond" ) ),
66  yUntil( ps.getParameter<int> ( "untilYear" ) ),
67  mUntil( ps.getParameter<int> ( "untilMonth" ) ),
68  dUntil( ps.getParameter<int> ( "untilDay" ) ),
69  hUntil( ps.getParameter<int> ( "untilHour" ) ),
70  pUntil( ps.getParameter<int> ( "untilMinute" ) ),
71  sUntil( ps.getParameter<int> ( "untilSecond" ) ),
72  dumpAtStart( ps.getParameter<bool>( "dumpAtStart" ) ),
73  dumpAtEnd( ps.getParameter<bool>( "dumpAtEnd" ) ),
74  bwdTime( ps.getParameter<long long int> ( "bwdTime" ) ),
75  fwdTime( ps.getParameter<long long int> ( "fwdTime" ) ),
76  minTime( ps.getParameter<long long int> ( "minTime" ) ),
77  omds_conn(),
78  util_conn(),
79  buff_conn(),
80  omds_session(),
81  util_session(),
82  buff_session(),
83  mapVersion( ps.getParameter<std::string> ( "mapVersion" ) ),
84  splitVersion( ps.getParameter<std::string> ( "splitVersion" ) ) {
85  std::cout << " PopCon application for DT HV data export "
87  << std::endl;
89  maxPayload = 1000;
90 }
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 95 of file DTHVStatusHandler.cc.

95  {
96 }

Member Function Documentation

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

Definition at line 878 of file DTHVStatusHandler.cc.

References DTHVStatus::begin(), checkStatusChange(), condTime(), generateEDF::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().

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

Definition at line 239 of file DTHVStatusHandler.cc.

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

Referenced by getNewObjects().

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

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

Referenced by checkForPeriod().

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

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

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

Definition at line 1414 of file DTHVStatusHandler.cc.

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

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

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

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

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

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

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

Definition at line 446 of file DTHVStatusHandler.cc.

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

Referenced by getChannelMap().

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

Definition at line 798 of file DTHVStatusHandler.cc.

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

Referenced by updateHVStatus().

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

Definition at line 1303 of file DTHVStatusHandler.cc.

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

Referenced by copyHVData().

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

Definition at line 301 of file DTHVStatusHandler.cc.

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

Referenced by checkNewData().

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

Definition at line 374 of file DTHVStatusHandler.cc.

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

Referenced by checkNewData().

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

Definition at line 329 of file DTHVStatusHandler.cc.

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

Referenced by checkNewData().

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

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

Referenced by checkStatusChange(), and offlineList().

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

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

Implements popcon::PopConSourceHandler< DTHVStatus >.

Definition at line 296 of file DTHVStatusHandler.cc.

Referenced by getNewObjects().

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

Definition at line 1387 of file DTHVStatusHandler.cc.

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

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

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

Definition at line 1041 of file DTHVStatusHandler.cc.

References DTHVAbstractCheck::flag::a, aliasMap, DTHVAbstractCheck::flag::c, channelSplit, DTHVAbstractCheck::checkCurrentStatus(), dataTag, getLayerValues(), AnalysisDataFormats_SUSYBSMObjects::hv, 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().

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

References condTime(), and snapshotValues.

Referenced by updateHVStatus().

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

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

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

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

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

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