CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Level1TriggerRates.cc
Go to the documentation of this file.
1 /*
2  * File: DataFormats/Scalers/src/Level1TriggerRates.cc (W.Badgett)
3  */
4 
7 
8 #include <iostream>
9 #include <cstdio>
10 
12  version_(0),
13  collectionTime_(0,0),
14  deltaNS_(0),
15  deltaT_(0.0),
16  gtTriggersRate_(0.0),
17  gtEventsRate_(0.0),
18  collectionTimeLumiSeg_(0,0),
19  triggersPhysicsGeneratedFDLRate_(0.0),
20  triggersPhysicsLostRate_(0.0),
21  triggersPhysicsLostBeamActiveRate_(0.0),
22  triggersPhysicsLostBeamInactiveRate_(0.0),
23  l1AsPhysicsRate_(0.0),
24  l1AsRandomRate_(0.0),
25  l1AsTestRate_(0.0),
26  l1AsCalibrationRate_(0.0),
27  deadtimePercent_(0.0),
28  deadtimeBeamActivePercent_(0.0),
29  deadtimeBeamActiveTriggerRulesPercent_(0.0),
30  deadtimeBeamActiveCalibrationPercent_(0.0),
31  deadtimeBeamActivePrivateOrbitPercent_(0.0),
32  deadtimeBeamActivePartitionControllerPercent_(0.0),
33  deadtimeBeamActiveTimeSlotPercent_(0.0),
34  gtAlgoCountsRate_(Level1TriggerScalers::nLevel1Triggers),
35  gtTechCountsRate_(Level1TriggerScalers::nLevel1TestTriggers)
36 {
37 }
38 
40 {
42 }
43 
45  int runNumber)
46 {
48  computeRates(s,runNumber);
49 }
50 
52  Level1TriggerScalers const& s2)
53 {
55 }
56 
58  Level1TriggerScalers const& s2,
59  int runNumber)
60 {
62  computeRates(s1,s2,runNumber);
63 }
64 
66 
67 
70 
72  int run)
73 {
74  version_ = t.version();
75 
76  collectionTime_.set_tv_sec(static_cast<long>(t.collectionTime().tv_sec));
78 
81 
82  collectionTimeLumiSeg_.set_tv_sec(static_cast<long>(t.collectionTimeLumiSeg().tv_sec));
84 
93 
98 
112 
113  const std::vector<unsigned int> gtAlgoCounts = t.gtAlgoCounts();
114  for ( std::vector<unsigned int>::const_iterator counts = gtAlgoCounts.begin();
115  counts != gtAlgoCounts.end(); ++counts)
116  {
117  gtAlgoCountsRate_.push_back(Level1TriggerScalers::rateLS(*counts,run));
118  }
119 
120  const std::vector<unsigned int> gtTechCounts = t.gtTechCounts();
121  for ( std::vector<unsigned int>::const_iterator counts = gtTechCounts.begin();
122  counts != gtTechCounts.end(); ++counts)
123  {
124  gtTechCountsRate_.push_back(Level1TriggerScalers::rateLS(*counts,run));
125  }
126 
127  deltaNS_ = 0ULL;
128  deltaT_ = 0.0;
129 }
130 
132  Level1TriggerScalers const& t2)
133 {
135 }
136 
138  Level1TriggerScalers const& t2,
139  int run)
140 {
141  computeRates(t1,run);
142 
143  unsigned long long zeit1 =
144  ( (unsigned long long)t1.collectionTime().tv_sec * 1000000000ULL)|
145  ( (unsigned long long)t1.collectionTime().tv_nsec );
146  unsigned long long zeit2 =
147  ( (unsigned long long)t2.collectionTime().tv_sec * 1000000000ULL)|
148  ( (unsigned long long)t2.collectionTime().tv_nsec );
149 
150  deltaT_ = 0.0;
151  deltaNS_ = 0ULL;
152  if ( zeit2 > zeit1 )
153  {
154  deltaNS_ = zeit2 - zeit1;
155  deltaT_ = ((double)deltaNS_) / 1.0E9;
156  gtTriggersRate_ =
157  ((double)(t2.gtTriggers()-t1.gtTriggers()))/deltaT_;
158  gtEventsRate_ =
159  ((double)(t2.gtEvents()-t1.gtEvents()))/deltaT_;
160  }
161 }
162 
163 
165 std::ostream& operator<<(std::ostream& s, const Level1TriggerRates& c)
166 {
167  char line[128];
168  char zeitHeaven[128];
169  struct tm * horaHeaven;
170 
171  s << "Level1TriggerRates Version: " << c.version()
172  << " Rates in Hz, DeltaT: ";
173 
174  if ( c.deltaNS() > 0 )
175  {
176  s << c.deltaT() << " sec" << std::endl;
177  }
178  else
179  {
180  s << "n/a" << std::endl;
181  }
182 
183  struct timespec secondsToHeaven = c.collectionTime();
184  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
185  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
186  sprintf(line, " CollectionTime: %s.%9.9d" ,
187  zeitHeaven, (int)secondsToHeaven.tv_nsec);
188  s << line << std::endl;
189 
190  sprintf(line, " GtTriggersRate: %22.3f Hz",
191  c.gtTriggersRate());
192  s << line << std::endl;
193 
194  sprintf(line, " GtEventsRate: %22.3f Hz",
195  c.gtEventsRate());
196  s << line << std::endl;
197 
198  secondsToHeaven = c.collectionTimeLumiSeg();
199  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
200  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
201  sprintf(line, " CollectionTimeLumiSeg: %s.%9.9d" ,
202  zeitHeaven, (int)secondsToHeaven.tv_nsec);
203  s << line << std::endl;
204 
205  sprintf(line, " TriggersPhysicsGeneratedFDLRate: %22.3f Hz",
207  s << line << std::endl;
208 
209  sprintf(line, " TriggersPhysicsLostRate: %22.3f Hz",
211  s << line << std::endl;
212 
213  sprintf(line, " TriggersPhysicsLostBeamActiveRate: %22.3f Hz",
215  s << line << std::endl;
216 
217  sprintf(line, " TriggersPhysicsLostBeamInactiveRate: %22.3f Hz",
219  s << line << std::endl;
220 
221  sprintf(line, " L1AsPhysicsRate: %22.3f Hz",
222  c.l1AsPhysicsRate());
223  s << line << std::endl;
224 
225  sprintf(line, " L1AsRandomRate: %22.3f Hz",
226  c.l1AsRandomRate());
227  s << line << std::endl;
228 
229  sprintf(line, " L1AsTestRate: %22.3f Hz",
230  c.l1AsTestRate());
231  s << line << std::endl;
232 
233  sprintf(line, " L1AsCalibrationRate: %22.3f Hz",
234  c.l1AsCalibrationRate());
235  s << line << std::endl;
236 
237  sprintf(line, " DeadtimePercent: %22.3f %%",
238  c.deadtimePercent());
239  s << line << std::endl;
240 
241  sprintf(line, " DeadtimeBeamActivePercent: %22.3f %%",
243  s << line << std::endl;
244 
245  sprintf(line, " DeadtimeBeamActiveTriggerRulesPercent: %22.3f %%",
247  s << line << std::endl;
248 
249  sprintf(line, " DeadtimeBeamActiveCalibrationPercent: %22.3f %%",
251  s << line << std::endl;
252 
253  sprintf(line, " DeadtimeBeamActivePrivateOrbitPercent: %22.3f %%",
255  s << line << std::endl;
256 
257  sprintf(line, " DeadtimeBeamActivePartitionControllerPercent:%22.3f %%",
259  s << line << std::endl;
260 
261  sprintf(line, " DeadtimeBeamActiveTimeSlotPercent: %22.3f %%",
263  s << line << std::endl;
264 
265  s << "Physics GtAlgoCountsRate, Hz" << std::endl;
266  const std::vector<double> gtAlgoCountsRate = c.gtAlgoCountsRate();
267  int length = gtAlgoCountsRate.size() / 4;
268  for ( int i=0; i<length; i++)
269  {
270  sprintf(line,
271  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
272  i, gtAlgoCountsRate[i],
273  (i+length), gtAlgoCountsRate[i+length],
274  (i+(length*2)), gtAlgoCountsRate[i+(length*2)],
275  (i+(length*3)), gtAlgoCountsRate[i+(length*3)]);
276  s << line << std::endl;
277  }
278 
279  s << "Test GtTechCountsRate, Hz" << std::endl;
280  const std::vector<double> gtTechCountsRate = c.gtTechCountsRate();
281  length = gtTechCountsRate.size() / 4;
282  for ( int i=0; i<length; i++)
283  {
284  sprintf(line,
285  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
286  i, gtTechCountsRate[i],
287  (i+length), gtTechCountsRate[i+length],
288  (i+(length*2)), gtTechCountsRate[i+(length*2)],
289  (i+(length*3)), gtTechCountsRate[i+(length*3)]);
290  s << line << std::endl;
291  }
292  return s;
293 }
double deadtimeBeamActiveTimeSlotPercent_
double l1AsTestRate() const
int i
Definition: DBlmapReader.cc:9
static double rateLS(unsigned long long counts)
unsigned long long gtEvents() const
unsigned long long deadtimeBeamActive() const
unsigned long long deadtimeBeamActivePrivateOrbit() const
unsigned long long triggersPhysicsGeneratedFDL() const
double deadtimeBeamActivePartitionControllerPercent() const
double triggersPhysicsGeneratedFDLRate() const
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
unsigned long long l1AsRandom() const
unsigned long long deltaNS_
std::vector< unsigned int > gtTechCounts() const
unsigned long long triggersPhysicsLost() const
unsigned long long triggersPhysicsLostBeamActive() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
double l1AsRandomRate() const
double triggersPhysicsLostBeamActiveRate() const
unsigned long long l1AsCalibration() const
tuple s2
Definition: indexGen.py:106
double gtTriggersRate() const
std::vector< double > gtAlgoCountsRate() const
double triggersPhysicsLostBeamInactiveRate_
double triggersPhysicsLostBeamActiveRate_
double deadtimeBeamActiveCalibrationPercent_
int version() const
get the data
std::vector< double > gtAlgoCountsRate_
double triggersPhysicsLostBeamInactiveRate() const
double deadtimeBeamActivePercent() const
std::vector< unsigned int > gtAlgoCounts() const
double deadtimeBeamActiveTriggerRulesPercent_
double deadtimeBeamActiveTriggerRulesPercent() const
double deadtimeBeamActivePrivateOrbitPercent() const
unsigned long long l1AsPhysics() const
static double percentLSActive(unsigned long long counts)
unsigned long long deadtimeBeamActiveTriggerRules() const
unsigned long long deltaNS() const
timespec collectionTimeLumiSeg()
unsigned long long l1AsTest() const
double deadtimeBeamActiveTimeSlotPercent() const
double gtEventsRate() const
unsigned long long deadtime() const
unsigned long long gtTriggers() const
static double percentLS(unsigned long long counts)
float gtTriggersRate() const
void computeRates(Level1TriggerScalers const &t1)
std::vector< double > gtTechCountsRate_
struct timespec collectionTimeLumiSeg() const
unsigned long long deadtimeBeamActiveTimeSlot() const
double triggersPhysicsGeneratedFDLRate_
double deadtimeBeamActivePrivateOrbitPercent_
unsigned long long deadtimeBeamActiveCalibration() const
double deadtimePercent() const
double triggersPhysicsLostRate() const
double deadtimeBeamActiveCalibrationPercent() const
unsigned long long triggersPhysicsLostBeamInactive() const
void set_tv_sec(long value)
Definition: TimeSpec.h:26
std::vector< double > gtTechCountsRate() const
unsigned long long deadtimeBeamActivePartitionController() const
double l1AsCalibrationRate() const
double deadtimeBeamActivePartitionControllerPercent_
double l1AsPhysicsRate() const
struct timespec collectionTime() const
double deltaT() const