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
L1CondDBIOVWriter Class Reference

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

Inheritance diagram for L1CondDBIOVWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1CondDBIOVWriter (const edm::ParameterSet &)
 
 ~L1CondDBIOVWriter ()
 
- 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_forceUpdate
 
bool m_ignoreTriggerKey
 
bool m_logKeys
 
bool m_logTransactions
 
std::vector< std::string > m_recordTypes
 
std::string m_tscKey
 
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 L1CondDBIOVWriter.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file L1CondDBIOVWriter.cc.

References edm::ParameterSet::getParameter(), m_recordTypes, record, and AlCaHLTBitMon_QueryRunRegistry::string.

51  : m_tscKey( iConfig.getParameter<std::string> ("tscKey") ),
52  m_ignoreTriggerKey( iConfig.getParameter<bool> ("ignoreTriggerKey") ),
53  m_logKeys( iConfig.getParameter<bool>( "logKeys" ) ),
54  m_logTransactions( iConfig.getParameter<bool>( "logTransactions" ) ),
55  m_forceUpdate( iConfig.getParameter<bool>( "forceUpdate" ) )
56 {
57  //now do what ever initialization is needed
58  typedef std::vector<edm::ParameterSet> ToSave;
59  ToSave toSave = iConfig.getParameter<ToSave> ("toPut");
60  for (ToSave::const_iterator it = toSave.begin (); it != toSave.end (); it++)
61  {
62  std::string record = it->getParameter<std::string> ("record");
63  std::string type = it->getParameter<std::string> ("type");
64  m_recordTypes.push_back( record + "@" + type ) ;
65  }
66 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
JetCorrectorParameters::Record record
Definition: classes.h:7
std::vector< std::string > m_recordTypes
L1CondDBIOVWriter::~L1CondDBIOVWriter ( )

Definition at line 69 of file L1CondDBIOVWriter.cc.

70 {
71 
72  // do anything here that needs to be done at desctruction time
73  // (e.g. close files, deallocate resources etc.)
74 
75 }

Member Function Documentation

void L1CondDBIOVWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 84 of file L1CondDBIOVWriter.cc.

References end, edm::hlt::Exception, edm::false, edm::EventSetup::get(), edm::EventBase::id(), combine::key, L1TriggerKey::kNullKey, log, m_forceUpdate, m_ignoreTriggerKey, m_logKeys, m_logTransactions, m_recordTypes, m_tscKey, m_writer, l1t::DataWriter::readObject(), ecalTPGAnalyzer_cfg::recordName, L1TriggerKey::recordToKeyMap(), python.rootplot.root2matplotlib::replace(), edm::EventID::run(), DTTTrigCorrFirst::run, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), funct::true, and l1t::DataWriter::updateIOV().

85 {
86  using namespace edm;
87 
88  // Get L1TriggerKeyList
89  L1TriggerKeyList keyList ;
90  l1t::DataWriter dataWriter ;
91  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
92  {
93  edm::LogError( "L1-O2O" )
94  << "Problem getting last L1TriggerKeyList" ;
95  }
96 
97  unsigned long long run = iEvent.id().run() ;
98 
99  L1TriggerKey::RecordToKey recordTypeToKeyMap ;
100 
101  bool triggerKeyIOVUpdated = true ;
102 
103  // Start log string, convert run number into string
104  std::stringstream ss ;
105  ss << run ;
106  std::string log = "KEYLOG runNumber=" + ss.str() ;
107  bool logRecords = true ;
108 
109  if( !m_ignoreTriggerKey )
110  {
111  if( !m_tscKey.empty() )
112  {
113  edm::LogVerbatim( "L1-O2O" )
114  << "Object key for L1TriggerKey@L1TriggerKeyRcd: "
115  << m_tscKey ;
116 
117  // Use TSC key and L1TriggerKeyList to find next run's
118  // L1TriggerKey token
119  std::string keyToken = keyList.token( m_tscKey ) ;
120 
121  // Update IOV sequence for this token with since-time = new run
122  triggerKeyIOVUpdated =
123  m_writer.updateIOV( "L1TriggerKeyRcd", keyToken, run, m_logTransactions ) ;
124 
125  // Read current L1TriggerKey directly from ORCON using token
126  L1TriggerKey key ;
127  m_writer.readObject( keyToken, key ) ;
128 
129  recordTypeToKeyMap = key.recordToKeyMap() ;
130 
131  // Replace spaces in key with ?s. Do reverse substitution when
132  // making L1TriggerKey.
133  std::string tmpKey = m_tscKey ;
134  replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
135  log += " tscKey=" + tmpKey ;
136  logRecords = false ;
137  }
138  else
139  {
140  // For use with Run Settings, no corresponding L1TrigerKey in
141  // ORCON.
142 
143  // Get L1TriggerKey from EventSetup
145  iSetup.get< L1TriggerKeyRcd >().get( esKey ) ;
146 
147  recordTypeToKeyMap = esKey->recordToKeyMap() ;
148  }
149  }
150  else
151  {
152  std::vector<std::string >::const_iterator
153  recordTypeItr = m_recordTypes.begin() ;
154  std::vector<std::string >::const_iterator
155  recordTypeEnd = m_recordTypes.end() ;
156 
157  for( ; recordTypeItr != recordTypeEnd ; ++recordTypeItr )
158  {
159  recordTypeToKeyMap.insert(
160  std::make_pair( *recordTypeItr, m_tscKey ) ) ;
161  }
162  }
163 
164  // If L1TriggerKey IOV was already up to date, then so are all its
165  // sub-records.
166  bool throwException = false ;
167 
168  if( triggerKeyIOVUpdated || m_forceUpdate )
169  {
170  // Loop over record@type in L1TriggerKey
171  L1TriggerKey::RecordToKey::const_iterator itr =
172  recordTypeToKeyMap.begin() ;
173  L1TriggerKey::RecordToKey::const_iterator end =
174  recordTypeToKeyMap.end() ;
175 
176  for( ; itr != end ; ++itr )
177  {
178  std::string recordType = itr->first ;
179  std::string objectKey = itr->second ;
180 
181  std::string recordName( recordType,
182  0, recordType.find_first_of("@") ) ;
183 
184  if( logRecords )
185  {
186  // Replace spaces in key with ?s. Do reverse substitution when
187  // making L1TriggerKey.
188  std::string tmpKey = objectKey ;
189  replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
190  log += " " + recordName + "Key=" + tmpKey ;
191  }
192 
193  // Do nothing if object key is null.
194  if( objectKey == L1TriggerKey::kNullKey )
195  {
196  edm::LogVerbatim( "L1-O2O" )
197  << "L1CondDBIOVWriter: null object key for "
198  << recordType << "; skipping this record." ;
199  }
200  else
201  {
202  // Find payload token
203  edm::LogVerbatim( "L1-O2O" )
204  << "Object key for "
205  << recordType << ": " << objectKey ;
206 
207  std::string payloadToken = keyList.token( recordType,
208  objectKey ) ;
209  if( payloadToken.empty() )
210  {
211  edm::LogVerbatim( "L1-O2O" )
212  << "L1CondDBIOVWriter: empty payload token for " +
213  recordType + ", key " + objectKey ;
214 
215  throwException = true ;
216  }
217  else
218  {
220  payloadToken,
221  run,
223  }
224  }
225  }
226  }
227 
228  if( m_logKeys )
229  {
230  edm::LogVerbatim( "L1-O2O" ) << log ;
231  }
232 
233  if( throwException )
234  {
235  throw cond::Exception( "L1CondDBIOVWriter: empty payload tokens" ) ;
236  }
237 }
RunNumber_t run() const
Definition: EventID.h:42
l1t::DataWriter m_writer
static std::vector< std::string > checklist log
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:26
static const std::string kNullKey
Definition: L1TriggerKey.h:42
std::vector< std::string > m_recordTypes
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKey.h:94
#define end
Definition: vmac.h:37
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriter.h:83
const T & get() const
Definition: EventSetup.h:55
edm::EventID id() const
Definition: EventBase.h:56
list key
Definition: combine.py:13
volatile std::atomic< bool > shutdown_flag false
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriter.cc:91
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
void L1CondDBIOVWriter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 242 of file L1CondDBIOVWriter.cc.

243 {
244 }
void L1CondDBIOVWriter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 248 of file L1CondDBIOVWriter.cc.

248  {
249 }

Member Data Documentation

bool L1CondDBIOVWriter::m_forceUpdate
private

Definition at line 68 of file L1CondDBIOVWriter.h.

Referenced by analyze().

bool L1CondDBIOVWriter::m_ignoreTriggerKey
private

Definition at line 62 of file L1CondDBIOVWriter.h.

Referenced by analyze().

bool L1CondDBIOVWriter::m_logKeys
private

Definition at line 64 of file L1CondDBIOVWriter.h.

Referenced by analyze().

bool L1CondDBIOVWriter::m_logTransactions
private

Definition at line 66 of file L1CondDBIOVWriter.h.

Referenced by analyze().

std::vector< std::string > L1CondDBIOVWriter::m_recordTypes
private

Definition at line 55 of file L1CondDBIOVWriter.h.

Referenced by analyze(), and L1CondDBIOVWriter().

std::string L1CondDBIOVWriter::m_tscKey
private

Definition at line 51 of file L1CondDBIOVWriter.h.

Referenced by analyze().

l1t::DataWriter L1CondDBIOVWriter::m_writer
private

Definition at line 50 of file L1CondDBIOVWriter.h.

Referenced by analyze().