test
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 Attributes
popcon::PopConBTransitionSourceHandler< T > Class Template Reference

#include <PopConBTransitionSourceHandler.h>

Inheritance diagram for popcon::PopConBTransitionSourceHandler< T >:
popcon::PopConSourceHandler< T >

Public Member Functions

bool checkBOn ()
 
virtual void getNewObjects () overridefinal
 
virtual void getObjectsForBTransition (bool isBOn)
 
virtual std::string id () const overridefinal
 
 PopConBTransitionSourceHandler (edm::ParameterSet const &pset)
 
virtual ~PopConBTransitionSourceHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< T >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Attributes

cond::persistency::ConnectionPool m_connection
 
edm::ParameterSet m_connectionPset
 
std::string m_connectionString
 
double m_currentThreshold
 
unsigned long long m_run
 
std::string m_tagForBOff
 
std::string m_tagForBOn
 
std::string m_tagForRunInfo
 

Additional Inherited Members

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

Detailed Description

template<class T>
class popcon::PopConBTransitionSourceHandler< T >

Definition at line 14 of file PopConBTransitionSourceHandler.h.

Constructor & Destructor Documentation

Definition at line 16 of file PopConBTransitionSourceHandler.h.

References cond::persistency::ConnectionPool::configure(), popcon::PopConBTransitionSourceHandler< T >::m_connection, popcon::PopConBTransitionSourceHandler< T >::m_connectionPset, and cond::persistency::ConnectionPool::setParameters().

16  :
17  m_run( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<unsigned long long>( "runNumber" ) ),
18  m_currentThreshold( pset.getParameter<edm::ParameterSet>( "BTransition" ).getUntrackedParameter<double>( "currentThreshold", 18000. ) ),
19  m_tagForRunInfo( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<std::string>( "tagForRunInfo" ) ),
20  m_tagForBOff( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<std::string>( "tagForBOff" ) ),
21  m_tagForBOn( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<std::string>( "tagForBOn" ) ),
22  m_connectionString( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<std::string>( "connect" ) ),
23  m_connectionPset( pset.getParameter<edm::ParameterSet>( "BTransition" ).getParameter<edm::ParameterSet>( "DBParameters" ) ) {
24  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler:" << __func__ << "]: "
25  << "Initialising Connection Pool" << std::endl;
28  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setParameters(const edm::ParameterSet &connectionPset)
template<class T >
virtual popcon::PopConBTransitionSourceHandler< T >::~PopConBTransitionSourceHandler ( )
inlinevirtual

Definition at line 30 of file PopConBTransitionSourceHandler.h.

30 {}

Member Function Documentation

template<class T >
bool popcon::PopConBTransitionSourceHandler< T >::checkBOn ( )
inline

Definition at line 34 of file PopConBTransitionSourceHandler.h.

References cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::createReadOnlySession(), cond::persistency::Session::fetchPayload(), cond::persistency::IOVProxy::find(), o2o::iov, cond::persistency::IOVProxy::loadedSize(), LogDebug, popcon::PopConBTransitionSourceHandler< T >::m_connection, popcon::PopConBTransitionSourceHandler< T >::m_connectionString, popcon::PopConBTransitionSourceHandler< T >::m_currentThreshold, popcon::PopConBTransitionSourceHandler< T >::m_run, popcon::PopConBTransitionSourceHandler< T >::m_tagForRunInfo, cond::Iov_t::payloadId, cond::persistency::Session::readIov(), dataDML::session, cond::Iov_t::since, cond::persistency::Transaction::start(), and cond::persistency::Session::transaction().

Referenced by popcon::PopConBTransitionSourceHandler< T >::getNewObjects().

34  {
35  //the output boolean is set to true as default
36  bool isBOn = true;
37  //reading RunInfo from Conditions
38  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
39  << "Initialising CondDB read-only session to " << m_connectionString << std::endl;
41  session.transaction().start();
42  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
43  << "Loading tag for RunInfo " << m_tagForRunInfo
44  << " and IOV valid for run number: " << m_run << std::endl;
46  cond::Iov_t currentIov = *(iov.find( m_run ));
47  LogDebug( "PopConBTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << m_tagForRunInfo
48  << " with size: "<< iov.loadedSize()
49  << ", IOV valid for run number " << m_run << " starting from: " << currentIov.since
50  << ", with corresponding payload hash: " << currentIov.payloadId
51  << std::endl;
52  //accessing the average magnet current for the run
53  double current_default = -1;
54  double avg_current = current_default;
55  avg_current = session.fetchPayload<RunInfo>( currentIov.payloadId )->m_avg_current;
56  LogDebug( "PopConBTransitionSourceHandler" ) << "Comparing value of magnet current: " << avg_current << " A for run: " << m_run
57  << " with the corresponding threshold: "<< m_currentThreshold << " A." << std::endl;
58  //comparing the magnet current with the user defined threshold
59  if( avg_current != current_default && avg_current <= m_currentThreshold ) isBOn = false;
60  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
61  << "The magnet was " << ( isBOn ? "ON" : "OFF" )
62  << " during run " << m_run << std::endl;
63  session.transaction().commit();
64  return isBOn;
65  }
#define LogDebug(id)
tuple session
Definition: dataDML.py:2333
void start(bool readOnly=true)
Definition: Session.cc:22
Time_t since
Definition: Types.h:54
Transaction & transaction()
Definition: Session.cc:66
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
tuple iov
Definition: o2o.py:307
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:314
Hash payloadId
Definition: Types.h:56
Session createReadOnlySession(const std::string &connectionString, const std::string &transactionId)
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:187
template<class T >
virtual void popcon::PopConBTransitionSourceHandler< T >::getNewObjects ( )
inlinefinaloverridevirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 107 of file PopConBTransitionSourceHandler.h.

References popcon::PopConBTransitionSourceHandler< T >::checkBOn(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), cond::TagInfo_t::lastInterval, cond::TagInfo_t::lastPayloadToken, popcon::PopConBTransitionSourceHandler< T >::m_run, cond::TagInfo_t::name, cond::TagInfo_t::size, findQualityFiles::size, and popcon::PopConSourceHandler< T >::tagInfo().

107  {
108  //check whats already inside of database
109  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
110  << "Destination Tag Info: name " << this->tagInfo().name
111  << ", size " << this->tagInfo().size
112  << ", last object valid since " << this->tagInfo().lastInterval.first
113  << ", hash " << this->tagInfo().lastPayloadToken << std::endl;
114  //check if a transfer is needed:
115  //if the new run number is smaller than or equal to the latest IOV, exit.
116  //This is needed as now the IOV Editor does not always protect for insertions:
117  //ANY and VALIDATION sychronizations are allowed to write in the past.
118  if( this->tagInfo().size > 0 && this->tagInfo().lastInterval.first >= m_run ) {
119  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
120  << "last IOV " << this->tagInfo().lastInterval.first
121  << ( this->tagInfo().lastInterval.first == m_run ? " is equal to" : " is larger than" )
122  << " the run proposed for insertion " << m_run
123  << ". No transfer needed." << std::endl;
124  return;
125  }
126  bool isBOn = checkBOn();
127  getObjectsForBTransition( isBOn );
128  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
129  << "END." << std::endl;
130  }
size_t size
Definition: Types.h:75
std::string name
Definition: Types.h:71
cond::ValidityInterval lastInterval
Definition: Types.h:73
std::string lastPayloadToken
Definition: Types.h:74
tuple size
Write out results.
cond::TagInfo_t const & tagInfo() const
template<class T >
virtual void popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition ( bool  isBOn)
inlinevirtual

Definition at line 67 of file PopConBTransitionSourceHandler.h.

References cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::createReadOnlySession(), cond::persistency::Session::fetchPayload(), cond::persistency::IOVProxy::find(), o2o::iov, cond::persistency::IOVProxy::loadedSize(), LogDebug, popcon::PopConBTransitionSourceHandler< T >::m_connection, popcon::PopConBTransitionSourceHandler< T >::m_connectionString, popcon::PopConBTransitionSourceHandler< T >::m_run, popcon::PopConBTransitionSourceHandler< T >::m_tagForBOff, popcon::PopConBTransitionSourceHandler< T >::m_tagForBOn, popcon::PopConSourceHandler< T >::m_to_transfer, popcon::PopConSourceHandler< T >::m_userTextLog, cond::TagInfo_t::name, cond::Iov_t::payloadId, createTree::pp, cond::persistency::Session::readIov(), dataDML::session, cond::Iov_t::since, contentValuesCheck::ss, cond::persistency::Transaction::start(), popcon::PopConSourceHandler< T >::tagInfo(), and cond::persistency::Session::transaction().

Referenced by popcon::PopConBTransitionSourceHandler< T >::getNewObjects().

67  {
68  //reading payloads for 0T and 3.8T from Conditions
69  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
70  << "Initialising CondDB read-only session to " << m_connectionString << std::endl;
72  session.transaction().start();
73  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
74  << "Loading tag for B " << ( isBOn ? "ON" : "OFF" ) << ": "
75  << ( isBOn ? m_tagForBOn : m_tagForBOff )
76  << " and IOV valid for run number: " << m_run << std::endl;
77  cond::persistency::IOVProxy iov = session.readIov( isBOn ? m_tagForBOn : m_tagForBOff, true );
78  cond::Iov_t currentIov = *(iov.find( m_run ));
79  LogDebug( "PopConBTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << ( isBOn ? m_tagForBOn : m_tagForBOff )
80  << " with size: "<< iov.loadedSize()
81  << ", IOV valid for run number " << m_run << " starting from: " << currentIov.since
82  << ", with corresponding payload hash: " << currentIov.payloadId
83  << std::endl;
84  if( currentIov.payloadId != this->tagInfo().lastPayloadToken ) {
85  std::ostringstream ss;
86  ss << "Exporting payload with hash " << currentIov.payloadId
87  << " corresponding to the calibrations for magnetic field "
88  << ( isBOn ? "ON" : "OFF" )
89  << " starting from run number: " << m_run;
90  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
91  << ss.str() << std::endl;
92  T* pp = new T( *(session.fetchPayload<T>( currentIov.payloadId )) );
93  this->m_to_transfer.push_back( std::make_pair( pp, m_run ) );
94  this->m_userTextLog = ss.str();
95  } else {
96  edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
97  << "The payload with hash " << currentIov.payloadId
98  << " corresponding to the calibrations for magnetic field "
99  << ( isBOn ? "ON" : "OFF" )
100  << " is still valid for run " << m_run
101  << " in the destination tag " << this->tagInfo().name
102  << ".\nNo transfer needed." <<std::endl;
103  }
104  session.transaction().commit();
105  }
#define LogDebug(id)
tuple session
Definition: dataDML.py:2333
tuple pp
Definition: createTree.py:15
void start(bool readOnly=true)
Definition: Session.cc:22
Time_t since
Definition: Types.h:54
Transaction & transaction()
Definition: Session.cc:66
std::string name
Definition: Types.h:71
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
tuple iov
Definition: o2o.py:307
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:314
Hash payloadId
Definition: Types.h:56
Session createReadOnlySession(const std::string &connectionString, const std::string &transactionId)
long double T
cond::TagInfo_t const & tagInfo() const
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:187
template<class T >
virtual std::string popcon::PopConBTransitionSourceHandler< T >::id ( ) const
inlinefinaloverridevirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 32 of file PopConBTransitionSourceHandler.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

32 { return std::string( "PopConBTransitionSourceHandler" ); }

Member Data Documentation

template<class T >
cond::persistency::ConnectionPool popcon::PopConBTransitionSourceHandler< T >::m_connection
private
template<class T >
edm::ParameterSet popcon::PopConBTransitionSourceHandler< T >::m_connectionPset
private
template<class T >
std::string popcon::PopConBTransitionSourceHandler< T >::m_connectionString
private
template<class T >
double popcon::PopConBTransitionSourceHandler< T >::m_currentThreshold
private
template<class T >
unsigned long long popcon::PopConBTransitionSourceHandler< T >::m_run
private
template<class T >
std::string popcon::PopConBTransitionSourceHandler< T >::m_tagForBOff
private
template<class T >
std::string popcon::PopConBTransitionSourceHandler< T >::m_tagForBOn
private
template<class T >
std::string popcon::PopConBTransitionSourceHandler< T >::m_tagForRunInfo
private