CFEL - ASG Software Suite  2.5.0
CASS
operations.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 Lutz Foucar
2 // (C) 2010 Thomas White - Updated to (outdated) PP framework
3 
4 /**
5  * @file operations.cpp file contains definition of processors that will
6  * operate on results of other processors
7  * @author Lutz Foucar
8  */
9 
10 #include <QtCore/QString>
11 #include <iterator>
12 #include <algorithm>
13 #include <numeric>
14 
15 #include "cass.h"
16 #include "operations.h"
17 #include "convenience_functions.h"
18 #include "cass_settings.h"
19 #include "log.h"
20 #include "input_base.h"
21 
22 
23 using namespace cass;
24 using namespace std;
25 using tr1::bind;
26 using tr1::placeholders::_1;
27 using tr1::placeholders::_2;
28 using tr1::placeholders::_3;
29 using tr1::placeholders::_4;
30 using tr1::placeholders::_5;
31 
32 namespace cass
33 {
34 /** provide own implementation of min_element to be able to compile
35  *
36  * It will search for the largest element in range but only checking real numbers
37  *
38  * This is just a slighly modfied copy from the cpp reference guide
39  */
40 template <class ForwardIterator>
41 ForwardIterator max_element ( ForwardIterator first, ForwardIterator last )
42 {
43  if (first==last) return last;
44  ForwardIterator largest = first;
45  while (!std::isfinite(*largest))
46  {
47  if (largest == last)
48  return first;
49  ++largest;
50  }
51 
52  while (++first!=last)
53  if (std::isfinite(*first))
54  if (*largest<*first)
55  largest=first;
56  return largest;
57 }
58 
59 /** provide own implementation of min_element to be able to compile
60  *
61  * It will search for the smallest element in range but only checking real numbers
62  *
63  * This is just a slightly modified copy from the cpp reference guide
64  */
65 template <class ForwardIterator>
66 ForwardIterator min_element ( ForwardIterator first, ForwardIterator last )
67 {
68  if (first==last) return last;
69  ForwardIterator smallest = first;
70  while (!std::isfinite(*smallest))
71  {
72  if (smallest == last)
73  return first;
74  ++smallest;
75  }
76 
77  while (++first!=last)
78  if (std::isfinite(*first))
79  if (*first<*smallest)
80  smallest=first;
81  return smallest;
82 }
83 }//end namespace cass
84 
85 
86 // ************ Operation on two results *************
87 
88 pp1::pp1(const name_t & name)
89  : Processor(name)
90 {
91  loadSettings(0);
92 }
93 
94 void pp1::loadSettings(size_t)
95 {
96  CASSSettings s;
97  s.beginGroup("Processor");
99  setupGeneral();
100  _one = setupDependency("InputOne");
101  _two = setupDependency("InputTwo");
102  bool ret (setupCondition());
103  if ( !(_one && _two && ret) )
104  return;
105 
106  const result_t &one(_one->result());
107  const result_t &two(_two->result());
108  if (one.shape() != two.shape())
109  throw invalid_argument("pp1::loadSettings() '"+name()+
110  "': InputOne '" + one.name() +
111  "' with dimension '" + toString(one.dim()) +
112  "', memory size '" + toString(one.size()) +
113  "' and shape '" + toString(one.shape().first) +
114  "x" + toString(one.shape().second) +
115  "' differs from InputTwo '" + two.name() +
116  "' with has dimension '" + toString(two.dim()) +
117  "', memory size '" + toString(two.size()) +
118  "' and shape '" + toString(two.shape().first) +
119  "x" + toString(two.shape().second));
120 
121  string operation(s.value("Operation","+").toString().toStdString());
122  if (operation == "+")
123  _op = plus<float>();
124  else if (operation == "-")
125  _op = minus<float>();
126  else if (operation == "/")
127  _op = divides<float>();
128  else if (operation == "*")
129  _op = multiplies<float>();
130  else if (operation == "AND")
131  _op = logical_and<bool>();
132  else if (operation == "OR")
133  _op = logical_or<bool>();
134  else if (operation == ">")
135  _op = greater<float>();
136  else if (operation == ">=")
137  _op = greater_equal<float>();
138  else if (operation == "<")
139  _op = less<float>();
140  else if (operation == "<=")
141  _op = less_equal<float>();
142  else if (operation == "==")
143  _op = equal_to<float>();
144  else if (operation == "!=")
145  _op = not_equal_to<float>();
146  else
147  throw invalid_argument("pp1::loadSettings() '" + name() +
148  "': operation '" + operation + "' is unkown.");
149 
150  createHistList(_one->result().clone());
151 
152  Log::add(Log::INFO,"Processor '" + name() +
153  "' will do operation '"+ operation + "'with '" + _one->name() +
154  "' as first and '" + _two->name() + "' as second argument" +
155  "'. Condition is '" + _condition->name() + "'");
156 }
157 
158 void pp1::process(const CASSEvent& evt, result_t &result)
159 {
160  const result_t &one(_one->result(evt.id()));
161  QReadLocker lock1(&(one.lock));
162  const result_t &two(_two->result(evt.id()));
163  QReadLocker lock2(&(two.lock));
164 
165  transform(one.begin(),one.begin()+one.datasize(), two.begin(), result.begin(),
166  _op);
167 }
168 
169 
170 
171 
172 
173 
174 
175 
176 // ************ processor 2: operation with const value
177 
178 pp2::pp2(const name_t &name)
179  : Processor(name)
180 {
181  loadSettings(0);
182 }
183 
184 void pp2::loadSettings(size_t)
185 {
186  CASSSettings s;
187  s.beginGroup("Processor");
189  setupGeneral();
190  _hist = setupDependency("InputName");
191  bool ret (setupCondition());
192  QString valuekey("Value");
193  QString valueparam(s.value(valuekey,1).toString());
194  bool IsFloatValue(false);
195  result_t::value_t val(valueparam.toFloat(&IsFloatValue));
196  if (!IsFloatValue)
197  {
198  _valuePP = setupDependency(valuekey.toStdString());
199  ret = _valuePP && ret;
200  _retrieveValue = std::tr1::bind(&pp2::valueFromPP,this,_1);
201  }
202  else
203  {
204  _retrieveValue = std::tr1::bind(&pp2::valueFromConst,this,_1);
205  _value = val;
206  }
207  if (!(_hist && ret))
208  return;
209 
210  if (!IsFloatValue && _valuePP->result().dim() != 0)
211  throw invalid_argument("pp2::loadSettings() '"+ name()+ " value '" +
212  _valuePP->name() + "' is not a 0d result");
213 
214  string operation(s.value("Operation","+").toString().toStdString());
215  if (operation == "+")
216  _op = plus<float>();
217  else if (operation == "-")
218  _op = minus<float>();
219  else if (operation == "/")
220  _op = divides<float>();
221  else if (operation == "*")
222  _op = multiplies<float>();
223  else if (operation == "AND")
224  _op = logical_and<bool>();
225  else if (operation == "OR")
226  _op = logical_or<bool>();
227  else if (operation == ">")
228  _op = greater<float>();
229  else if (operation == ">=")
230  _op = greater_equal<float>();
231  else if (operation == "<")
232  _op = less<float>();
233  else if (operation == "<=")
234  _op = less_equal<float>();
235  else if (operation == "==")
236  _op = equal_to<float>();
237  else if (operation == "!=")
238  _op = not_equal_to<float>();
239  else
240  throw invalid_argument("pp2::loadSettings() '" + name() +
241  "': operation '" + operation + "' is unkown.");
242 
243  string valuePos(s.value("ValuePos","first").toString().toStdString());
244  if (valuePos == "first")
245  _setParamPos = std::tr1::bind(&pp2::ValAtFirst,this,_1);
246  else if (valuePos == "second")
247  _setParamPos = std::tr1::bind(&pp2::ValAtSecond,this,_1);
248  else
249  throw invalid_argument("pp2::loadSettings() '" + name() +
250  "': value position '" + valuePos + "' is unkown.");
251 
252  createHistList(_hist->result().clone());
253  Log::add(Log::INFO,"Processor '" + name() + "' operation '" + operation +
254  "' on '" + _hist->name() + "' with " +
255  (!IsFloatValue ? "value in '"+_valuePP->name() : "constant '"+
256  toString(_value)) +
257  "'. Condition is "+ _condition->name() + "'");
258 }
259 
261 {
262  return std::tr1::bind(_op,val,_1);
263 }
264 
266 {
267  return std::tr1::bind(_op,_1,val);
268 }
269 
271 {
272  return _value;
273 }
274 
276 {
277  const result_t &value(_valuePP->result(id));
278  QReadLocker lock(&value.lock);
279  return value.getValue();
280 }
281 
282 void pp2::process(const CASSEvent& evt, result_t &result)
283 {
284  const result_t &input(_hist->result(evt.id()));
285  QReadLocker lock(&input.lock);
286 
287  /** only do the operation on the datasize to avoid doing the operation on the
288  * statistics
289  */
290  transform(input.begin(), input.begin()+input.datasize(), result.begin(),
291  _setParamPos(_retrieveValue(evt.id())));
292 }
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 // ************ processor 4: Apply boolean NOT to 0D results *************
304 
305 pp4::pp4(const name_t &name)
306  : Processor(name)
307 {
308  loadSettings(0);
309 }
310 
311 void pp4::loadSettings(size_t)
312 {
313  setupGeneral();
314  _one = setupDependency("InputName");
315  bool ret (setupCondition());
316  if (!(_one && ret))
317  return;
318  if (_one->result().dim() != 0)
319  throw invalid_argument("pp4::loadSettings() '"+ name()+ " value '" +
320  _one->name() + "' is not a 0d result, but needs to be");
322  Log::add(Log::INFO,"Processor '" + name() + "' will apply NOT to Processor '" +
323  _one->name() + "'. Condition is '" + _condition->name() + "'");
324 }
325 
326 void pp4::process(const CASSEvent& evt, result_t &result)
327 {
328  const result_t &one(_one->result(evt.id()));
329  QReadLocker lock(&one.lock);
330 
331  result.setValue(!one.isTrue());
332 }
333 
334 
335 
336 
337 
338 
339 
340 
341 
342 
343 
344 // ********** processor 9: Check if results is in given range ************
345 
346 pp9::pp9(const name_t &name)
347  : Processor(name)
348 {
349  loadSettings(0);
350 }
351 
352 void pp9::loadSettings(size_t)
353 {
354  CASSSettings s;
355  s.beginGroup("Processor");
357  _range = make_pair(s.value("LowerLimit",0).toFloat(),
358  s.value("UpperLimit",0).toFloat());
359  setupGeneral();
360  _one = setupDependency("InputName");
361  bool ret (setupCondition());
362  if (!(_one && ret))
363  return;
365 
366  Log::add(Log::INFO,"Processor '" + name()
367  + "' will check whether hist in Processor '" + _one->name() +
368  "' is between '" + toString(_range.first) + "' and '" +
369  toString(_range.second) + "' Both values are exclusive." +
370  " Condition is '" + _condition->name() + "'");
371 }
372 
373 void pp9::process(const CASSEvent& evt, result_t &result)
374 {
375  const result_t &one(_one->result(evt.id()));
376  QReadLocker lock(&one.lock);
377 
378  /** only accumulate over the range that contains actual data */
379  const float value (accumulate(one.begin(), one.begin()+one.datasize(), 0.f));
380 
381  result.setValue(_range.first < value && value < _range.second);
382 }
383 
384 
385 
386 
387 
388 
389 // ********** processor 12: PP with constant value ************
390 
391 pp12::pp12(const name_t &name)
392  : Processor(name)
393 {
394  loadSettings(0);
395 }
396 
397 void pp12::loadSettings(size_t)
398 {
399  CASSSettings s;
400  s.beginGroup("Processor");
402  string type(s.value("ValueType","0D").toString().toStdString());
403  if (type == "0D")
404  {
406  }
407  else if (type == "1D")
408  {
410  (new result_t
411  (result_t::axe_t(s.value("XNbrBins",1).toInt(),
412  s.value("XLow",0).toFloat(),
413  s.value("XUp",1).toFloat(),
414  s.value("XTitle","x-axis").toString().toStdString()
415  )));
416  }
417  else if (type == "2D")
418  {
420  (new result_t
421  (result_t::axe_t(s.value("XNbrBins",1).toInt(),
422  s.value("XLow",0).toFloat(),
423  s.value("XUp",1).toFloat(),
424  s.value("XTitle","x-axis").toString().toStdString()),
425  result_t::axe_t(s.value("YNbrBins",1).toInt(),
426  s.value("YLow",0).toFloat(),
427  s.value("YUp",1).toFloat(),
428  s.value("YTitle","y-axis").toString().toStdString())));
429  }
430  else
431  {
432  throw invalid_argument("pp12::loadSettings(): '" + name() +
433  "' unknown valuetype '" + type + "' provided");
434  }
435 
436  float value(s.value("Value",0).toFloat());
437  if (name() == "DefaultTrueHist")
438  value = true;
439  if (name() == "DefaultFalseHist")
440  value = false;
441  fill(_res->begin(), _res->end(), value);
442 
443  _hide = s.value("Hide",true).toBool();
444 
445  Log::add(Log::INFO,"Processor '" + name() + "' has constant value of '" +
446  toString(value) + "' and is of type '" + type + "'");
447 }
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 // ************ processor 13: return the result (identity operation) *****
458 
459 pp13::pp13(const name_t &name)
460  : Processor(name)
461 {
462  loadSettings(0);
463 }
464 
465 void pp13::loadSettings(size_t)
466 {
467  setupGeneral();
468  _one = setupDependency("InputName");
469  bool ret (setupCondition());
470  if (!(_one && ret))
471  return;
472  createHistList(_one->result().clone());
473 
474  Log::add(Log::INFO,"Processor '" + name() +
475  "' will return a copy of Processor '" + _one->name() +
476  "'. Condition is '" + _condition->name() + "'");
477 }
478 
479 void pp13::process(const CASSEvent& evt, result_t &result)
480 {
481  const result_t &one(_one->result(evt.id()));
482  QReadLocker lock(&one.lock);
483 
484  result.assign(one);
485 }
486 
487 
488 
489 
490 
491 
492 
493 
494 
495 // *** pp14 ?: operator
496 
497 pp14::pp14(const name_t &name)
498  : Processor(name)
499 {
500  loadSettings(0);
501 }
502 
503 void pp14::loadSettings(size_t)
504 {
505  CASSSettings s;
506  s.beginGroup("Processor");
508  setupGeneral();
509 
510  _one = setupDependency("InputOne");
511  _two = setupDependency("InputTwo");
512 
513  bool ret (setupCondition());
514  if ( !(_one && _two && ret) )
515  return;
516 
517  const result_t &one(_one->result());
518  const result_t &two(_two->result());
519  if (one.dim() != two.dim())
520  throw invalid_argument("pp14::loadSettings() "+name()+": First '" +
521  _one->name() + "' with dimension '" +
522  toString(one.dim()) + "' and Second '" +
523  _two->name() + "' with dimension '" +
524  toString(two.dim()) +
525  "' don't have the same dimension");
526 
527  createHistList(_one->result().clone());
528 
529  Log::add(Log::INFO,"Processor '" + name() + "' returns '" +
530  _one->name() + "' when condition input is true and '" +
531  _two->name() + "' otherwise. Condition is "+ _condition->name());
532 }
533 
535 {
537  result_t &result(*(pointer->second));
538  QWriteLocker lock(&(result.lock));
539  result.id(evt.id());
540 
541  if (_condition->result(evt.id()).isTrue())
542  result.assign(_one->result(evt.id()));
543  else
544  result.assign(_two->result(evt.id()));
545 
546  _resultList.latest(pointer);
547 }
548 
549 
550 
551 
552 
553 
554 
555 
556 
557 // ********** processor 15: Check if value has changed ************
558 
559 pp15::pp15(const name_t &name)
560  : AccumulatingProcessor(name)
561 {
562  loadSettings(0);
563 }
564 
565 void pp15::loadSettings(size_t)
566 {
567  CASSSettings s;
568  s.beginGroup("Processor");
570  _previousVal = 0;
571  setupGeneral();
572  _hist = setupDependency("InputName");
573  bool ret (setupCondition());
574  if (!(_hist && ret))
575  return;
576  if (_hist->result().dim() != 0 )
577  throw runtime_error("pp15::loadSettings() " + name() +": Result '" +
578  _hist->name() + "' is not 0D, but needs to be");
579  _difference = s.value("Difference",0.).toFloat();
580  if (fabs(_difference) < std::numeric_limits<result_t::value_t>::epsilon() )
581  _difference = std::numeric_limits<result_t::value_t>::epsilon();
583 
584  Log::add(Log::INFO,"processor '" + name() +
585  "' will check whether the difference between the current and the" +
586  " previous value of '" + _hist->name() +
587  "' is bigger than '"+ toString(_difference) +
588  "'. It will use condition '" + _condition->name() +"'");
589 }
590 
591 void pp15::process(const CASSEvent& evt, result_t &result)
592 {
593  const result_t &val(_hist->result(evt.id()));
594  QReadLocker lock1(&val.lock);
595 
596  const float value(val.getValue());
597 
598  result.setValue(fabs(value-_previousVal) > _difference);
600 }
601 
602 
603 
604 
605 
606 
607 
608 
609 
610 
611 // ****************** processor 40: Threshold result ********************
612 
613 pp40::pp40(const name_t &name)
614  : Processor(name)
615 {
616  loadSettings(0);
617 }
618 
619 void pp40::loadSettings(size_t)
620 {
621  CASSSettings s;
622  s.beginGroup("Processor");
624  _one = setupDependency("InputName");
625  _userVal = s.value("UserVal",0.f).toFloat();
626  setupGeneral();
627  bool ret (setupCondition());
628  QString valuekey("Threshold");
629  QString valueparam(s.value(valuekey,1).toString());
630  bool IsFloatValue(false);
631  result_t::value_t val(valueparam.toFloat(&IsFloatValue));
632  if (!IsFloatValue)
633  {
634  _threshPP = setupDependency(valuekey.toStdString());
635  ret = _threshPP && ret;
636  _applyThresh = std::tr1::bind(&pp40::applyIdxwiseThreshold,this,_1,_2,_3);
637  }
638  else
639  {
640  _applyThresh = std::tr1::bind(&pp40::applyConstantThreshold,this,_1,_2,_3);
641  _threshold = val;
642  }
643  if (!(_one && ret))
644  return;
645  createHistList(_one->result().clone());
646  Log::add(Log::INFO,"Processor '" + name() +
647  "' will threshold Result in Processor '" + _one->name() +
648  (IsFloatValue ? ("' above '" + toString(_threshold)) :
649  ("' indexwise with threshold values defined in '" + _threshPP->name())) +
650  "'. In case the value is below the threshold it will be set to '" +
651  toString(_userVal) + "'. Condition is '" + _condition->name() + "'");
652 }
653 
655  const result_t::value_t& thresh)
656 {
657  return ((thresh < value) ? value : _userVal);
658 }
659 
661  result_t &out,
662  const CASSEvent::id_t & /*id*/)
663 {
664  transform(in.begin(), in.begin() + in.datasize(),
665  out.begin(),
666  std::tr1::bind(&pp40::threshold,this,_1,_threshold));
667 }
668 
670  result_t &out,
671  const CASSEvent::id_t &id)
672 {
673  const result_t &thresh(_threshPP->result(id));
674  QReadLocker lock(&thresh.lock);
675  transform(in.begin(), in.begin() + in.datasize(),
676  thresh.begin(),
677  out.begin(),
678  std::tr1::bind(&pp40::threshold,this,_1,_2));
679 }
680 
681 void pp40::process(const CASSEvent& evt, result_t &result)
682 {
683  const result_t &one(_one->result(evt.id()));
684  QReadLocker lock(&one.lock);
685 
686  _applyThresh(one, result, evt.id());
687 
688  /** only threshold the area containing data */
689 // transform(one.begin(), one.begin()+one.datasize(), result.begin(),
690 // bind2nd(threshold(), _threshold));
691 }
692 
693 
694 
695 
696 
697 // ****************** processor 41: more advanced threshold results ********************
698 
699 pp41::pp41(const name_t &name)
700  : Processor(name)
701 {
702  loadSettings(0);
703 }
704 
705 void pp41::loadSettings(size_t)
706 {
707  CASSSettings s;
708  s.beginGroup("Processor");
710  setupGeneral();
711  _one = setupDependency("InputName");
712  _threshold = setupDependency("ThresholdName");
713  bool ret (setupCondition());
714  if (!(_one && _threshold && ret))
715  return;
716  _userVal = s.value("UserVal",0.f).toFloat();
717  _lowerBound = s.value("LowerLimit",0.5).toFloat();
718  _upperBound = s.value("UpperLimit",1.5).toFloat();
719  if (_one->result().shape() != _threshold->result().shape())
720  throw invalid_argument("pp41:loadSettings() '" + name() +
721  "' Shape of hist to threshold '" + _one->name() + "'(" +
722  toString(_one->result().shape().first) + "x" +
723  toString(_one->result().shape().second) +
724  ") and the threshold '" + _threshold->name() + "' (" +
725  toString(_threshold->result().shape().first) + "x" +
726  toString(_threshold->result().shape().second) + ") differ.");
727  createHistList(_one->result().clone());
728  Log::add(Log::INFO,"Processor '" + name() +
729  "' will set bins in Processor '" + _one->name() +
730  "' to '" + toString(_userVal) + "' when the corresponding bin in '"
731  + _threshold->name() + "' is between '" + toString(_lowerBound) +
732  "' and '" + toString(_upperBound) +
733  "' where the boarders are exclusive. Condition is '"
734  + _condition->name() + "'");
735 }
736 
738 {
739  return (_lowerBound < checkval && checkval < _upperBound) ? _userVal : val;
740 }
741 
742 void pp41::process(const CASSEvent& evt, result_t &result)
743 {
744  const result_t &input(_one->result(evt.id()));
745  QReadLocker lock1(&input.lock);
746  const result_t &thresh(_threshold->result(evt.id()));
747  QReadLocker lock2(&thresh.lock);
748 
749  /** only check the data area of the input */
750  transform(input.begin(), input.begin()+input.datasize(), thresh.begin(),
751  result.begin(), std::tr1::bind(&pp41::checkrange,this,_1,_2));
752 }
753 
754 
755 
756 
757 
758 
759 
760 
761 
762 
763 
764 
765 // *** processors 50 projects 2d hist to 1d histo for a selected region of the axis ***
766 
767 pp50::pp50(const name_t &name)
768  : Processor(name)
769 {
770  loadSettings(0);
771 }
772 
773 void pp50::loadSettings(size_t)
774 {
775  CASSSettings s;
776  s.beginGroup("Processor");
778  setupGeneral();
779  _pHist = setupDependency("InputName");
780  bool ret (setupCondition());
781  if (!(ret && _pHist))
782  return;
783  if (_pHist->result().dim() != 2)
784  throw invalid_argument("pp50::loadSettings()'" + name() +
785  "': Result '" + _pHist->name() +
786  "' is not a 2D Result.");
787  const result_t &hist(_pHist->result());
788 
789  const result_t::axe_t &xAxis(hist.axis(result_t::xAxis));
790  const result_t::axe_t &yAxis(hist.axis(result_t::yAxis));
791  _nX = xAxis.nBins;
792 
793  pair<float,float> userRange(make_pair(s.value("Low",-1e6).toFloat(),
794  s.value("Up", 1e6).toFloat()));
795  if (userRange.first >= userRange.second)
796  throw invalid_argument("pp50::loadSettings: '"+name()+"' Low'" +
797  toString(userRange.first) +
798  "' is bigger or equal to Up'" +
799  toString(userRange.second) + "'");
800  string axis(s.value("Axis","xAxis").toString().toStdString());
801  if (axis == "xAxis")
802  {
803  _xRange = make_pair(0,xAxis.nBins);
804  _yRange.first = yAxis.bin(userRange.first);
805  _yRange.second = yAxis.bin(userRange.second);
806  if (_yRange.first == _yRange.second)
807  throw invalid_argument("pp50::loadSettings: '" + name() +
808  "': Low'" + toString(userRange.first) +
809  "' is giving the the same row as Up'" +
810  toString(userRange.second) + "'");
811  if (_yRange.first < 0)
812  throw invalid_argument("pp50::loadSettings: '" + name() +
813  "': Low'" + toString(userRange.first) +
814  "' is smaller than the lowest possible value '" +
815  toString(yAxis.low) + "'");
816  if (static_cast<int>(yAxis.nBins) < _yRange.first)
817  throw invalid_argument("pp50::loadSettings: '" + name() +
818  "': Low '" + toString(userRange.first) +
819  "' is higher than the highest possible value '" +
820  toString(yAxis.up) + "'");
821  if (_yRange.second < 0)
822  throw invalid_argument("pp50::loadSettings: '" + name() +
823  "': Up '" + toString(userRange.second) +
824  "' is smaller than the lowest possible value '" +
825  toString(yAxis.low) + "'");
826  if (static_cast<int>(yAxis.nBins) < _yRange.second)
827  throw invalid_argument("pp50::loadSettings: '" + name() +
828  "': Up '" + toString(userRange.second) +
829  "' is higher than the highest possible value '" +
830  toString(yAxis.up) + "'");
831  _project = std::tr1::bind(&pp50::projectToX,this,_1,_2);
833  }
834  else if (axis == "yAxis")
835  {
836  _xRange.first = xAxis.bin(userRange.first);
837  _xRange.second = xAxis.bin(userRange.second);
838  _yRange = make_pair(0,yAxis.nBins);
839  if (_xRange.first == _xRange.second)
840  throw invalid_argument("pp50::loadSettings: '" + name() +
841  "': Low '" + toString(userRange.first) +
842  "' is giving the the same column as Up '" +
843  toString(userRange.second) + "'");
844  if (_xRange.first < 0)
845  throw invalid_argument("pp50::loadSettings: '" + name() +
846  "': Low '" + toString(userRange.first) +
847  "' is smaller than the lowest possible value '" +
848  toString(xAxis.low) + "'");
849  if (static_cast<int>(xAxis.nBins) < _xRange.first)
850  throw invalid_argument("pp50::loadSettings: '" + name() +
851  "': Low '" + toString(userRange.first) +
852  "' is higher than the highest possible value '" +
853  toString(xAxis.up) + "'");
854  if (_xRange.second < 0)
855  throw invalid_argument("pp50::loadSettings: '" + name() +
856  "': Up '" + toString(userRange.second) +
857  "' is smaller than the lowest possible value '" +
858  toString(xAxis.low) + "'");
859  if (static_cast<int>(xAxis.nBins) < _xRange.second)
860  throw invalid_argument("pp50::loadSettings: '" + name() +
861  "': Up '" + toString(userRange.second) +
862  "' is higher than the highest possible value '" +
863  toString(xAxis.up) + "'");
864  _project = std::tr1::bind(&pp50::projectToY,this,_1,_2);
866  }
867  else
868  {
869  throw invalid_argument("pp50::loadSettings() '" + name() +
870  "': requested axis '" + axis + "' is not recognized");
871  }
872 
873  Log::add(Log::INFO,"Processor '" + name() +
874  "' will project result of Processor '" + _pHist->name() +
875  "' from '" + toString(userRange.first) + "' to '" +
876  toString(userRange.second) + "' to the " + axis +
877  ". The area in result coordinates lower left '" +
878  toString(_xRange.first) + "x" + toString(_yRange.first) +
879  "'; upper right '" + toString(_xRange.second) + "x" +
880  toString(_yRange.second) +"'. Condition is '" + _condition->name() +
881  "'");
882 }
883 
885 {
886  for(int y(_yRange.first); y<_yRange.second; ++y)
887  for(int x(_xRange.first); x<_xRange.second; ++x)
888  dest[x] += src[y*_nX + x];
889 }
890 
892 {
893  for(int y(_yRange.first); y<_yRange.second; ++y)
894  for(int x(_xRange.first); x<_xRange.second; ++x)
895  dest[y] += src[y*_nX + x];
896 }
897 
898 void pp50::process(const CASSEvent& evt, result_t &result)
899 {
900  const result_t &one(_pHist->result(evt.id()));
901  QReadLocker lock(&one.lock);
902 
903  _project(one.begin(),result.begin());
904 }
905 
906 
907 
908 
909 
910 
911 
912 
913 
914 
915 
916 
917 
918 // *** processors 51 calcs integral over a region in 1d histo ***
919 
920 pp51::pp51(const name_t &name)
921  : Processor(name)
922 {
923  loadSettings(0);
924 }
925 
926 void pp51::loadSettings(size_t)
927 {
928  CASSSettings s;
929  s.beginGroup("Processor");
931  setupGeneral();
932  _input = setupDependency("InputName");
933  bool ret (setupCondition());
934  if (!(ret && _input))
935  return;
936  const result_t &input(_input->result());
937  if (input.dim() != 1)
938  throw invalid_argument("pp51::loadSettings: '" + name() +
939  "': result '" + input.name() + "' is not a 1d result.");
940  const result_t::axe_t &xaxis(input.axis(result_t::xAxis));
941  pair<float,float> userrange(make_pair(s.value("XLow",-1e6).toFloat(),
942  s.value("XUp", 1e6).toFloat()));
943  if (userrange.first >= userrange.second)
944  throw invalid_argument("pp51::loadSettings: '"+name()+"' XLow '" +
945  toString(userrange.first) +
946  "' is bigger or equal to XUp '" +
947  toString(userrange.second) + "'");
948  _range.first = xaxis.bin(userrange.first);
949  _range.second = xaxis.bin(userrange.second);
950  if (_range.first == _range.second)
951  throw invalid_argument("pp51::loadSettings: '" + name() +
952  "': XLow '" + toString(userrange.first) +
953  "' is giving the the same column as XUp '" +
954  toString(userrange.second) + "'");
955  if (_range.first < 0)
956  throw invalid_argument("pp51::loadSettings: '" + name() +
957  "': XLow '" + toString(userrange.first) +
958  "' is smaller than the lowest possible value '" +
959  toString(xaxis.low) + "'");
960  if (static_cast<int>(xaxis.nBins) < _range.first)
961  throw invalid_argument("pp51::loadSettings: '" + name() +
962  "': XLow '" + toString(userrange.first) +
963  "' is higher than the highest possible value '" +
964  toString(xaxis.up) + "'");
965  if (_range.second < 0)
966  throw invalid_argument("pp51::loadSettings: '" + name() +
967  "': Xup '" + toString(userrange.second) +
968  "' is smaller than the lowest possible value '" +
969  toString(xaxis.low) + "'");
970  if (static_cast<int>(xaxis.nBins) < _range.second)
971  throw invalid_argument("pp51::loadSettings: '" + name() +
972  "': Xup '" + toString(userrange.second) +
973  "' is higher than the highest possible value '" +
974  toString(xaxis.up) + "'");
975  _baseline = std::tr1::bind(&pp51::constantBaseline,this,_1);
976  string output("Processor '" + name() +
977  "' will create integral of 1D results in Processor '" + input.name() +
978  "' from '" + toString(userrange.first) + "(" + toString(_range.first) +
979  ")' to '" + toString(userrange.second) + "(" + toString(_range.second) +
980  ")'.");
981 
982  if (s.value("BaselineXLow","None").toString() != "None")
983  {
984  pair<float,float> baselineuserrange(make_pair(s.value("BaselineXLow",-1e6).toFloat(),
985  s.value("BaselineXUp", 1e6).toFloat()));
986  if (baselineuserrange.first >= baselineuserrange.second)
987  throw invalid_argument("pp51::loadSettings: '"+name()+"' BaselineXLow '" +
988  toString(baselineuserrange.first) +
989  "' is bigger or equal to BaselineXUp '" +
990  toString(baselineuserrange.second) + "'");
991  _baselineRange.first = xaxis.bin(baselineuserrange.first);
992  _baselineRange.second = xaxis.bin(baselineuserrange.second);
993  if (_baselineRange.first == _baselineRange.second)
994  throw invalid_argument("pp51::loadSettings: '" + name() +
995  "': BaselineXLow '" + toString(baselineuserrange.first) +
996  "' is giving the the same column as BaselineXUp '" +
997  toString(baselineuserrange.second) + "'");
998  if (_baselineRange.first < 0)
999  throw invalid_argument("pp51::loadSettings: '" + name() +
1000  "': BaselineXLow '" + toString(baselineuserrange.first) +
1001  "' is smaller than the lowest possible value '" +
1002  toString(xaxis.low) + "'");
1003  if (static_cast<int>(xaxis.nBins) < _baselineRange.first)
1004  throw invalid_argument("pp51::loadSettings: '" + name() +
1005  "': BaselineXLow '" + toString(baselineuserrange.first) +
1006  "' is higher than the highest possible value '" +
1007  toString(xaxis.up) + "'");
1008  if (_baselineRange.second < 0)
1009  throw invalid_argument("pp51::loadSettings: '" + name() +
1010  "': BaselineXup '" + toString(baselineuserrange.second) +
1011  "' is smaller than the lowest possible value '" +
1012  toString(xaxis.low) + "'");
1013  if (static_cast<int>(xaxis.nBins) < _baselineRange.second)
1014  throw invalid_argument("pp51::loadSettings: '" + name() +
1015  "': BaselineXup '" + toString(baselineuserrange.second) +
1016  "' is higher than the highest possible value '" +
1017  toString(xaxis.up) + "'");
1018  _baseline = std::tr1::bind(&pp51::baselineFromInput,this,_1);
1019  output += (". It will use range from '" + toString(baselineuserrange.first) +
1020  "(" + toString(_baselineRange.first) + ")' to '" +
1021  toString(baselineuserrange.second) + "(" +
1022  toString(_baselineRange.second) + ")' to determine the baseline.");
1023  }
1024  else
1025  {
1026  output += (". It will use a constant baseline of 0");
1027  }
1028 
1029 
1031 
1032  output += (" Condition is '" + _condition->name() + "'");
1033  Log::add(Log::INFO,output);
1034 }
1035 
1037 {
1038  result_t::const_iterator begin(input.begin()+_baselineRange.first);
1039  result_t::const_iterator end(input.begin()+_baselineRange.second);
1040  const float sum(accumulate(begin,end, 0.f));
1041  const float nPoints(distance(begin,end));
1042  return (sum/nPoints);
1043 }
1044 
1045 void pp51::process(const CASSEvent& evt, result_t &result)
1046 {
1047  const result_t &input(_input->result(evt.id()));
1048  QReadLocker lock(&input.lock);
1049 
1050  result_t::const_iterator begin(input.begin()+_range.first);
1051  result_t::const_iterator end(input.begin()+_range.second);
1052  const float nPoints(distance(begin,end));
1053 
1054  result.setValue(accumulate(begin, end, -1.0f * nPoints*_baseline(input)));
1055 }
1056 
1057 
1058 
1059 
1060 
1061 
1062 
1063 
1064 
1065 // *** processor 56 stores previous version of another result ***
1066 
1067 pp56::pp56(const name_t &name)
1068  : Processor(name)
1069 {
1070  loadSettings(0);
1071 }
1072 
1074 {
1075  setupGeneral();
1076  _pHist = setupDependency("InputName");
1077  bool ret (setupCondition());
1078  if (!(ret && _pHist))
1079  return;
1080  const result_t &one(_pHist->result());
1081  createHistList(one.clone());
1082  Log::add(Log::INFO,"processor '" + name() +
1083  "' stores the previous result from Processor '" + _pHist->name() +
1084  "'. Condition on processor '" + _condition->name() +"'");
1085 }
1086 
1087 void pp56::process(const CASSEvent& evt, result_t &result)
1088 {
1089  /** get reference to the input */
1090  const result_t& one(_pHist->result(evt.id()));
1091 
1092  /** lock this and the input */
1093  QReadLocker rlock(&one.lock);
1094  QWriteLocker wlock(&_previous.lock);
1095 
1096  /** copy the old to the result */
1097  result.assign(_previous);
1098 
1099  /** copy the current to the store */
1100  _previous.assign(one);
1101 }
1102 
1103 
1104 
1105 
1106 
1107 
1108 
1109 
1110 
1111 
1112 
1113 
1114 
1115 
1116 
1117 
1118 
1119 
1120 // *** processors 57 weighted projects 2d hist to 1d histo for a selected region of the axis ***
1121 
1122 pp57::pp57(const name_t &name)
1123  : Processor(name)
1124 {
1125  loadSettings(0);
1126 }
1127 
1129 {
1130  CASSSettings s;
1131  s.beginGroup("Processor");
1133  setupGeneral();
1134  _pHist = setupDependency("InputName");
1135  bool ret (setupCondition());
1136  if (!(ret && _pHist))
1137  return;
1138  const result_t &input(_pHist->result());
1139  if (input.dim() != 2)
1140  throw invalid_argument("pp57::setupParameters()'" + name() +
1141  "': Error the processor we depend on '" + input.name() +
1142  "' is not a 2D result.");
1143  _excludeVal = s.value("ExclusionValue",0).toFloat();
1144 
1145  pair<float,float> userRange(make_pair(s.value("Low",-1e6).toFloat(),
1146  s.value("Up", 1e6).toFloat()));
1147  if (userRange.first >= userRange.second)
1148  throw invalid_argument("pp57::loadSettings: '"+name()+"' Low'" +
1149  toString(userRange.first) +
1150  "' is bigger or equal to Up'" +
1151  toString(userRange.second) + "'");
1152 
1153  const result_t::axe_t &xAxis(input.axis(result_t::xAxis));
1154  const result_t::axe_t &yAxis(input.axis(result_t::yAxis));
1155  _nX = xAxis.nBins;
1156 
1157  string axis(s.value("Axis","xAxis").toString().toStdString());
1158  if (axis == "xAxis")
1159  {
1160  _Xrange = make_pair(0,xAxis.nBins);
1161  _Yrange.first = yAxis.bin(userRange.first);
1162  _Yrange.second = yAxis.bin(userRange.second);
1163  if (_Yrange.first == _Yrange.second)
1164  throw invalid_argument("pp57::loadSettings: '" + name() +
1165  "': Low '" + toString(userRange.first) +
1166  "' is giving the the same row as Up '" +
1167  toString(userRange.second) + "'");
1168  if (_Yrange.first < 0)
1169  throw invalid_argument("pp57::loadSettings: '" + name() +
1170  "': Low '" + toString(userRange.first) +
1171  "' is smaller than the lowest possible value '" +
1172  toString(yAxis.low) + "'");
1173  if (static_cast<int>(yAxis.nBins) < _Yrange.first)
1174  throw invalid_argument("pp57::loadSettings: '" + name() +
1175  "': Low '" + toString(userRange.first) +
1176  "' is higher than the highest possible value '" +
1177  toString(yAxis.up) + "'");
1178  if (_Yrange.second < 0)
1179  throw invalid_argument("pp57::loadSettings: '" + name() +
1180  "': Up '" + toString(userRange.second) +
1181  "' is smaller than the lowest possible value '" +
1182  toString(yAxis.low) + "'");
1183  if (static_cast<int>(yAxis.nBins) < _Yrange.second)
1184  throw invalid_argument("pp57::loadSettings: '" + name() +
1185  "': Up '" + toString(userRange.second) +
1186  "' is higher than the highest possible value '" +
1187  toString(yAxis.up) + "'");
1188  _project = std::tr1::bind(&pp57::projectToX,this,_1,_2,_3);
1190  }
1191  else if (axis == "yAxis")
1192  {
1193  _Xrange.first = xAxis.bin(userRange.first);
1194  _Xrange.second = xAxis.bin(userRange.second);
1195  if (_Xrange.first == _Xrange.second)
1196  throw invalid_argument("pp57::loadSettings: '" + name() +
1197  "': Low '" + toString(userRange.first) +
1198  "' is giving the the same column as Up '" +
1199  toString(userRange.second) + "'");
1200  if (_Xrange.first < 0)
1201  throw invalid_argument("pp57::loadSettings: '" + name() +
1202  "': Low '" + toString(userRange.first) +
1203  "' is smaller than the lowest possible value '" +
1204  toString(xAxis.low) + "'");
1205  if (static_cast<int>(xAxis.nBins) < _Xrange.first)
1206  throw invalid_argument("pp57::loadSettings: '" + name() +
1207  "': Low '" + toString(userRange.first) +
1208  "' is higher than the highest possible value '" +
1209  toString(xAxis.up) + "'");
1210  if (_Xrange.second < 0)
1211  throw invalid_argument("pp57::loadSettings: '" + name() +
1212  "': Up '" + toString(userRange.second) +
1213  "' is smaller than the lowest possible value '" +
1214  toString(xAxis.low) + "'");
1215  if (static_cast<int>(xAxis.nBins) < _Xrange.second)
1216  throw invalid_argument("pp57::loadSettings: '" + name() +
1217  "': Up '" + toString(userRange.second) +
1218  "' is higher than the highest possible value '" +
1219  toString(xAxis.up) + "'");
1220  _Yrange = make_pair(0,yAxis.nBins);
1221  _project = std::tr1::bind(&pp57::projectToY,this,_1,_2,_3);
1223  }
1224  else
1225  {
1226  throw invalid_argument("pp57::loadSettings() '" + name() +
1227  "': requested _axis '" + axis + "' is not recognized");
1228  }
1229  Log::add(Log::INFO,"Processor '" + name() +
1230  "' will project result of Processor '" + input.name() +
1231  "' from '" + toString(userRange.first) + "' to '" +
1232  toString(userRange.second) + "' onto the " + axis +
1233  ". The area in result coordinates lower left '" +
1234  toString(_Xrange.first) + "x" + toString(_Yrange.first) +
1235  "'; upper right '" + toString(_Xrange.second) + "x" +
1236  toString(_Yrange.second) + "'. Condition is '" + _condition->name() +
1237  "'");
1238 }
1239 
1241  result_t::iterator norm)
1242 {
1243  for(int y(_Yrange.first); y<_Yrange.second; ++y)
1244  for(int x(_Xrange.first); x<_Xrange.second; ++x)
1245  {
1246  const float pixval(src[y*_nX + x]);
1247  if (!fuzzycompare(pixval,_excludeVal))
1248  {
1249  result[x] += pixval;
1250  norm[x] += 1;
1251  }
1252  }
1253 }
1254 
1256  result_t::iterator norm)
1257 {
1258  for(int y(_Yrange.first); y<_Yrange.second; ++y)
1259  for(int x(_Xrange.first); x<_Xrange.second; ++x)
1260  {
1261  const float pixval(src[y*_nX + x]);
1262  if (!fuzzycompare(pixval,_excludeVal))
1263  {
1264  result[y] += pixval;
1265  norm[y] += 1;
1266  }
1267  }
1268 }
1269 
1270 void pp57::process(const CASSEvent& evt, result_t &result)
1271 {
1272  const result_t &one(_pHist->result(evt.id()));
1273  QReadLocker lock(&one.lock);
1274 
1275  /** project to axis and remember how many pixels have been added at which
1276  * bin. Then normalize to the number of added pixels
1277  */
1278  result_t::storage_t norm(result.size(),0);
1279  _project(one.begin(),result.begin(),norm.begin());
1280  transform(result.begin(),result.begin()+result.datasize(),
1281  norm.begin(),result.begin(), divides<result_t::value_t>());
1282 }
1283 
1284 
1285 
1286 
1287 
1288 
1289 
1290 
1291 
1292 
1293 // *** processor 60 histogram results ***
1294 
1295 pp60::pp60(const name_t &name)
1296  : Processor(name)
1297 {
1298  loadSettings(0);
1299 }
1300 
1302 {
1303  CASSSettings s;
1304  s.beginGroup("Processor");
1306  setupGeneral();
1307  bool ret (setupCondition());
1308  _input = setupDependency("XName");
1309  QString weightkey("Weight");
1310  QString weightparam(s.value(weightkey,1).toString());
1311  bool isFloat(false);
1312  result_t::value_t weight(weightparam.toFloat(&isFloat));
1313  string output;
1314  if (isFloat)
1315  {
1316  _weight = weight;
1317  output += (" Using a constant weight of '" + toString(_weight) + "'");
1318  }
1319  else
1320  {
1321  _weightProc = setupDependency(weightkey.toStdString());
1322  ret = _weightProc && ret;
1323  if (_weightProc)
1324  output += (" Using the weights taken from '" + _weightProc->name() + "'");
1325  }
1326  if (!(ret && _input))
1327  return;
1328 
1329  bool CountsPerBin(s.value("RememberCounts",false).toBool());
1330  bool ConstantFromProc(_weightProc && _weightProc->result().dim() == 0);
1331 
1332  if (isFloat && CountsPerBin)
1333  _histogram = std::tr1::bind(&pp60::histogramAndBinCountWithConstant,this,_1,_2,_3,_4);
1334  if (isFloat && !CountsPerBin)
1335  _histogram = std::tr1::bind(&pp60::histogramWithConstant,this,_1,_2,_3,_4);
1336  if (!isFloat && CountsPerBin && !ConstantFromProc)
1337  _histogram = std::tr1::bind(&pp60::histogramAndBinCountWithWeights,this,_1,_2,_3,_4);
1338  if (!isFloat && !CountsPerBin && !ConstantFromProc)
1339  _histogram = std::tr1::bind(&pp60::histogramWithWeights,this,_1,_2,_3,_4);
1340  if (!isFloat && CountsPerBin && ConstantFromProc)
1341  _histogram = std::tr1::bind(&pp60::histogramAndBinCountWithWeightFrom0D,this,_1,_2,_3,_4);
1342  if (!isFloat && !CountsPerBin && ConstantFromProc)
1343  _histogram = std::tr1::bind(&pp60::histogramWithWeightFrom0D,this,_1,_2,_3,_4);
1344 
1345  if (CountsPerBin)
1346  {
1349  (new result_t
1350  (result_t::axe_t(s.value("XNbrBins",1).toUInt(),
1351  s.value("XLow",0).toFloat(),
1352  s.value("XUp",0).toFloat(),
1353  s.value("XTitle","x-axis").toString().toStdString()),
1354  /** @note this allows to address the y bin with 0.1 and 1.1 */
1355  result_t::axe_t(2,0,2,"bins"))));
1356  output += ("' and remember the counts per bin");
1357  }
1358  else
1360 
1361 
1362 
1363  if(!isFloat && _weightProc->result().shape() != _input->result().shape())
1364  throw invalid_argument("pp60:loadSettings() " + name() +
1365  ": The processor containing the weights '" +
1366  _weightProc->name() + "' differs in its shape '" +
1367  toString(_weightProc->result().shape().first) + "x" +
1368  toString(_weightProc->result().shape().second) +
1369  "' from the input '" + _input->name() + "' shape '" +
1370  toString(_input->result().shape().first) + "x" +
1371  toString(_input->result().shape().second) + "'");
1372 
1373  Log::add(Log::INFO,"processor '" + name() +
1374  "' histograms values from Processor '" + _input->name() + "'. " +
1375  output + ". Condition on Processor '" + _condition->name() + "'");
1376 }
1377 
1381  result_t &result)
1382 {
1383  const result_t &weights(_weightProc->result(id));
1384  QReadLocker lock(&weights.lock);
1385 
1386  result_t::const_iterator weight(weights.begin());
1387  for (; in != last; ++in, ++weight)
1388  result.histogram(*in,*weight);
1389 }
1390 
1394  result_t &result)
1395 {
1396  const result_t &weight(_weightProc->result(id));
1397  QReadLocker lock(&weight.lock);
1398 
1399  const result_t::value_t w(weight.getValue());
1400  for (; in != last; ++in)
1401  result.histogram(*in,w);
1402 }
1403 
1407  result_t &result)
1408 {
1409  for (; in != last; ++in)
1410  result.histogram(*in,_weight);
1411 }
1412 
1416  result_t &result)
1417 {
1418  const result_t &weights(_weightProc->result(id));
1419  QReadLocker lock(&weights.lock);
1420 
1421  result_t::const_iterator weight(weights.begin());
1422  for (; in != last; ++in, ++weight)
1423  {
1424  result.histogram(make_pair(*in,0.1),*weight);
1425  result.histogram(make_pair(*in,0.1));
1426  }
1427 }
1428 
1432  result_t &result)
1433 {
1434  const result_t &weight(_weightProc->result(id));
1435  QReadLocker lock(&weight.lock);
1436 
1437  const result_t::value_t w(weight.getValue());
1438  for (; in != last; ++in)
1439  {
1440  result.histogram(make_pair(*in,0.1),w);
1441  result.histogram(make_pair(*in,0.1));
1442  }
1443 }
1444 
1448  result_t &result)
1449 {
1450  for (; in != last; ++in)
1451  {
1452  result.histogram(make_pair(*in,0.1),_weight);
1453  result.histogram(make_pair(*in,1.1));
1454  }
1455 }
1456 
1457 void pp60::process(const CASSEvent& evt, result_t &result)
1458 {
1459  const result_t &input(_input->result(evt.id()));
1460  QReadLocker lock(&input.lock);
1461 
1462  _histogram(evt.id(), input.begin(), input.begin()+input.datasize(), result);
1463 }
1464 
1465 
1466 
1467 
1468 
1469 
1470 
1471 
1472 
1473 
1474 
1475 // *** processor 61 averages result ***
1476 
1477 pp61::pp61(const name_t &name)
1478  : AccumulatingProcessor(name)
1479 {
1480  loadSettings(0);
1481 }
1482 
1484 {
1485  CASSSettings s;
1486  s.beginGroup("Processor");
1488  setupGeneral();
1489  unsigned average = s.value("NbrOfAverages", 1).toUInt();
1490  if (average)
1491  {
1492  _alpha = 2./static_cast<float>(average+1.);
1493  _scale = std::tr1::bind(&pp61::movingInitializationScale,this);
1494  }
1495  else
1496  {
1497  _scale = std::tr1::bind(&pp61::cumulativeScale,this);
1498  _alpha = 0.;
1499  }
1500  _alpha = average ? 2./static_cast<float>(average+1.) : 0.;
1501  _pHist = setupDependency("InputName");
1502  bool ret (setupCondition());
1503  if (!(ret && _pHist))
1504  return;
1505  /** @NOTE:
1506  * In case we're running a moving average (_alpha is non-zero), we need to
1507  * initialize the the first value of the moving average. Here we initialize
1508  * it with the mean of the first datapoints, meaning we'll check if the
1509  * _alpha calculated for the cumulative averaging is still larger than the
1510  * _alpha for the moving averge. If its smaller than the _alpha of the
1511  * cumulative average it means that the current datum will not have as much
1512  * weight. Therefore from this point onward, we should use the _alpha of the
1513  * moving averge to start "forgetting" older values by putting comparatively
1514  * more weight on the newer datums.
1515  */
1516  QString averageType(s.value("AveragingType","Normal").toString());
1517  if (averageType == "Normal")
1518  _func = std::tr1::bind(&pp61::average,this,_1,_2,_3);
1519  else if (averageType == "Square")
1520  _func = std::tr1::bind(&pp61::squareAverage,this,_1,_2,_3);
1521  else
1522  throw invalid_argument("pp61::loadSettings() " + name() +
1523  ": requested Averaging type '" +
1524  averageType.toStdString() + "' unknown.");
1525  createHistList(_pHist->result().clone());
1526  /** @NOTE: initialize the result to be zero, otherwise the cumulatinve
1527  * averaging won't produce correct results
1528  */
1529  _result->clear();
1530  Log::add(Log::INFO,"processor '" + name() +
1531  "' averages result from Processor '" + _pHist->name() +
1532  "' alpha for the averaging '" + toString(_alpha) +
1533  "'. Condition on processor '" + _condition->name() + "'");
1534 }
1535 
1537  result_t::value_t aveOld,
1538  result_t::value_t scale)
1539 {
1540  return aveOld + scale*(val - aveOld);
1541 }
1542 
1544  result_t::value_t aveOld,
1545  result_t::value_t scale)
1546 {
1547  return aveOld + scale*(val*val - aveOld);
1548 }
1549 
1551 {
1553  /** when the first value of the moving avererage has been initialized (see
1554  * comment above), we can then procede by using the moving average's _alpha
1555  */
1556  if (scale < _alpha)
1557  {
1558  _scale = std::tr1::bind(&pp61::movingScale,this);
1559  scale = _alpha;
1560  }
1561  return scale;
1562 }
1563 
1564 void pp61::process(const CASSEvent& evt, result_t &result)
1565 {
1566  const result_t& one(_pHist->result(evt.id()));
1567  QReadLocker lock(&one.lock);
1568 
1569  /** @NOTE: the nbr of accumulated events needs to be increased BEFORE
1570  * calculating the scale because the cumulative scale expect the scale
1571  * to be \f$\frac{1}{n+1}\f$
1572  */
1574  transform(one.begin(), one.begin()+one.datasize(),
1575  result.begin(), result.begin(), std::tr1::bind(_func,_1,_2,_scale()));
1576 }
1577 
1578 
1579 
1580 
1581 
1582 
1583 
1584 
1585 
1586 
1587 
1588 
1589 // *** processor 62 sums up result ***
1590 
1591 pp62::pp62(const name_t &name)
1592  : AccumulatingProcessor(name)
1593 {
1594  loadSettings(0);
1595 }
1596 
1598 {
1599  setupGeneral();
1600  _pHist = setupDependency("InputName");
1601  bool ret (setupCondition());
1602  if (!(ret && _pHist))
1603  return;
1604  createHistList(_pHist->result().clone());
1605  Log::add(Log::INFO,"processor '" + name() +
1606  "' sums up results from Processor '" + _pHist->name() +
1607  "'. Condition on processor '" + _condition->name() + "'");
1608 }
1609 
1610 void pp62::process(const CASSEvent& evt, result_t &result)
1611 {
1612  const result_t& one(_pHist->result(evt.id()));
1613  QReadLocker lock(&one.lock);
1614 
1615  transform(one.begin(),one.end(),result.begin(),result.begin(),plus<float>());
1617 }
1618 
1619 
1620 
1621 
1622 
1623 
1624 
1625 
1626 // *** processors 63 calculate the time average of a 0d/1d/2d hist given the number
1627 // of samples that are going to be used in the calculation ***
1628 
1629 pp63::pp63(const name_t &name)
1630  : AccumulatingProcessor(name),
1631  _num_seen_evt(0),
1632  _when_first_evt(0),
1633  _first_fiducials(0)
1634 {
1635  loadSettings(0);
1636 }
1637 
1639 {
1640  CASSSettings s;
1641  s.beginGroup("Processor");
1643  const size_t min_time_user (s.value("MinTime",0).toUInt());
1644  const size_t max_time_user (s.value("MaxTime",300).toUInt());
1645  _timerange = make_pair(min_time_user,max_time_user);
1646  _nbrSamples=s.value("NumberOfSamples",5).toUInt();
1647  setupGeneral();
1648  _pHist = setupDependency("InputName");
1649  bool ret (setupCondition());
1650  if (!(ret && _pHist))
1651  return;
1652  createHistList(_pHist->result().clone());
1653  Log::add(Log::INFO,"Processor '" + name() +
1654  "' will calculate the time average of result of Processor '" + _pHist->name() +
1655  "' from now '" + toString(s.value("MinTime",0).toUInt()) + "' to '" +
1656  toString(s.value("MaxTime",300).toUInt()) + "' seconds '" + toString(_timerange.first) +
1657  "' ; '" + toString(_timerange.second) + "' each bin is equivalent to up to '" +
1658  toString(_nbrSamples) + "' measurements," +
1659  " Condition on Processor '" + _condition->name() + "'");
1660 }
1661 
1662 void pp63::process(const CASSEvent& evt, result_t &result)
1663 {
1664  //#define debug1
1665 #ifdef debug1
1666  char timeandday[40];
1667  struct tm * timeinfo;
1668 #endif
1669  uint32_t fiducials;
1670  time_t now_of_event;
1671  const result_t& one(_pHist->result(evt.id()));
1672 
1673  // using docu at http://asg.mpimf-heidelberg.mpg.de/index.php/Howto_retrieve_the_Bunch-/Event-id
1674  //remember the time of the first event
1675  if(_when_first_evt==0)
1676  {
1677  _when_first_evt=static_cast<time_t>(evt.id()>>32);
1678 #ifdef debug1
1679  timeinfo = localtime ( &_when_first_evt );
1680  strftime(timeandday,40,"%Y%m%d %H%M%S",timeinfo);
1681  cout<<"Starting now is "<< timeandday <<" "<<_num_seen_evt<< " "<<_nbrSamples <<endl;
1682 #endif
1683  _num_seen_evt=1;
1684  _first_fiducials=static_cast<uint32_t>(evt.id() & 0x000000001FFFFF00);
1685  }
1686  now_of_event=static_cast<time_t>(evt.id()>>32);
1687 #ifdef debug1
1688  timeinfo = localtime ( &now_of_event );
1689  strftime(timeandday,40,"%Y%m%d %H%M%S",timeinfo);
1690 #endif
1691  fiducials=static_cast<uint32_t>(evt.id() & 0x000000001FFFFF00);
1692 #ifdef debug1
1693  timeinfo = localtime ( &now_of_event );
1694  strftime(timeandday,40,"%Y%m%d %H%M%S",timeinfo);
1695  // cout<<"Starting now is "<< timeandday <<" "<<_num_seen_evt<< " "<<_nbrSamples <<endl;
1696  cout<<"ora "<< timeandday<<" "<<_first_fiducials << " " <<fiducials << " " << _num_seen_evt <<endl;
1697 #endif
1698  if(fiducials>_first_fiducials+(_nbrSamples-1)*4608 /*0x1200 ??why*/
1699  && now_of_event>=_when_first_evt)
1700  {
1701 #ifdef debug1
1702  cout <<"time to forget"<<endl;
1703 #endif
1704  //remember the time also whenever (_num_seen_evt-1)%_nbrSamples==0
1705  _first_fiducials=fiducials;
1706  _when_first_evt=now_of_event;
1707  _num_seen_evt=1;
1708  }
1709 
1710  // if(now_of_event<_when_first_evt-100)
1711  if(_first_fiducials>fiducials)
1712  {
1713 #ifdef debug1
1714  cout <<"extra time to forget"<<endl;
1715 #endif
1716  //remember the time also whenever (_num_seen_evt-1)%_nbrSamples==0
1717  _first_fiducials=fiducials;
1718  _when_first_evt=now_of_event;
1719  _num_seen_evt=1;
1720  }
1721  QReadLocker lock(&one.lock);
1722 
1723  transform(one.begin(),one.end(), result.begin(), result.begin(),
1724  TimeAverage(float(_num_seen_evt)));
1725  ++_num_seen_evt;
1726  if(_num_seen_evt>_nbrSamples+1) cout<<"pp64::process(): How... it smells like fish! "
1727  <<_num_seen_evt
1728  <<" "<<_nbrSamples
1729  <<endl;
1730 }
1731 
1732 
1733 
1734 
1735 
1736 
1737 
1738 
1739 
1740 
1741 
1742 
1743 
1744 // *** pp 64 takes a 0d result (value) as input and writes it in the last bin of a 1d result
1745 // *** while shifting all other previously saved values one bin to the left.
1746 
1747 pp64::pp64(const name_t &name)
1748  : AccumulatingProcessor(name)
1749 {
1750  loadSettings(0);
1751 }
1752 
1754 {
1755  CASSSettings s;
1756 
1757  s.beginGroup("Processor");
1759 
1760  _hist = setupDependency("InputName");
1761 
1762  bool ret (setupCondition());
1763  if ( !(_hist && ret) ) return;
1764 
1765  setupGeneral();
1766  _size = s.value("Size", 10000).toUInt();
1767 
1769 
1770  Log::add(Log::INFO,"Processor '" + name() +
1771  "' will make a history of values of result in processor '" +
1772  _hist->name() + ", size of history '" + toString(_size) +
1773  "' Condition on processor '" + _condition->name() + "'");
1774 }
1775 
1776 void pp64::process(const CASSEvent &evt, result_t &result)
1777 {
1778  const result_t &values(_hist->result(evt.id()));
1779  QReadLocker lock(&(values.lock));
1780 
1781  /** @note since the rotate algorithm is quite fast, it might be faster to do
1782  * it like this. Otherwise we have to branch, which might be slower
1783  */
1785  result_t::const_iterator valueEnd(values.end());
1786  for(; value != valueEnd ;++value)
1787  {
1788  rotate(result.begin(), result.begin()+1, result.end());
1789  result[_size-1] = *value;
1790  }
1791 }
1792 
1793 
1794 
1795 
1796 
1797 
1798 
1799 // *** processor 65 histograms 2 0D values to 2D histogram ***
1800 
1801 pp65::pp65(const name_t &name)
1802  : Processor(name)
1803 {
1804  loadSettings(0);
1805 }
1806 
1808 {
1809  CASSSettings s;
1810  s.beginGroup("Processor");
1812  setupGeneral();
1813  bool ret(setupCondition());
1814  _xInput = setupDependency("XName");
1815  _yInput = setupDependency("YName");
1816  QString weightkey("Weight");
1817  QString weightparam(s.value(weightkey,1).toString());
1818  bool isFloat(false);
1819  result_t::value_t weight(weightparam.toFloat(&isFloat));
1820  string output;
1821  if (isFloat)
1822  {
1823  _weight = weight;
1824  output += (" Using a constant weight of '" + toString(_weight) + "'");
1825  }
1826  else
1827  {
1828  _weightInput = setupDependency(weightkey.toStdString());
1829  ret = _weightInput && ret;
1830  if (_weightInput)
1831  output += (" Using the weights taken from '" + _weightInput->name() + "'");
1832  }
1833 
1834  if ( !(_xInput && _xInput && ret) )
1835  return;
1836 
1837  if (_xInput->result().shape() != _yInput->result().shape())
1838  throw runtime_error("pp65::loadSettings() " + name() + " XName '" +
1839  _xInput->name() + "' with shape '" +
1840  toString(_xInput->result().shape().first) + "x" +
1841  toString(_xInput->result().shape().second) +
1842  "' and YName '" + _yInput->name() + "' with shape '" +
1843  toString(_yInput->result().shape().first) + "x" +
1844  toString(_yInput->result().shape().second) + "' differ");
1845  if (_weightInput && _weightInput->result().dim() != 0 &&
1846  _xInput->result().shape() != _weightInput->result().shape())
1847  throw runtime_error("pp65::loadSettings() " + name() + ": The input '" +
1848  _xInput->name() + "' and '" + _yInput->name() +
1849  "' with shape '" +
1850  toString(_xInput->result().shape().first) + "x" +
1851  toString(_xInput->result().shape().second) +
1852  "' and the weight input '" + _weightInput->name() +
1853  "' with shape '" +
1854  toString(_weightInput->result().shape().first) + "x" +
1855  toString(_weightInput->result().shape().second) +
1856  "' differ");
1857 
1858  bool CountsPerBin(s.value("RememberCounts",false).toBool());
1859  bool ConstantFromProc(_weightInput && _weightInput->result().dim() == 0);
1860 
1861  if (isFloat && CountsPerBin)
1862  _histogram = std::tr1::bind(&pp65::histogramAndBinCountWithConstant,this,_1,_2,_3,_4,_5);
1863  if (isFloat && !CountsPerBin)
1864  _histogram = std::tr1::bind(&pp65::histogramWithConstant,this,_1,_2,_3,_4,_5);
1865  if (!isFloat && CountsPerBin && !ConstantFromProc)
1866  _histogram = std::tr1::bind(&pp65::histogramAndBinCountWithWeights,this,_1,_2,_3,_4,_5);
1867  if (!isFloat && !CountsPerBin && !ConstantFromProc)
1868  _histogram = std::tr1::bind(&pp65::histogramWithWeights,this,_1,_2,_3,_4,_5);
1869  if (!isFloat && CountsPerBin && ConstantFromProc)
1870  _histogram = std::tr1::bind(&pp65::histogramAndBinCountWithWeightFrom0DInput,this,_1,_2,_3,_4,_5);
1871  if (!isFloat && !CountsPerBin && ConstantFromProc)
1872  _histogram = std::tr1::bind(&pp65::histogramWithWeightFrom0DInput,this,_1,_2,_3,_4,_5);
1873 
1874  if (CountsPerBin)
1875  {
1876  _origYAxis.nBins = s.value("YNbrBins",1).toUInt();
1877  _origYAxis.low = s.value("YLow",0).toFloat();
1878  _origYAxis.up = s.value("YUp",0).toFloat();
1879  _origYAxis.title = s.value("YTitle","y-axis").toString().toStdString();
1882  (new result_t
1883  (result_t::axe_t(s.value("XNbrBins",1).toUInt(),
1884  s.value("XLow",0).toFloat(),
1885  s.value("XUp",0).toFloat(),
1886  s.value("XTitle","x-axis").toString().toStdString()),
1889  output += ("' and remember the counts per bin");
1890  }
1891  else
1893 
1894  Log::add(Log::INFO,"processor '" + name() +
1895  "': histograms values from Processor '" + _xInput->name() +
1896  "' as x-input and '" + _yInput->name() + "' as y-input. " + output +
1897  " Condition on Processor '" + _condition->name() + "'");
1898 }
1899 
1904  result_t &result)
1905 {
1906  const result_t &weights(_weightInput->result(id));
1907  QReadLocker lock(&weights.lock);
1908 
1909  result_t::const_iterator weight(weights.begin());
1910  for (; xin != xlast; ++xin, ++weight, ++yin)
1911  result.histogram(make_pair(*xin,*yin),*weight);
1912 }
1913 
1918  result_t &result)
1919 {
1920  const result_t &weight(_weightInput->result(id));
1921  QReadLocker lock(&weight.lock);
1922 
1923  const result_t::value_t w(weight.getValue());
1924  for (; xin != xlast; ++xin, ++yin)
1925  result.histogram(make_pair(*xin,*yin),w);
1926 }
1927 
1932  result_t &result)
1933 {
1934  for (; xin != xlast; ++xin, ++yin)
1935  result.histogram(make_pair(*xin,*yin),_weight);
1936 }
1937 
1942  result_t &result)
1943 {
1944  const result_t &weights(_weightInput->result(id));
1945  QReadLocker lock(&weights.lock);
1946 
1947  const result_t::axe_t &xaxis(result.axis(result_t::xAxis));
1948  const size_t distToCounts(xaxis.nBins + _origYAxis.nBins);
1949  result_t::const_iterator weight(weights.begin());
1950  for (; xin != xlast; ++xin, ++weight, ++yin)
1951  {
1952  const size_t idx(histogramming::bin(xaxis, _origYAxis, make_pair(*xin,*yin)));
1953  result[idx] += *weight;
1954  result[idx+distToCounts] += 1;
1955  }
1956 }
1957 
1962  result_t &result)
1963 {
1964  const result_t &weight(_weightInput->result(id));
1965  QReadLocker lock(&weight.lock);
1966 
1967  const result_t::axe_t &xaxis(result.axis(result_t::xAxis));
1968  const size_t distToCounts(xaxis.nBins + _origYAxis.nBins);
1969  const result_t::value_t w(weight.getValue());
1970  for (; xin != xlast; ++xin, ++yin)
1971  {
1972  const size_t idx(histogramming::bin(xaxis, _origYAxis, make_pair(*xin,*yin)));
1973  result[idx] += w;
1974  result[idx+distToCounts] += 1;
1975  }
1976 }
1977 
1982  result_t &result)
1983 {
1984  const result_t::axe_t &xaxis(result.axis(result_t::xAxis));
1985  const size_t distToCounts(xaxis.nBins + _origYAxis.nBins);
1986  for (; xin != xlast; ++xin, ++yin)
1987  {
1988  const size_t idx(histogramming::bin(xaxis, _origYAxis, make_pair(*xin,*yin)));
1989  result[idx] += _weight;
1990  result[idx+distToCounts] += 1;
1991  }
1992 }
1993 
1994 void pp65::process(const CASSEvent& evt, result_t &result)
1995 {
1996  const result_t &xin(_xInput->result(evt.id()));
1997  QReadLocker lock1(&xin.lock);
1998  const result_t &yin(_yInput->result(evt.id()));
1999  QReadLocker lock2(&yin.lock);
2000 
2001  _histogram(evt.id(), xin.begin(), xin.begin()+xin.datasize(), yin.begin(),
2002  result);
2003 }
2004 
2005 
2006 
2007 
2008 
2009 
2010 
2011 
2012 
2013 
2014 
2015 
2016 // *** processor 66 combines 2 1D traces to 2D result ***
2017 
2018 pp66::pp66(const name_t &name)
2019  : Processor(name)
2020 {
2021  loadSettings(0);
2022 }
2023 
2025 {
2026  setupGeneral();
2027  _one = setupDependency("XName");
2028  _two = setupDependency("YName");
2029  bool ret (setupCondition());
2030  if ( !(_one && _two && ret) )
2031  return;
2032  const result_t &one(_one->result());
2033  const result_t &two(_two->result());
2034  if (one.dim() != 1 || two.dim() != 1)
2035  throw invalid_argument("pp66::loadSettings() "+name()+": First '" +
2036  _one->name() + "' with dimension '" +
2037  toString(one.dim()) + "' or Second '" +
2038  _two->name() + "' has dimension '" +
2039  toString(two.dim()) + "' does not have dimension 1");
2042  (new result_t(one.axis(result_t::xAxis), two.axis(result_t::xAxis))));
2043 
2044  Log::add(Log::INFO,"processor '" + name() +
2045  "' creates a 2D result from Processor '" + _one->name() +
2046  "' and '" + _two->name() + "'. condition on Processor '" +
2047  _condition->name() + "'");
2048 }
2049 
2050 void pp66::process(const CASSEvent& evt, result_t &result)
2051 {
2052  const result_t &one(_one->result(evt.id()));
2053  QReadLocker lock1(&one.lock);
2054  const result_t &two(_two->result(evt.id()));
2055  QReadLocker lock2(&two.lock);
2056 
2057  const size_t oneNBins(one.shape().first);
2058  const size_t twoNBins(two.shape().first);
2059  for (size_t j(0); j < twoNBins; ++j)
2060  for (size_t i(0); i < oneNBins; ++i)
2061  result[j*oneNBins+i] = one[i]*two[j];
2062 }
2063 
2064 
2065 
2066 
2067 
2068 
2069 
2070 
2071 
2072 
2073 
2074 
2075 
2076 
2077 
2078 // *** processor 68 histograms 0D and 1d Histogram to 2D result ***
2079 
2080 pp68::pp68(const name_t &name)
2081  : Processor(name)
2082 {
2083  loadSettings(0);
2084 }
2085 
2087 {
2088  CASSSettings s;
2089  s.beginGroup("Processor");
2091  setupGeneral();
2092  _one = setupDependency("XName");
2093  _two = setupDependency("YName");
2094  bool ret (setupCondition());
2095  if ( !(_one && _two && ret) )
2096  return;
2097  if (_one->result().dim() != 1 || _two->result().dim() != 0)
2098  throw runtime_error("pp68::loadSettings() '" + name() + "': Either '" +
2099  _one->name() + "' is not 1D or '" + _two->name() +
2100  "' is not a 0D Hist");
2101  const result_t &one(_one->result());
2102  const result_t::axe_t &xaxis(one.axis(result_t::xAxis));
2105  (new result_t
2106  (xaxis, result_t::axe_t( s.value("YNbrBins",1).toUInt(),
2107  s.value("YLow",0).toFloat(),
2108  s.value("YUp",0).toFloat(),
2109  s.value("YTitle","y-axis").toString().toStdString()))));
2110  Log::add(Log::INFO,"processor '" + name() +
2111  "' makes a 2D Histogram where '" + _one->name() +
2112  "' defines the x axis to fill and '" + _two->name() +
2113  "' defines the y axis bin. Condition on Processor '" +
2114  _condition->name() + "'");
2115 }
2116 
2117 void pp68::process(const CASSEvent& evt, result_t &result)
2118 {
2119  const result_t &one(_one->result(evt.id()));
2120  QReadLocker lock1(&one.lock);
2121  const result_t &two(_two->result(evt.id()));
2122  QReadLocker lock2(&two.lock);
2123 
2124  const result_t::shape_t::first_type nxbins(result.shape().first);
2125  const result_t::axe_t yaxis(result.axis(result_t::yAxis));
2126  const int ybin(yaxis.bin(two.getValue()));
2127  if (!yaxis.isOverflow(ybin) && !yaxis.isUnderflow(ybin))
2128  copy(one.begin(), one.begin()+one.datasize(), result.begin()+(ybin*nxbins));
2129 }
2130 
2131 
2132 
2133 
2134 
2135 
2136 
2137 
2138 
2139 // *** processor 69 combines 2 0D values to 1D scatter plot ***
2140 
2141 pp69::pp69(const name_t &name)
2142  : AccumulatingProcessor(name)
2143 {
2144  loadSettings(0);
2145 }
2146 
2148 {
2149  setupGeneral();
2150  _one = setupDependency("XName");
2151  _two = setupDependency("YName");
2152  bool ret (setupCondition());
2153  if ( !(_one && _two && ret) )
2154  return;
2155  if (_one->result().dim() != 0 || _two->result().dim() != 0)
2156  throw runtime_error("pp69::loadSettings() '" + name() + "': Either '" +
2157  _one->name() + "' or '" + _two->name() + "' is not a 0D Hist");
2159  Log::add(Log::INFO,"processor '" + name() +
2160  "' makes a 1D Histogram where '"+ _one->name() +
2161  "' defines the x bin to set and '" + _two->name() +
2162  "' defines the y value of the x bin"
2163  ". Condition on Processor '" + _condition->name() + "'");
2164 }
2165 
2166 void pp69::process(const CASSEvent& evt, result_t &result)
2167 {
2168  const result_t &one(_one->result(evt.id()));
2169  QReadLocker lock1(&one.lock);
2170  const result_t &two(_two->result(evt.id()));
2171  QReadLocker lock2(&two.lock);
2172 
2173  /** histogram the first value, which will return an iterator pointing to the
2174  * correct bin. We can then write the second value to the correct bin
2175  */
2176  *(result.histogram(one.getValue())) = two.getValue();
2177  /** increase the number of fills */
2179 }
2180 
2181 
2182 
2183 
2184 
2185 
2186 
2187 
2188 
2189 
2190 
2191 
2192 
2193 
2194 // *** pp 70 subsets a result ***
2195 
2196 pp70::pp70(const name_t &name)
2197  : Processor(name),
2198  _offset(make_pair(0,0))
2199 {
2200  loadSettings(0);
2201 }
2202 
2204 {
2205  CASSSettings s;
2206  s.beginGroup("Processor");
2208  setupGeneral();
2209  _input = setupDependency("InputName");
2210  bool ret (setupCondition());
2211  if (!(ret && _input))
2212  return;
2213 
2214  const result_t& input(_input->result());
2215  if (input.dim() == 0)
2216  throw invalid_argument("pp70::loadSettings(): Can't subset 0D result '" +
2217  input.name() + "'");
2218 
2219  const result_t::axe_t &xaxis(input.axis(result_t::xAxis));
2220  pair<float,float> userXRange;
2221  userXRange.first = s.value("XLow",0).toFloat();
2222  userXRange.second = s.value("XUp",1).toFloat();
2223  if (userXRange.first >= userXRange.second)
2224  throw invalid_argument("pp70::loadSettings: '" + name() + "' XLow '" +
2225  toString(userXRange.first) +
2226  "' is bigger or equal to XUp '" +
2227  toString(userXRange.second) + "'");
2228 
2229  _offset.first = xaxis.bin(userXRange.first);
2230  const int binXUp(xaxis.bin(userXRange.second));
2231  if (_offset.first == binXUp)
2232  throw invalid_argument("pp70::loadSettings: '" + name() +
2233  "': XLow '" + toString(userXRange.first) +
2234  "' is giving the the same column as XUp '" +
2235  toString(userXRange.second) + "'");
2236  if (_offset.first < 0)
2237  throw invalid_argument("pp70::loadSettings: '" + name() +
2238  "': XLow '" + toString(userXRange.first) +
2239  "' is smaller than the lowest possible value '" +
2240  toString(xaxis.low) + "'");
2241  if (static_cast<int>(xaxis.nBins) < _offset.first)
2242  throw invalid_argument("pp70::loadSettings: '" + name() +
2243  "': XLow '" + toString(userXRange.first) +
2244  "' is bigger than the highest possible value '" +
2245  toString(xaxis.up) + "'");
2246  if (binXUp < 0)
2247  throw invalid_argument("pp70::loadSettings: '" + name() +
2248  "': XUp '" + toString(userXRange.second) +
2249  "' is smaller than the lowest possible value '" +
2250  toString(xaxis.low) + "'");
2251  if (static_cast<int>(xaxis.nBins) < binXUp)
2252  throw invalid_argument("pp70::loadSettings: '" + name() +
2253  "': XUp '" + toString(userXRange.second) +
2254  "' is bigger than the highest possible value '" +
2255  toString(xaxis.up) + "'");
2256  const size_t nXBins(binXUp-_offset.first);
2257  const float xLow(userXRange.first);
2258  const float xUp(userXRange.second);
2259  string output("pp70::loadSettings '" + name() +
2260  "': returns a subset of result in processor '" + input.name() +
2261  "' which has dimension '" + toString(input.dim()) +
2262  "'. Subset is xLow:" + toString(userXRange.first) + "(" +
2263  toString(_offset.first) + "), xUp:" + toString(userXRange.second) +
2264  "(" + toString(binXUp) + "), xNbrBins:" + toString(nXBins));
2265  if (1 == input.dim())
2266  {
2268  (new result_t(result_t::axe_t(nXBins,xLow,xUp,xaxis.title))));
2269  }
2270  else if (2 == input.dim())
2271  {
2272  const result_t::axe_t &yaxis(input.axis(result_t::yAxis));
2273  pair<float,float> userYRange;
2274  userYRange.first = s.value("YLow",0).toFloat();
2275  userYRange.second = s.value("YUp",1).toFloat();
2276  if (userYRange.first >= userYRange.second)
2277  throw invalid_argument("pp70::loadSettings: '" + name() + "' YLow '" +
2278  toString(userYRange.first) +
2279  "' is bigger or equal to YUp '" +
2280  toString(userYRange.second) + "'");
2281  _offset.second = yaxis.bin(userYRange.first);
2282  const int binYUp(yaxis.bin(userYRange.second));
2283  if (_offset.second == binYUp)
2284  throw invalid_argument("pp70::loadSettings: '" + name() +
2285  "': YLow '" + toString(userYRange.first) +
2286  "' is giving the the same row as YUp '" +
2287  toString(userYRange.second) + "'");
2288  if (_offset.second < 0)
2289  throw invalid_argument("pp70::loadSettings: '" + name() +
2290  "': YLow '" + toString(userYRange.first) +
2291  "' is smaller than the lowest possible value '" +
2292  toString(yaxis.low) + "'");
2293  if (static_cast<int>(yaxis.nBins) < _offset.second)
2294  throw invalid_argument("pp70::loadSettings: '" + name() +
2295  "': YLow '" + toString(userYRange.first) +
2296  "' is bigger than the highest possible value '" +
2297  toString(yaxis.up) + "'");
2298  if (binYUp < 0)
2299  throw invalid_argument("pp70::loadSettings: '" + name() +
2300  "': YUp '" + toString(userYRange.second) +
2301  "' is smaller than the lowest possible value '" +
2302  toString(yaxis.low) + "'");
2303  if (static_cast<int>(yaxis.nBins) < binYUp)
2304  throw invalid_argument("pp70::loadSettings: '" + name() +
2305  "': YUp '" + toString(userYRange.second) +
2306  "' is bigger than the highest possible value '" +
2307  toString(yaxis.up) + "'");
2308  const size_t nYBins(binYUp - _offset.second);
2309  const float yLow (userYRange.first);
2310  const float yUp (userYRange.second);
2313  (new result_t
2314  (result_t::axe_t(nXBins,xLow,xUp,xaxis.title),
2315  result_t::axe_t(nYBins,yLow,yUp,yaxis.title))));
2316  output += ", yLow:"+ toString(yLow) + "(" + toString(_offset.second) +
2317  "), yUp:" + toString(yUp) + "(" + toString(binYUp) +
2318  "), yNbrBins:"+ toString(nYBins);
2319  }
2320  output += ". Condition on processor '" + _condition->name() + "'";
2321  Log::add(Log::INFO,output);
2322 }
2323 
2324 void pp70::process(const CASSEvent& evt, result_t &result)
2325 {
2326  const result_t& input(_input->result(evt.id()));
2327  QReadLocker lock(&input.lock);
2328 
2329  const size_t resNX(result.shape().first);
2330  const size_t resNY(result.shape().second);
2331  const size_t inNX(input.shape().first);
2332  for (size_t y(0);y < resNY; ++y)
2333  {
2334  const size_t inStart((_offset.second+y)*inNX + _offset.first);
2335  const size_t inEnd(inStart + resNX);
2336  const size_t resStart(y*resNX);
2337  copy(input.begin()+inStart, input.begin()+inEnd, result.begin()+resStart);
2338  }
2339 }
2340 
2341 
2342 
2343 
2344 
2345 
2346 
2347 // *** pp 71 returns a user specific value of a Histogram ***
2348 
2349 pp71::pp71(const name_t &name)
2350  : Processor(name)
2351 {
2352  loadSettings(0);
2353 }
2354 
2356 {
2357  CASSSettings s;
2358  s.beginGroup("Processor");
2360  setupGeneral();
2361  _pHist = setupDependency("InputName");
2362  bool ret (setupCondition());
2363  if (!(ret && _pHist))
2364  return;
2365  string functype(s.value("RetrieveType","max").toString().toStdString());
2366  if (functype == "max")
2367  _func = &cass::max_element<result_t::const_iterator>;
2368  else if (functype == "min")
2369  _func = &cass::min_element<result_t::const_iterator>;
2370  else
2371  throw invalid_argument("pp71::loadSettings(): RetrieveType '" + functype +
2372  "' unknown.");
2373 
2375  Log::add(Log::INFO,"Processor '" + name() +
2376  "' returns the value in '" + _pHist->name() +
2377  "' that is retrieved by using function type '" + functype +
2378  "' .Condition on processor '" + _condition->name() + "'");
2379 }
2380 
2381 void pp71::process(const CASSEvent& evt, result_t &result)
2382 {
2383  const result_t& one(_pHist->result(evt.id()));
2384  QReadLocker lock(&one.lock);
2385 
2386  result.setValue(*(_func(one.begin(), one.begin()+one.datasize())));
2387 }
2388 
2389 
2390 
2391 
2392 
2393 
2394 
2395 
2396 // *** pp 75 clears a result ***
2397 
2398 pp75::pp75(const name_t &name)
2399  : Processor(name)
2400 {
2401  loadSettings(0);
2402 }
2403 
2405 {
2406  CASSSettings s;
2407  s.beginGroup("Processor");
2409  setupGeneral();
2410  _hist = setupDependency("InputName");
2411  bool ret (setupCondition());
2412  if (!(ret && _hist))
2413  return;
2414  Log::add(Log::INFO,"Processor '" + name() +
2415  "' clears the result in processor '" + _hist->name() +
2416  "'. Condition is "+ _condition->name());
2417 }
2418 
2420 {
2421  throw logic_error("pp75::result: '"+name()+"' should never be called");
2422 }
2423 
2425 {
2426  if (_condition->result(evt.id()).isTrue())
2427  const_cast<result_t&>(_hist->result(evt.id())).clear();
2428 }
2429 
2430 
2431 
2432 
2433 
2434 
2435 // *** pp 76 quit program
2436 
2437 pp76::pp76(const name_t &name)
2438  : Processor(name)
2439 {
2440  loadSettings(0);
2441 }
2442 
2444 {
2445  setupGeneral();
2446  if (!setupCondition())
2447  return;
2448  Log::add(Log::INFO,"Processor '" + name() +
2449  "' will quit CASS.. Condition is "+ _condition->name());
2450 }
2451 
2453 {
2454  throw logic_error("pp75::result: '"+name()+"' should never be called");
2455 }
2456 
2458 {
2459  if (_condition->result(evt.id()).isTrue())
2460  InputBase::reference().end();
2461 }
2462 
2463 
2464 
2465 
2466 
2467 
2468 
2469 
2470 
2471 
2472 
2473 // *** pp 77 checks ids
2474 
2475 pp77::pp77(const name_t &name)
2476  : Processor(name)
2477 {
2478  loadSettings(0);
2479 }
2480 
2482 {
2483  setupGeneral();
2484  if (!setupCondition())
2485  return;
2486  CASSSettings s;
2487  s.beginGroup("Processor");
2489  _list.clear();
2490  string filename(s.value("List","").toString().toStdString());
2491  ifstream file(filename.c_str(),ios::in);
2492  if (!file.is_open())
2493  throw invalid_argument("pp77::loadSettings(): list file '" + filename +
2494  "' could not be opened.");
2495  uint64_t id;
2496  while (file.good())
2497  {
2498  file >> id;
2499  _list.push_back(id);
2500  }
2502 
2503  Log::add(Log::INFO,"Processor '" + name() +
2504  "' will check whether eventid in file '" + filename +
2505  "'. Condition is "+ _condition->name());
2506 }
2507 
2508 void pp77::process(const CASSEvent& evt, result_t &result)
2509 {
2510  result.setValue(find(_list.begin(),_list.end(),evt.id()) != _list.end());
2511 }
2512 
2513 
2514 
2515 
2516 
2517 
2518 
2519 
2520 
2521 // *** pp 78 counter ***
2522 
2523 pp78::pp78(const name_t &name)
2524  : AccumulatingProcessor(name)
2525 {
2526  loadSettings(0);
2527 }
2528 
2530 {
2531  setupGeneral();
2532  if (!setupCondition())
2533  return;
2535  Log::add(Log::INFO,"Processor '" + name() +
2536  "' counts how many times its process is called. '" +
2537  "'. Condition is '"+ _condition->name() + "'");
2538 }
2539 
2540 void pp78::process(const CASSEvent&, result_t &result)
2541 {
2542  ++(result[0]);
2543 }
2544 
2545 
2546 
2547 
2548 
2549 
2550 
2551 
2552 
2553 
2554 
2555 
2556 
2557 // *** pp 81 returns the highest bin of a 1D Histogram ***
2558 
2559 pp81::pp81(const name_t &name)
2560  : Processor(name)
2561 {
2562  loadSettings(0);
2563 }
2564 
2566 {
2567  CASSSettings s;
2568  s.beginGroup("Processor");
2570  setupGeneral();
2571  _pHist = setupDependency("InputName");
2572  bool ret (setupCondition());
2573  if (!(ret && _pHist))
2574  return;
2575  if (_pHist->result().dim() != 1)
2576  throw invalid_argument("pp81::loadSettings() '" + name() + "': '" +
2577  _pHist->name() + "' is not a 1D hist");
2578  string functype(s.value("RetrieveType","max").toString().toStdString());
2579  if (functype == "max")
2580  _func = &cass::max_element<result_t::const_iterator>;
2581  else if (functype == "min")
2582  _func = &cass::min_element<result_t::const_iterator>;
2583  else
2584  throw invalid_argument("pp81::loadSettings(): RetrieveType '" + functype +
2585  "' unknown.");
2586 
2588  Log::add(Log::INFO,"Processor '" + name() +
2589  "' returns the maximum bin in '" + _pHist->name() +
2590  "' .Condition on processor '" + _condition->name() + "'");
2591 }
2592 
2593 void pp81::process(const CASSEvent& evt, result_t &result)
2594 {
2595  const result_t& one(_pHist->result(evt.id()));
2596  QReadLocker lock(&one.lock);
2597 
2598  result_t::const_iterator it(_func(one.begin(), one.begin()+one.datasize()));
2599  const size_t bin(distance(one.begin(),it));
2600  result.setValue(one.axis(result_t::xAxis).pos(bin));
2601 }
2602 
2603 
2604 
2605 
2606 
2607 
2608 
2609 
2610 
2611 
2612 
2613 
2614 
2615 
2616 
2617 
2618 // *** pp 82 returns statistics value of all bins in a Histogram ***
2619 
2620 pp82::pp82(const name_t &name)
2621  : Processor(name)
2622 {
2623  loadSettings(0);
2624 }
2625 
2627 {
2628  CASSSettings s;
2629  s.beginGroup("Processor");
2631  setupGeneral();
2632  _pHist = setupDependency("InputName");
2633  bool ret(setupCondition());
2634  if (!(ret && _pHist))
2635  return;
2636 
2637  string functype(s.value("Statistics","sum").toString().toStdString());
2638  if (functype == "sum")
2639  {
2640  _val = &cumstat_t::sum;
2641  _value = std::tr1::bind(&pp82::cummulativeStatistics,this,_1);
2642  }
2643  else if (functype == "mean")
2644  {
2645  _val = &cumstat_t::mean;
2646  _value = std::tr1::bind(&pp82::cummulativeStatistics,this,_1);
2647  }
2648  else if (functype == "stdv")
2649  {
2650  _val = &cumstat_t::stdv;
2651  _value = std::tr1::bind(&pp82::cummulativeStatistics,this,_1);
2652  }
2653  else if (functype == "variance")
2654  {
2656  _value = std::tr1::bind(&pp82::cummulativeStatistics,this,_1);
2657  }
2658  else if (functype == "median")
2659  {
2660  _value = std::tr1::bind(&pp82::medianCalc,this,_1);
2661  }
2662  else
2663  throw invalid_argument("pp82::loadSettings(): Statistics type '" + functype +
2664  "' unknown.");
2665 
2667 
2668  Log::add(Log::INFO,"Processor '" + name() +
2669  "' returns the '" + functype + "' of all bins in '" + _pHist->name() +
2670  "' .Condition on processor '" + _condition->name() + "'");
2671 }
2672 
2674 {
2675  cumstat_t stat;
2676  stat.addDistribution(res.begin(),res.begin()+res.datasize());
2677  return _val(stat);
2678 }
2679 
2681 {
2682  med_t stat;
2683  stat.addDistribution(res.begin(),res.begin()+res.datasize());
2684  return stat.median();
2685 }
2686 
2687 void pp82::process(const CASSEvent& evt, result_t &result)
2688 {
2689  const result_t &one(_pHist->result(evt.id()));
2690  QReadLocker lock(&one.lock);
2691 
2692  result.setValue(_value(one));
2693 }
2694 
2695 
2696 
2697 
2698 
2699 
2700 
2701 
2702 
2703 
2704 
2705 
2706 
2707 
2708 
2709 
2710 
2711 
2712 // *** pp 85 return full width at half maximum in given range of 1D histgoram ***
2713 
2714 pp85::pp85(const name_t &name)
2715  : Processor(name)
2716 {
2717  loadSettings(0);
2718 }
2719 
2721 {
2722  CASSSettings s;
2723  s.beginGroup("Processor");
2725  setupGeneral();
2726  _pHist = setupDependency("InputName");
2727  bool ret (setupCondition());
2728  if (!(ret && _pHist))
2729  return;
2730  const result_t &hist(_pHist->result());
2731  if (hist.dim() != 1)
2732  throw invalid_argument("pp85::loadSettings()'" + name() +
2733  "': Error the result we depend on '" + _pHist->name() +
2734  "' is not a 1D Histogram.");
2735  pair<float,float> userXRange(make_pair(s.value("XLow",0).toFloat(),
2736  s.value("XUp",1).toFloat()));
2737  if (userXRange.first >= userXRange.second)
2738  throw invalid_argument("pp85::loadSettings: '"+name()+"' XLow '" +
2739  toString(userXRange.first) +
2740  "' is bigger or equal to XUp '" +
2741  toString(userXRange.second) + "'");
2742  const result_t::axe_t &xaxis(hist.axis(result_t::xAxis));
2743  _xRange.first = xaxis.bin(userXRange.first);
2744  _xRange.second = xaxis.bin(userXRange.second);
2745  if (_xRange.first == _xRange.second)
2746  throw invalid_argument("pp85::loadSettings: '" + name() +
2747  "': XLow '" + toString(userXRange.first) +
2748  "' is giving the the same column as XUp '" +
2749  toString(userXRange.second) + "'");
2750  if (_xRange.first < 0)
2751  throw invalid_argument("pp85::loadSettings: '" + name() +
2752  "': XLow '" + toString(userXRange.first) +
2753  "' is smaller than the lowest possible value '" +
2754  toString(xaxis.low) + "'");
2755  if (static_cast<int>(xaxis.nBins) < _xRange.first)
2756  throw invalid_argument("pp85::loadSettings: '" + name() +
2757  "': XLow '" + toString(userXRange.first) +
2758  "' is higher than the highest possible value '" +
2759  toString(xaxis.up) + "'");
2760  if (_xRange.second < 0)
2761  throw invalid_argument("pp85::loadSettings: '" + name() +
2762  "': XUp '" + toString(userXRange.second) +
2763  "' is smaller than the lowest possible value '" +
2764  toString(xaxis.low) + "'");
2765  if (static_cast<int>(xaxis.nBins) < _xRange.second)
2766  throw invalid_argument("pp85::loadSettings: '" + name() +
2767  "': XUp '" + toString(userXRange.second) +
2768  "' is higher than the highest possible value '" +
2769  toString(xaxis.up) + "'");
2770 
2771  _fraction = s.value("Fraction",0.5).toFloat();
2773  Log::add(Log::INFO,"Processor '" + name() +
2774  "' returns the full width at half maximum in '" + _pHist->name() +
2775  "' of the range from xlow '" + toString(userXRange.first) +
2776  "' to xup '" + toString(userXRange.second) +
2777  "' which in bins is from '" + toString(_xRange.first) + "' to '" +
2778  toString(_xRange.second) +
2779  "' .Condition on processor '" + _condition->name() + "'");
2780 }
2781 
2782 void pp85::process(const CASSEvent& evt, result_t &result)
2783 {
2784  const result_t& one(_pHist->result(evt.id()));
2785  QReadLocker lock(&one.lock);
2786 
2787  result_t::const_iterator xRangeBegin(one.begin()+_xRange.first);
2788  result_t::const_iterator xRangeEnd(one.begin()+_xRange.second);
2789  result_t::const_iterator maxElementIt(cass::max_element(xRangeBegin, xRangeEnd));
2790  result_t::const_iterator minElementIt(cass::min_element(xRangeBegin, xRangeEnd));
2791  const float fracMax((*maxElementIt-*minElementIt) * _fraction + *minElementIt);
2792 
2793  result_t::const_iterator leftSide;
2794  result_t::const_iterator rightSide;
2795  for(result_t::const_iterator iVal(maxElementIt);
2796  (iVal != xRangeBegin) && (*iVal > fracMax);
2797  --iVal)
2798  {
2799  leftSide = iVal;
2800  }
2801  for(result_t::const_iterator iVal(maxElementIt);
2802  (iVal != xRangeEnd) && (*iVal > fracMax);
2803  ++iVal)
2804  {
2805  rightSide = iVal;
2806  }
2807  const result_t::axe_t xaxis(one.axis((result_t::xAxis)));
2808  const float lowerLeftPos (xaxis.pos(distance(one.begin(),leftSide)));
2809  const float lowerRightPos(xaxis.pos(distance(one.begin(),rightSide)));
2810  const float upperLeftPos (xaxis.pos(distance(one.begin(),leftSide-1)));
2811  const float upperRightPos(xaxis.pos(distance(one.begin(),rightSide+1)));
2812  const float lowerdist(lowerRightPos - lowerLeftPos);
2813  const float upperdist(upperRightPos - upperLeftPos);
2814  const float fwfm((upperdist+lowerdist)*0.5);
2815 
2816  result.setValue(fwfm);
2817 }
2818 
2819 
2820 
2821 
2822 
2823 
2824 
2825 
2826 
2827 
2828 
2829 
2830 
2831 
2832 
2833 
2834 
2835 
2836 
2837 
2838 
2839 
2840 // *** pp 86 return x position of a step in 1D histgoram ***
2841 
2842 pp86::pp86(const name_t &name)
2843  : Processor(name)
2844 {
2845  loadSettings(0);
2846 }
2847 
2849 {
2850  CASSSettings s;
2851  s.beginGroup("Processor");
2853  setupGeneral();
2854  _pHist = setupDependency("InputName");
2855  bool ret (setupCondition());
2856  if (!(ret && _pHist))
2857  return;
2858  const result_t &hist(_pHist->result());
2859  if (hist.dim() != 1)
2860  throw invalid_argument("pp86::loadSettings()'" + name() +
2861  "': Error the processor we depend on '" + _pHist->name() +
2862  "' does not contain a 1D result.");
2863  const result_t::axe_t &xaxis(hist.axis(result_t::xAxis));
2864 
2865  pair<float,float> userXRangeStep(make_pair(s.value("XLow",0).toFloat(),
2866  s.value("XUp",1).toFloat()));
2867  if (userXRangeStep.first >= userXRangeStep.second)
2868  throw invalid_argument("pp86::loadSettings: '" + name() + "' XLow '" +
2869  toString(userXRangeStep.first) +
2870  "' is bigger or equal to XUp '" +
2871  toString(userXRangeStep.second) + "'");
2872  _xRangeStep.first = xaxis.bin(userXRangeStep.first);
2873  _xRangeStep.second = xaxis.bin(userXRangeStep.second);
2874  if (_xRangeStep.first == _xRangeStep.second)
2875  throw invalid_argument("pp86::loadSettings: '" + name() +
2876  "': XLow '" + toString(userXRangeStep.first) +
2877  "' is giving the the same column as XUp '" +
2878  toString(userXRangeStep.second) + "'");
2879  if (_xRangeStep.first < 0)
2880  throw invalid_argument("pp86::loadSettings: '" + name() +
2881  "': XLow '" + toString(userXRangeStep.first) +
2882  "' is smaller than the lowest possible value '" +
2883  toString(xaxis.low) + "'");
2884  if (static_cast<int>(xaxis.nBins) < _xRangeStep.first)
2885  throw invalid_argument("pp86::loadSettings: '" + name() +
2886  "': XLow '" + toString(userXRangeStep.first) +
2887  "' is higher than the highest possible value '" +
2888  toString(xaxis.up) + "'");
2889  if (_xRangeStep.second < 0)
2890  throw invalid_argument("pp86::loadSettings: '" + name() +
2891  "': XUp '" + toString(userXRangeStep.second) +
2892  "' is smaller than the lowest possible value '" +
2893  toString(xaxis.low) + "'");
2894  if (static_cast<int>(xaxis.nBins) < _xRangeStep.second)
2895  throw invalid_argument("pp86::loadSettings: '" + name() +
2896  "': XUp '" + toString(userXRangeStep.second) +
2897  "' is higher than the highest possible value '" +
2898  toString(xaxis.up) + "'");
2899 
2900  pair<float,float> userXRangeBaseline(make_pair(s.value("BaselineLow",0).toFloat(),
2901  s.value("BaselineUp",1).toFloat()));
2902  if (userXRangeBaseline.first >= userXRangeBaseline.second)
2903  throw invalid_argument("pp86::loadSettings: '"+name()+"' BaselineLow '" +
2904  toString(userXRangeBaseline.first) +
2905  "' is bigger or equal to BaselineUp '" +
2906  toString(userXRangeBaseline.second) + "'");
2907  _xRangeBaseline.first = xaxis.bin(userXRangeBaseline.first);
2908  _xRangeBaseline.second = xaxis.bin(userXRangeBaseline.second);
2909  if (_xRangeBaseline.first == _xRangeBaseline.second)
2910  throw invalid_argument("pp86::loadSettings: '" + name() +
2911  "': BaselineLow '" + toString(userXRangeBaseline.first) +
2912  "' is giving the the same column as BaselineUp '" +
2913  toString(userXRangeBaseline.second) + "'");
2914  if (_xRangeBaseline.first < 0)
2915  throw invalid_argument("pp86::loadSettings: '" + name() +
2916  "': BaselineLow '" + toString(userXRangeBaseline.first) +
2917  "' is smaller than the lowest possible value '" +
2918  toString(xaxis.low) + "'");
2919  if (static_cast<int>(xaxis.nBins) < _xRangeBaseline.first)
2920  throw invalid_argument("pp86::loadSettings: '" + name() +
2921  "': BaselineLow '" + toString(userXRangeBaseline.first) +
2922  "' is higher than the highest possible value '" +
2923  toString(xaxis.up) + "'");
2924  if (_xRangeBaseline.second < 0)
2925  throw invalid_argument("pp86::loadSettings: '" + name() +
2926  "': BaselineUp '" + toString(userXRangeBaseline.second) +
2927  "' is smaller than the lowest possible value '" +
2928  toString(xaxis.low) + "'");
2929  if (static_cast<int>(xaxis.nBins) < _xRangeBaseline.second)
2930  throw invalid_argument("pp86::loadSettings: '" + name() +
2931  "': BaselineUp '" + toString(userXRangeBaseline.second) +
2932  "' is higher than the highest possible value '" +
2933  toString(xaxis.up) + "'");
2934 
2935  _userFraction = s.value("Fraction",0.5).toFloat();
2936 
2938  Log::add(Log::INFO, "Processor '" + name() +
2939  "' returns the position of the step in '" + _pHist->name() +
2940  "' in the range from xlow '" + toString(userXRangeStep.first) +
2941  "' to xup '" + toString(userXRangeStep.second) +
2942  "' which in bins is from '" + toString(_xRangeStep.first) +
2943  "' to '" + toString(_xRangeStep.second) +
2944  "'. Where the baseline is defined in range '" +
2945  toString(userXRangeBaseline.first) + "' to '" +
2946  toString(userXRangeBaseline.second) + "' which in bins is from '" +
2947  toString(_xRangeBaseline.first) + "' to '" +
2948  toString(_xRangeBaseline.second) + "'. The Fraction is '" +
2949  toString(_userFraction) + "' .Condition on processor '" +
2950  _condition->name() + "'");
2951 }
2952 
2953 void pp86::process(const CASSEvent& evt, result_t &result)
2954 {
2955  const result_t& one(_pHist->result(evt.id()));
2956  QReadLocker lock(&one.lock);
2957 
2958  result_t::const_iterator baselineBegin(one.begin()+_xRangeBaseline.first);
2959  result_t::const_iterator baselineEnd(one.begin()+_xRangeBaseline.second);
2960  const float baseline(accumulate(baselineBegin,baselineEnd,0.f) /
2961  static_cast<float>(distance(baselineBegin,baselineEnd)));
2962 
2963  result_t::const_iterator stepRangeBegin(one.begin()+_xRangeStep.first);
2964  result_t::const_iterator stepRangeEnd(one.begin()+_xRangeStep.second);
2965 
2966  result_t::const_iterator maxElementIt
2967  (std::max_element(stepRangeBegin, stepRangeEnd));
2968  const float halfMax((*maxElementIt+baseline) * _userFraction);
2969 
2970  result_t::const_iterator stepIt(stepRangeBegin+1);
2971  for ( ; stepIt != maxElementIt ; stepIt++ )
2972  if ( *(stepIt-1) <= halfMax && halfMax < *stepIt )
2973  break;
2974  const size_t steppos(distance(one.begin(),stepIt));
2975 
2976  result.setValue(steppos);
2977 }
2978 
2979 
2980 
2981 
2982 
2983 
2984 
2985 
2986 
2987 
2988 
2989 
2990 
2991 
2992 
2993 
2994 // *** pp 87 return center of mass in range of 1D histgoram ***
2995 
2996 pp87::pp87(const name_t &name)
2997  : Processor(name)
2998 {
2999  loadSettings(0);
3000 }
3001 
3003 {
3004  CASSSettings s;
3005  s.beginGroup("Processor");
3007  setupGeneral();
3008  _pHist = setupDependency("InputName");
3009  bool ret (setupCondition());
3010  if (!(ret && _pHist))
3011  return;
3012  const result_t &hist(_pHist->result());
3013  if (hist.dim() != 1)
3014  throw invalid_argument("pp87::loadSettings()'" + name() +
3015  "': Error the processor we depend on '" + _pHist->name() +
3016  "' does not contain a 1D result.");
3017  const result_t::axe_t &xaxis(hist.axis(result_t::xAxis));
3018  pair<float,float> userXRange(make_pair(s.value("XLow",0).toFloat(),
3019  s.value("XUp",1).toFloat()));
3020  if (userXRange.first >= userXRange.second)
3021  throw invalid_argument("pp87::loadSettings: '"+name()+"' XLow '" +
3022  toString(userXRange.first) +
3023  "' is bigger or equal to XUp '" +
3024  toString(userXRange.second) + "'");
3025  _xRange.first = xaxis.bin(userXRange.first);
3026  _xRange.second = xaxis.bin(userXRange.second);
3027  if (_xRange.first == _xRange.second)
3028  throw invalid_argument("pp87::loadSettings: '" + name() +
3029  "': XLow '" + toString(userXRange.first) +
3030  "' is giving the the same column as XUp '" +
3031  toString(userXRange.second) + "'");
3032  if (_xRange.first < 0)
3033  throw invalid_argument("pp87::loadSettings: '" + name() +
3034  "': XLow '" + toString(userXRange.first) +
3035  "' is smaller than the lowest possible value '" +
3036  toString(xaxis.low) + "'");
3037  if (static_cast<int>(xaxis.nBins) < _xRange.first)
3038  throw invalid_argument("pp87::loadSettings: '" + name() +
3039  "': XLow '" + toString(userXRange.first) +
3040  "' is higher than the highest possible value '" +
3041  toString(xaxis.up) + "'");
3042  if (_xRange.second < 0)
3043  throw invalid_argument("pp87::loadSettings: '" + name() +
3044  "': XUp '" + toString(userXRange.second) +
3045  "' is smaller than the lowest possible value '" +
3046  toString(xaxis.low) + "'");
3047  if (static_cast<int>(xaxis.nBins) < _xRange.second)
3048  throw invalid_argument("pp87::loadSettings: '" + name() +
3049  "': XUp '" + toString(userXRange.second) +
3050  "' is higher than the highest possible value '" +
3051  toString(xaxis.up) + "'");
3052 
3054  Log::add(Log::INFO, "Processor '" + name() +
3055  "' returns the center of mass in '" + _pHist->name() +
3056  "' in the range from xlow '" + toString(userXRange.first) +
3057  "' to xup '" + toString(userXRange.second) +
3058  "' which in bins is from '" + toString(_xRange.first) + "' to '" +
3059  toString(_xRange.second) +
3060  "' .Condition on processor '"+_condition->name()+"'");
3061 }
3062 
3063 void pp87::process(const CASSEvent& evt, result_t &result)
3064 {
3065  const result_t& data(_pHist->result(evt.id()));
3066  QReadLocker lock(&data.lock);
3067 
3068  const result_t::axe_t &xAxis(data.axis(result_t::xAxis));
3069 
3070  float integral(0);
3071  float weight(0);
3072  for (int i(_xRange.first); i < _xRange.second; ++i)
3073  {
3074  integral += (data[i]);
3075  const float pos(xAxis.pos(i));
3076  weight += (data[i]*pos);
3077  }
3078  const float com(weight/integral);
3079 
3080  result.setValue(com);
3081 }
3082 
3083 
3084 
3085 
3086 
3087 
3088 
3089 // *** pp 88 returns an axis parameter ***
3090 
3091 pp88::pp88(const name_t &name)
3092  : Processor(name)
3093 {
3094  loadSettings(0);
3095 }
3096 
3098 {
3099  CASSSettings s;
3100  s.beginGroup("Processor");
3102 
3103  setupGeneral();
3104  _pHist = setupDependency("InputName");
3105  bool ret (setupCondition());
3106  if (!(ret && _pHist))
3107  return;
3108 
3109  QString axisparam(s.value("AxisParameter","XNbrBins").toString());
3110  if (axisparam == "XNbrBins")
3111  {
3114  }
3115  else if (axisparam == "XLow")
3116  {
3119  }
3120  else if (axisparam == "XUp")
3121  {
3124  }
3125  else if (axisparam == "YNbrBins")
3126  {
3129  }
3130  else if (axisparam == "YLow")
3131  {
3134  }
3135  else if (axisparam == "YUp")
3136  {
3139  }
3140  else
3141  throw invalid_argument("pp88 '" + name() + "' AxisParameter '" +
3142  axisparam.toStdString() + "' is unknown.");
3143 
3144  if (_pHist->result().dim() == 0)
3145  throw invalid_argument("pp88 '" + name() + "' result '" + _pHist->name() +
3146  "' has dimension 0, which has no axis properties.");
3147 
3148  if ((axisparam == "YNbrBins" || axisparam == "YLow" || axisparam == "YUp")
3149  && _pHist->result().dim() == 1)
3150  throw invalid_argument("pp88 '" + name() + "' result '" + _pHist->name() +
3151  "' has dimension 1 thus doesn't contain '" +
3152  axisparam.toStdString() + "'");
3153 
3155  Log::add(Log::INFO,"Processor '" + name() +
3156  "' returns axis parameter'"+ axisparam.toStdString() +
3157  "' of result in processor '" + _pHist->name() +
3158  "'. Condition on Processor '" + _condition->name() + "'");
3159 }
3160 
3161 void pp88::process(const CASSEvent& evt, result_t &result)
3162 {
3163  const result_t& hist(_pHist->result(evt.id()));
3164  QReadLocker lock(&hist.lock);
3165 
3166  result.setValue(_func(hist.axis(_axisId)));
3167 }
3168 
3169 
3170 
3171 
3172 
3173 
3174 
3175 
3176 // *** pp 89 high/low pass filter ***
3177 
3178 pp89::pp89(const name_t &name)
3179  : Processor(name)
3180 {
3181  loadSettings(0);
3182 }
3183 
3185 {
3186  CASSSettings s;
3187  s.beginGroup("Processor");
3189 
3190  setupGeneral();
3191  _pHist = setupDependency("InputName");
3192  bool ret (setupCondition());
3193  if (!(ret && _pHist))
3194  return;
3195 
3196  const float RC(1.f/(s.value("Cutoff",100.f).toFloat() * 2 * 3.1415));
3197  const float dt(1.f/s.value("SampleRate",100.f).toFloat());
3198 
3199  QString filtertype(s.value("FilterType","LowPass").toString());
3200  if (filtertype == "LowPass")
3201  {
3202  // float RC = 1.0/(CUTOFF*2*3.14);
3203  // float dt = 1.0/SAMPLE_RATE;
3204  // float alpha = dt/(RC+dt);
3205  _alpha = dt/(RC+dt);
3206  _func = std::tr1::bind(&pp89::lowPass,this,_1,_2);
3207  }
3208  else if (filtertype == "HighPass")
3209  {
3210  // float RC = 1.0/(CUTOFF*2*3.14);
3211  // float dt = 1.0/SAMPLE_RATE;
3212  // float alpha = RC/(RC + dt);
3213  _alpha = RC/(RC+dt);
3214  _func = std::tr1::bind(&pp89::highPass,this,_1,_2);
3215  }
3216  else
3217  throw invalid_argument("pp89 '" + name() + "' FilterType '" +
3218  filtertype.toStdString() + "' is unknown.");
3219 
3220  if (_pHist->result().dim() != 1)
3221  throw invalid_argument("pp89 '" + name() + "' result '" + _pHist->name() +
3222  "' is not a 1D result");
3223 
3224  createHistList(_pHist->result().clone());
3225  Log::add(Log::INFO,"Processor '" + name() +
3226  "' does "+ filtertype.toStdString() +
3227  "' operation on result in processor '" + _pHist->name() +
3228  "'. Condition on Processor '" + _condition->name() + "'");
3229 }
3230 
3232  result_t::iterator filtered)
3233 {
3234 // float RC = 1.0/(CUTOFF*2*3.14);
3235 // float dt = 1.0/SAMPLE_RATE;
3236 // float alpha = RC/(RC + dt);
3237 // float filteredArray[numSamples];
3238 // filteredArray[0] = data.recordedSamples[0];
3239 // for (i = 1; i<numSamples; i++){
3240 // filteredArray[i] = alpha * (filteredArray[i-1] + data.recordedSamples[i] - data.recordedSamples[i-1]);
3241 // }
3242 // data.recordedSamples = filteredArray;
3243 
3244  *filtered = _alpha * (*(filtered-1) + *orig - *(orig-1));
3245 
3246 }
3247 
3249  result_t::iterator filtered)
3250 {
3251 // float RC = 1.0/(CUTOFF*2*3.14);
3252 // float dt = 1.0/SAMPLE_RATE;
3253 // float alpha = dt/(RC+dt);
3254 // float filteredArray[numSamples];
3255 // filteredArray[0] = data.recordedSamples[0];
3256 // for(i=1; i<numSamples; i++){
3257 // filteredArray[i] = filteredArray[i-1] + (alpha*(data.recordedSamples[i] - filteredArray[i-1]));
3258 // }
3259 // data.recordedSamples = filteredArray;
3260 
3261  *filtered = *(filtered-1) + (_alpha * (*orig - *(filtered-1)));
3262 }
3263 
3264 void pp89::process(const CASSEvent& evt, result_t &result)
3265 {
3266  const result_t& in(_pHist->result(evt.id()));
3267  QReadLocker lock(&in.lock);
3268 
3269  result_t::const_iterator inIt(in.begin());
3270  result_t::const_iterator inEnd(in.begin()+in.datasize());
3271  result_t::iterator outIt(result.begin());
3272 
3273  *outIt++ = *inIt++;
3274  while (inIt != inEnd)
3275  {
3276  _func(inIt,outIt);
3277  ++inIt;
3278  ++outIt;
3279  }
3280 }
3281 
3282 
3283 
3284 
3285 
3286 
3287 
3288 // *** pp 91 return a list of minima in a result ***
3289 
3290 pp91::pp91(const name_t &name)
3291  : Processor(name)
3292 {
3293  loadSettings(0);
3294 }
3295 
3297 {
3298  CASSSettings s;
3299  s.beginGroup("Processor");
3301  setupGeneral();
3302  _input = setupDependency("InputName");
3303  bool ret (setupCondition());
3304  if (!(ret && _input))
3305  return;
3306  const result_t &input(_input->result());
3307  if (input.dim() != 1)
3308  throw invalid_argument("pp91::loadSettings()'" + name() +
3309  "': Error the processor we depend on '" + input.name() +
3310  "' does not contain a 1D result.");
3311  _range = s.value("Range",10).toUInt();
3312 
3313  string extremePointTypes(s.value("ExtremePointType","minima").toString().toStdString());
3314  if (extremePointTypes == "minima")
3315  _op = greater<result_t::value_t>();
3316  else if (extremePointTypes == "maxima")
3317  _op = less<result_t::value_t>();
3318  else
3319  throw invalid_argument("pp91::loadSettings()'" + name() +
3320  "': extreme point type '" + extremePointTypes +
3321  "' is unrecognized");
3322 
3324  Log::add(Log::INFO, "Processor '" + name() +
3325  "' returns a list of local " + extremePointTypes + " in '" +
3326  _input->name() + "'. The local " + extremePointTypes + " are the " +
3327  extremePointTypes + " within a range of '" + toString(_range) +
3328  "' .Condition on processor '"+_condition->name() + "'");
3329 }
3330 
3331 void pp91::process(const CASSEvent& evt, result_t &result)
3332 {
3333  const result_t& data(_input->result(evt.id()));
3334  QReadLocker lock(&data.lock);
3335 
3336  const result_t::axe_t &xAxis(data.axis(result_t::xAxis));
3337 
3338  result.resetTable();
3339  table_t candidate(nbrOf,0);
3340 
3341  for (size_t i=_range;i < data.datasize()-_range; ++i)
3342  {
3343  if (!std::isfinite(data[i]))
3344  continue;
3345 
3346  float curval(data[i]);
3347  bool isExtreme(true);
3348  for (size_t j=i-_range; j < i+_range; ++j)
3349  {
3350  if(isnan(data[j]) || _op(curval,data[j]))
3351  {
3352  isExtreme = false;
3353  break;
3354  }
3355  }
3356  if (isExtreme)
3357  {
3358  candidate[Index] = i;
3359  candidate[Position] = xAxis.pos(i);
3360  candidate[Value] = data[i];
3361  result.appendRows(candidate);
3362  }
3363  }
3364 }
std::tr1::function< result_t::value_t()> _scale
function that will return the scale that should be used for the average
Definition: operations.h:1166
virtual void process(const CASSEvent &, result_t &)
process event
CachedList::item_type result_t
define the results
Definition: processor.h:52
result_t::value_t cumulativeScale()
retrieve the cumulative scale for the current datum
Definition: operations.h:1145
shared_pointer _two
processor containing 0D result
Definition: operations.h:1577
result_t::value_t _weight
the constant weight
Definition: operations.h:1472
storage_t::const_iterator const_iterator
a const iterator on the storage
Definition: result.hpp:338
virtual void process(const CASSEvent &, result_t &)
process event
func_t _histogram
function used for histogramming
Definition: operations.h:1067
result_t::value_t movingScale()
retrieve the moving average scale after the initialization of the "first" point
Definition: operations.h:1153
std::pair< int, int > _baselineRange
range we want to have the baseline for the integral over in result bins
Definition: operations.h:746
void appendRows(const storage_t &rows)
add row(s) to the result
Definition: result.hpp:724
value_t getValue() const
return the value
Definition: result.hpp:558
shared_pointer _pHist
processor containing the 2d result we want to project
Definition: operations.h:678
Event to store all LCLS Data.
Definition: cass_event.h:32
result_t::value_t _alpha
alpha for the running average
Definition: operations.h:1160
std::tr1::function< result_t::value_t(const result_t::axe_t &)> _func
function to retrieve the parameter from the axis
Definition: operations.h:2238
virtual void createHistList(result_t::shared_pointer result)
create result list.
Definition: processor.cpp:79
void applyConstantThreshold(const result_t &in, result_t &out, const CASSEvent::id_t &id)
apply a constant threshold
Definition: operations.cpp:660
shared_pointer _pHist
processor containing result to store
Definition: operations.h:806
virtual void process(const CASSEvent &, result_t &)
process event
bool fuzzycompare(const T &first, const T &second)
fuzzy compare two floating point variables
const_iterator end() const
retrieve iterator to the end of storage
Definition: result.hpp:632
virtual void process(const CASSEvent &, result_t &)
process event
virtual void loadSettings(size_t)
load the settings of the pp
pp57(const name_t &name)
constructor
pp64(const name_t &)
constructor
float baselineFromInput(const result_t &input)
get the baseline for the integration
shared_pointer _weightInput
processor containing the weights
Definition: operations.h:1475
std::vector< value_t > storage_t
the storage of this container
Definition: result.hpp:332
binaryoperation_t _op
the operand
Definition: operations.h:184
std::pair< int, int > _xRangeStep
the requested x-axis limits for find the step in bins
Definition: operations.h:2139
pp65(const name_t &name)
constructor
virtual void loadSettings(size_t)
load the settings
const item_type & latest() const
retrieve the latest item
Definition: cached_list.hpp:75
virtual void process(const CASSEvent &evt, result_t &)
process event
Definition: operations.cpp:158
const name_t name() const
retrieve the name of this processor
Definition: processor.h:167
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:591
pp86(const name_t &name)
constructor
void histogramAndBinCountWithWeights(CASSEvent::id_t id, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with weights from another processor
pp40(const name_t &name)
constructor
Definition: operations.cpp:613
result_t::value_t _userVal
the value that will be set
Definition: operations.h:607
float value_t
the values of this container
Definition: result.hpp:326
std::tr1::function< void(result_t::const_iterator, result_t::iterator)> _func
function to retrieve the parameter from the axis
Definition: operations.h:2337
void highPass(result_t::const_iterator orig, result_t::iterator filtered)
high pass filtering function
virtual void loadSettings(size_t)
load the settings
Settings for CASS.
Definition: cass_settings.h:30
result_t::value_t cummulativeStatistics(const result_t &res)
retrieve the statistics value from the cummulative statistics calculator
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
Definition: result.hpp:323
std::tr1::function< cumstat_t::value_type(const cumstat_t &)> _val
the type of function used to retrive the wanted element
Definition: operations.h:2017
result_t::axe_t _origYAxis
y-axis object of the original size (without the nbr fills part)
Definition: operations.h:1478
std::vector< uint64_t > _list
the list of ids
Definition: operations.h:1849
float constantBaseline(const result_t &)
get constant baseline
Definition: operations.h:760
result_t _previous
the previous result
Definition: operations.h:803
shared_pointer _input
processor containing input result
Definition: operations.h:1671
std::tr1::function< result_t::value_t(const result_t &)> _value
function to retrieve the statistics type
Definition: operations.h:2020
pp69(const name_t &name)
constructor
shared_pointer _hist
processor containing input result
Definition: operations.h:175
virtual void loadSettings(size_t)
load the settings of the pp
void histogramWithWeightFrom0D(CASSEvent::id_t id, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with weight from 0D processor
virtual void loadSettings(size_t)
load the settings of the pp
Processor::result_t::shared_pointer set2DHist(const Processor::name_t &name)
function to set the 2d histogram properties from the ini file.
pp78(const name_t &name)
constructor
void assign(const self_type &in)
copy the contents of a different result to this result
Definition: result.hpp:906
void lowPass(result_t::const_iterator orig, result_t::iterator filtered)
low pass filtering function
shared_pointer _one
pp containing input result
Definition: operations.h:601
result_t::value_t _difference
the maximum difference to previous val that is accepted
Definition: operations.h:455
size_type size() const
return the raw size of the storage
Definition: result.hpp:881
void histogramAndBinCountWithConstant(CASSEvent::id_t unused, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with user provided constant weight
result_t::value_t _threshold
the threshold
Definition: operations.h:538
pp66(const name_t &name)
constructor
shared_pointer _one
processor containing result
Definition: operations.h:363
uint64_t id_t
define the id type
Definition: cass_event.h:52
virtual void loadSettings(size_t)
load the settings of the pp
Definition: operations.cpp:773
shared_pointer _yInput
processor containing Y-axis value
Definition: operations.h:1469
shared_pointer _pHist
processor containing input result
Definition: operations.h:2074
virtual void loadSettings(size_t)
load the settings of the pp
bool _hide
flag to tell whether this pp should be hidden in the dropdown list
Definition: processor.h:262
statistics calculator for a cummulative statistic
virtual void loadSettings(size_t)
load the settings
STL namespace.
file contains processors that will operate on results of other processors
an axis of a more than 0 dimensional container
Definition: result.hpp:29
virtual void process(const CASSEvent &, result_t &)
process event
virtual void process(const CASSEvent &, result_t &)
process event
result_t::value_t _previousVal
the value of the previous event
Definition: operations.h:452
virtual void process(const CASSEvent &, result_t &)
process event
float _excludeVal
the value that should be excluded in the summation
Definition: operations.h:898
std::string title
the title of the axis
Definition: result.hpp:296
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:742
void histogramAndBinCountWithConstant(CASSEvent::id_t unused, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with constant weight
void resetTable()
reset the table like result
Definition: result.hpp:740
ForwardIterator min_element(ForwardIterator first, ForwardIterator last)
provide own implementation of min_element to be able to compile
Definition: operations.cpp:66
unaryoperation_t ValAtFirst(result_t::value_t val)
bind the value to the first parameter of the binaryoperation
Definition: operations.cpp:260
size_t bin(const Axis< AxisPrecessionType > &xaxis, const ResultValueType &value)
calculate the index of the lineared array
Definition: result.hpp:143
void histogramAndBinCountWithWeightFrom0D(CASSEvent::id_t id, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with weights from 0D processor
shared_pointer _two
processor containing input when false result
Definition: operations.h:410
size_t _nX
the size of the original image in X
Definition: operations.h:895
shared_pointer _one
processor containing x-axis 0D result
Definition: operations.h:1619
virtual void process(const CASSEvent &, result_t &)
process event
shared_pointer _two
processor containing y-axis 0D result
Definition: operations.h:1622
size_t _nbrEventsAccumulated
the number of events the processor has accumulated
Definition: processor.h:359
shared_pointer _hist
processor containing input result
Definition: operations.h:1768
shared_pointer _input
pp containing input histogram
Definition: operations.h:2402
void projectToY(result_t::const_iterator src, result_t::iterator result, result_t::iterator norm)
integrate the columns
void histogramAndBinCountWithWeights(CASSEvent::id_t id, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with weights from another processor
statistics calculator for a median
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:565
result_t::value_t _weight
the weight in case it is a constant
Definition: operations.h:1061
pp50(const name_t &name)
constructor
Definition: operations.cpp:767
virtual void process(const CASSEvent &, result_t &)
process event
pp1(const name_t &name)
constructor
Definition: operations.cpp:88
std::tr1::function< bool(const result_t::value_t &, const result_t::value_t &)> _op
operation to find the extreme point
Definition: operations.h:2408
size_t nBins
the number of bins in this axis
Definition: result.hpp:287
virtual void loadSettings(size_t)
load the settings of the pp
virtual void process(const CASSEvent &, result_t &)
process event
pp68(const name_t &name)
constructor
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:898
std::pair< int, int > _range
range we want to have the integral over in result bins
Definition: operations.h:743
uint64_t id() const
retrieve the id of the result
Definition: result.hpp:934
result_t::value_t checkrange(result_t::value_t val, result_t::value_t checkval)
check if value is in range and return another value
Definition: operations.cpp:737
std::tr1::function< result_t::const_iterator(result_t::const_iterator, result_t::const_iterator)> _func
the type of function used to retrive the wanted bin
Definition: operations.h:1936
pp89(const name_t &name)
constructor
void histogramWithConstant(CASSEvent::id_t unused, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with user provided constant weight
shared_pointer _threshold
pp containing threshold result
Definition: operations.h:604
value_type mean() const
retrieve the mean of the distribution
pp63(const name_t &)
constructor
virtual void loadSettings(size_t)
load the settings of the pp
shared_pointer _hist
pp containing the value to check
Definition: operations.h:449
uint32_t _first_fiducials
time when the first samples was used in the point in time
Definition: operations.h:1259
virtual void process(const CASSEvent &, result_t &)
process event
virtual void loadSettings(size_t)
load the settings of the pp
void applyIdxwiseThreshold(const result_t &in, result_t &out, const CASSEvent::id_t &id)
apply a indexwise threshold
Definition: operations.cpp:669
shared_pointer _one
pp containing X-axis 1D result to combine
Definition: operations.h:1525
result_t::value_t _value
the value for the unary operation
Definition: operations.h:181
static void add(Level level, const std::string &line)
add a string to the log
Definition: log.cpp:31
pp75(const name_t &name)
constructor
void setValue(const_reference value)
assign the result container to a value
Definition: result.hpp:543
const_iterator begin() const
retrieve a iterator for read access to beginning
Definition: result.hpp:608
iter_type newItem(const id_type &id)
get an item for processing
virtual void loadSettings(size_t)
load the settings
std::pair< int, int > _xRange
the requested x-axis limits in bins
Definition: operations.h:2189
fromStdString(const std::string &str)
result_t::value_t medianCalc(const result_t &res)
retrieve the statistics value from the median statistics calculator
size_t _range
the requested x-axis limits in histogram coordinates
Definition: operations.h:2405
pp76(const name_t &name)
constructor
bool isTrue() const
evaluate whether value is zero
Definition: result.hpp:577
std::tr1::function< void(result_t::const_iterator, result_t::iterator, result_t::iterator)> _project
the function used to project the image
Definition: operations.h:903
ForwardIterator max_element(ForwardIterator first, ForwardIterator last)
provide own implementation of min_element to be able to compile
Definition: operations.cpp:41
void histogramWithConstant(CASSEvent::id_t unused, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with constant weight
std::pair< int, int > _offset
offset in x and y to the first bin of the input
Definition: operations.h:1674
shared_pointer _pHist
processor containing input result
Definition: operations.h:2008
result_t::storage_t table_t
definition of the table
Definition: operations.h:2390
shared_pointer _pHist
processor containing input result
Definition: operations.h:2232
void projectToY(result_t::const_iterator src, result_t::iterator dest)
project 2d result to y axis
Definition: operations.cpp:891
shared_pointer _pHist
processor containing input result
Definition: operations.h:1933
virtual void process(const CASSEvent &, result_t &)
process event
base class for processors.
Definition: processor.h:39
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
Definition: processor.cpp:114
size_t _num_seen_evt
the number of samples seen up to now and used in the point
Definition: operations.h:1254
std::tr1::function< void(result_t::const_iterator, result_t::iterator)> _project
function that will do the projection
Definition: operations.h:691
const axis_t & axis() const
read access to the axis
Definition: result.hpp:449
pp85(const name_t &name)
constructor
time_t _when_first_evt
time when the first samples was used in the point in time
Definition: operations.h:1258
virtual void loadSettings(size_t)
load the settings of the pp
pp82(const name_t &name)
constructor
shared_pointer _hist
processor containing input result
Definition: operations.h:1300
std::tr1::function< result_t::value_t(result_t::value_t)> unaryoperation_t
define the unary operation
Definition: operations.h:136
void histogramWithWeights(CASSEvent::id_t id, result_t::const_iterator in, result_t::const_iterator last, result_t &result)
histogam with weights from another processor
CachedList _resultList
the list of results
Definition: processor.h:271
virtual void loadSettings(size_t)
load the settings of the pp
Definition: operations.cpp:503
result_t::axis_name _axisId
the id of the axis
Definition: operations.h:2235
std::pair< int, int > _xRange
the requested x-axis limits in bins
Definition: operations.h:2077
shared_pointer _pHist
processor containing input result
Definition: operations.h:2186
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:397
pp41(const name_t &name)
constructor
Definition: operations.cpp:699
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:373
virtual void process(const CASSEvent &, result_t &)
process event
file contains declaration of classes and functions that help other processors to do their job...
shared_pointer _one
pp containing input result
Definition: operations.h:532
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:94
std::tr1::function< result_t::value_t(result_t::value_t, result_t::value_t)> _op
the operand
Definition: operations.h:77
virtual void process(const CASSEvent &, result_t &)
process event
float _userFraction
user fraction of the height between low and up
Definition: operations.h:2145
setParamPos_t _setParamPos
function to set the value to the requested parameter position
Definition: operations.h:187
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:311
pp77(const name_t &name)
constructor
virtual void loadSettings(size_t)
load the settings of the pp
virtual const result_t & result(const CASSEvent::id_t eventid=0)
overwrite the retrieval of an result
QReadWriteLock lock
lock for locking operations on the data of the container
Definition: result.hpp:954
result_t::value_t _userVal
the user value that will be set when the threshold is applied
Definition: operations.h:535
shared_pointer _pHist
processor containing input result
Definition: operations.h:2136
value_type sum() const
retrieve the sum of all dati that have been added
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:465
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:705
virtual void loadSettings(size_t)
load the settings of the pp
pp61(const name_t &name)
constructor
virtual void loadSettings(size_t)
load the settings
shared_pointer _pHist
processor containing the 2d result we want to project
Definition: operations.h:886
pp71(const name_t &name)
constructor
file contains global definitions for project cass
pp91(const name_t &name)
constructor
shared_pointer _one
processor containing first result
Definition: operations.h:269
result_t::value_t valueFromPP(const CASSEvent::id_t &id)
retrieve value from Processor
Definition: operations.cpp:275
shared_pointer _pHist
processor containing result to sum
Definition: operations.h:1204
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:326
id_t & id()
setters
Definition: cass_event.h:64
size_t _size
the number of bins in the result, range is fixed
Definition: operations.h:1303
pp70(const name_t &name)
constructor
virtual void process(const CASSEvent &, result_t &)
process event
std::string toString(const Type &t)
convert any type to a string
Definition: cass.h:63
shared_pointer _pHist
processor containing input result
Definition: operations.h:2330
result_t::value_t squareAverage(result_t::value_t val, result_t::value_t aveOld, result_t::value_t scale)
function that will calculate the square average
auxiliary data[Processor]
shared_pointer _valuePP
processor containing 0D value for the unary operation
Definition: operations.h:178
shared_pointer _two
processor containing the second result
Definition: operations.h:74
shared_pointer _pHist
processor containing result to average
Definition: operations.h:1169
pp87(const name_t &name)
constructor
valueRetrieval_t _retrieveValue
function to retrieve the value for the unary operation
Definition: operations.h:190
std::pair< result_t::value_t, result_t::value_t > _range
the requested range that the value should be in
Definition: operations.h:272
binary function for averaging.
shared_pointer _xInput
processor containing X axis value
Definition: operations.h:1466
result_t::value_t threshold(const result_t::value_t &value, const result_t::value_t &thres)
the thresholding function
Definition: operations.cpp:654
result_t::shared_pointer _res
the constant result
Definition: operations.h:324
pp51(const name_t &name)
constructor
Definition: operations.cpp:920
value(const QString &key, const QVariant &defaultValue=QVariant()
std::pair< int, int > _xRange
range we want to project
Definition: operations.h:681
shared_pointer _one
processor containing result
Definition: operations.h:225
pp2(const name_t &name)
constructor
Definition: operations.cpp:178
virtual void createHistList(result_t::shared_pointer result)
create the list of results
Definition: processor.h:348
shared_pointer _one
processor containing the first result
Definition: operations.h:71
contains the base class for all input modules
virtual void processEvent(const CASSEvent &)
process event
shared_pointer _weightProc
processor containing the weight
Definition: operations.h:1064
storage_t::iterator iterator
a iterator on the storage
Definition: result.hpp:335
value_t low
lower end of the axis
Definition: result.hpp:290
virtual void process(const CASSEvent &evt, result_t &)
process event
Definition: operations.cpp:282
std::pair< size_t, size_t > _timerange
range of time that we use for the angular distribution
Definition: operations.h:1248
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:184
std::pair< int, int > _xRangeBaseline
the requested x-axis limits for find the baseline in bins
Definition: operations.h:2142
virtual void process(const CASSEvent &, result_t &)
process event
shared_pointer _pHist
processor containing result to work on
Definition: operations.h:1245
void setupGeneral()
general setup of the processor
Definition: processor.cpp:85
void histogramWithWeightFrom0DInput(CASSEvent::id_t id, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with constant weight from input
value_t up
upper end of the axis
Definition: result.hpp:293
std::tr1::function< result_t::const_iterator(result_t::const_iterator, result_t::const_iterator)> _func
the type of function used to retrive the wanted element
Definition: operations.h:1721
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:352
result_t::value_t _upperBound
the upper boundary of the range
Definition: operations.h:613
float _fraction
the fraction of the range
Definition: operations.h:2080
pp13(const name_t &name)
constructor
Definition: operations.cpp:459
std::tr1::function< void(const result_t &, result_t &, const CASSEvent::id_t &)> _applyThresh
the funtion that applies the threshold to the input
Definition: operations.h:498
virtual void loadSettings(size_t)
load the settings
file contains specialized class that do the settings for cass
void addDistribution(InputIterator first, InputIterator last)
add a number of dati to the distribution
virtual const result_t & result(const CASSEvent::id_t eventid=0)
overwrite the retrieval of an result
pp4(const name_t &name)
constructor
Definition: operations.cpp:305
result_t::value_t movingInitializationScale()
retrieve the moving average scale during the initialization
result_t::value_t valueFromConst(const CASSEvent::id_t &evt)
retrieve value constant
Definition: operations.cpp:270
shared_pointer _input
processor containing the 1d result we want to integrate
Definition: operations.h:740
iterator histogram(const value_t &pos, const value_t &weight=1)
add the weight at the right bin for the value in the 1d array
Definition: result.hpp:651
Example of how to use the sacla online input
Definition: SACLA-online.ini:2
virtual void loadSettings(size_t)
load the settings of the pp
pp12(const name_t &)
constructor
Definition: operations.cpp:391
void projectToX(result_t::const_iterator src, result_t::iterator result, result_t::iterator norm)
integrate the rows
pp81(const name_t &name)
constructor
value_type median() const
retrieve the median of the distribution
std::tr1::function< result_t::value_t(result_t::value_t, result_t::value_t, result_t::value_t)> _func
function that will do the averagin
Definition: operations.h:1163
virtual void process(const CASSEvent &, result_t &)
process event
virtual void processEvent(const CASSEvent &)
overwrite process event
an accumulating processor
Definition: processor.h:289
pp14(const name_t &name)
constructor
Definition: operations.cpp:497
void projectToX(result_t::const_iterator src, result_t::iterator dest)
project 2d result to x axis
Definition: operations.cpp:884
list_type::iterator iter_type
define an iterator for the list
Definition: cached_list.hpp:56
virtual void process(const CASSEvent &, result_t &)
process event
result_t::shared_pointer _result
the result that accumulates the events
Definition: processor.h:356
virtual void loadSettings(size_t)
load the settings
void histogramWithWeights(CASSEvent::id_t id, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with weights from another processor
std::pair< int, int > _Xrange
range in X we want to project
Definition: operations.h:889
shared_pointer _condition
pointer to the processor that will contain the condition
Definition: processor.h:277
pp56(const name_t &name)
constructor
shared_pointer _two
pp containing Y-axis 1D result to combine
Definition: operations.h:1528
Processor::result_t::shared_pointer set1DHist(const Processor::name_t &name)
function to set the 1d histogram properties from the ini file.
virtual void process(const CASSEvent &, result_t &)
process event
shared_pointer _input
processor containing result to histogram
Definition: operations.h:1058
void addDistribution(InputIterator first, InputIterator last)
add a number of dati to the distribution
size_t _nX
the nbr of bins in the original image
Definition: operations.h:687
unaryoperation_t ValAtSecond(result_t::value_t val)
bind the value to the second parameter of the binaryoperation
Definition: operations.cpp:265
static shared_pointer::element_type & reference()
get reference to the singelton instance
Definition: input_base.cpp:28
shape_t shape() const
return the shape of the result
Definition: result.hpp:811
virtual void loadSettings(size_t)
load the settings of the pp
bool setupCondition(bool defaultConditionType=true)
setup the condition.
Definition: processor.cpp:94
virtual void processEvent(const CASSEvent &)
overwrite process event
Definition: operations.cpp:534
std::string name_t
define the name type
Definition: processor.h:46
virtual void process(const CASSEvent &, result_t &)
process event
float _alpha
factor used for filtering
Definition: operations.h:2333
std::tr1::function< float(const result_t &)> _baseline
the function that will return the baseline
Definition: operations.h:763
pp88(const name_t &name)
constructor
contains a logger for cass
pp60(const name_t &name)
constructor
pp9(const name_t &name)
constructor
Definition: operations.cpp:346
virtual void process(const CASSEvent &, result_t &)
process event
std::pair< int, int > _yRange
range we want to project
Definition: operations.h:684
virtual void loadSettings(size_t)
load the settings of the pp
Definition: operations.cpp:926
pp62(const name_t &)
constructor
virtual void process(const CASSEvent &, result_t &)
process event
result_t::value_t average(result_t::value_t val, result_t::value_t aveOld, result_t::value_t scale)
function for normal averaging.
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:681
check if there is some light in the chamber based upon the GMD value
size_t _nbrSamples
the number of bins in the result, range is fixed
Definition: operations.h:1251
virtual void process(const CASSEvent &, result_t &)
process event
Definition: operations.cpp:479
size_type datasize() const
return the size of the data as determined by the axis
Definition: result.hpp:872
virtual void process(const CASSEvent &, result_t &)
process event
shared_pointer _threshPP
pp containing the indexwise threshold
Definition: operations.h:529
virtual void loadSettings(size_t)
load the settings of the pp
std::pair< int, int > _Yrange
range in Y we want to project
Definition: operations.h:892
void histogramAndBinCountWithWeightFrom0DInput(CASSEvent::id_t id, result_t::const_iterator xin, result_t::const_iterator xlast, result_t::const_iterator yin, result_t &result)
histogam with constant weight from input
value_type stdv() const
retrieve the standart deviation of the distribution
shared_pointer _one
processor containing the 1D result
Definition: operations.h:1574
beginGroup(const QString &prefix)
virtual void loadSettings(size_t)
load the settings
value_type variance() const
retrieve the variance of the distribution
virtual void loadSettings(size_t)
load the settings of this pp
Definition: operations.cpp:619
shared_pointer _one
processor containing input when true result
Definition: operations.h:407
pp15(const name_t &name)
constructor
Definition: operations.cpp:559
func_t _histogram
the function to histogram the values
Definition: operations.h:1481
result_t::value_t _lowerBound
the lower boundary of the range
Definition: operations.h:610
virtual void process(const CASSEvent &, result_t &)
process event
virtual void loadSettings(size_t)
load the settings of the pp
virtual void loadSettings(size_t)
load the settings of the pp
virtual const result_t & result(const CASSEvent::id_t eventid=0)
retrieve a result for a given id.
Definition: processor.cpp:54
virtual void loadSettings(size_t)
load the settings of the pp
shared_pointer _pHist
processor containing the input result
Definition: operations.h:1718
virtual void loadSettings(size_t)
load the settings of the pp