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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 48 of file L1CondDBIOVWriter.cc.

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

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

Definition at line 67 of file L1CondDBIOVWriter.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 82 of file L1CondDBIOVWriter.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 240 of file L1CondDBIOVWriter.cc.

241 {
242 }
void L1CondDBIOVWriter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 246 of file L1CondDBIOVWriter.cc.

246  {
247 }

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