CFEL - ASG Software Suite  2.5.0
CASS
delayline_non_sorting.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 Lutz Foucar
2 
3 /**
4  * @file delayline_non_sorting.cpp ile contains the class that finds detectorhits
5  * without sorting
6  *
7  * @author Lutz Foucar
8  */
9 
10 
11 #include "delayline_non_sorting.h"
12 
13 #include "poscalculator.hpp"
14 #include "cass_settings.h"
15 #include "signal_producer.h"
16 
17 using namespace std;
18 using namespace cass::ACQIRIS;
19 using namespace std::tr1;
20 
21 DelaylineNonSorting::DelaylineNonSorting()
23 {}
24 
26 {
28  typedef signals_t::iterator sigIt_t;
29 
30  /** extract the signal arrays from the signal producers */
31  signals_t &f1signals (_layerCombination.first.first->output());
32  signals_t &f2signals (_layerCombination.first.second->output());
33  signals_t &s1signals (_layerCombination.second.first->output());
34  signals_t &s2signals (_layerCombination.second.second->output());
35 
36  /** extract the iterators from the arrays */
37  sigIt_t iF1(f1signals.begin());
38  sigIt_t iF2 (f2signals.begin());
39  sigIt_t iS1 (s1signals.begin());
40  sigIt_t iS2 (s2signals.begin());
41 
42  /** find out which array is the shortest and assign the iterators of that
43  * array to the loop variables */
44  size_t minsize(f1signals.size());
45  sigIt_t sigIt(f1signals.begin());
46  sigIt_t end(f1signals.end());
47  if (minsize > f2signals.size())
48  {
49  minsize = f2signals.size();
50  sigIt = f2signals.begin();
51  end = f2signals.end();
52  }
53  if (minsize > s1signals.size())
54  {
55  minsize = s1signals.size();
56  sigIt = s1signals.begin();
57  end = s1signals.end();
58  }
59  if (minsize > s2signals.size())
60  {
61  minsize = s2signals.size();
62  sigIt = s2signals.begin();
63  end = s2signals.end();
64  }
65 
66  /** go linear through all hits and create detectorhits for each entry in the
67  * array
68  */
69  for (; sigIt != end; ++sigIt, ++iF1, ++iF2, ++iS1, ++iS2)
70  {
72  const double f1 ((*iF1)[time]);
73  const double f2 ((*iF2)[time]);
74  const double s1 ((*iS1)[time]);
75  const double s2 ((*iS2)[time]);
76  const double f ((f1-f2) * _sf.first);
77  const double s ((s1-s2) * _sf.second);
78  const pair<double,double> pos ((*_poscalc)(make_pair(f,s)));
79  hit[x] = pos.first;
80  hit[y] = pos.second;
81  hit[t] = 0;
82  hits.push_back(hit);
83  }
84  return hits;
85 }
86 
88 {
89  enum LayerComb{xy,uv,uw,vw};
90 
91  DelaylineType delaylinetype
92  (static_cast<DelaylineType>(s.value("DelaylineType",Hex).toInt()));
93 
94  s.beginGroup("NonSorting");
95  LayerComb lc (static_cast<LayerComb>(s.value("LayersToUse",xy).toInt()));
96  if ((lc == xy) && (delaylinetype == Hex))
97  throw invalid_argument("DelaylineNonSorting::loadSettings: Error using layers xy for Hex-Detector");
98  if ((delaylinetype == Quad) && (lc == uv || lc == uw || lc == vw))
99  throw invalid_argument("DelaylineNonSorting::loadSettings: Error using layers uv, uw or vw for Quad-Detector");
100 
101  switch (lc)
102  {
103  case (xy):
104  _layerCombination = make_pair(make_pair(&d.layers()['X'].wireends()['1'],
105  &d.layers()['X'].wireends()['2']),
106  make_pair(&d.layers()['Y'].wireends()['1'],
107  &d.layers()['Y'].wireends()['2']));
108  _poscalc = std::tr1::shared_ptr<PositionCalculator>(new XYCalc);
109  break;
110  case (uv):
111  _layerCombination = make_pair(make_pair(&d.layers()['U'].wireends()['1'],
112  &d.layers()['U'].wireends()['2']),
113  make_pair(&d.layers()['V'].wireends()['1'],
114  &d.layers()['V'].wireends()['2']));
115  _poscalc = std::tr1::shared_ptr<PositionCalculator>(new UVCalc);
116  break;
117  case (uw):
118  _layerCombination = make_pair(make_pair(&d.layers()['U'].wireends()['1'],
119  &d.layers()['U'].wireends()['2']),
120  make_pair(&d.layers()['W'].wireends()['1'],
121  &d.layers()['W'].wireends()['2']));
122  _poscalc = std::tr1::shared_ptr<PositionCalculator>(new UWCalc);
123  break;
124  case (vw):
125  _layerCombination = make_pair(make_pair(&d.layers()['V'].wireends()['1'],
126  &d.layers()['V'].wireends()['2']),
127  make_pair(&d.layers()['W'].wireends()['1'],
128  &d.layers()['W'].wireends()['2']));
129  _poscalc = std::tr1::shared_ptr<PositionCalculator>(new VWCalc);
130  break;
131  default:
132 // throw invalid_argument("DelaylineDetectorAnalyzerSimple::loadSettings: Layercombination '" +
133 // toString(lc) + "' not available");
134  break;
135  }
136  _sf = make_pair(s.value("ScalefactorFirstLayer",0.4).toDouble(),
137  s.value("ScalefactorSecondLayer",0.4).toDouble());
138  s.endGroup();
139 }
std::vector< double > detectorHit_t
define a detector hit
detectorHits_t & operator()(detectorHits_t &hits)
retrieve detector hits from signals
contains classes for calculating the position in a DLD
SignalProducer::signals_t signals_t
typedefs for shorter code
file contains the classes that describe how to analyze the waveform and stores the result...
std::vector< signal_t > signals_t
std::pair< double, double > _sf
the scalefactor for the two layers (convert ns -> mm)
position calculator for hex anodes u and v layer
Settings for CASS.
Definition: cass_settings.h:30
std::pair< std::pair< SignalProducer *, SignalProducer * >, std::pair< SignalProducer *, SignalProducer * > > _layerCombination
the layer combination
std::vector< detectorHit_t > detectorHits_t
define container for all detector hits
define which of the hitfinders defined above will be used as hit
STL namespace.
void loadSettings(CASSSettings &, DelaylineDetector &)
load the settings of the analyzer
Average out the iShit status to get the avererage hits
position calculator for hex anodes u and v layer
anodelayers_t & layers()
return the layers
DelaylineType
the types of delayline detectors that are available
std::tr1::shared_ptr< PositionCalculator > _poscalc
the calculator to calc the position for the correlated wireend signals
signals_t::iterator sigIt_t
typedefs for shorter code
value(const QString &key, const QVariant &defaultValue=QVariant()
position calculator for hex anodes u and w layer
file contains specialized class that do the settings for cass
position calculator for quad anode
file contains the class that finds detectorhits without sorting
beginGroup(const QString &prefix)
Base class for all detector analyzers.