CFEL - ASG Software Suite  2.5.0
CASS
convenience_functions.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 Lutz Foucar
2 
3 /**
4  * @file convenience_functions.cpp file contains definition of functions that
5  * help other processors to do their job.
6  *
7  * @author Lutz Foucar
8  */
9 
10 #include <string>
11 
12 #include "convenience_functions.h"
13 
14 #include "cass_exceptions.hpp"
15 #include "cass_settings.h"
17 #include "delayline_detector.h"
18 #include "log.h"
19 
20 using namespace cass;
21 using namespace ACQIRIS;
22 using namespace std;
23 
25 {
26  //open the settings//
27  CASSSettings s;
28  s.beginGroup("Processor");
30  //create new histogram using the parameters//
31  Log::add(Log::VERBOSEINFO,string("set1dHist(): Creating 1D histogram with") +
32  " XNbrBins:" + toString(s.value("XNbrBins",1).toUInt()) +
33  " XLow:" + toString(s.value("XLow",0).toFloat()) +
34  " XUp:" + toString(s.value("XUp",0).toFloat()) +
35  " XTitle:" + s.value("XTitle","x-axis").toString().toStdString());
38  (s.value("XNbrBins",1).toUInt(),
39  s.value("XLow",0).toFloat(),
40  s.value("XUp",0).toFloat(),
41  s.value("XTitle","x-axis").toString().toStdString())));
42 }
43 
45 {
46  //open the settings//
47  CASSSettings s;
48  s.beginGroup("Processor");
50  //create new histogram using the parameters//
51  Log::add(Log::VERBOSEINFO,string("set2DHist(): Creating 2D histogram with") +
52  " XNbrBins:" + toString(s.value("XNbrBins",1).toUInt()) +
53  " XLow:" + toString(s.value("XLow",0).toFloat()) +
54  " XUp:" + toString(s.value("XUp",0).toFloat()) +
55  " XTitle:" + s.value("XTitle","x-axis").toString().toStdString() +
56  " YNbrBins:" + toString(s.value("YNbrBins",1).toUInt()) +
57  " YLow:" + toString(s.value("YLow",0).toFloat()) +
58  " YUp:" + toString(s.value("YUp",0).toFloat()) +
59  " YTitle:" + s.value("YTitle","y-axis").toString().toStdString());
62  s.value("XNbrBins",1).toUInt(),
63  s.value("XLow",0).toFloat(),
64  s.value("XUp",0).toFloat(),
65  s.value("XTitle","x-axis").toString().toStdString()),
67  s.value("YNbrBins",1).toUInt(),
68  s.value("YLow",0).toFloat(),
69  s.value("YUp",0).toFloat(),
70  s.value("YTitle","y-axis").toString().toStdString())));
71 }
72 
74  int ppNbr,
75  const string &key)
76 {
77  string detector
78  (s.value("Detector","blubb").toString().toStdString());
80  if (dethelp->detectortype() != Delayline)
81  throw invalid_argument("pp" + toString(ppNbr) + "::loadSettings()'" + key +
82  "': Error detector '" + detector +
83  "' is not a Delaylinedetector.");
84  dethelp->loadSettings();
85  return detector;
86 }
87 
89  const string &detector,
90  int ppNbr,
91  const string &key)
92 {
93  string particle (s.value("Particle","NeP").toString().toStdString());
94  const DelaylineDetector &det(
95  dynamic_cast<const DelaylineDetector&>(HelperAcqirisDetectors::instance(detector)->detector()));
96  if (det.particles().end() == det.particles().find(particle))
97  throw invalid_argument("pp" + toString(ppNbr) + "::loadSettings()'" + key +
98  "': Error Particle '" + particle +
99  "' is not defined for detector '" + detector +"'");
100  return particle;
101 }
102 
file contains declaration of classes that extract information of acqiris detectors.
Settings for CASS.
Definition: cass_settings.h:30
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
Definition: result.hpp:323
Processor::result_t::shared_pointer set2DHist(const Processor::name_t &name)
function to set the 2d histogram properties from the ini file.
std::tr1::shared_ptr< HelperAcqirisDetectors > shared_pointer
typedef a shared pointer of this
STL namespace.
an axis of a more than 0 dimensional container
Definition: result.hpp:29
file contains custom exceptions used in cass
std::string loadParticle(CASSSettings &s, const std::string &detector, int ppNbr, const std::string &key)
load particle for a specific detector
static void add(Level level, const std::string &line)
add a string to the log
Definition: log.cpp:31
file contains the classes that describe a delayline detector.
fromStdString(const std::string &str)
file contains declaration of classes and functions that help other processors to do their job...
std::string toString(const Type &t)
convert any type to a string
Definition: cass.h:63
std::string loadDelayDet(CASSSettings &s, int ppNbr, const std::string &key)
load detector from file
value(const QString &key, const QVariant &defaultValue=QVariant()
file contains specialized class that do the settings for cass
static shared_pointer instance(const helperinstancesmap_t::key_type &detector)
static function creating instance of this.
Processor::result_t::shared_pointer set1DHist(const Processor::name_t &name)
function to set the 1d histogram properties from the ini file.
Electron detector
Definition: hdf5-input.ini:62
std::string name_t
define the name type
Definition: processor.h:46
contains a logger for cass
beginGroup(const QString &prefix)