CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
popcon::PopConESTransitionSourceHandler< T > Class Template Reference

#include <PopConESTransitionSourceHandler.h>

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

Public Member Functions

bool checkLowGain ()
 
void getNewObjects () final
 
virtual void getObjectsForESTransition (bool isLowGain)
 
std::string id () const final
 
 PopConESTransitionSourceHandler (edm::ParameterSet const &pset)
 
 ~PopConESTransitionSourceHandler () override
 
- 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
 
std::string m_ESGain
 
unsigned long long m_run
 
std::string m_tagForHighGain
 
std::string m_tagForLowGain
 
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)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< T >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

template<class T>
class popcon::PopConESTransitionSourceHandler< T >

Definition at line 14 of file PopConESTransitionSourceHandler.h.

Constructor & Destructor Documentation

Definition at line 16 of file PopConESTransitionSourceHandler.h.

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

16  :
17  m_run( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<unsigned long long>( "runNumber" ) ),
18  // m_currentThreshold( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getUntrackedParameter<double>( "currentThreshold", 18000. ) ),
19  m_tagForRunInfo( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<std::string>( "tagForRunInfo" ) ),
20  m_ESGain( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<std::string>( "ESGain" ) ),
21  m_tagForLowGain( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<std::string>( "ESLowGainTag" ) ),
22  m_tagForHighGain( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<std::string>( "ESHighGainTag" ) ),
23  m_connectionString( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<std::string>( "connect" ) ),
24  m_connectionPset( pset.getParameter<edm::ParameterSet>( "ESTransition" ).getParameter<edm::ParameterSet>( "DBParameters" ) ) {
25  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler:" << __func__ << "]: "
26  << "Initialising Connection Pool" << std::endl;
29  }
T getParameter(std::string const &) const
void setParameters(const edm::ParameterSet &connectionPset)

Definition at line 31 of file PopConESTransitionSourceHandler.h.

31 {}

Member Function Documentation

template<class T >
bool popcon::PopConESTransitionSourceHandler< T >::checkLowGain ( )
inline

Definition at line 35 of file PopConESTransitionSourceHandler.h.

References popcon::PopConSourceHandler< T >::dbSession(), cond::persistency::IOVProxy::find(), cond::persistency::IOVProxy::loadedSize(), LogDebug, popcon::PopConESTransitionSourceHandler< T >::m_ESGain, popcon::PopConESTransitionSourceHandler< T >::m_run, popcon::PopConESTransitionSourceHandler< T >::m_tagForRunInfo, cond::Iov_t::payloadId, cond::persistency::Session::readIov(), dataDML::session, cond::Iov_t::since, and cond::persistency::Session::transaction().

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

35  {
36  //the output boolean is set to true as default
37  bool isLowGain = true;
39  //reading RunInfo from Conditions
41  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: "
42  << "Loading tag for RunInfo " << m_tagForRunInfo
43  << " and IOV valid for run number: " << m_run << std::endl;
45  cond::Iov_t currentIov = *(iov.find( m_run ));
46  LogDebug( "PopConESTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << m_tagForRunInfo
47  << " with size: "<< iov.loadedSize()
48  << ", IOV valid for run number " << m_run << " starting from: " << currentIov.since
49  << ", with corresponding payload hash: " << currentIov.payloadId << std::endl;
50  /* accessing the average magnet current for the run
51  double current_default = -1;
52  double avg_current = current_default;
53  avg_current = session.fetchPayload<RunInfo>( currentIov.payloadId )->m_avg_current;
54  LogDebug( "PopConESTransitionSourceHandler" ) << "Comparing value of magnet current: " << avg_current << " A for run: " << m_run
55  << " with the corresponding threshold: "<< m_currentThreshold << " A." << std::endl;
56  comparing the magnet current with the user defined threshold
57  if( avg_current != current_default && avg_current <= m_currentThreshold ) isLowGain = false;
58  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: "
59  << "The magnet was " << ( isBOn ? "ON" : "OFF" )
60  << " during run " << m_run << std::endl; */
61  if (m_ESGain=="HIGH") {
62  isLowGain=false;}
63  else {
64  isLowGain = true;}
65  trans.close();
66  return isLowGain;
67  }
#define LogDebug(id)
cond::persistency::Session & dbSession() const
Time_t since
Definition: Types.h:55
Transaction & transaction()
Definition: Session.cc:66
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
Hash payloadId
Definition: Types.h:57
template<class T >
void popcon::PopConESTransitionSourceHandler< T >::getNewObjects ( )
inlinefinalvirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 114 of file PopConESTransitionSourceHandler.h.

References popcon::PopConESTransitionSourceHandler< T >::checkLowGain(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), cond::TagInfo_t::lastInterval, cond::TagInfo_t::lastPayloadToken, popcon::PopConESTransitionSourceHandler< T >::m_run, cond::TagInfo_t::name, cond::TagInfo_t::size, findQualityFiles::size, and popcon::PopConSourceHandler< T >::tagInfo().

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

Definition at line 69 of file PopConESTransitionSourceHandler.h.

References cond::persistency::Session::createIov(), popcon::PopConSourceHandler< T >::dbSession(), cond::persistency::Session::editIov(), idDealer::editor, cond::persistency::Session::existsIov(), cond::persistency::IOVProxy::find(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), cond::persistency::IOVProxy::loadedSize(), LogDebug, popcon::PopConESTransitionSourceHandler< T >::m_run, popcon::PopConESTransitionSourceHandler< T >::m_tagForHighGain, popcon::PopConESTransitionSourceHandler< T >::m_tagForLowGain, popcon::PopConSourceHandler< T >::m_userTextLog, cond::TagInfo_t::name, cond::Iov_t::payloadId, cond::persistency::Session::readIov(), dataDML::session, cond::persistency::IOVEditor::setDescription(), cond::Iov_t::since, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< T >::tagInfo(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

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

69  {
70  //reading payloads for 0T and 3.8T from Conditions
73  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: "
74  << "Loading tag for ES " << ( isLowGain ? "LowGain" : "HighGain" ) << ": "
75  << ( isLowGain ? m_tagForLowGain : m_tagForHighGain )
76  << " and IOV valid for run number: " << m_run << std::endl;
77  cond::persistency::IOVProxy iov = session.readIov( isLowGain ? m_tagForLowGain : m_tagForHighGain, true );
78  cond::Iov_t currentIov = *(iov.find( m_run ));
79  LogDebug( "PopConESTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << ( isLowGain ? m_tagForLowGain : m_tagForHighGain )
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  std::string destTag = this->tagInfo().name;
85  if( currentIov.payloadId != this->tagInfo().lastPayloadToken ) {
86  std::ostringstream ss;
87  ss << "Adding iov with since "<<m_run<<" pointing to hash " << currentIov.payloadId
88  << " corresponding to the ES Gain "
89  << ( isLowGain ? "LOW" : "HIGH" );
90  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: "
91  << ss.str() << std::endl;
93  if( session.existsIov( destTag ) ){
94  editor = session.editIov( destTag );
95  } else {
96  editor = session.createIov<T>( destTag, iov.timeType() );
97  editor.setDescription( "Tag created by PopConESTransitionSourceHandler" );
98  }
99  editor.insert( m_run, currentIov.payloadId );
100  editor.flush();
101  this->m_userTextLog = ss.str();
102  } else {
103  edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: "
104  << "The payload with hash " << currentIov.payloadId
105  << " corresponding to ES Gain"
106  << ( isLowGain ? "LOW" : "HIGH" )
107  << " is still valid for run " << m_run
108  << " in the destination tag " << destTag
109  << ".\nNo transfer needed." <<std::endl;
110  }
111  trans.close();
112  }
#define LogDebug(id)
cond::persistency::Session & dbSession() const
Time_t since
Definition: Types.h:55
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:188
void setDescription(const std::string &description)
Definition: IOVEditor.cc:128
Transaction & transaction()
Definition: Session.cc:66
std::string name
Definition: Types.h:74
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
cond::TimeType timeType() const
Definition: IOVProxy.cc:227
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
Hash payloadId
Definition: Types.h:57
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:156
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:152
bool existsIov(const std::string &tag)
Definition: Session.cc:97
long double T
cond::TagInfo_t const & tagInfo() const
template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::id ( ) const
inlinefinalvirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 33 of file PopConESTransitionSourceHandler.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

33 { return std::string( "PopConESTransitionSourceHandler" ); }

Member Data Documentation

template<class T >
edm::ParameterSet popcon::PopConESTransitionSourceHandler< T >::m_connectionPset
private
template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_connectionString
private

Definition at line 148 of file PopConESTransitionSourceHandler.h.

template<class T >
double popcon::PopConESTransitionSourceHandler< T >::m_currentThreshold
private

Definition at line 141 of file PopConESTransitionSourceHandler.h.

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_ESGain
private
template<class T >
unsigned long long popcon::PopConESTransitionSourceHandler< T >::m_run
private
template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForHighGain
private
template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForLowGain
private
template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForRunInfo
private