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 }
float const intensityForBeam2() const
Definition: FillInfo.cc:163
ParticleTypeId m_particles1
Definition: FillInfo.h:153
float const crossingAngle() const
Definition: FillInfo.cc:157
void setBetaStar(float const &betaStar)
Definition: FillInfo.cc:221
void setCrossingAngle(float const &angle)
Definition: FillInfo.cc:219
std::bitset< bunchSlots+1 > m_bunchConfiguration2
Definition: FillInfo.h:160
std::vector< unsigned short > bunchConfigurationForBeam2() const
Definition: FillInfo.cc:200
unsigned short m_bunches1
Definition: FillInfo.h:151
ParticleType
Definition: FillInfo.h:16
unsigned short const fillNumber() const
Definition: FillInfo.cc:139
unsigned short m_bunches2
Definition: FillInfo.h:151
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
bool isBunchInBeam1(size_t const &bunch) const
Definition: FillInfo.cc:183
void setCollidingBunches(unsigned short const &collidingBunches)
Definition: FillInfo.cc:209
float const energy() const
Definition: FillInfo.cc:165
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:317
cond::Time_t m_beginTime
Definition: FillInfo.h:155
void setIntensityForBeam2(float const &intensity)
Definition: FillInfo.cc:225
unsigned short m_lhcFill
Definition: FillInfo.h:150
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: FillInfo.cc:313
unsigned short const bunchesInBeam2() const
Definition: FillInfo.cc:145
void setFillType(FillTypeId const &fillType)
Definition: FillInfo.cc:213
float m_crossingAngle
Definition: FillInfo.h:154
float m_betastar
Definition: FillInfo.h:154
void setIntensityForBeam1(float const &intensity)
Definition: FillInfo.cc:223
std::string m_injectionScheme
Definition: FillInfo.h:156
void setBunchesInBeam1(unsigned short const &bunches)
Definition: FillInfo.cc:205
ParticleTypeId const particleTypeForBeam2() const
Definition: FillInfo.cc:155
bool equal(const T &first, const T &second)
Definition: Equal.h:32
FillInfo()
Definition: FillInfo.cc:72
cond::Time_t const beginTime() const
Definition: FillInfo.cc:169
std::bitset< bunchSlots+1 > m_bunchConfiguration1
Definition: FillInfo.h:160
cond::Time_t const endTime() const
Definition: FillInfo.cc:171
unsigned short const collidingBunches() const
Definition: FillInfo.cc:147
unsigned long long Time_t
Definition: Time.h:14
static std::vector< unsigned short > bitsetToVector(std::bitset< FillInfo::bunchSlots+1 > const &bs)
Definition: FillInfo.cc:8
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam1() const
Definition: FillInfo.cc:308
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
Definition: FillInfo.cc:217
void setEndTime(cond::Time_t const &endTime)
Definition: FillInfo.cc:233
cond::Time_t m_endTime
Definition: FillInfo.h:155
unsigned short m_targetBunches
Definition: FillInfo.h:151
bool isBunchInBeam2(size_t const &bunch) const
Definition: FillInfo.cc:189
float m_energy
Definition: FillInfo.h:154
void setTargetBunches(unsigned short const &targetBunches)
Definition: FillInfo.cc:211
std::vector< unsigned short > bunchConfigurationForBeam1() const
Definition: FillInfo.cc:196
FillTypeId m_fillType
Definition: FillInfo.h:152
bool is25nsBunchSpacing() const
Definition: FillInfo.cc:177
void print(std::stringstream &ss) const
Definition: FillInfo.cc:276
void setFill(unsigned short const &lhcFill, bool const &fromData=true)
Definition: FillInfo.cc:115
~FillInfo()
Definition: FillInfo.cc:112
FillTypeId const fillType() const
Definition: FillInfo.cc:151
bool m_isData
Definition: FillInfo.h:149
unsigned short m_collidingBunches
Definition: FillInfo.h:151
float m_intensity1
Definition: FillInfo.h:154
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
Definition: FillInfo.cc:215
float const intensityForBeam1() const
Definition: FillInfo.cc:161
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam2() const
Definition: FillInfo.cc:310
cond::Time_t m_createTime
Definition: FillInfo.h:155
cond::Time_t const createTime() const
Definition: FillInfo.cc:167
static std::string fillTypeToString(FillInfo::FillTypeId const &fillType)
Definition: FillInfo.cc:20
unsigned short const bunchesInBeam1() const
Definition: FillInfo.cc:143
static std::string particleTypeToString(FillInfo::ParticleTypeId const &particleType)
Definition: FillInfo.cc:45
void setBeginTime(cond::Time_t const &beginTime)
Definition: FillInfo.cc:231
std::string const & injectionScheme() const
Definition: FillInfo.cc:173
std::ostream & operator<<(std::ostream &os, FillInfo fillInfo)
Definition: FillInfo.cc:321
ParticleTypeId const particleTypeForBeam1() const
Definition: FillInfo.cc:153
void setBunchesInBeam2(unsigned short const &bunches)
Definition: FillInfo.cc:207
ParticleTypeId m_particles2
Definition: FillInfo.h:153
void setEnergy(float const &energy)
Definition: FillInfo.cc:227
Definition: TkAlStyle.h:43
float const betaStar() const
Definition: FillInfo.cc:159
unsigned short const targetBunches() const
Definition: FillInfo.cc:149
bool const isData() const
Definition: FillInfo.cc:141
boost::posix_time::ptime to_boost(Time_t iValue)
void setCreationTime(cond::Time_t const &createTime)
Definition: FillInfo.cc:229
void setInjectionScheme(std::string const &injectionScheme)
Definition: FillInfo.cc:235
string endTime
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
float m_intensity2
Definition: FillInfo.h:154