CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 ( )

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 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 75 of file L1CondDBPayloadWriter.cc.

References end, edm::hlt::Exception, edm::false, l1t::DataWriter::fillLastTriggerKeyList(), edm::EventSetup::get(), combine::key, L1TriggerKey::kNullKey, m_logTransactions, m_newL1TriggerKeyList, m_overwriteKeys, m_writeConfigData, m_writeL1TriggerKey, m_writer, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), funct::true, 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 = 0 ;
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 }
virtual char const * what() const
Definition: Exception.cc:141
static const std::string kNullKey
Definition: L1TriggerKey.h:42
std::string writePayload(const edm::EventSetup &setup, const std::string &recordType)
Definition: DataWriter.cc:21
#define end
Definition: vmac.h:37
void writeKeyList(L1TriggerKeyList *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
Definition: DataWriter.cc:60
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:196
const T & get() const
Definition: EventSetup.h:55
list key
Definition: combine.py:13
volatile std::atomic< bool > shutdown_flag false
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
void L1CondDBPayloadWriter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 247 of file L1CondDBPayloadWriter.cc.

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

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