CMS 3D CMS Logo

FillInfo.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <iterator>
5 #include <stdexcept>
6 
7 //helper function: returns the positions of the bits in the bitset that are set (i.e., have a value of 1).
8 static std::vector<unsigned short> bitsetToVector(std::bitset<FillInfo::bunchSlots + 1> const& bs) {
9  std::vector<unsigned short> vec;
10  //reserve space only for the bits in the bitset that are set
11  vec.reserve(bs.count());
12  for (size_t i = 0; i < bs.size(); ++i) {
13  if (bs.test(i))
14  vec.push_back((unsigned short)i);
15  }
16  return vec;
17 }
18 
19 //helper function: returns the enum for fill types in string type
21  std::string s_fillType("UNKNOWN");
22  switch (fillType) {
23  case FillInfo::UNKNOWN:
24  s_fillType = std::string("UNKNOWN");
25  break;
26  case FillInfo::PROTONS:
27  s_fillType = std::string("PROTONS");
28  break;
29  case FillInfo::IONS:
30  s_fillType = std::string("IONS");
31  break;
32  case FillInfo::COSMICS:
33  s_fillType = std::string("COSMICS");
34  break;
35  case FillInfo::GAP:
36  s_fillType = std::string("GAP");
37  break;
38  default:
39  s_fillType = std::string("UNKNOWN");
40  }
41  return s_fillType;
42 }
43 
44 //helper function: returns the enum for particle types in string type
46  std::string s_particleType("NONE");
47  switch (particleType) {
48  case FillInfo::NONE:
49  s_particleType = std::string("NONE");
50  break;
51  case FillInfo::PROTON:
52  s_particleType = std::string("PROTON");
53  break;
54  case FillInfo::PB82:
55  s_particleType = std::string("PB82");
56  break;
57  case FillInfo::AR18:
58  s_particleType = std::string("AR18");
59  break;
60  case FillInfo::D:
61  s_particleType = std::string("D");
62  break;
63  case FillInfo::XE54:
64  s_particleType = std::string("XE54");
65  break;
66  default:
67  s_particleType = std::string("NONE");
68  }
69  return s_particleType;
70 }
71 
73  : m_isData(false),
74  m_lhcFill(0),
75  m_bunches1(0),
76  m_bunches2(0),
77  m_collidingBunches(0),
78  m_targetBunches(0),
79  m_fillType(FillTypeId::UNKNOWN),
80  m_particles1(ParticleTypeId::NONE),
81  m_particles2(ParticleTypeId::NONE),
82  m_crossingAngle(0.),
83  m_betastar(0.),
84  m_intensity1(0.),
85  m_intensity2(0.),
86  m_energy(0.),
87  m_createTime(0),
88  m_beginTime(0),
89  m_endTime(0),
90  m_injectionScheme("None") {}
91 
92 FillInfo::FillInfo(unsigned short const& lhcFill, bool const& fromData)
93  : m_isData(fromData),
94  m_lhcFill(lhcFill),
95  m_bunches1(0),
96  m_bunches2(0),
97  m_collidingBunches(0),
98  m_targetBunches(0),
99  m_fillType(FillTypeId::UNKNOWN),
100  m_particles1(ParticleTypeId::NONE),
101  m_particles2(ParticleTypeId::NONE),
102  m_crossingAngle(0.),
103  m_betastar(0.),
104  m_intensity1(0.),
105  m_intensity2(0.),
106  m_energy(0.),
107  m_createTime(0),
108  m_beginTime(0),
109  m_endTime(0),
110  m_injectionScheme("None") {}
111 
113 
114 //reset instance
115 void FillInfo::setFill(unsigned short const& lhcFill, bool const& fromData) {
116  m_isData = fromData;
117  m_lhcFill = lhcFill;
118  m_bunches1 = 0;
119  m_bunches2 = 0;
120  m_collidingBunches = 0;
121  m_targetBunches = 0;
125  m_crossingAngle = 0.;
126  m_betastar = 0.;
127  m_intensity1 = 0;
128  m_intensity2 = 0;
129  m_energy = 0.;
130  m_createTime = 0;
131  m_beginTime = 0;
132  m_endTime = 0;
133  m_injectionScheme = "None";
134  m_bunchConfiguration1.reset();
135  m_bunchConfiguration2.reset();
136 }
137 
138 //getters
139 unsigned short const FillInfo::fillNumber() const { return m_lhcFill; }
140 
141 bool const FillInfo::isData() const { return m_isData; }
142 
143 unsigned short const FillInfo::bunchesInBeam1() const { return m_bunches1; }
144 
145 unsigned short const FillInfo::bunchesInBeam2() const { return m_bunches2; }
146 
147 unsigned short const FillInfo::collidingBunches() const { return m_collidingBunches; }
148 
149 unsigned short const FillInfo::targetBunches() const { return m_targetBunches; }
150 
152 
154 
156 
157 float const FillInfo::crossingAngle() const { return m_crossingAngle; }
158 
159 float const FillInfo::betaStar() const { return m_betastar; }
160 
161 float const FillInfo::intensityForBeam1() const { return m_intensity1; }
162 
163 float const FillInfo::intensityForBeam2() const { return m_intensity2; }
164 
165 float const FillInfo::energy() const { return m_energy; }
166 
168 
170 
171 cond::Time_t const FillInfo::endTime() const { return m_endTime; }
172 
174 
175 //returns a boolean, true if the injection scheme has a leading 25ns
176 //TODO: parse the circulating bunch configuration, instead of the string.
178  const std::string prefix("25ns");
179  return std::equal(prefix.begin(), prefix.end(), m_injectionScheme.begin());
180 }
181 
182 //returns a boolean, true if the bunch slot number is in the circulating bunch configuration
183 bool FillInfo::isBunchInBeam1(size_t const& bunch) const {
184  if (bunch == 0)
185  throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1!
186  return m_bunchConfiguration1.test(bunch);
187 }
188 
189 bool FillInfo::isBunchInBeam2(size_t const& bunch) const {
190  if (bunch == 0)
191  throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1!
192  return m_bunchConfiguration2.test(bunch);
193 }
194 
195 //member functions returning *by value* a vector with all filled bunch slots
196 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam1() const {
198 }
199 
200 std::vector<unsigned short> FillInfo::bunchConfigurationForBeam2() const {
202 }
203 
204 //setters
205 void FillInfo::setBunchesInBeam1(unsigned short const& bunches) { m_bunches1 = bunches; }
206 
207 void FillInfo::setBunchesInBeam2(unsigned short const& bunches) { m_bunches2 = bunches; }
208 
209 void FillInfo::setCollidingBunches(unsigned short const& collidingBunches) { m_collidingBunches = collidingBunches; }
210 
211 void FillInfo::setTargetBunches(unsigned short const& targetBunches) { m_targetBunches = targetBunches; }
212 
214 
216 
218 
220 
222 
223 void FillInfo::setIntensityForBeam1(float const& intensity) { m_intensity1 = intensity; }
224 
225 void FillInfo::setIntensityForBeam2(float const& intensity) { m_intensity2 = intensity; }
226 
227 void FillInfo::setEnergy(float const& energy) { m_energy = energy; }
228 
230 
232 
234 
236 
237 //sets all values in one go
238 void FillInfo::setBeamInfo(unsigned short const& bunches1,
239  unsigned short const& bunches2,
240  unsigned short const& collidingBunches,
241  unsigned short const& targetBunches,
242  FillTypeId const& fillType,
243  ParticleTypeId const& particleType1,
244  ParticleTypeId const& particleType2,
245  float const& angle,
246  float const& beta,
247  float const& intensity1,
248  float const& intensity2,
249  float const& energy,
250  cond::Time_t const& createTime,
251  cond::Time_t const& beginTime,
252  cond::Time_t const& endTime,
253  std::string const& scheme,
254  std::bitset<bunchSlots + 1> const& bunchConf1,
255  std::bitset<bunchSlots + 1> const& bunchConf2) {
256  this->setBunchesInBeam1(bunches1);
257  this->setBunchesInBeam2(bunches2);
258  this->setCollidingBunches(collidingBunches);
259  this->setTargetBunches(targetBunches);
260  this->setFillType(fillType);
261  this->setParticleTypeForBeam1(particleType1);
262  this->setParticleTypeForBeam2(particleType2);
263  this->setCrossingAngle(angle);
264  this->setBetaStar(beta);
265  this->setIntensityForBeam1(intensity1);
266  this->setIntensityForBeam2(intensity2);
267  this->setEnergy(energy);
268  this->setCreationTime(createTime);
269  this->setBeginTime(beginTime);
270  this->setEndTime(endTime);
271  this->setInjectionScheme(scheme);
272  this->setBunchBitsetForBeam1(bunchConf1);
273  this->setBunchBitsetForBeam2(bunchConf2);
274 }
275 
276 void FillInfo::print(std::stringstream& ss) const {
277  ss << "LHC fill: " << m_lhcFill << std::endl
278  << "Bunches in Beam 1: " << m_bunches1 << std::endl
279  << "Bunches in Beam 2: " << m_bunches2 << std::endl
280  << "Colliding bunches at IP5: " << m_collidingBunches << std::endl
281  << "Target bunches at IP5: " << m_targetBunches << std::endl
282  << "Fill type: " << fillTypeToString(m_fillType) << std::endl
283  << "Particle type for Beam 1: " << particleTypeToString(m_particles1) << std::endl
284  << "Particle type for Beam 2: " << particleTypeToString(m_particles2) << std::endl
285  << "Crossing angle (urad): " << m_crossingAngle << std::endl
286  << "Beta star (cm): " << m_betastar << std::endl
287  << "Average Intensity for Beam 1 (number of charges): " << m_intensity1 << std::endl
288  << "Average Intensity for Beam 2 (number of charges): " << m_intensity2 << std::endl
289  << "Energy (GeV): " << m_energy << std::endl
290  << "Creation time of the fill: " << boost::posix_time::to_iso_extended_string(cond::time::to_boost(m_createTime))
291  << std::endl
292  << "Begin time of Stable Beam flag: "
293  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(m_beginTime)) << std::endl
294  << "End time of the fill: " << boost::posix_time::to_iso_extended_string(cond::time::to_boost(m_endTime))
295  << std::endl
296  << "Injection scheme as given by LPC: " << m_injectionScheme << std::endl;
297  std::vector<unsigned short> bunchVector1 = this->bunchConfigurationForBeam1();
298  std::vector<unsigned short> bunchVector2 = this->bunchConfigurationForBeam2();
299  ss << "Bunches filled for Beam 1 (total " << bunchVector1.size() << "): ";
300  std::copy(bunchVector1.begin(), bunchVector1.end(), std::ostream_iterator<unsigned short>(ss, ", "));
301  ss << std::endl;
302  ss << "Bunches filled for Beam 2 (total " << bunchVector2.size() << "): ";
303  std::copy(bunchVector2.begin(), bunchVector2.end(), std::ostream_iterator<unsigned short>(ss, ", "));
304  ss << std::endl;
305 }
306 
307 //protected getters
308 std::bitset<FillInfo::bunchSlots + 1> const& FillInfo::bunchBitsetForBeam1() const { return m_bunchConfiguration1; }
309 
310 std::bitset<FillInfo::bunchSlots + 1> const& FillInfo::bunchBitsetForBeam2() const { return m_bunchConfiguration2; }
311 
312 //protected setters
313 void FillInfo::setBunchBitsetForBeam1(std::bitset<FillInfo::bunchSlots + 1> const& bunchConfiguration) {
314  m_bunchConfiguration1 = bunchConfiguration;
315 }
316 
317 void FillInfo::setBunchBitsetForBeam2(std::bitset<FillInfo::bunchSlots + 1> const& bunchConfiguration) {
318  m_bunchConfiguration2 = bunchConfiguration;
319 }
320 
321 std::ostream& operator<<(std::ostream& os, FillInfo fillInfo) {
322  std::stringstream ss;
323  fillInfo.print(ss);
324  os << ss.str();
325  return os;
326 }
fillTypeToString
static std::string fillTypeToString(FillInfo::FillTypeId const &fillType)
Definition: FillInfo.cc:20
FillInfo::bunchesInBeam2
unsigned const short bunchesInBeam2() const
Definition: FillInfo.cc:145
FillInfo::XE54
Definition: FillInfo.h:16
mps_fire.i
i
Definition: mps_fire.py:355
FillInfo::AR18
Definition: FillInfo.h:16
FillInfo::setBunchesInBeam2
void setBunchesInBeam2(unsigned short const &bunches)
Definition: FillInfo.cc:207
FillInfo::m_particles2
ParticleTypeId m_particles2
Definition: FillInfo.h:153
FillInfo::setParticleTypeForBeam1
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
Definition: FillInfo.cc:215
funct::false
false
Definition: Factorize.h:34
FillInfo::targetBunches
unsigned const short targetBunches() const
Definition: FillInfo.cc:149
FillInfo::setParticleTypeForBeam2
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
Definition: FillInfo.cc:217
cond::time::to_boost
boost::posix_time::ptime to_boost(Time_t iValue)
Definition: TimeConversions.h:39
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
FillInfo::setCrossingAngle
void setCrossingAngle(float const &angle)
Definition: FillInfo.cc:219
FillInfo::m_bunches1
unsigned short m_bunches1
Definition: FillInfo.h:151
BeamSpotFakeParameters_cfi.betaStar
betaStar
Definition: BeamSpotFakeParameters_cfi.py:19
FillInfo::setTargetBunches
void setTargetBunches(unsigned short const &targetBunches)
Definition: FillInfo.cc:211
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
FillInfo
Definition: FillInfo.h:13
FillInfo::m_lhcFill
unsigned short m_lhcFill
Definition: FillInfo.h:150
FillInfo::injectionScheme
const std::string & injectionScheme() const
Definition: FillInfo.cc:173
FillInfo::crossingAngle
const float crossingAngle() const
Definition: FillInfo.cc:157
FillInfo::isData
const bool isData() const
Definition: FillInfo.cc:141
FillInfo::m_createTime
cond::Time_t m_createTime
Definition: FillInfo.h:155
FillInfo::print
void print(std::stringstream &ss) const
Definition: FillInfo.cc:276
FillInfo::COSMICS
Definition: FillInfo.h:15
FillInfo::bunchBitsetForBeam1
const std::bitset< bunchSlots+1 > & bunchBitsetForBeam1() const
Definition: FillInfo.cc:308
FillInfo::particleTypeForBeam2
const ParticleTypeId particleTypeForBeam2() const
Definition: FillInfo.cc:155
FillInfo::m_collidingBunches
unsigned short m_collidingBunches
Definition: FillInfo.h:151
FillInfo::FillInfo
FillInfo()
Definition: FillInfo.cc:72
FillInfo::m_particles1
ParticleTypeId m_particles1
Definition: FillInfo.h:153
FillInfo::NONE
Definition: FillInfo.h:16
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
cms::cuda::bs
bs
Definition: HistoContainer.h:127
FillInfo::m_intensity1
float m_intensity1
Definition: FillInfo.h:154
FillInfo::setBunchBitsetForBeam2
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:317
FillInfo::fillNumber
unsigned const short fillNumber() const
Definition: FillInfo.cc:139
FillInfo::setCreationTime
void setCreationTime(cond::Time_t const &createTime)
Definition: FillInfo.cc:229
FillInfo::bunchConfigurationForBeam1
std::vector< unsigned short > bunchConfigurationForBeam1() const
Definition: FillInfo.cc:196
FillInfo::m_injectionScheme
std::string m_injectionScheme
Definition: FillInfo.h:156
FillInfo::setBetaStar
void setBetaStar(float const &betaStar)
Definition: FillInfo.cc:221
FillInfo::setIntensityForBeam2
void setIntensityForBeam2(float const &intensity)
Definition: FillInfo.cc:225
FillInfo::setBeamInfo
void setBeamInfo(unsigned short const &bunches1, unsigned short const &bunches2, unsigned short const &collidingBunches, unsigned short const &targetBunches, FillTypeId const &fillType, ParticleTypeId const &particleType1, ParticleTypeId const &particleType2, float const &angle, float const &beta, float const &intensity1, float const &intensity2, float const &energy, cond::Time_t const &createTime, cond::Time_t const &beginTime, cond::Time_t const &endTime, std::string const &scheme, std::bitset< bunchSlots+1 > const &bunchConf1, std::bitset< bunchSlots+1 > const &bunchConf2)
Definition: FillInfo.cc:238
FillInfo::setCollidingBunches
void setCollidingBunches(unsigned short const &collidingBunches)
Definition: FillInfo.cc:209
FillInfo::IONS
Definition: FillInfo.h:15
FillInfo::m_intensity2
float m_intensity2
Definition: FillInfo.h:154
FillInfo::m_targetBunches
unsigned short m_targetBunches
Definition: FillInfo.h:151
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
FillInfo::D
Definition: FillInfo.h:16
FillInfo::isBunchInBeam2
bool isBunchInBeam2(size_t const &bunch) const
Definition: FillInfo.cc:189
FillInfo::isBunchInBeam1
bool isBunchInBeam1(size_t const &bunch) const
Definition: FillInfo.cc:183
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FillInfo::endTime
const cond::Time_t endTime() const
Definition: FillInfo.cc:171
FillInfo::setIntensityForBeam1
void setIntensityForBeam1(float const &intensity)
Definition: FillInfo.cc:223
FillInfo::setEndTime
void setEndTime(cond::Time_t const &endTime)
Definition: FillInfo.cc:233
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
FillInfo::bunchBitsetForBeam2
const std::bitset< bunchSlots+1 > & bunchBitsetForBeam2() const
Definition: FillInfo.cc:310
FillInfo::PROTON
Definition: FillInfo.h:16
FillInfo::m_crossingAngle
float m_crossingAngle
Definition: FillInfo.h:154
FillInfo::beginTime
const cond::Time_t beginTime() const
Definition: FillInfo.cc:169
FillInfo::m_betastar
float m_betastar
Definition: FillInfo.h:154
FillInfo::m_beginTime
cond::Time_t m_beginTime
Definition: FillInfo.h:155
FillInfo::setInjectionScheme
void setInjectionScheme(std::string const &injectionScheme)
Definition: FillInfo.cc:235
FillInfo::setFillType
void setFillType(FillTypeId const &fillType)
Definition: FillInfo.cc:213
FillInfo::m_bunches2
unsigned short m_bunches2
Definition: FillInfo.h:151
bitsetToVector
static std::vector< unsigned short > bitsetToVector(std::bitset< FillInfo::bunchSlots+1 > const &bs)
Definition: FillInfo.cc:8
FillInfo::bunchConfigurationForBeam2
std::vector< unsigned short > bunchConfigurationForBeam2() const
Definition: FillInfo.cc:200
FillInfo::intensityForBeam2
const float intensityForBeam2() const
Definition: FillInfo.cc:163
FillInfo::UNKNOWN
Definition: FillInfo.h:15
generator_cfi.scheme
scheme
Definition: generator_cfi.py:22
FillInfo::energy
const float energy() const
Definition: FillInfo.cc:165
FillInfo::createTime
const cond::Time_t createTime() const
Definition: FillInfo.cc:167
FillInfo::FillType
FillType
Definition: FillInfo.h:15
SiStripSubdetector::UNKNOWN
Definition: SiStripEnums.h:5
FillInfo::m_bunchConfiguration1
std::bitset< bunchSlots+1 > m_bunchConfiguration1
Definition: FillInfo.h:160
FillInfo::fillType
const FillTypeId fillType() const
Definition: FillInfo.cc:151
FillInfo::m_isData
bool m_isData
Definition: FillInfo.h:149
FillInfo::setBunchBitsetForBeam1
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:313
FillInfo::is25nsBunchSpacing
bool is25nsBunchSpacing() const
Definition: FillInfo.cc:177
operator<<
std::ostream & operator<<(std::ostream &os, FillInfo fillInfo)
Definition: FillInfo.cc:321
FillInfo::PB82
Definition: FillInfo.h:16
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
NONE
Definition: TkAlStyle.cc:47
FillInfo::m_endTime
cond::Time_t m_endTime
Definition: FillInfo.h:155
FillInfo::m_energy
float m_energy
Definition: FillInfo.h:154
FillInfo::GAP
Definition: FillInfo.h:15
FillInfo::collidingBunches
unsigned const short collidingBunches() const
Definition: FillInfo.cc:147
FillInfo::setFill
void setFill(unsigned short const &lhcFill, bool const &fromData=true)
Definition: FillInfo.cc:115
FillInfo::bunchesInBeam1
unsigned const short bunchesInBeam1() const
Definition: FillInfo.cc:143
FillInfo.h
TimeConversions.h
FillInfo::m_bunchConfiguration2
std::bitset< bunchSlots+1 > m_bunchConfiguration2
Definition: FillInfo.h:160
FillInfo::intensityForBeam1
const float intensityForBeam1() const
Definition: FillInfo.cc:161
FillInfo::setBeginTime
void setBeginTime(cond::Time_t const &beginTime)
Definition: FillInfo.cc:231
PbPb_ZMuSkimMuonDPG_cff.particleType
particleType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:27
FillInfo::m_fillType
FillTypeId m_fillType
Definition: FillInfo.h:152
FillInfo::setBunchesInBeam1
void setBunchesInBeam1(unsigned short const &bunches)
Definition: FillInfo.cc:205
cond::serialization::equal
bool equal(const T &first, const T &second)
Definition: Equal.h:32
FillInfo::~FillInfo
~FillInfo()
Definition: FillInfo.cc:112
particleTypeToString
static std::string particleTypeToString(FillInfo::ParticleTypeId const &particleType)
Definition: FillInfo.cc:45
FillInfo::setEnergy
void setEnergy(float const &energy)
Definition: FillInfo.cc:227
FillInfo::PROTONS
Definition: FillInfo.h:15
FillInfo::betaStar
const float betaStar() const
Definition: FillInfo.cc:159
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14
FillInfo::particleTypeForBeam1
const ParticleTypeId particleTypeForBeam1() const
Definition: FillInfo.cc:153
FillInfo::ParticleType
ParticleType
Definition: FillInfo.h:16