CMS 3D CMS Logo

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

#include <DataWriter.h>

Public Member Functions

 DataWriter ()
 
bool fillLastTriggerKeyList (L1TriggerKeyList &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 (L1TriggerKeyList *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
 
std::string writePayload (const edm::EventSetup &setup, const std::string &recordType)
 
 ~DataWriter ()
 

Detailed Description

Definition at line 36 of file DataWriter.h.

Constructor & Destructor Documentation

l1t::DataWriter::DataWriter ( )

Definition at line 13 of file DataWriter.cc.

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

Definition at line 14 of file DataWriter.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

14 {}

Member Function Documentation

bool l1t::DataWriter::fillLastTriggerKeyList ( L1TriggerKeyList output)

Definition at line 198 of file DataWriter.cc.

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

Referenced by L1CondDBIOVWriter::analyze(), L1CondDBPayloadWriter::analyze(), L1O2OTestAnalyzer::analyze(), L1GtRunSettingsViewer::analyze(), L1ConfigOnlineProdBase< TRcd, TData >::getObjectKey(), and L1SubsystemKeysOnlineProd::produce().

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

Definition at line 183 of file DataWriter.cc.

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

Referenced by fillLastTriggerKeyList().

184 {
186  if( !poolDb.isAvailable() )
187  {
188  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
189  ) ;
190  }
191 
192  cond::TagInfo tagInfo ;
193  poolDb->tagInfo( recordName, tagInfo ) ;
194  return tagInfo.lastPayloadToken ;
195 }
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::DataWriter::payloadToken ( const std::string &  recordName,
edm::RunNumber_t  runNumber 
)

Definition at line 155 of file DataWriter.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 L1O2OTestAnalyzer::analyze(), readObject(), updateIOV(), writeKeyList(), and writePayload().

157 {
159  if( !poolDb.isAvailable() )
160  {
161  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
162  ) ;
163  }
164 
165  // Get tag corresponding to EventSetup record name.
166  std::string iovTag = poolDb->tag( recordName ) ;
167 
168  // Get IOV token for tag.
170  cond::persistency::IOVProxy iov = session.readIov( iovTag );
171  session.transaction().start();
172 
174  auto iP = iov.find( runNumber );
175  if( iP != iov.end() ){
176  payloadToken = (*iP).payloadId;
177  }
178  session.transaction().commit() ;
179  return payloadToken ;
180 }
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 payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:155
std::string tag(const std::string &recordName)
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
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::DataWriter::readObject ( const std::string &  payloadToken,
T outputObject 
)

Definition at line 79 of file DataWriter.h.

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

Referenced by L1CondDBIOVWriter::analyze(), L1GtRunSettingsViewer::analyze(), and fillLastTriggerKeyList().

81 {
83  if( !poolDb.isAvailable() )
84  {
85  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
86  ) ;
87  }
88 
90  session.transaction().start(true);
91 
92  // Get object from CondDB
93  std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken) ;
94  outputObject = *ref ;
95  session.transaction().commit ();
96 }
persistency::Exception Exception
Definition: Exception.h:25
void start(bool readOnly=true)
Definition: Session.cc:22
cond::persistency::Session session() const
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:215
Transaction & transaction()
Definition: Session.cc:66
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:155
bool isAvailable() const
Definition: Service.h:46
long double T
bool l1t::DataWriter::updateIOV ( const std::string &  esRecordName,
const std::string &  payloadToken,
edm::RunNumber_t  sinceRun,
bool  logTransactions = false 
)

Definition at line 93 of file DataWriter.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 CaloConfigWriter::analyze(), L1TCaloParamsWriter::analyze(), CaloParamsWriter::analyze(), L1CondDBIOVWriter::analyze(), and writeKeyList().

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

tr.start( false );

Definition at line 61 of file DataWriter.cc.

References 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 L1CondDBPayloadWriter::analyze().

64 {
66  if( !poolDb.isAvailable() )
67  {
68  throw cond::Exception( "DataWriter: PoolDBOutputService not available."
69  ) ;
70  }
71 
75 
76  // Write L1TriggerKeyList payload and save payload token before committing
77  std::shared_ptr<L1TriggerKeyList> pointer(keyList);
78  std::string payloadToken = session.storePayload(*pointer );
79 
80  // Commit before calling updateIOV(), otherwise PoolDBOutputService gets
81  // confused.
82  //tr.commit ();
83  tr.close ();
84 
85  // Set L1TriggerKeyList IOV
86  updateIOV( "L1TriggerKeyListRcd",
87  payloadToken,
88  sinceRun,
89  logTransactions ) ;
90 }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
Transaction & transaction()
Definition: Session.cc:66
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:155
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
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriter.cc:93
std::string l1t::DataWriter::writePayload ( const edm::EventSetup setup,
const std::string &  recordType 
)

Definition at line 19 of file DataWriter.cc.

References reco::get(), edm::Service< T >::isAvailable(), nullptr, payloadToken(), cond::service::PoolDBOutputService::session(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::Session::transaction(), and cscNeutronWriter_cfi::writer.

Referenced by CaloConfigWriter::analyze(), L1TCaloParamsWriter::analyze(), CaloParamsWriter::analyze(), and L1CondDBPayloadWriter::analyze().

21 {
22  WriterFactory* factory = WriterFactory::get();
23  std::unique_ptr<WriterProxy> writer(factory->create( recordType + "@Writer" )) ;
24  if( writer.get() == nullptr )
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 
54  tr.close();
55 // tr.commit ();
56 
57  return payloadToken ;
58 }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
#define nullptr
Transaction & transaction()
Definition: Session.cc:66
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:155
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