CMS 3D CMS Logo

Classes | Functions | Variables
LHCInfoImpl Namespace Reference

Classes

struct  IOVComp
 
struct  LumiSectionFilter
 

Functions

template<typename T >
TaccessParams (std::vector< T > &params, size_t index)
 
bool comparePayloads (const LHCInfo &rhs, const LHCInfo &lhs)
 
template<typename T >
const TgetOneParam (const std::vector< std::vector< T > > &params, size_t index)
 
template<typename T >
const TgetParams (const std::vector< T > &params, size_t index)
 
bool makeFillDataQuery (cond::persistency::Session &session, const std::string &conditionString, const coral::AttributeList &fillDataBindVariables, std::unique_ptr< LHCInfo > &targetPayload, bool debug)
 
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo > > >::const_iterator search (const cond::Time_t &val, const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo >>> &container)
 
void setElementData (cond::Time_t since, const std::string &dipVal, unsigned int elementNr, float value, LHCInfo &payload, std::set< cond::Time_t > &initList)
 
template<typename T >
void setOneParam (std::vector< std::vector< T > > &params, size_t index, const T &value)
 
template<typename T >
void setParams (std::vector< T > &params, size_t index, const T &value)
 
size_t transferPayloads (const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo >>> &buffer, std::vector< std::shared_ptr< LHCInfo >> &payloadBuffer, std::vector< std::pair< LHCInfo *, cond::Time_t >> &vecToTransfer, std::shared_ptr< LHCInfo > &prevPayload)
 

Variables

static const std::map< std::string, int > vecMap
 

Function Documentation

◆ accessParams()

template<typename T >
T& LHCInfoImpl::accessParams ( std::vector< T > &  params,
size_t  index 
)

Definition at line 124 of file LHCInfo.cc.

124  {
125  if (index >= params.size())
126  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
127  return params[index];
128  }

References CalibrationSummaryClient_cfi::params.

Referenced by LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), and LHCInfo::beam2VC().

◆ comparePayloads()

bool LHCInfoImpl::comparePayloads ( const LHCInfo rhs,
const LHCInfo lhs 
)

Definition at line 794 of file LHCInfoPopConSourceHandler.cc.

794  {
795  if (rhs.fillNumber() != lhs.fillNumber())
796  return false;
797  if (rhs.delivLumi() != lhs.delivLumi())
798  return false;
799  if (rhs.recLumi() != lhs.recLumi())
800  return false;
801  if (rhs.instLumi() != lhs.instLumi())
802  return false;
803  if (rhs.instLumiError() != lhs.instLumiError())
804  return false;
805  if (rhs.crossingAngle() != rhs.crossingAngle())
806  return false;
807  if (rhs.betaStar() != rhs.betaStar())
808  return false;
809  if (rhs.lhcState() != rhs.lhcState())
810  return false;
811  if (rhs.lhcComment() != rhs.lhcComment())
812  return false;
813  if (rhs.ctppsStatus() != rhs.ctppsStatus())
814  return false;
815  return true;
816  }

References LHCInfo::betaStar(), LHCInfo::crossingAngle(), LHCInfo::ctppsStatus(), LHCInfo::delivLumi(), LHCInfo::fillNumber(), LHCInfo::instLumi(), LHCInfo::instLumiError(), LHCInfo::lhcComment(), LHCInfo::lhcState(), and LHCInfo::recLumi().

Referenced by transferPayloads().

◆ getOneParam()

template<typename T >
const T& LHCInfoImpl::getOneParam ( const std::vector< std::vector< T > > &  params,
size_t  index 
)

◆ getParams()

template<typename T >
const T& LHCInfoImpl::getParams ( const std::vector< T > &  params,
size_t  index 
)

Definition at line 117 of file LHCInfo.cc.

117  {
118  if (index >= params.size())
119  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
120  return params[index];
121  }

References CalibrationSummaryClient_cfi::params.

Referenced by LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), LHCInfo::beam2VC(), and LHCInfo::lumiPerBX().

◆ makeFillDataQuery()

bool LHCInfoImpl::makeFillDataQuery ( cond::persistency::Session session,
const std::string &  conditionString,
const coral::AttributeList &  fillDataBindVariables,
std::unique_ptr< LHCInfo > &  targetPayload,
bool  debug 
)

Definition at line 68 of file LHCInfoPopConSourceHandler.cc.

72  {
73  coral::ISchema& runTimeLoggerSchema = session.nominalSchema();
74  //prepare the query for table 1:
75  std::unique_ptr<coral::IQuery> fillDataQuery(runTimeLoggerSchema.newQuery());
76  //FROM clause
77  fillDataQuery->addToTableList(std::string("RUNTIME_SUMMARY"));
78  //SELECT clause
79  fillDataQuery->addToOutputList(std::string("LHCFILL"));
80  fillDataQuery->addToOutputList(std::string("NBUNCHESBEAM1"));
81  fillDataQuery->addToOutputList(std::string("NBUNCHESBEAM2"));
82  fillDataQuery->addToOutputList(std::string("NCOLLIDINGBUNCHES"));
83  fillDataQuery->addToOutputList(std::string("NTARGETBUNCHES"));
84  fillDataQuery->addToOutputList(std::string("RUNTIME_TYPE_ID"));
85  fillDataQuery->addToOutputList(std::string("PARTY1"));
86  fillDataQuery->addToOutputList(std::string("PARTY2"));
87  fillDataQuery->addToOutputList(std::string("INTENSITYBEAM1"));
88  fillDataQuery->addToOutputList(std::string("INTENSITYBEAM2"));
89  fillDataQuery->addToOutputList(std::string("ENERGY"));
90  fillDataQuery->addToOutputList(std::string("CREATETIME"));
91  fillDataQuery->addToOutputList(std::string("BEGINTIME"));
92  fillDataQuery->addToOutputList(std::string("ENDTIME"));
93  fillDataQuery->addToOutputList(std::string("INJECTIONSCHEME"));
94  //WHERE clause
95  fillDataQuery->setCondition(conditionString, fillDataBindVariables);
96  //ORDER BY clause
97  std::string orderStr("BEGINTIME");
98  //define query output
99  coral::AttributeList fillDataOutput;
100  fillDataOutput.extend<unsigned short>(std::string("LHCFILL"));
101  fillDataOutput.extend<unsigned short>(std::string("NBUNCHESBEAM1"));
102  fillDataOutput.extend<unsigned short>(std::string("NBUNCHESBEAM2"));
103  fillDataOutput.extend<unsigned short>(std::string("NCOLLIDINGBUNCHES"));
104  fillDataOutput.extend<unsigned short>(std::string("NTARGETBUNCHES"));
105  fillDataOutput.extend<int>(std::string("RUNTIME_TYPE_ID"));
106  fillDataOutput.extend<int>(std::string("PARTY1"));
107  fillDataOutput.extend<int>(std::string("PARTY2"));
108  fillDataOutput.extend<float>(std::string("INTENSITYBEAM1"));
109  fillDataOutput.extend<float>(std::string("INTENSITYBEAM2"));
110  fillDataOutput.extend<float>(std::string("ENERGY"));
111  fillDataOutput.extend<coral::TimeStamp>(std::string("CREATETIME"));
112  fillDataOutput.extend<coral::TimeStamp>(std::string("BEGINTIME"));
113  fillDataOutput.extend<coral::TimeStamp>(std::string("ENDTIME"));
114  fillDataOutput.extend<std::string>(std::string("INJECTIONSCHEME"));
115  fillDataQuery->defineOutput(fillDataOutput);
116  fillDataQuery->limitReturnedRows(1);
117  //execute the query
118  coral::ICursor& fillDataCursor = fillDataQuery->execute();
119  //
120  unsigned short currentFill = 0;
121  unsigned short bunches1 = 0, bunches2 = 0, collidingBunches = 0, targetBunches = 0;
123  LHCInfo::ParticleTypeId particleType1 = LHCInfo::NONE, particleType2 = LHCInfo::NONE;
124  float intensityBeam1 = 0., intensityBeam2 = 0., energy = 0.;
125  coral::TimeStamp stableBeamStartTimeStamp, beamDumpTimeStamp;
126  cond::Time_t creationTime = 0ULL, stableBeamStartTime = 0ULL, beamDumpTime = 0ULL;
127  std::string injectionScheme("None");
128  std::ostringstream ss;
129  bool ret = false;
130  if (fillDataCursor.next()) {
131  ret = true;
132  if (debug) {
133  std::ostringstream qs;
134  fillDataCursor.currentRow().toOutputStream(qs);
135  }
136  coral::Attribute const& fillAttribute = fillDataCursor.currentRow()[std::string("LHCFILL")];
137  if (!fillAttribute.isNull()) {
138  currentFill = fillAttribute.data<unsigned short>();
139  }
140  coral::Attribute const& bunches1Attribute = fillDataCursor.currentRow()[std::string("NBUNCHESBEAM1")];
141  if (!bunches1Attribute.isNull()) {
142  bunches1 = bunches1Attribute.data<unsigned short>();
143  }
144  coral::Attribute const& bunches2Attribute = fillDataCursor.currentRow()[std::string("NBUNCHESBEAM2")];
145  if (!bunches2Attribute.isNull()) {
146  bunches2 = bunches2Attribute.data<unsigned short>();
147  }
148  coral::Attribute const& collidingBunchesAttribute = fillDataCursor.currentRow()[std::string("NCOLLIDINGBUNCHES")];
149  if (!collidingBunchesAttribute.isNull()) {
150  collidingBunches = collidingBunchesAttribute.data<unsigned short>();
151  }
152  coral::Attribute const& targetBunchesAttribute = fillDataCursor.currentRow()[std::string("NTARGETBUNCHES")];
153  if (!targetBunchesAttribute.isNull()) {
154  targetBunches = targetBunchesAttribute.data<unsigned short>();
155  }
156  //RUNTIME_TYPE_ID IS NOT NULL
157  fillType =
158  static_cast<LHCInfo::FillTypeId>(fillDataCursor.currentRow()[std::string("RUNTIME_TYPE_ID")].data<int>());
159  coral::Attribute const& particleType1Attribute = fillDataCursor.currentRow()[std::string("PARTY1")];
160  if (!particleType1Attribute.isNull()) {
161  particleType1 = static_cast<LHCInfo::ParticleTypeId>(particleType1Attribute.data<int>());
162  }
163  coral::Attribute const& particleType2Attribute = fillDataCursor.currentRow()[std::string("PARTY2")];
164  if (!particleType2Attribute.isNull()) {
165  particleType2 = static_cast<LHCInfo::ParticleTypeId>(particleType2Attribute.data<int>());
166  }
167  coral::Attribute const& intensityBeam1Attribute = fillDataCursor.currentRow()[std::string("INTENSITYBEAM1")];
168  if (!intensityBeam1Attribute.isNull()) {
169  intensityBeam1 = intensityBeam1Attribute.data<float>();
170  }
171  coral::Attribute const& intensityBeam2Attribute = fillDataCursor.currentRow()[std::string("INTENSITYBEAM2")];
172  if (!intensityBeam2Attribute.isNull()) {
173  intensityBeam2 = intensityBeam2Attribute.data<float>();
174  }
175  coral::Attribute const& energyAttribute = fillDataCursor.currentRow()[std::string("ENERGY")];
176  if (!energyAttribute.isNull()) {
177  energy = energyAttribute.data<float>();
178  }
179  }
180  if (ret) {
181  //CREATETIME IS NOT NULL
182  creationTime = cond::time::from_boost(
183  fillDataCursor.currentRow()[std::string("CREATETIME")].data<coral::TimeStamp>().time());
184  //BEGINTIME is imposed to be NOT NULL in the WHERE clause
185  stableBeamStartTimeStamp = fillDataCursor.currentRow()[std::string("BEGINTIME")].data<coral::TimeStamp>();
186  stableBeamStartTime = cond::time::from_boost(stableBeamStartTimeStamp.time());
187  coral::Attribute const& beamDumpTimeAttribute = fillDataCursor.currentRow()[std::string("ENDTIME")];
188  if (!beamDumpTimeAttribute.isNull()) {
189  beamDumpTimeStamp = beamDumpTimeAttribute.data<coral::TimeStamp>();
190  beamDumpTime = cond::time::from_boost(beamDumpTimeStamp.time());
191  }
192  coral::Attribute const& injectionSchemeAttribute = fillDataCursor.currentRow()[std::string("INJECTIONSCHEME")];
193  if (!injectionSchemeAttribute.isNull()) {
194  injectionScheme = injectionSchemeAttribute.data<std::string>();
195  }
196  //fix an inconsistency in RunTimeLogger: if the fill type is defined, the particle type should reflect it!
197  if (fillType != LHCInfo::UNKNOWN && (particleType1 == LHCInfo::NONE || particleType2 == LHCInfo::NONE)) {
198  switch (fillType) {
199  case LHCInfo::PROTONS:
200  particleType1 = LHCInfo::PROTON;
201  particleType2 = LHCInfo::PROTON;
202  break;
203  case LHCInfo::IONS:
204  particleType1 = LHCInfo::PB82;
205  particleType2 = LHCInfo::PB82;
206  break;
207  case LHCInfo::UNKNOWN:
208  case LHCInfo::COSMICS:
209  case LHCInfo::GAP:
210  break;
211  }
212  }
213  targetPayload.reset(new LHCInfo());
214  targetPayload->setFillNumber(currentFill);
215  targetPayload->setBunchesInBeam1(bunches1);
216  targetPayload->setBunchesInBeam2(bunches2);
217  targetPayload->setCollidingBunches(collidingBunches);
218  targetPayload->setTargetBunches(targetBunches);
219  targetPayload->setFillType(fillType);
220  targetPayload->setParticleTypeForBeam1(particleType1);
221  targetPayload->setParticleTypeForBeam2(particleType2);
222  targetPayload->setIntensityForBeam1(intensityBeam1);
223  targetPayload->setIntensityForBeam2(intensityBeam2);
224  targetPayload->setEnergy(energy);
225  targetPayload->setCreationTime(creationTime);
226  targetPayload->setBeginTime(stableBeamStartTime);
227  targetPayload->setEndTime(beamDumpTime);
228  targetPayload->setInjectionScheme(injectionScheme);
229  }
230  return ret;
231  }

References LHCInfo::COSMICS, debug, HCALHighEnergyHPDFilter_cfi::energy, cond::time::from_boost(), LHCInfo::GAP, LHCInfo::IONS, cond::persistency::Session::nominalSchema(), LHCInfo::NONE, LHCInfo::PB82, LHCInfo::PROTON, LHCInfo::PROTONS, runTheMatrix::ret, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, ntuplemaker::time, and LHCInfo::UNKNOWN.

Referenced by LHCInfoPopConSourceHandler::getFillData(), and LHCInfoPopConSourceHandler::getNextFillData().

◆ search()

std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfo> > >::const_iterator LHCInfoImpl::search ( const cond::Time_t val,
const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo >>> &  container 
)

Definition at line 60 of file LHCInfoPopConSourceHandler.cc.

61  {
62  if (container.empty())
63  return container.end();
64  auto p = std::upper_bound(container.begin(), container.end(), val, IOVComp());
65  return (p != container.begin()) ? p - 1 : container.end();
66  }

References AlCaHLTBitMon_ParallelJobs::p, cuda_std::upper_bound(), and heppy_batch::val.

Referenced by LHCInfoImpl::LumiSectionFilter::process().

◆ setElementData()

void LHCInfoImpl::setElementData ( cond::Time_t  since,
const std::string &  dipVal,
unsigned int  elementNr,
float  value,
LHCInfo payload,
std::set< cond::Time_t > &  initList 
)

Definition at line 633 of file LHCInfoPopConSourceHandler.cc.

638  {
639  if (initList.find(since) == initList.end()) {
640  payload.beam1VC().resize(LHCInfo::bunchSlots, 0.);
641  payload.beam2VC().resize(LHCInfo::bunchSlots, 0.);
642  payload.beam1RF().resize(LHCInfo::bunchSlots, 0.);
643  payload.beam2RF().resize(LHCInfo::bunchSlots, 0.);
644  initList.insert(since);
645  }
646  // set the current values to all of the payloads of the lumi section samples after the current since
647  if (elementNr < LHCInfo::bunchSlots) {
648  switch (vecMap.at(dipVal)) {
649  case 1:
650  payload.beam1VC()[elementNr] = value;
651  break;
652  case 2:
653  payload.beam2VC()[elementNr] = value;
654  break;
655  case 3:
656  payload.beam1RF()[elementNr] = value;
657  break;
658  case 4:
659  payload.beam2RF()[elementNr] = value;
660  break;
661  default:
662  break;
663  }
664  }
665  }

References LHCInfo::bunchSlots, jets_cff::payload, writeEcalDQMStatus::since, relativeConstraints::value, and vecMap.

Referenced by LHCInfoPopConSourceHandler::getEcalData().

◆ setOneParam()

template<typename T >
void LHCInfoImpl::setOneParam ( std::vector< std::vector< T > > &  params,
size_t  index,
const T value 
)

◆ setParams()

template<typename T >
void LHCInfoImpl::setParams ( std::vector< T > &  params,
size_t  index,
const T value 
)

Definition at line 149 of file LHCInfo.cc.

149  {
150  if (index >= params.size())
151  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
152  params[index] = value;
153  }

References CalibrationSummaryClient_cfi::params, and relativeConstraints::value.

Referenced by LHCInfo::setBeam1RF(), LHCInfo::setBeam1VC(), LHCInfo::setBeam2RF(), LHCInfo::setBeam2VC(), and LHCInfo::setLumiPerBX().

◆ transferPayloads()

size_t LHCInfoImpl::transferPayloads ( const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo >>> &  buffer,
std::vector< std::shared_ptr< LHCInfo >> &  payloadBuffer,
std::vector< std::pair< LHCInfo *, cond::Time_t >> &  vecToTransfer,
std::shared_ptr< LHCInfo > &  prevPayload 
)

Definition at line 818 of file LHCInfoPopConSourceHandler.cc.

821  {
822  size_t niovs = 0;
823  for (auto& iov : buffer) {
824  bool add = false;
825  LHCInfo& payload = *iov.second;
826  cond::Time_t since = iov.first;
827  if (vecToTransfer.empty()) {
828  add = true;
829  } else {
830  LHCInfo& lastAdded = *vecToTransfer.back().first;
831  if (!comparePayloads(lastAdded, payload)) {
832  add = true;
833  }
834  }
835  if (add) {
836  niovs++;
837  vecToTransfer.push_back(std::make_pair(&payload, since));
838  payloadBuffer.push_back(iov.second);
839  prevPayload = iov.second;
840  }
841  }
842  return niovs;
843  }

References PVValHelper::add(), edmScanValgrind::buffer, comparePayloads(), jets_cff::payload, and writeEcalDQMStatus::since.

Referenced by LHCInfoPopConSourceHandler::getNewObjects().

Variable Documentation

◆ vecMap

const std::map<std::string, int> LHCInfoImpl::vecMap
static
Initial value:
= {
{"Beam1/beamPhaseMean", 1}, {"Beam2/beamPhaseMean", 2}, {"Beam1/cavPhaseMean", 3}, {"Beam2/cavPhaseMean", 4}}

Definition at line 631 of file LHCInfoPopConSourceHandler.cc.

Referenced by setElementData().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
LHCInfo::UNKNOWN
Definition: LHCInfo.h:14
LHCInfo::GAP
Definition: LHCInfo.h:14
LHCInfo::lhcComment
std::string const & lhcComment() const
Definition: LHCInfo.cc:214
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
LHCInfo
Definition: LHCInfo.h:12
LHCInfo::PROTON
Definition: LHCInfo.h:15
LHCInfo::COSMICS
Definition: LHCInfo.h:14
LHCInfo::fillNumber
unsigned const short fillNumber() const
Definition: LHCInfo.cc:158
LHCInfo::IONS
Definition: LHCInfo.h:14
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
debug
#define debug
Definition: HDRShower.cc:19
LHCInfo::lhcState
std::string const & lhcState() const
Definition: LHCInfo.cc:212
LHCInfo::crossingAngle
const float crossingAngle() const
Definition: LHCInfo.cc:182
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
SurfaceOrientation::inner
Definition: Surface.h:19
LHCInfoImpl::comparePayloads
bool comparePayloads(const LHCInfo &rhs, const LHCInfo &lhs)
Definition: LHCInfoPopConSourceHandler.cc:794
LHCInfo::FillType
FillType
Definition: LHCInfo.h:14
writeEcalDQMStatus.since
since
Definition: writeEcalDQMStatus.py:53
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
jets_cff.payload
payload
Definition: jets_cff.py:34
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LHCInfoImpl::vecMap
static const std::map< std::string, int > vecMap
Definition: LHCInfoPopConSourceHandler.cc:631
cond::time::from_boost
Time_t from_boost(boost::posix_time::ptime bt)
Definition: TimeConversions.h:43
cond::persistency::Session::nominalSchema
coral::ISchema & nominalSchema()
Definition: Session.cc:224
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
LHCInfo::instLumiError
const float instLumiError() const
Definition: LHCInfo.cc:198
LHCInfo::recLumi
const float recLumi() const
Definition: LHCInfo.cc:194
LHCInfo::instLumi
const float instLumi() const
Definition: LHCInfo.cc:196
value
Definition: value.py:1
LHCInfo::delivLumi
const float delivLumi() const
Definition: LHCInfo.cc:192
LHCInfo::PB82
Definition: LHCInfo.h:15
LHCInfo::NONE
Definition: LHCInfo.h:15
LHCInfo::bunchSlots
static const size_t bunchSlots
Definition: LHCInfo.h:58
heppy_batch.val
val
Definition: heppy_batch.py:351
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
LHCInfo::PROTONS
Definition: LHCInfo.h:14
ntuplemaker.time
time
Definition: ntuplemaker.py:310
LHCInfo::betaStar
const float betaStar() const
Definition: LHCInfo.cc:184
LHCInfo::ParticleType
ParticleType
Definition: LHCInfo.h:15
LHCInfo::ctppsStatus
std::string const & ctppsStatus() const
Definition: LHCInfo.cc:216