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
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
ESProxyIndex const * esGetTokenIndices (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::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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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
 

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)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 34 of file BeamSpotRcdPrinter.cc.

Constructor & Destructor Documentation

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

Definition at line 56 of file BeamSpotRcdPrinter.cc.

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

56  :
58  m_condDb ( iConfig.getParameter< std::string >("conditionDatabase") ),
59  m_tagName ( iConfig.getParameter< std::string >("tagName") ),
60  m_startTime( iConfig.getParameter< unsigned long long >("startIOV") ),
61  m_endTime ( iConfig.getParameter< unsigned long long >("endIOV") ),
62  m_output ( iConfig.getParameter< std::string >("output") )
63 {
66 }
T getParameter(std::string const &) const
cond::persistency::ConnectionPool m_connectionPool
void setParameters(const edm::ParameterSet &connectionPset)
unsigned long long m_startTime
unsigned long long m_endTime
BeamSpotRcdPrinter::~BeamSpotRcdPrinter ( )
override

Definition at line 68 of file BeamSpotRcdPrinter.cc.

68  {
69 }

Member Function Documentation

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

Definition at line 71 of file BeamSpotRcdPrinter.cc.

References cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::createSession(), cond::persistency::IOVProxy::end(), Exception, cond::persistency::Session::fetchPayload(), cond::persistency::IOVProxy::find(), groupFilesInBlocks::fout, m_condDb, m_connectionPool, m_endTime, m_output, m_startTime, m_tagName, jets_cff::payload, cond::persistency::Session::readIov(), cond::persistency::Transaction::start(), cond::persistency::Session::transaction(), and BSPrintUtils::unpack().

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 153 of file BeamSpotRcdPrinter.cc.

References DEFINE_FWK_MODULE.

153  {
154 }
void BeamSpotRcdPrinter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 132 of file BeamSpotRcdPrinter.cc.

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

132  {
133 
135  desc.add<std::string>("conditionDatabase","frontier://FrontierProd/CMS_CONDITIONS");
136  desc.add<std::string>("tagName","BeamSpotObjects_PCL_byLumi_v0_prompt");
137  desc.add<unsigned long long>("startIOV",1406859487478481);
138  desc.add<unsigned long long>("endIOV",1406876667347162);
139  desc.add<std::string>("output","summary.txt");
140  desc.add<std::string>("connect","");
141 
142  edm::ParameterSetDescription descDBParameters;
143  descDBParameters.addUntracked<std::string>("authenticationPath","");
144  descDBParameters.addUntracked<int>("authenticationSystem",0);
145  descDBParameters.addUntracked<std::string>("security","");
146  descDBParameters.addUntracked<int>("messageLevel",0);
147 
148  desc.add<edm::ParameterSetDescription>("DBParameters",descDBParameters);
149  descriptions.add("BeamSpotRcdPrinter", desc);
150 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

std::string BeamSpotRcdPrinter::m_condDb
private

Definition at line 46 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

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

Definition at line 45 of file BeamSpotRcdPrinter.cc.

Referenced by analyze(), and BeamSpotRcdPrinter().

unsigned long long BeamSpotRcdPrinter::m_endTime
private

Definition at line 51 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

std::string BeamSpotRcdPrinter::m_output
private

Definition at line 53 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

unsigned long long BeamSpotRcdPrinter::m_startTime
private

Definition at line 50 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().

std::string BeamSpotRcdPrinter::m_tagName
private

Definition at line 47 of file BeamSpotRcdPrinter.cc.

Referenced by analyze().