CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
cond::AlignSplitIOV Class Reference
Inheritance diagram for cond::AlignSplitIOV:
cond::Utilities

Public Member Functions

 AlignSplitIOV ()
 
int execute () override
 
template<class T >
std::string processPayloadContainer (cond::DbSession &sourcedb, cond::DbSession &destdb, const std::string &token, const std::string &containerName)
 
 ~AlignSplitIOV ()
 
- Public Member Functions inherited from cond::Utilities
void addAuthenticationOptions ()
 
void addConfigFileOption ()
 
void addConnectOption ()
 
void addConnectOption (const std::string &connectionOptionName, const std::string &shortName, const std::string &helpEntry)
 
void addDictionaryOption ()
 
void addLogDBOption ()
 
template<typename T >
void addOption (const std::string &fullName, const std::string &shortName, const std::string &helpEntry)
 
template<>
void addOption (const std::string &fullName, const std::string &shortName, const std::string &helpEntry)
 
void addSQLOutputOption ()
 
std::string getAuthenticationPathValue ()
 
std::string getConfigFileValue ()
 
std::string getConnectValue ()
 
std::string getDictionaryValue ()
 
std::string getLogDBValue ()
 
template<typename T >
T getOptionValue (const std::string &fullName)
 
std::string getPasswordValue ()
 
std::string getUserValue ()
 
bool hasDebug ()
 
bool hasOptionValue (const std::string &fullName)
 
void initializePluginManager ()
 
cond::DbSession openDbSession (const std::string &connectionParameterName, bool readOnly=false)
 
cond::DbSession openDbSession (const std::string &connectionParameterName, const std::string &role, bool readOnly=false)
 
void parseCommand (int argc, char **argv)
 
int run (int argc, char **argv)
 
 Utilities (const std::string &commandName, std::string positionalParameter=std::string(""))
 
virtual ~Utilities ()
 

Additional Inherited Members

- Protected Member Functions inherited from cond::Utilities
void initializeForDbConnection ()
 
cond::DbSession newDbSession (const std::string &connectionString, bool readOnly=false)
 
cond::DbSession newDbSession (const std::string &connectionString, const std::string &role, bool readOnly=false)
 
- Protected Attributes inherited from cond::Utilities
edm::ServiceTokenm_currentToken = 0
 

Detailed Description

Definition at line 38 of file aligncond_split_iov.cc.

Constructor & Destructor Documentation

cond::AlignSplitIOV::AlignSplitIOV ( )

Definition at line 52 of file aligncond_split_iov.cc.

References cond::Utilities::addAuthenticationOptions(), and cond::Utilities::addConnectOption().

53  :Utilities("aligncond_split_iov")
54 {
55  addConnectOption("sourceConnect","s","source connection string(required)");
56  addConnectOption("destConnect","d","destionation connection string(required)");
57  addOption<std::string>("sourceTag","i","tag to export( default = destination tag)");
58  addOption<std::string>("destTag","t","destination tag (required)");
60  addOption<bool>("verbose","v","verbose");
61 }
void addConnectOption()
Definition: Utilities.cc:111
void addAuthenticationOptions()
Definition: Utilities.cc:104
Utilities(const std::string &commandName, std::string positionalParameter=std::string(""))
Definition: Utilities.cc:25
cond::AlignSplitIOV::~AlignSplitIOV ( )

Definition at line 63 of file aligncond_split_iov.cc.

64 {
65 
66 }

Member Function Documentation

int cond::AlignSplitIOV::execute ( )
overridevirtual

Reimplemented from cond::Utilities.

Definition at line 68 of file aligncond_split_iov.cc.

References cond::MetaData::addMapping(), cond::IOVEditor::append(), cond::IOVProxy::begin(), cond::DbSession::classNameForItem(), cond::DbScopedTransaction::commit(), counter, gather_cfg::cout, cond::IOVEditor::create(), idDealer::editor, cond::IOVProxy::end(), cond::TimeTypeSpecs::endValue, cond::MetaData::getToken(), o2o::iov, max(), bookConverter::min, cond::IOVEditor::stamp(), cond::DbScopedTransaction::start(), cond::DbTransaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::IOVProxy::timetype(), cond::timeTypeSpecs, cond::IOVEditor::token(), cond::DbSession::transaction(), python.IdGenerator::transaction, and cond::userInfo().

69 {
71 
72  std::string sourceConnect = getOptionValue<std::string>("sourceConnect");
73  std::string destConnect = getOptionValue<std::string>("destConnect");
74 
75  std::string destTag = getOptionValue<std::string>("destTag");
76  std::string sourceTag(destTag);
77  if (hasOptionValue("sourceTag"))
78  sourceTag = getOptionValue<std::string>("sourceTag");
79  bool verbose = hasOptionValue("verbose");
80 
83 
84  std::string sourceiovtoken;
85  cond::TimeType sourceiovtype;
86 
87  std::string destiovtoken;
88 
89  cond::DbSession sourcedb = openDbSession("sourceConnect", false);
90  cond::DbSession destdb = openDbSession("destConnect");
91 
92  sourcedb.transaction().start(false);
93  cond::MetaData sourceMetadata(sourcedb);
94  sourceiovtoken = sourceMetadata.getToken(sourceTag);
95  if (sourceiovtoken.empty())
96  throw std::runtime_error(std::string("tag ") + sourceTag + std::string(" not found"));
97 
98  if (verbose)
99  std::cout << "source iov token: " << sourceiovtoken << std::endl;
100 
101  cond::IOVProxy iov(sourcedb, sourceiovtoken);
102  sourceiovtype = iov.timetype();
103  if (verbose)
104  std::cout << "source iov type " << sourceiovtype << std::endl;
105 
106  since = std::max(since, cond::timeTypeSpecs[sourceiovtype].beginValue);
107  till = std::min(till, cond::timeTypeSpecs[sourceiovtype].endValue);
108 
109  unsigned int counter = 0;
110  for (cond::IOVProxy::const_iterator ioviterator = iov.begin();
111  ioviterator != iov.end();
112  ++ioviterator) {
113 
114  std::stringstream newTag;
115  newTag << destTag << "_" << counter;
116 
117  std::cout << "iov " << counter << ":\t"
118  << ioviterator->since() << " \t "
119  << ioviterator->till() << std::endl;
120 
121  if (verbose)
122  std::cout << "\t" << ioviterator->token() << std::endl;
123 
125  transaction.start(false);
126  std::string payloadContainerName = sourcedb.classNameForItem(ioviterator->token());
127  std::string objToken;
128  if (payloadContainerName=="Alignments")
129  objToken = processPayloadContainer<Alignments>(sourcedb, destdb,
130  ioviterator->token(), payloadContainerName);
131  else if (payloadContainerName=="AlignmentErrors")
132  objToken = processPayloadContainer<AlignmentErrors>(sourcedb, destdb,
133  ioviterator->token(), payloadContainerName);
134  else if (payloadContainerName=="AlignmentSurfaceDeformations")
135  objToken = processPayloadContainer<AlignmentSurfaceDeformations>(sourcedb, destdb,
136  ioviterator->token(), payloadContainerName);
137  else if (payloadContainerName=="SiPixelLorentzAngle")
138  objToken = processPayloadContainer<SiPixelLorentzAngle>(sourcedb, destdb,
139  ioviterator->token(), payloadContainerName);
140  else if (payloadContainerName=="SiStripLorentzAngle")
141  objToken = processPayloadContainer<SiStripLorentzAngle>(sourcedb, destdb,
142  ioviterator->token(), payloadContainerName);
143  else if (payloadContainerName=="SiStripBackPlaneCorrection")
144  objToken = processPayloadContainer<SiStripBackPlaneCorrection>(sourcedb, destdb,
145  ioviterator->token(), payloadContainerName);
146  else {
147  return 1;
148  }
149 
150  cond::IOVEditor editor(destdb);
151  editor.create(iov.timetype(), cond::timeTypeSpecs[sourceiovtype].endValue);
152  editor.append(cond::timeTypeSpecs[sourceiovtype].beginValue, objToken);
153  std::string iovToken = editor.token();
154  editor.stamp(cond::userInfo(),false);
155 
156  cond::MetaData metadata(destdb);
157  metadata.addMapping(newTag.str(), iovToken, sourceiovtype);
158  transaction.commit();
159 
160  ::sleep(1);
161 
162  ++counter;
163  }
164 
165  std::cout << "Total # of payload objects: " << counter << std::endl;
166 
167  return 0;
168 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
std::string classNameForItem(const std::string &objectId)
Definition: DbSession.cc:292
DbTransaction & transaction()
Definition: DbSession.cc:208
TimeType
Definition: Time.h:21
int start(bool readOnly=false)
start transaction
unsigned long long Time_t
Definition: Time.h:16
tuple iov
Definition: o2o.py:307
const T & max(const T &a, const T &b)
void initializePluginManager()
Definition: Utilities.cc:202
tuple editor
Definition: idDealer.py:73
bool hasOptionValue(const std::string &fullName)
Definition: Utilities.cc:188
static std::atomic< unsigned int > counter
cond::DbSession openDbSession(const std::string &connectionParameterName, bool readOnly=false)
Definition: Utilities.cc:267
std::string userInfo()
Definition: IOVInfo.cc:9
tuple cout
Definition: gather_cfg.py:121
Time_t endValue
Definition: Time.h:46
iov_range_iterator const_iterator
Definition: IOVProxy.h:160
template<class T >
std::string cond::AlignSplitIOV::processPayloadContainer ( cond::DbSession sourcedb,
cond::DbSession destdb,
const std::string &  token,
const std::string &  containerName 
)

Definition at line 171 of file aligncond_split_iov.cc.

References cond::DbSession::createDatabase(), cond::DbSession::getTypedObject(), and cond::DbSession::storeObject().

175 {
176  boost::shared_ptr<T> object = sourcedb.getTypedObject<T>(token);
177  destdb.createDatabase();
178  return destdb.storeObject(object.get(), containerName);
179 }
std::string storeObject(const T *object, const std::string &containerName)
Definition: DbSession.h:132
bool createDatabase()
Definition: DbSession.cc:221
long double T
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
Definition: DbSession.h:126