CMS 3D CMS Logo

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

#include <L1CondDBIOVWriterExt.h>

Inheritance diagram for L1CondDBIOVWriterExt:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1CondDBIOVWriterExt (const edm::ParameterSet &)
 
 ~L1CondDBIOVWriterExt ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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_rsKey
 
std::string m_tscKey
 l1t::DataWriter m_writer ; More...
 
l1t::DataWriterExt 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 &)
 
- 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

Definition at line 16 of file L1CondDBIOVWriterExt.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file L1CondDBIOVWriterExt.cc.

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

14  : m_tscKey( iConfig.getParameter<std::string> ("tscKey") ),
15  m_rsKey( iConfig.getParameter<std::string> ("rsKey") ),
16  m_ignoreTriggerKey( iConfig.getParameter<bool> ("ignoreTriggerKey") ),
17  m_logKeys( iConfig.getParameter<bool>( "logKeys" ) ),
18  m_logTransactions( iConfig.getParameter<bool>( "logTransactions" ) ),
19  m_forceUpdate( iConfig.getParameter<bool>( "forceUpdate" ) )
20 {
21  //now do what ever initialization is needed
22  typedef std::vector<edm::ParameterSet> ToSave;
23  ToSave toSave = iConfig.getParameter<ToSave> ("toPut");
24  for (ToSave::const_iterator it = toSave.begin (); it != toSave.end (); it++)
25  {
26  std::string record = it->getParameter<std::string> ("record");
27  std::string type = it->getParameter<std::string> ("type");
28  m_recordTypes.push_back( record + "@" + type ) ;
29  }
30 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
JetCorrectorParameters::Record record
Definition: classes.h:7
std::vector< std::string > m_recordTypes
std::string m_tscKey
l1t::DataWriter m_writer ;
L1CondDBIOVWriterExt::~L1CondDBIOVWriterExt ( )

Definition at line 33 of file L1CondDBIOVWriterExt.cc.

34 {
35 
36  // do anything here that needs to be done at desctruction time
37  // (e.g. close files, deallocate resources etc.)
38 
39 }

Member Function Documentation

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

Definition at line 43 of file L1CondDBIOVWriterExt.cc.

References end, funct::false, l1t::DataWriterExt::fillLastTriggerKeyList(), edm::EventSetup::get(), edm::EventBase::id(), crabWrapper::key, L1TriggerKeyExt::kNullKey, cmsBatch::log, m_forceUpdate, m_ignoreTriggerKey, m_logKeys, m_logTransactions, m_recordTypes, m_rsKey, m_tscKey, m_writer, l1t::DataWriterExt::readObject(), align_cfg::recordName, L1TriggerKeyExt::recordToKeyMap(), python.rootplot.root2matplotlib::replace(), edm::EventID::run(), findQualityFiles::run, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), L1TriggerKeyListExt::token(), funct::true, and l1t::DataWriterExt::updateIOV().

44 {
45  using namespace edm;
46 
47  // Get L1TriggerKeyListExt
48  L1TriggerKeyListExt keyList ;
49  l1t::DataWriterExt dataWriter ;
50  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
51  {
52  edm::LogError( "L1-O2O" )
53  << "Problem getting last L1TriggerKeyListExt" ;
54  }
55 
56  unsigned long long run = iEvent.id().run() ;
57 
58  L1TriggerKeyExt::RecordToKey recordTypeToKeyMap ;
59 
60  bool triggerKeyIOVUpdated = true ;
61 
62  // Start log string, convert run number into string
63  std::stringstream ss ;
64  ss << run ;
65  std::string log = "KEYLOG runNumber=" + ss.str() ;
66  bool logRecords = true ;
67 
68  std::string m_Key = m_tscKey + ":" + m_rsKey;
69 
70  if( !m_ignoreTriggerKey )
71  {
72  if( !m_tscKey.empty() && !m_rsKey.empty() )
73  {
74  edm::LogVerbatim( "L1-O2O" )
75  << "Object key for L1TriggerKeyExt@L1TriggerKeyExtRcd: "
76  << m_tscKey << " : " << m_rsKey ;
77 
78  // Use TSC key and L1TriggerKeyListExt to find next run's
79  // L1TriggerKey token
80  std::string keyToken = keyList.token( m_Key ) ;
81 
82  // Update IOV sequence for this token with since-time = new run
83  triggerKeyIOVUpdated =
84  m_writer.updateIOV( "L1TriggerKeyExtRcd", keyToken, run, m_logTransactions ) ;
85 
86  // Read current L1TriggerKeyExt directly from ORCON using token
88  m_writer.readObject( keyToken, key ) ;
89 
90  recordTypeToKeyMap = key.recordToKeyMap() ;
91 
92  // Replace spaces in key with ?s. Do reverse substitution when
93  // making L1TriggerKeyExt.
94  std::string tmpKey = m_Key ;
95  replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
96  log += " tscKey:rsKey=" + tmpKey ;
97  logRecords = false ;
98  }
99  else
100  {
101  // For use with Run Settings, no corresponding L1TrigerKey in
102  // ORCON.
103 
104  // Get L1TriggerKeyExt from EventSetup
106  iSetup.get< L1TriggerKeyExtRcd >().get( esKey ) ;
107 
108  recordTypeToKeyMap = esKey->recordToKeyMap() ;
109  }
110  }
111  else
112  {
113  std::vector<std::string >::const_iterator
114  recordTypeItr = m_recordTypes.begin() ;
115  std::vector<std::string >::const_iterator
116  recordTypeEnd = m_recordTypes.end() ;
117 
118  for( ; recordTypeItr != recordTypeEnd ; ++recordTypeItr )
119  {
120  recordTypeToKeyMap.insert(
121  std::make_pair( *recordTypeItr, m_Key ) ) ;
122  }
123  }
124 
125  // If L1TriggerKeyExt IOV was already up to date, then so are all its
126  // sub-records.
127  bool throwException = false ;
128 
129  if( triggerKeyIOVUpdated || m_forceUpdate )
130  {
131  // Loop over record@type in L1TriggerKeyExt
132  L1TriggerKeyExt::RecordToKey::const_iterator itr =
133  recordTypeToKeyMap.begin() ;
134  L1TriggerKeyExt::RecordToKey::const_iterator end =
135  recordTypeToKeyMap.end() ;
136 
137  for( ; itr != end ; ++itr )
138  {
139  std::string recordType = itr->first ;
140  std::string objectKey = itr->second ;
141 
142  std::string recordName( recordType,
143  0, recordType.find_first_of("@") ) ;
144 
145  if( logRecords )
146  {
147  // Replace spaces in key with ?s. Do reverse substitution when
148  // making L1TriggerKeyExt.
149  std::string tmpKey = objectKey ;
150  replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
151  log += " " + recordName + "Key=" + tmpKey ;
152  }
153 
154  // Do nothing if object key is null.
155  if( objectKey == L1TriggerKeyExt::kNullKey )
156  {
157  edm::LogVerbatim( "L1-O2O" )
158  << "L1CondDBIOVWriterExt: null object key for "
159  << recordType << "; skipping this record." ;
160  }
161  else
162  {
163  // Find payload token
164  edm::LogVerbatim( "L1-O2O" )
165  << "Object key for "
166  << recordType << ": " << objectKey ;
167 
168  std::string payloadToken = keyList.token( recordType,
169  objectKey ) ;
170  if( payloadToken.empty() )
171  {
172  edm::LogVerbatim( "L1-O2O" )
173  << "L1CondDBIOVWriterExt: empty payload token for " +
174  recordType + ", key " + objectKey ;
175 
176  throwException = true ;
177  }
178  else
179  {
181  payloadToken,
182  run,
184  }
185  }
186  }
187  }
188 
189  if( m_logKeys )
190  {
191  edm::LogVerbatim( "L1-O2O" ) << log ;
192  }
193 
194  if( throwException )
195  {
196  throw cond::Exception( "L1CondDBIOVWriterExt: empty payload tokens" ) ;
197  }
198 }
RunNumber_t run() const
Definition: EventID.h:39
persistency::Exception Exception
Definition: Exception.h:25
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriterExt.h:79
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
static const std::string kNullKey
def replace(string, replacements)
const RecordToKey & recordToKeyMap() const
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
std::vector< std::string > m_recordTypes
#define end
Definition: vmac.h:37
std::map< std::string, std::string > RecordToKey
std::string m_tscKey
l1t::DataWriter m_writer ;
const T & get() const
Definition: EventSetup.h:56
l1t::DataWriterExt m_writer
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
std::string token(const std::string &tscKey) const
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void L1CondDBIOVWriterExt::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 203 of file L1CondDBIOVWriterExt.cc.

204 {
205 }
void L1CondDBIOVWriterExt::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 209 of file L1CondDBIOVWriterExt.cc.

209  {
210 }

Member Data Documentation

bool L1CondDBIOVWriterExt::m_forceUpdate
private

Definition at line 48 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

bool L1CondDBIOVWriterExt::m_ignoreTriggerKey
private

Definition at line 42 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

bool L1CondDBIOVWriterExt::m_logKeys
private

Definition at line 44 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

bool L1CondDBIOVWriterExt::m_logTransactions
private

Definition at line 46 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

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

Definition at line 35 of file L1CondDBIOVWriterExt.h.

Referenced by analyze(), and L1CondDBIOVWriterExt().

std::string L1CondDBIOVWriterExt::m_rsKey
private

Definition at line 31 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

std::string L1CondDBIOVWriterExt::m_tscKey
private

l1t::DataWriter m_writer ;

Definition at line 31 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().

l1t::DataWriterExt L1CondDBIOVWriterExt::m_writer
private

Definition at line 28 of file L1CondDBIOVWriterExt.h.

Referenced by analyze().