CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::map< cond::Time_t, std::shared_ptr< LHCInfo >> &iovsToTransfer, std::shared_ptr< LHCInfo > &prevPayload)
 

Variables

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

Function Documentation

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

Definition at line 124 of file LHCInfo.cc.

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

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  }
bool LHCInfoImpl::comparePayloads ( const LHCInfo rhs,
const LHCInfo lhs 
)

Definition at line 792 of file LHCInfoPopConSourceHandler.cc.

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().

792  {
793  if (rhs.fillNumber() != lhs.fillNumber())
794  return false;
795  if (rhs.delivLumi() != lhs.delivLumi())
796  return false;
797  if (rhs.recLumi() != lhs.recLumi())
798  return false;
799  if (rhs.instLumi() != lhs.instLumi())
800  return false;
801  if (rhs.instLumiError() != lhs.instLumiError())
802  return false;
803  if (rhs.crossingAngle() != rhs.crossingAngle())
804  return false;
805  if (rhs.betaStar() != rhs.betaStar())
806  return false;
807  if (rhs.lhcState() != rhs.lhcState())
808  return false;
809  if (rhs.lhcComment() != rhs.lhcComment())
810  return false;
811  if (rhs.ctppsStatus() != rhs.ctppsStatus())
812  return false;
813  return true;
814  }
std::string const & lhcState() const
Definition: LHCInfo.cc:212
std::string const & ctppsStatus() const
Definition: LHCInfo.cc:216
float const delivLumi() const
Definition: LHCInfo.cc:192
float const crossingAngle() const
Definition: LHCInfo.cc:182
float const instLumiError() const
Definition: LHCInfo.cc:198
std::string const & lhcComment() const
Definition: LHCInfo.cc:214
float const instLumi() const
Definition: LHCInfo.cc:196
float const recLumi() const
Definition: LHCInfo.cc:194
float const betaStar() const
Definition: LHCInfo.cc:184
unsigned short const fillNumber() const
Definition: LHCInfo.cc:158
template<typename T >
const T& LHCInfoImpl::getOneParam ( const std::vector< std::vector< T > > &  params,
size_t  index 
)

Definition at line 131 of file LHCInfo.cc.

References SurfaceOrientation::inner, mergeVDriftHistosByStation::name, and submitPVValidationJobs::params.

Referenced by LHCInfo::beginTime(), LHCInfo::betaStar(), LHCInfo::bunchesInBeam1(), LHCInfo::bunchesInBeam2(), LHCInfo::collidingBunches(), LHCInfo::createTime(), LHCInfo::crossingAngle(), LHCInfo::ctppsStatus(), LHCInfo::delivLumi(), LHCInfo::endTime(), LHCInfo::energy(), LHCInfo::fillNumber(), LHCInfo::fillType(), LHCInfo::injectionScheme(), LHCInfo::instLumi(), LHCInfo::instLumiError(), LHCInfo::intensityForBeam1(), LHCInfo::intensityForBeam2(), LHCInfo::lhcComment(), LHCInfo::lhcState(), LHCInfo::lumiSection(), LHCInfo::particleTypeForBeam1(), LHCInfo::particleTypeForBeam2(), LHCInfo::recLumi(), and LHCInfo::targetBunches().

131  {
132  if (index >= params.size())
133  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
134  const std::vector<T>& inner = params[index];
135  if (inner.empty())
136  throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() +
137  " has no value stored.");
138  return inner[0];
139  }
long double T
template<typename T >
const T& LHCInfoImpl::getParams ( const std::vector< T > &  params,
size_t  index 
)

Definition at line 117 of file LHCInfo.cc.

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

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  }
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 67 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::COSMICS, BeamSpotPI::creationTime, relval_parameters_module::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, and LHCInfo::UNKNOWN.

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

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

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

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

60  {
61  if (container.empty())
62  return container.end();
63  auto p = std::upper_bound(container.begin(), container.end(), val, IOVComp());
64  return (p != container.begin()) ? p - 1 : container.end();
65  }
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
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 632 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::beam1RF(), LHCInfo::beam1VC(), LHCInfo::beam2RF(), LHCInfo::beam2VC(), LHCInfo::bunchSlots, relativeConstraints::value, and vecMap.

Referenced by LHCInfoPopConSourceHandler::getEcalData().

637  {
638  if (initList.find(since) == initList.end()) {
639  payload.beam1VC().resize(LHCInfo::bunchSlots, 0.);
640  payload.beam2VC().resize(LHCInfo::bunchSlots, 0.);
641  payload.beam1RF().resize(LHCInfo::bunchSlots, 0.);
642  payload.beam2RF().resize(LHCInfo::bunchSlots, 0.);
643  initList.insert(since);
644  }
645  // set the current values to all of the payloads of the lumi section samples after the current since
646  if (elementNr < LHCInfo::bunchSlots) {
647  switch (vecMap.at(dipVal)) {
648  case 1:
649  payload.beam1VC()[elementNr] = value;
650  break;
651  case 2:
652  payload.beam2VC()[elementNr] = value;
653  break;
654  case 3:
655  payload.beam1RF()[elementNr] = value;
656  break;
657  case 4:
658  payload.beam2RF()[elementNr] = value;
659  break;
660  default:
661  break;
662  }
663  }
664  }
static const std::map< std::string, int > vecMap
std::vector< float > const & beam1VC() const
Definition: LHCInfo.cc:220
std::vector< float > const & beam2RF() const
Definition: LHCInfo.cc:226
std::vector< float > const & beam1RF() const
Definition: LHCInfo.cc:224
std::vector< float > const & beam2VC() const
Definition: LHCInfo.cc:222
static size_t const bunchSlots
Definition: LHCInfo.h:58
template<typename T >
void LHCInfoImpl::setOneParam ( std::vector< std::vector< T > > &  params,
size_t  index,
const T value 
)
template<typename T >
void LHCInfoImpl::setParams ( std::vector< T > &  params,
size_t  index,
const T value 
)

Definition at line 149 of file LHCInfo.cc.

References relativeConstraints::value.

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

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  }
size_t LHCInfoImpl::transferPayloads ( const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfo >>> &  buffer,
std::map< cond::Time_t, std::shared_ptr< LHCInfo >> &  iovsToTransfer,
std::shared_ptr< LHCInfo > &  prevPayload 
)

Definition at line 816 of file LHCInfoPopConSourceHandler.cc.

References PVValHelper::add(), edmScanValgrind::buffer, comparePayloads(), jetCorrFactors_cfi::payload, and SiStripO2O_cfg_template::since.

Referenced by LHCInfoPopConSourceHandler::getNewObjects().

818  {
819  size_t niovs = 0;
820  for (auto& iov : buffer) {
821  bool add = false;
822  auto payload = iov.second;
823  cond::Time_t since = iov.first;
824  if (iovsToTransfer.empty()) {
825  add = true;
826  } else {
827  LHCInfo& lastAdded = *iovsToTransfer.rbegin()->second;
828  if (!comparePayloads(lastAdded, *payload)) {
829  add = true;
830  }
831  }
832  if (add) {
833  niovs++;
834  iovsToTransfer.insert(std::make_pair(since, payload));
835  prevPayload = iov.second;
836  }
837  }
838  return niovs;
839  }
bool comparePayloads(const LHCInfo &rhs, const LHCInfo &lhs)
unsigned long long Time_t
Definition: Time.h:14
void add(std::map< std::string, TH1 * > &h, TH1 *hist)

Variable Documentation

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 630 of file LHCInfoPopConSourceHandler.cc.

Referenced by setElementData().