CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1CondDBPayloadWriter Class Reference

#include <CondTools/L1Trigger/interface/L1CondDBPayloadWriter.h>

Inheritance diagram for L1CondDBPayloadWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1CondDBPayloadWriter (const edm::ParameterSet &)
 
 ~L1CondDBPayloadWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

bool m_logTransactions
 
bool m_newL1TriggerKeyList
 
bool m_overwriteKeys
 
bool m_writeConfigData
 
bool m_writeL1TriggerKey
 
l1t::DataWriter m_writer
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 38 of file L1CondDBPayloadWriter.h.

Constructor & Destructor Documentation

L1CondDBPayloadWriter::L1CondDBPayloadWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 48 of file L1CondDBPayloadWriter.cc.

49  : m_writeL1TriggerKey( iConfig.getParameter< bool >( "writeL1TriggerKey" )),
50  m_writeConfigData( iConfig.getParameter< bool >( "writeConfigData" ) ),
51  m_overwriteKeys( iConfig.getParameter< bool >( "overwriteKeys" ) ),
52  m_logTransactions( iConfig.getParameter<bool>( "logTransactions" ) ),
53  m_newL1TriggerKeyList( iConfig.getParameter< bool >( "newL1TriggerKeyList" ) )
54 {
55  //now do what ever initialization is needed
56 
57 }
T getParameter(std::string const &) const
L1CondDBPayloadWriter::~L1CondDBPayloadWriter ( )
override

Definition at line 60 of file L1CondDBPayloadWriter.cc.

61 {
62 
63  // do anything here that needs to be done at desctruction time
64  // (e.g. close files, deallocate resources etc.)
65 
66 }

Member Function Documentation

void L1CondDBPayloadWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 75 of file L1CondDBPayloadWriter.cc.

References L1TriggerKeyList::addKey(), end, funct::false, l1t::DataWriter::fillLastTriggerKeyList(), edm::EventSetup::get(), crabWrapper::key, L1TriggerKey::kNullKey, m_logTransactions, m_newL1TriggerKeyList, m_overwriteKeys, m_writeConfigData, m_writeL1TriggerKey, m_writer, nullptr, L1TriggerKey::recordToKeyMap(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), L1TriggerKeyList::token(), funct::true, L1TriggerKey::tscKey(), cms::Exception::what(), l1t::DataWriter::writeKeyList(), and l1t::DataWriter::writePayload().

77 {
78  using namespace edm;
79 
80  // Get L1TriggerKeyList and make a copy
81  L1TriggerKeyList oldKeyList ;
82 
84  {
85  if( !m_writer.fillLastTriggerKeyList( oldKeyList ) )
86  {
87  edm::LogError( "L1-O2O" )
88  << "Problem getting last L1TriggerKeyList" ;
89  }
90  }
91 
92  L1TriggerKeyList* keyList = nullptr ;
93 
94  // Write L1TriggerKey to ORCON with no IOV
95  std::string token ;
97 
98  // Before calling writePayload(), check if TSC key is already in
99  // L1TriggerKeyList. writePayload() will not catch this situation in
100  // the case of dummy configurations.
101  bool triggerKeyOK = true ;
102  try
103  {
104  // Get L1TriggerKey
105  iSetup.get< L1TriggerKeyRcd >().get( key ) ;
106 
107  if( !m_overwriteKeys )
108  {
109  triggerKeyOK = oldKeyList.token( key->tscKey() ) == "" ;
110  }
111  }
113  {
114  triggerKeyOK = false ;
115  edm::LogVerbatim( "L1-O2O" ) << ex.what() ;
116  }
117 
118  if( triggerKeyOK && m_writeL1TriggerKey )
119  {
120  edm::LogVerbatim( "L1-O2O" )
121  << "Object key for L1TriggerKeyRcd@L1TriggerKey: "
122  << key->tscKey() ;
123  token = m_writer.writePayload( iSetup,
124  "L1TriggerKeyRcd@L1TriggerKey" ) ;
125  }
126 
127  // If L1TriggerKey is invalid, then all configuration data is already in DB
128  bool throwException = false ;
129 
130  if( !token.empty() || !m_writeL1TriggerKey )
131  {
132  // Record token in L1TriggerKeyList
133  if( m_writeL1TriggerKey )
134  {
135  keyList = new L1TriggerKeyList( oldKeyList ) ;
136  if( !( keyList->addKey( key->tscKey(),
137  token,
138  m_overwriteKeys ) ) )
139  {
140  throw cond::Exception( "L1CondDBPayloadWriter: TSC key "
141  + key->tscKey()
142  + " already in L1TriggerKeyList" ) ;
143  }
144  }
145 
146  if( m_writeConfigData )
147  {
148  // Loop over record@type in L1TriggerKey
149  L1TriggerKey::RecordToKey::const_iterator it =
150  key->recordToKeyMap().begin() ;
151  L1TriggerKey::RecordToKey::const_iterator end =
152  key->recordToKeyMap().end() ;
153 
154  for( ; it != end ; ++it )
155  {
156  // Do nothing if object key is null.
157  if( it->second == L1TriggerKey::kNullKey )
158  {
159  edm::LogVerbatim( "L1-O2O" )
160  << "L1CondDBPayloadWriter: null object key for "
161  << it->first << "; skipping this record." ;
162  }
163  else
164  {
165  // Check key is new before writing
166  if( oldKeyList.token( it->first, it->second ) == "" ||
168  {
169  // Write data to ORCON with no IOV
170  if( oldKeyList.token( it->first, it->second ) != "" )
171  {
172  edm::LogVerbatim( "L1-O2O" )
173  << "*** Overwriting payload: object key for "
174  << it->first << ": " << it->second ;
175  }
176  else
177  {
178  edm::LogVerbatim( "L1-O2O" )
179  << "object key for "
180  << it->first << ": " << it->second ;
181  }
182 
183  try
184  {
185  token = m_writer.writePayload( iSetup, it->first ) ;
186  }
187  catch( l1t::DataInvalidException& ex )
188  {
189  edm::LogVerbatim( "L1-O2O" )
190  << ex.what()
191  << " Skipping to next record." ;
192 
193  throwException = true ;
194 
195  continue ;
196  }
197 
198  if( !token.empty() )
199  {
200  // Record token in L1TriggerKeyList
201  if( !keyList )
202  {
203  keyList = new L1TriggerKeyList( oldKeyList ) ;
204  }
205 
206  if( !( keyList->addKey( it->first,
207  it->second,
208  token,
209  m_overwriteKeys ) ) )
210  {
211  // This should never happen because of the check
212  // above, but just in case....
213  throw cond::Exception(
214  "L1CondDBPayloadWriter: subsystem key "
215  + it->second + " for " + it->first
216  + " already in L1TriggerKeyList" ) ;
217  }
218  }
219  }
220  else
221  {
222  edm::LogVerbatim( "L1-O2O" )
223  << "L1CondDBPayloadWriter: object key "
224  << it->second << " for " << it->first
225  << " already in L1TriggerKeyList" ;
226  }
227  }
228  }
229  }
230  }
231 
232  if( keyList )
233  {
234  // Write L1TriggerKeyList to ORCON
235  m_writer.writeKeyList( keyList, 0, m_logTransactions ) ;
236  }
237 
238  if( throwException )
239  {
240  throw l1t::DataInvalidException( "Payload problem found." ) ;
241  }
242 }
persistency::Exception Exception
Definition: Exception.h:25
static const std::string kNullKey
Definition: L1TriggerKey.h:42
char const * what() const override
Definition: Exception.cc:141
#define nullptr
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKey.h:94
std::string writePayload(const edm::EventSetup &setup, const std::string &recordType)
Definition: DataWriter.cc:19
#define end
Definition: vmac.h:39
void writeKeyList(L1TriggerKeyList *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
Definition: DataWriter.cc:61
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:198
std::string token(const std::string &tscKey) const
const std::string & tscKey() const
Definition: L1TriggerKey.h:87
HLT enums.
T get() const
Definition: EventSetup.h:62
bool addKey(const std::string &tscKey, const std::string &payloadToken, bool overwriteKey=false)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void L1CondDBPayloadWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 247 of file L1CondDBPayloadWriter.cc.

248 {
249 }
void L1CondDBPayloadWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 253 of file L1CondDBPayloadWriter.cc.

253  {
254 }

Member Data Documentation

bool L1CondDBPayloadWriter::m_logTransactions
private

Definition at line 62 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

bool L1CondDBPayloadWriter::m_newL1TriggerKeyList
private

Definition at line 65 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

bool L1CondDBPayloadWriter::m_overwriteKeys
private

Definition at line 60 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

bool L1CondDBPayloadWriter::m_writeConfigData
private

Definition at line 57 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

bool L1CondDBPayloadWriter::m_writeL1TriggerKey
private

Definition at line 54 of file L1CondDBPayloadWriter.h.

Referenced by analyze().

l1t::DataWriter L1CondDBPayloadWriter::m_writer
private

Definition at line 50 of file L1CondDBPayloadWriter.h.

Referenced by analyze().