Skip to content

Commit

Permalink
created perLS PopCon: cloned old one, removed irrelevant code and adj…
Browse files Browse the repository at this point in the history
…usted the rest
  • Loading branch information
JanChyczynski committed Aug 18, 2022
1 parent 190a475 commit 67071cc
Show file tree
Hide file tree
Showing 6 changed files with 730 additions and 1 deletion.
63 changes: 63 additions & 0 deletions CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef LHCINFOPOPCONSOURCEHANDLER_H
#define LHCINFOPOPCONSOURCEHANDLER_H

#include <string>

#include "CondCore/PopCon/interface/PopConSourceHandler.h"
#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "CondCore/CondDB/interface/Types.h"
#include "CondTools/RunInfo/interface/OMSAccess.h"


namespace cond {
class OMSService;
}

class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCInfoPerLS> {
public:
LHCInfoPerLSPopConSourceHandler(const edm::ParameterSet& pset);
~LHCInfoPerLSPopConSourceHandler() override;
void getNewObjects() override;
std::string id() const override;

static constexpr unsigned int kLumisectionsQueryLimit = 4000;

private:
void addEmptyPayload(cond::Time_t iov);

bool makeFillPayload(std::unique_ptr<LHCInfoPerLS>& targetPayload,
const cond::OMSServiceResult& queryResult);


size_t getLumiData(const cond::OMSService& service,
unsigned short fillId,
const boost::posix_time::ptime& beginFillTime,
const boost::posix_time::ptime& endFillTime);
bool getCTTPSData(cond::persistency::Session& session,
const boost::posix_time::ptime& beginFillTime,
const boost::posix_time::ptime& endFillTime);

private:
bool m_debug;
// starting date for sampling
boost::posix_time::ptime m_startTime;
boost::posix_time::ptime m_endTime;
// sampling interval in seconds
unsigned int m_samplingInterval;
bool m_endFill = true;
std::string m_name;
//for reading from relational database source
std::string m_connectionString, m_ecalConnectionString;
std::string m_dipSchema, m_authpath;
std::string m_omsBaseUrl;
std::unique_ptr<LHCInfoPerLS> m_fillPayload;
std::shared_ptr<LHCInfoPerLS> m_prevPayload;
cond::Time_t m_startFillTime;
cond::Time_t m_endFillTime;
cond::Time_t m_prevEndFillTime;
std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS> > > m_tmpBuffer;
bool m_lastPayloadEmpty = false;
};

#endif
6 changes: 5 additions & 1 deletion CondTools/RunInfo/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@

<library file="LHCInfoPerFillAnalyzer.cc" name="LHCInfoPerFillAnalyzer">
<flags EDM_PLUGIN="1"/>
</library>
</library>

<library file="LHCInfoPerLSPopConAnalyzer.cc" name="CondToolsLHCInfoPerLSPopConAnalyzer">
<flags EDM_PLUGIN="1"/>
</library>
7 changes: 7 additions & 0 deletions CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "CondCore/PopCon/interface/PopConAnalyzer.h"
#include "CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h"
#include "FWCore/Framework/interface/MakerMacros.h"

typedef popcon::PopConAnalyzer<LHCInfoPerLSPopConSourceHandler> LHCInfoPerLSPopConAnalyzer;
//define this as a plug-in
DEFINE_FWK_MODULE(LHCInfoPerLSPopConAnalyzer);
88 changes: 88 additions & 0 deletions CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import socket
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
process = cms.Process("LHCInfoPerLSPopulator")
from CondCore.CondDB.CondDB_cfi import *
#process.load("CondCore.DBCommon.CondDBCommon_cfi")
#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db'
#process.CondDBCommon.DBParameters.authenticationPath = '.'
#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1)

sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R'
if socket.getfqdn().find('.cms') != -1:
sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R'

options = VarParsing.VarParsing()
options.register( 'destinationConnection'
, 'sqlite_file:lhcinfo_pop_test.db' #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, "Connection string to the DB where payloads will be possibly written."
)
options.register( 'targetConnection'
, '' #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, """Connection string to the target DB:
if not empty (default), this provides the latest IOV and payloads to compare;
it is the DB where payloads should be finally uploaded."""
)
options.register( 'tag'
, 'LHCInfoPerLS_PopCon_start_test'
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, "Tag written in destinationConnection and finally appended in targetConnection."
)
options.register( 'messageLevel'
, 0 #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.int
, "Message level; default to 0"
)
options.parseArguments()

CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )

process.MessageLogger = cms.Service("MessageLogger",
cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
destinations = cms.untracked.vstring('cout')
)

process.source = cms.Source("EmptyIOVSource",
lastValue = cms.uint64(1),
timetype = cms.string('runnumber'),
firstValue = cms.uint64(1),
interval = cms.uint64(1)
)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
CondDBConnection,
timetype = cms.untracked.string('timestamp'),
toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerLSRcd'),
tag = cms.string( options.tag )
)
)
)

process.Test1 = cms.EDAnalyzer("LHCInfoPerLSPopConAnalyzer",
SinceAppendMode = cms.bool(True),
record = cms.string('LHCInfoPerLSRcd'),
name = cms.untracked.string('LHCInfo'),
Source = cms.PSet(fill = cms.untracked.uint32(6417),
startTime = cms.untracked.string('2021-09-10 03:10:18.000'),
# endTime = cms.untracked.string('2018-04-06 05:00:00.000'),
samplingInterval = cms.untracked.uint32( 600 ),
endFill = cms.untracked.bool(True),
connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"),
ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"),
DIPSchema = cms.untracked.string("CMS_BEAM_COND"),
omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"),
#authenticationPath = cms.untracked.string("."),
debug=cms.untracked.bool(False)
),
loggingOn = cms.untracked.bool(True),
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)
)

process.p = cms.Path(process.Test1)
88 changes: 88 additions & 0 deletions CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import socket
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
process = cms.Process("LHCInfoPerLSPopulator")
from CondCore.CondDB.CondDB_cfi import *
#process.load("CondCore.DBCommon.CondDBCommon_cfi")
#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db'
#process.CondDBCommon.DBParameters.authenticationPath = '.'
#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1)

sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R'
if socket.getfqdn().find('.cms') != -1:
sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R'

options = VarParsing.VarParsing()
options.register( 'destinationConnection'
, 'sqlite_file:lhcinfo_pop_test.db' #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, "Connection string to the DB where payloads will be possibly written."
)
options.register( 'targetConnection'
, '' #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, """Connection string to the target DB:
if not empty (default), this provides the latest IOV and payloads to compare;
it is the DB where payloads should be finally uploaded."""
)
options.register( 'tag'
, 'LHCInfoPerLS_PopCon_start_test'
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.string
, "Tag written in destinationConnection and finally appended in targetConnection."
)
options.register( 'messageLevel'
, 0 #default value
, VarParsing.VarParsing.multiplicity.singleton
, VarParsing.VarParsing.varType.int
, "Message level; default to 0"
)
options.parseArguments()

CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )

process.MessageLogger = cms.Service("MessageLogger",
cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
destinations = cms.untracked.vstring('cout')
)

process.source = cms.Source("EmptyIOVSource",
lastValue = cms.uint64(1),
timetype = cms.string('runnumber'),
firstValue = cms.uint64(1),
interval = cms.uint64(1)
)

process.PoolDBOutputService = cms.Service("PoolDBOutputService",
CondDBConnection,
timetype = cms.untracked.string('timestamp'),
toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerLSRcd'),
tag = cms.string( options.tag )
)
)
)

process.Test1 = cms.EDAnalyzer("LHCInfoPerLSPopConAnalyzer",
SinceAppendMode = cms.bool(True),
record = cms.string('LHCInfoPerLSRcd'),
name = cms.untracked.string('LHCInfo'),
Source = cms.PSet(fill = cms.untracked.uint32(6417),
startTime = cms.untracked.string('2021-09-10 03:10:18.000'),
# endTime = cms.untracked.string('2018-04-06 05:00:00.000'),
samplingInterval = cms.untracked.uint32( 600 ),
endFill = cms.untracked.bool(False),
connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"),
ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"),
DIPSchema = cms.untracked.string("CMS_BEAM_COND"),
omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"),
#authenticationPath = cms.untracked.string("."),
debug=cms.untracked.bool(False)
),
loggingOn = cms.untracked.bool(True),
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)
)

process.p = cms.Path(process.Test1)
Loading

0 comments on commit 67071cc

Please sign in to comment.