CMS 3D CMS Logo

List of all members | Public Member Functions
l1t::DataWriterExt Class Reference

#include <DataWriterExt.h>

Public Member Functions

 DataWriterExt ()
 
bool fillLastTriggerKeyList (L1TriggerKeyListExt &output)
 
std::string lastPayloadToken (const std::string &recordName)
 
std::string payloadToken (const std::string &recordName, edm::RunNumber_t runNumber)
 
template<class T >
void readObject (const std::string &payloadToken, T &outputObject)
 
bool updateIOV (const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
 
void writeKeyList (L1TriggerKeyListExt *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
 
std::string writePayload (const edm::EventSetup &setup, const std::string &recordType)
 
 ~DataWriterExt ()
 

Detailed Description

Definition at line 36 of file DataWriterExt.h.

Constructor & Destructor Documentation

l1t::DataWriterExt::DataWriterExt ( )

Definition at line 13 of file DataWriterExt.cc.

13 {}
l1t::DataWriterExt::~DataWriterExt ( )

Definition at line 14 of file DataWriterExt.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

14 {}

Member Function Documentation

bool l1t::DataWriterExt::fillLastTriggerKeyList ( L1TriggerKeyListExt output)

Definition at line 199 of file DataWriterExt.cc.

References funct::false, lastPayloadToken(), readObject(), AlCaHLTBitMon_QueryRunRegistry::string, and funct::true.

Referenced by L1CondDBPayloadWriterExt::analyze(), L1CondDBIOVWriterExt::analyze(), L1O2OTestAnalyzerExt::analyze(), L1ConfigOnlineProdBaseExt< TRcd, TData >::getObjectKey(), and L1SubsystemKeysOnlineProdExt::produce().

200 {
201  std::string keyListToken =
202  lastPayloadToken( "L1TriggerKeyListExtRcd" ) ;
203  if( keyListToken.empty() )
204  {
205  return false ;
206  }
207  else
208  {
209  readObject( keyListToken, output ) ;
210  return true ;
211  }
212 }
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriterExt.h:79
std::string lastPayloadToken(const std::string &recordName)
std::string l1t::DataWriterExt::lastPayloadToken ( const std::string &  recordName)

Definition at line 184 of file DataWriterExt.cc.

References edm::Service< T >::isAvailable(), cond::TagInfo_t::lastPayloadToken, and cond::service::PoolDBOutputService::tagInfo().

Referenced by fillLastTriggerKeyList().

185 {
187  if( !poolDb.isAvailable() )
188  {
189  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
190  ) ;
191  }
192 
193  cond::TagInfo tagInfo ;
194  poolDb->tagInfo( recordName, tagInfo ) ;
195  return tagInfo.lastPayloadToken ;
196 }
persistency::Exception Exception
Definition: Exception.h:25
bool isAvailable() const
Definition: Service.h:46
void tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string lastPayloadToken
Definition: Types.h:76
std::string l1t::DataWriterExt::payloadToken ( const std::string &  recordName,
edm::RunNumber_t  runNumber 
)

Definition at line 156 of file DataWriterExt.cc.

References cond::persistency::Transaction::commit(), cond::persistency::IOVProxy::end(), cond::persistency::IOVProxy::find(), edm::Service< T >::isAvailable(), cond::persistency::Session::readIov(), cond::service::PoolDBOutputService::session(), dataDML::session, cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::tag(), and cond::persistency::Session::transaction().

Referenced by L1O2OTestAnalyzerExt::analyze(), readObject(), updateIOV(), writeKeyList(), and writePayload().

158 {
160  if( !poolDb.isAvailable() )
161  {
162  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
163  ) ;
164  }
165 
166  // Get tag corresponding to EventSetup record name.
167  std::string iovTag = poolDb->tag( recordName ) ;
168 
169  // Get IOV token for tag.
171  cond::persistency::IOVProxy iov = session.readIov( iovTag );
172  session.transaction().start();
173 
175  auto iP = iov.find( runNumber );
176  if( iP != iov.end() ){
177  payloadToken = (*iP).payloadId;
178  }
179  session.transaction().commit() ;
180  return payloadToken ;
181 }
persistency::Exception Exception
Definition: Exception.h:25
void start(bool readOnly=true)
Definition: Session.cc:22
cond::persistency::Session session() const
Transaction & transaction()
Definition: Session.cc:66
std::string tag(const std::string &recordName)
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:46
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
Iterator end() const
Definition: IOVProxy.cc:297
template<class T >
void l1t::DataWriterExt::readObject ( const std::string &  payloadToken,
T outputObject 
)

session.transaction().start(true);

session.transaction().commit ();

Definition at line 79 of file DataWriterExt.h.

References cond::persistency::Session::fetchPayload(), cond::service::PoolDBOutputService::forceInit(), edm::Service< T >::isAvailable(), payloadToken(), cond::service::PoolDBOutputService::session(), and dataDML::session.

Referenced by L1CondDBIOVWriterExt::analyze(), and fillLastTriggerKeyList().

81 {
83  if( !poolDb.isAvailable() )
84  {
85  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
86  ) ;
87  }
88 
89  poolDb->forceInit();
92 
93  // Get object from CondDB
94  std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken) ;
95  outputObject = *ref ;
97 }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:46
long double T
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:215
bool l1t::DataWriterExt::updateIOV ( const std::string &  esRecordName,
const std::string &  payloadToken,
edm::RunNumber_t  sinceRun,
bool  logTransactions = false 
)

Definition at line 94 of file DataWriterExt.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::endOfTime(), funct::false, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), cond::TagInfo_t::lastInterval, cond::TagInfo_t::lastPayloadToken, payloadToken(), AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::tag(), cond::service::PoolDBOutputService::tagInfo(), and funct::true.

Referenced by L1CondDBIOVWriterExt::analyze(), and writeKeyList().

98 {
99  edm::LogVerbatim( "L1-O2O" ) << esRecordName
100  << " PAYLOAD TOKEN " << payloadToken ;
101 
103  if (!poolDb.isAvailable())
104  {
105  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
106  ) ;
107  }
108 
109  bool iovUpdated = true ;
110 
111  if( poolDb->isNewTagRequest( esRecordName ) )
112  {
113  sinceRun = poolDb->beginOfTime() ;
114  poolDb->createNewIOV( payloadToken,
115  sinceRun,
116  poolDb->endOfTime(),
117  esRecordName,
118  logTransactions ) ;
119  }
120  else
121  {
122  cond::TagInfo tagInfo ;
123  poolDb->tagInfo( esRecordName, tagInfo ) ;
124 
125  if( sinceRun == 0 ) // find last since and add 1
126  {
127  sinceRun = tagInfo.lastInterval.first ;
128  ++sinceRun ;
129  }
130 
131  if( tagInfo.lastPayloadToken != payloadToken )
132  {
133  poolDb->appendSinceTime( payloadToken,
134  sinceRun,
135  esRecordName,
136  logTransactions ) ;
137  }
138  else
139  {
140  iovUpdated = false ;
141  edm::LogVerbatim( "L1-O2O" ) << "IOV already up to date." ;
142  }
143  }
144 
145  if( iovUpdated )
146  {
147  edm::LogVerbatim( "L1-O2O" ) << esRecordName << " "
148  << poolDb->tag( esRecordName )
149  << " SINCE " << sinceRun ;
150  }
151 
152  return iovUpdated ;
153 }
persistency::Exception Exception
Definition: Exception.h:25
std::string tag(const std::string &recordName)
cond::ValidityInterval lastInterval
Definition: Types.h:75
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:46
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
void tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string lastPayloadToken
Definition: Types.h:76
void l1t::DataWriterExt::writeKeyList ( L1TriggerKeyListExt keyList,
edm::RunNumber_t  sinceRun = 0,
bool  logTransactions = false 
)

tr.start( false );

tr.commit ();

Definition at line 61 of file DataWriterExt.cc.

References cond::service::PoolDBOutputService::forceInit(), edm::Service< T >::isAvailable(), payloadToken(), cond::service::PoolDBOutputService::session(), dataDML::session, cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::Session::transaction(), and updateIOV().

Referenced by L1CondDBPayloadWriterExt::analyze().

64 {
66  if( !poolDb.isAvailable() )
67  {
68  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
69  ) ;
70  }
71 
72  poolDb->forceInit();
76 
77  // Write L1TriggerKeyListExt payload and save payload token before committing
78  std::shared_ptr<L1TriggerKeyListExt> pointer(keyList);
79  std::string payloadToken = session.storePayload(*pointer );
80 
81  // Commit before calling updateIOV(), otherwise PoolDBOutputService gets
82  // confused.
84  tr.close ();
85 
86  // Set L1TriggerKeyListExt IOV
87  updateIOV( "L1TriggerKeyListExtRcd",
88  payloadToken,
89  sinceRun,
90  logTransactions ) ;
91 }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
Transaction & transaction()
Definition: Session.cc:66
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:46
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:189
std::string l1t::DataWriterExt::writePayload ( const edm::EventSetup setup,
const std::string &  recordType 
)

cond::persistency::TransactionScope tr(poolDb->session().transaction());

Definition at line 19 of file DataWriterExt.cc.

References reco::get(), edm::Service< T >::isAvailable(), payloadToken(), AlCaHLTBitMon_QueryRunRegistry::string, and cscNeutronWriter_cfi::writer.

Referenced by L1CondDBPayloadWriterExt::analyze().

21 {
22  WriterFactory* factory = WriterFactory::get();
23  std::auto_ptr<WriterProxy> writer(factory->create( recordType + "@Writer" )) ;
24  if( writer.get() == 0 )
25  {
26  throw cond::Exception( "DataWriter: could not create WriterProxy with name "
27  + recordType + "@Writer" ) ;
28  }
29 
31  if (!poolDb.isAvailable())
32  {
33  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
34  ) ;
35  }
36 
37  // 2010-02-16: Move session and transaction to WriterProxy::save(). Otherwise, if another transaction is
38  // started while WriterProxy::save() is called (e.g. in a ESProducer like L1ConfigOnlineProdBase), the
39  // transaction here will become read-only.
40 // cond::DbSession session = poolDb->session();
41 // cond::DbScopedTransaction tr(session);
42 
44 // // if throw transaction will unroll
45 // tr.start(false);
46 
47  // update key to have new payload registered for record-type pair.
48  // std::string payloadToken = writer->save( setup, session ) ;
49  std::string payloadToken = writer->save( setup ) ;
50 
51  edm::LogVerbatim( "L1-O2O" ) << recordType << " PAYLOAD TOKEN "
52  << payloadToken ;
53 
55 // tr.commit ();
56 
57  return payloadToken ;
58 }
persistency::Exception Exception
Definition: Exception.h:25
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:46
edmplugin::PluginFactory< l1t::WriterProxy *()> WriterFactory
Definition: WriterProxy.h:88
T get(const Candidate &c)
Definition: component.h:55