CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
BeamSpotRcdPrinter Class Reference
Inheritance diagram for BeamSpotRcdPrinter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
 BeamSpotRcdPrinter (const edm::ParameterSet &iConfig)
 
void endJob () override
 
 ~BeamSpotRcdPrinter () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

std::string m_condDb
 
cond::persistency::ConnectionPool m_connectionPool
 
unsigned long long m_endTime
 
std::string m_output
 
unsigned long long m_startTime
 
std::string m_tagName
 
bool m_verbose
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 33 of file BeamSpotRcdPrinter.cc.

Constructor & Destructor Documentation

◆ BeamSpotRcdPrinter()

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

Definition at line 55 of file BeamSpotRcdPrinter.cc.

References cond::persistency::ConnectionPool::configure(), edm::ParameterSet::getParameter(), m_connectionPool, and cond::persistency::ConnectionPool::setParameters().

56  : m_connectionPool(),
57  m_condDb(iConfig.getParameter<std::string>("conditionDatabase")),
58  m_tagName(iConfig.getParameter<std::string>("tagName")),
59  m_startTime(iConfig.getParameter<unsigned long long>("startIOV")),
60  m_endTime(iConfig.getParameter<unsigned long long>("endIOV")),
61  m_output(iConfig.getParameter<std::string>("output")),
62  m_verbose(iConfig.getParameter<bool>("verbose")) {
65 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
cond::persistency::ConnectionPool m_connectionPool
void setParameters(const edm::ParameterSet &connectionPset)
unsigned long long m_startTime
unsigned long long m_endTime

◆ ~BeamSpotRcdPrinter()

BeamSpotRcdPrinter::~BeamSpotRcdPrinter ( )
overridedefault

Member Function Documentation

◆ analyze()

void BeamSpotRcdPrinter::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 67 of file BeamSpotRcdPrinter.cc.

References cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::createSession(), Exception, cond::persistency::Session::fetchPayload(), cond::persistency::IOVArray::find(), groupFilesInBlocks::fout, m_condDb, m_connectionPool, m_endTime, m_output, m_startTime, m_tagName, m_verbose, jetsAK4_Puppi_cff::payload, cond::persistency::Session::readIov(), cond::persistency::IOVProxy::selectAll(), contentValuesCheck::ss, cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::Session::transaction(), and BSPrintUtils::unpack().

67  {
68  cond::Time_t startIov = m_startTime;
69  cond::Time_t endIov = m_endTime;
70  if (startIov > endIov)
71  throw cms::Exception("endTime must be greater than startTime!");
72  edm::LogInfo("BeamSpotRcdPrinter") << "[BeamSpotRcdPrinter::" << __func__ << "] "
73  << "Set start time " << startIov << "\n ... Set end time " << endIov;
74 
75  // open db session
76  edm::LogInfo("BeamSpotRcdPrinter") << "[BeamSpotRcdPrinter::" << __func__ << "] "
77  << "Query the condition database " << m_condDb;
79  condDbSession.transaction().start(true);
80 
81  std::stringstream ss;
82  // list of times with new IOVs within the time range
83  std::vector<cond::Time_t> vTime;
84 
85  // query the database
86  edm::LogInfo("BeamSpotRcdPrinter") << "[BeamSpotRcdPrinter::" << __func__ << "] "
87  << "Reading IOVs from tag " << m_tagName;
88  cond::persistency::IOVProxy iovProxy = condDbSession.readIov(m_tagName); // load all?
89  auto iovs = iovProxy.selectAll();
90  auto iiov = iovs.find(startIov);
91  auto eiov = iovs.find(endIov);
92  int niov = 0;
93  while (iiov != iovs.end() && (*iiov).since <= (*eiov).since) {
94  // convert cond::Time_t to seconds since epoch
95  if ((*iiov).since < startIov) {
96  vTime.push_back(startIov);
97  } else {
98  vTime.push_back((*iiov).since);
99  }
100  auto payload = condDbSession.fetchPayload<BeamSpotObjects>((*iiov).payloadId);
101  auto runLS = BSPrintUtils::unpack((*iiov).since);
102  // print IOVs summary
103  ss << runLS.first << "," << runLS.second << " (" << (*iiov).since << ")"
104  << " [hash: " << (*iiov).payloadId << "] \n"
105  << *payload << std::endl;
106 
107  ++iiov;
108  ++niov;
109  }
110 
111  vTime.push_back(endIov); // used to compute last IOV duration
112 
113  edm::LogInfo("BeamSpotRcdPrinter") << "[BeamSpotRcdPrinter::" << __func__ << "] "
114  << "Read " << niov << " IOVs from tag " << m_tagName
115  << " corresponding to the specified time interval.\n\n"
116  << (m_verbose ? ss.str() : std::string{});
117 
118  condDbSession.transaction().commit();
119 
120  if (!m_output.empty()) {
121  std::ofstream fout;
122  fout.open(m_output);
123  fout << ss.str();
124  fout.close();
125  }
126 }
void start(bool readOnly=true)
Definition: Session.cc:18
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
cond::persistency::ConnectionPool m_connectionPool
Transaction & transaction()
Definition: Session.cc:52
unsigned long long Time_t
Definition: Time.h:14
unsigned long long m_startTime
Session createSession(const std::string &connectionString, bool writeCapable=false)
Iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:101
unsigned long long m_endTime
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
Log< level::Info, false > LogInfo
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)

◆ endJob()

void BeamSpotRcdPrinter::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 148 of file BeamSpotRcdPrinter.cc.

148 {}

◆ fillDescriptions()

void BeamSpotRcdPrinter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 128 of file BeamSpotRcdPrinter.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

128  {
130  desc.add<std::string>("conditionDatabase", "frontier://FrontierProd/CMS_CONDITIONS");
131  desc.add<std::string>("tagName", "BeamSpotObjects_PCL_byLumi_v0_prompt");
132  desc.add<unsigned long long>("startIOV", 1406859487478481);
133  desc.add<unsigned long long>("endIOV", 1406876667347162);
134  desc.add<std::string>("output", "summary.txt")->setComment("ASCII file with the full tag dump information");
135  desc.add<bool>("verbose", true)->setComment("print to screen the dump of all the payloads");
136  desc.add<std::string>("connect", "");
137 
138  edm::ParameterSetDescription descDBParameters;
139  descDBParameters.addUntracked<std::string>("authenticationPath", "");
140  descDBParameters.addUntracked<int>("authenticationSystem", 0);
141  descDBParameters.addUntracked<std::string>("security", "");
142  descDBParameters.addUntracked<int>("messageLevel", 0);
143 
144  desc.add<edm::ParameterSetDescription>("DBParameters", descDBParameters);
145  descriptions.add("BeamSpotRcdPrinter", desc);
146 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ m_condDb

std::string BeamSpotRcdPrinter::m_condDb
private

Definition at line 43 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

◆ m_connectionPool

cond::persistency::ConnectionPool BeamSpotRcdPrinter::m_connectionPool
private

Definition at line 42 of file BeamSpotRcdPrinter.cc.

Referenced by analyze(), and BeamSpotRcdPrinter().

◆ m_endTime

unsigned long long BeamSpotRcdPrinter::m_endTime
private

Definition at line 48 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

◆ m_output

std::string BeamSpotRcdPrinter::m_output
private

Definition at line 50 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

◆ m_startTime

unsigned long long BeamSpotRcdPrinter::m_startTime
private

Definition at line 47 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

◆ m_tagName

std::string BeamSpotRcdPrinter::m_tagName
private

Definition at line 44 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

◆ m_verbose

bool BeamSpotRcdPrinter::m_verbose
private

Definition at line 52 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().