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 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 ()
 
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::map< Time_t, std::shared_ptr< T > > Container
 
typedef std::unique_ptr< TRef
 
typedef PopConSourceHandler< Tself
 
typedef cond::Time_t Time_t
 
typedef T value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< T >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< T >
Container m_iovs
 
std::vector< std::pair< T *, Time_t > > 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

◆ PopConESTransitionSourceHandler()

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

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. ) ),
20  pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<std::string>("tagForRunInfo")),
21  m_ESGain(pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<std::string>("ESGain")),
23  pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<std::string>("ESLowGainTag")),
25  pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<std::string>("ESHighGainTag")),
26  m_connectionString(pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<std::string>("connect")),
28  pset.getParameter<edm::ParameterSet>("ESTransition").getParameter<edm::ParameterSet>("DBParameters")) {
29  edm::LogInfo("PopConESTransitionSourceHandler") << "["
30  << "PopConESTransitionSourceHandler:" << __func__ << "]: "
31  << "Initialising Connection Pool" << std::endl;
34  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setParameters(const edm::ParameterSet &connectionPset)
Log< level::Info, false > LogInfo

◆ ~PopConESTransitionSourceHandler()

Definition at line 36 of file PopConESTransitionSourceHandler.h.

36 {}

Member Function Documentation

◆ checkLowGain()

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

Definition at line 40 of file PopConESTransitionSourceHandler.h.

References popcon::PopConSourceHandler< T >::dbSession(), cond::persistency::IOVProxy::getInterval(), 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(), cond::Iov_t::since, and cond::persistency::Session::transaction().

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

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

◆ getNewObjects()

template<class T >
void popcon::PopConESTransitionSourceHandler< T >::getNewObjects ( )
inlinefinalvirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 121 of file PopConESTransitionSourceHandler.h.

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

121  {
122  //check whats already inside of database
123  edm::LogInfo("PopConESTransitionSourceHandler")
124  << "["
125  << "PopConESTransitionSourceHandler::" << __func__ << "]: "
126  << "Destination Tag Info: name " << this->tagInfo().name << ", size " << this->tagInfo().size
127  << ", last object valid since " << this->tagInfo().lastInterval.since << ", hash "
128  << this->tagInfo().lastInterval.payloadId << std::endl;
129  //check if a transfer is needed:
130  //if the new run number is smaller than or equal to the latest IOV, exit.
131  //This is needed as now the IOV Editor does not always protect for insertions:
132  //ANY and VALIDATION sychronizations are allowed to write in the past.
133  if (this->tagInfo().size > 0 && this->tagInfo().lastInterval.since >= m_run) {
134  edm::LogInfo("PopConESTransitionSourceHandler")
135  << "["
136  << "PopConESTransitionSourceHandler::" << __func__ << "]: "
137  << "last IOV " << this->tagInfo().lastInterval.since
138  << (this->tagInfo().lastInterval.since == m_run ? " is equal to" : " is larger than")
139  << " the run proposed for insertion " << m_run << ". No transfer needed." << std::endl;
140  return;
141  }
142  bool isLowGain = checkLowGain();
143  getObjectsForESTransition(isLowGain);
144  edm::LogInfo("PopConESTransitionSourceHandler") << "["
145  << "PopConESTransitionSourceHandler::" << __func__ << "]: "
146  << "END." << std::endl;
147  }
size
Write out results.
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
std::string name
Definition: Types.h:72
cond::TagInfo_t const & tagInfo() const
Hash payloadId
Definition: Types.h:55
Log< level::Info, false > LogInfo

◆ getObjectsForESTransition()

template<class T >
virtual void popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition ( bool  isLowGain)
inlinevirtual

Definition at line 76 of file PopConESTransitionSourceHandler.h.

References cond::persistency::Session::createIov(), popcon::PopConSourceHandler< T >::dbSession(), cond::persistency::Session::editIov(), cond::persistency::Session::existsIov(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVProxy::getInterval(), 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(), cond::persistency::IOVEditor::setDescription(), cond::Iov_t::since, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< T >::tagInfo(), cond::persistency::IOVProxy::tagInfo(), cond::Tag_t::timeType, and cond::persistency::Session::transaction().

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

76  {
77  //reading payloads for 0T and 3.8T from Conditions
80  edm::LogInfo("PopConESTransitionSourceHandler") << "["
81  << "PopConESTransitionSourceHandler::" << __func__ << "]: "
82  << "Loading tag for ES " << (isLowGain ? "LowGain" : "HighGain")
83  << ": " << (isLowGain ? m_tagForLowGain : m_tagForHighGain)
84  << " and IOV valid for run number: " << m_run << std::endl;
86  cond::Iov_t currentIov = iov.getInterval(m_run);
87  LogDebug("PopConESTransitionSourceHandler")
88  << "Loaded IOV sequence from tag " << (isLowGain ? m_tagForLowGain : m_tagForHighGain)
89  << " with size: " << iov.loadedSize() << ", IOV valid for run number " << m_run
90  << " starting from: " << currentIov.since << ", with corresponding payload hash: " << currentIov.payloadId
91  << std::endl;
92  std::string destTag = this->tagInfo().name;
93  if (currentIov.payloadId != this->tagInfo().lastInterval.payloadId) {
94  std::ostringstream ss;
95  ss << "Adding iov with since " << m_run << " pointing to hash " << currentIov.payloadId
96  << " corresponding to the ES Gain " << (isLowGain ? "LOW" : "HIGH");
97  edm::LogInfo("PopConESTransitionSourceHandler")
98  << "["
99  << "PopConESTransitionSourceHandler::" << __func__ << "]: " << ss.str() << std::endl;
101  if (session.existsIov(destTag)) {
102  editor = session.editIov(destTag);
103  } else {
104  editor = session.createIov<T>(destTag, iov.tagInfo().timeType);
105  editor.setDescription("Tag created by PopConESTransitionSourceHandler");
106  }
107  editor.insert(m_run, currentIov.payloadId);
108  editor.flush();
109  this->m_userTextLog = ss.str();
110  } else {
111  edm::LogInfo("PopConESTransitionSourceHandler")
112  << "["
113  << "PopConESTransitionSourceHandler::" << __func__ << "]: "
114  << "The payload with hash " << currentIov.payloadId << " corresponding to ES Gain"
115  << (isLowGain ? "LOW" : "HIGH") << " is still valid for run " << m_run << " in the destination tag "
116  << destTag << ".\nNo transfer needed." << std::endl;
117  }
118  trans.close();
119  }
Time_t since
Definition: Types.h:53
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
void setDescription(const std::string &description)
Definition: IOVEditor.cc:139
Transaction & transaction()
Definition: Session.cc:52
std::string name
Definition: Types.h:72
cond::TagInfo_t const & tagInfo() const
Hash payloadId
Definition: Types.h:55
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:320
cond::Tag_t tagInfo() const
Definition: IOVProxy.cc:246
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
Log< level::Info, false > LogInfo
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
TimeType timeType
Definition: Types.h:63
bool existsIov(const std::string &tag)
Definition: Session.cc:77
cond::persistency::Session & dbSession() const
long double T
#define LogDebug(id)

◆ id()

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::id ( ) const
inlinefinalvirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 38 of file PopConESTransitionSourceHandler.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

◆ m_connection

◆ m_connectionPset

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

◆ m_connectionString

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

Definition at line 158 of file PopConESTransitionSourceHandler.h.

◆ m_currentThreshold

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

Definition at line 151 of file PopConESTransitionSourceHandler.h.

◆ m_ESGain

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_ESGain
private

◆ m_run

template<class T >
unsigned long long popcon::PopConESTransitionSourceHandler< T >::m_run
private

◆ m_tagForHighGain

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForHighGain
private

◆ m_tagForLowGain

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForLowGain
private

◆ m_tagForRunInfo

template<class T >
std::string popcon::PopConESTransitionSourceHandler< T >::m_tagForRunInfo
private