11 #include <QtCore/QString>
36 class PreAverage : std::binary_function<float,float,float>
58 const double n = 1./_alpha;
60 return (n*Average_Nm1 - currentValue)/(n-1.);
92 throw invalid_argument(
"pp400::loadSettings(): Unsupported dimension of requested histogram");
95 settings.
value(
"TofUp",1).toFloat());
101 t0 = settings.
value(
"t0",0).toFloat();
103 e0 = settings.
value(
"e0",0).toFloat();
107 tb1 = settings.
value(
"tb1",0).toFloat();
108 tb2 = settings.
value(
"tb2",0).toFloat();
120 "' converts ToF into Energy scale '" +
_pHist->name() +
121 "' which has dimension '" +
toString(one.dim()) +
" test TofUp:" +
131 if (energy<0) energy = 0;
139 double bin_size=xaxis.
pos(2)-xaxis.pos(1);
147 double SizeOfBins = (EUp-Elow)/
NbrBins;
148 for (
size_t i = 0; i <
NbrBins; ++i)
152 double tofBinUp =
calcEtoTof (SizeOfBins * i+Elow);
153 double tofBinLow =
calcEtoTof (SizeOfBins * ( i + 1 )+Elow);
155 size_t klow(0), kup(0);
157 klow = xaxis.bin(tofBinLow);
158 kup = xaxis.bin(tofBinUp);
160 if (klow == kup) Energy[i] = (tofBinUp - tofBinLow)/bin_size * (Tof[klow]-offset);
162 else if ((kup - klow) == 1 ) Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)/bin_size * (Tof[klow+1]-offset) + (tofBinUp - xaxis.pos(kup))/bin_size * (Tof[kup]-offset);
164 else if ((kup - klow) > 1 )
166 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)/bin_size * (Tof[klow+1]-offset) + (tofBinUp - xaxis.pos(kup))/bin_size * (Tof[kup]-offset);
167 for (
size_t j = klow + 1; j < kup; ++j)
168 Energy[i] += (Tof[j]-offset);
216 throw runtime_error(
"pp400::loadSettings(): Unknown dimension of incomming histogram");
219 settings.
value(
"TofUp",1).toFloat());
224 t0 = settings.
value(
"t0",0).toFloat();
225 t1 = settings.
value(
"t1",0).toFloat();
226 MtC0 = settings.
value(
"MtC0",0).toFloat();
227 MtC1 = settings.
value(
"MtC1",0).toFloat();
228 tb1 = settings.
value(
"tb1",0).toFloat();
229 tb2 = settings.
value(
"tb2",0).toFloat();
245 "' converts ToF into MassTo ChargeRatio scale'" +
_pHist->name() +
246 "' which has dimension '" +
toString(one.dim()) +
" TofUp:" +
251 ". Condition on processor '" +
_condition->name() +
"'");
257 if (MasstoCharge<0) MasstoCharge = 0;
258 return (
alpha * sqrt(MasstoCharge) +
beta);
269 double bin_size=xaxis.
pos(2)-xaxis.pos(1);
273 double SizeOfBins = (MtCUp-MtCDown) /
NbrBins;
274 for (
size_t i = 0; i <
NbrBins; ++i)
278 double tofBinLow =
calcMtCtoTof (SizeOfBins * i + MtCDown);
279 double tofBinUp =
calcMtCtoTof (SizeOfBins * ( i + 1 )+MtCDown);
281 long klow(0), kup(0);
282 klow=xaxis.bin(tofBinLow);
283 kup=xaxis.bin(tofBinUp);
287 MtC[i] = (Tof[klow]-
offset)*(tofBinUp-tofBinLow)/bin_size;
289 else if ((kup - klow) == 1 ) MtC[i] =(Tof[klow]-offset)*(xaxis.pos(klow + 1) - tofBinLow)/bin_size + (Tof[kup]-offset)*(tofBinUp -xaxis.pos(kup))/bin_size;
290 else if ((kup - klow) > 1 )
292 MtC[i] = (Tof[klow]-
offset)*(xaxis.pos(klow + 1) - tofBinLow)/bin_size + (Tof[kup]-offset)*(tofBinUp -xaxis.pos(kup))/bin_size;
293 for (
long j = klow + 1; j < kup; ++j)
294 MtC[i] += Tof[j]-offset;
338 " beamline data. Condition is '" +
_condition->name() +
"'");
345 (dynamic_cast<const Device&>
347 const Device::bldMap_t bld(md.BeamlineData());
349 const double ebCharge
350 (bld.find(
"EbeamCharge") == bld.end() ? 0 : bld.find(
"EbeamCharge")->second);
351 const double peakCurrent
352 (bld.find(
"EbeamPkCurrBC2") == bld.end() ? 0 : bld.find(
"EbeamPkCurrBC2")->second);
354 const double puleduration (ebCharge/peakCurrent*1.0e-9);
389 throw runtime_error(
"pp406::loadSettings(): Unknown dimension of incomming histogram");
391 if (constHist.dim() != 0 )
392 throw invalid_argument(
"pp406::loadSettings(): HistZeroD '" +
_constHist->name() +
393 "' is not a 0D histogram");
396 settings.
value(
"TofUp",1).toFloat());
402 t0 = settings.
value(
"t0",0).toFloat();
404 e0 = settings.
value(
"e0",0).toFloat();
408 tb1 = settings.
value(
"tb1",0).toFloat();
409 tb2 = settings.
value(
"tb2",0).toFloat();
421 _pHist->name() +
"' which has dimension '" +
toString(one.dim()) +
422 "' with constant in 0D Histogram in Processor '" +
_constHist->name() +
425 "'. Conversion parameters e0:"+
toString(
e0) +
" t0(bin):" +
433 if (energy<0) energy = 0;
441 double bin_size=xaxis.
pos(2)-xaxis.pos(1);
449 double SizeOfBins = (EUp-Elow)/
NbrBins;
450 for (
size_t i = 0; i <
NbrBins; ++i)
454 double tofBinUp =
calcEtoTof (SizeOfBins * i+Elow);
455 double tofBinLow =
calcEtoTof (SizeOfBins * ( i + 1 )+Elow);
457 size_t klow(0), kup(0);
459 klow = xaxis.bin(tofBinLow);
460 kup = xaxis.bin(tofBinUp);
463 if (klow == kup) Energy[i] = (tofBinUp - tofBinLow)/bin_size * (Tof[klow]-offset);
465 else if ((kup - klow) == 1 ) Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)/bin_size * (Tof[klow+1]-offset) + (tofBinUp - xaxis.pos(kup))/bin_size * (Tof[kup]-offset);
467 else if ((kup - klow) > 1 )
469 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)/bin_size * (Tof[klow+1]-offset) + (tofBinUp - xaxis.pos(kup))/bin_size * (Tof[kup]-offset);
470 for (
size_t j = klow + 1; j < kup; ++j)
471 Energy[i] += (Tof[j]-offset);
520 throw runtime_error(
"pp407::loadSettings(): Unknown dimension of incomming histogram");
523 settings.
value(
"TofUp",1).toFloat());
529 t0 = settings.
value(
"t0",0).toFloat();
531 e0 = settings.
value(
"e0",0).toFloat();
535 tb1 = settings.
value(
"tb1",0).toFloat();
536 tb2 = settings.
value(
"tb2",0).toFloat();
548 _pHist->name() +
"' which has dimension '" +
toString(one.dim()) +
558 if (energy<0) energy = 0;
566 return (Tof[binlow] +(Tof[binlow+1]-Tof[binlow])/bin_size * (tofPos - xaxis.pos(binlow)) );
573 const double bin_size=xaxis.
pos(2)-xaxis.pos(1);
581 double SizeOfBins = (EUp-Elow)/
NbrBins;
582 for (
size_t i = 0; i <
NbrBins; ++i)
586 double tofBinUp =
calcEtoTof (SizeOfBins * i+Elow);
587 double tofBinLow =
calcEtoTof (SizeOfBins * ( i + 1 )+Elow);
589 size_t klow(0), kup(0);
591 klow = xaxis.bin(tofBinLow);
592 kup = xaxis.bin(tofBinUp);
594 double tofValueUp =
calcTofValue(tofBinUp,klow,bin_size,Tof);
595 double tofValueLow =
calcTofValue(tofBinLow,klow,bin_size,Tof);
598 if (klow == kup) Energy[i] = (tofBinUp - tofBinLow)*((tofValueUp+tofValueLow)/2-
offset)/bin_size;
600 else if ((kup - klow) == 1 )
601 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)*((Tof[klow + 1]+tofValueLow)/2-
offset)/bin_size
602 + (tofBinUp - xaxis.pos(kup))*((Tof[kup]+tofValueUp)/2-
offset)/bin_size;
604 else if ((kup - klow) > 1 )
606 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)*((Tof[klow + 1]+tofValueLow)/2-
offset)/bin_size
607 + (tofBinUp - xaxis.pos(kup))*((Tof[kup]+tofValueUp)/2-
offset)/bin_size;
609 for (
size_t j = klow + 1; j < kup; ++j)
610 Energy[i] += (Tof[j]-offset);
658 throw runtime_error(
"pp408::loadSettings(): Unknown dimension of incomming histogram");
660 if (constHist.dim() != 0 )
661 throw invalid_argument(
"pp408::loadSettings(): HistZeroD '" +
_constHist->name() +
662 "' is not a 0D histogram");
665 settings.
value(
"TofUp",1).toFloat());
671 t0 = settings.
value(
"t0",0).toFloat();
673 e0 = settings.
value(
"e0",0).toFloat();
677 tb1 = settings.
value(
"tb1",0).toFloat();
678 tb2 = settings.
value(
"tb2",0).toFloat();
690 _pHist->name() +
"' which has dimension '" +
toString(one.dim()) +
691 "' with constant in 0D Histogram in Processor '" +
_constHist->name() +
694 "'. Conversion parameters e0:" +
toString(
e0) +
" t0(bin):" +
702 if (energy<0) energy = 0;
703 if ((energy +
ediff) < 0)
711 return (Tof[binlow] +(Tof[binlow+1]-Tof[binlow])/bin_size * (tofPos - xaxis.pos(binlow)) );
718 double bin_size=xaxis.
pos(2)-xaxis.pos(1);
726 double SizeOfBins = (EUp-Elow)/
NbrBins;
727 for (
size_t i = 0; i <
NbrBins; ++i)
731 double tofBinUp =
calcEtoTof (SizeOfBins * i+Elow);
732 double tofBinLow =
calcEtoTof (SizeOfBins * ( i + 1 )+Elow);
733 if((tofBinUp < 0)|| (tofBinUp > TofUp))
735 size_t klow(0), kup(0);
737 klow = xaxis.bin(tofBinLow);
738 kup = xaxis.bin(tofBinUp);
740 double tofValueUp =
calcTofValue(tofBinUp,klow,bin_size,Tof);
741 double tofValueLow =
calcTofValue(tofBinLow,klow,bin_size,Tof);
743 if (klow == kup) Energy[i] = (tofBinUp - tofBinLow)*((tofValueUp+tofValueLow)/2-
offset)/bin_size;
745 else if ((kup - klow) == 1 )
746 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)*((Tof[klow + 1]+tofValueLow)/2-
offset)/bin_size
747 + (tofBinUp - xaxis.pos(kup))*((Tof[kup]+tofValueUp)/2-
offset)/bin_size;
749 else if ((kup - klow) > 1 )
751 Energy[i] = (xaxis.pos(klow + 1) - tofBinLow)*((Tof[klow + 1]+tofValueLow)/2-
offset)/bin_size
752 + (tofBinUp - xaxis.pos(kup))*((Tof[kup]+tofValueUp)/2-
offset)/bin_size;
754 for (
size_t j = klow + 1; j < kup; ++j)
755 Energy[i] += (Tof[j]-offset);
815 for (
unsigned int i=0; i<nbrBins; i++)
816 for (
unsigned int j=0; j<nbrBins; j++)
818 variance[i*nbrBins+j] = ((variance[i*nbrBins+j]*(n-1)) + (data[i]-averageOld[i])* (data[j]-averageNew[j]))/n;
834 transform(one.
begin(),one.
end(), ave.
begin(), averagePre.begin(),
875 const float intensity,
876 const float intensityAveOld,
882 for (
unsigned int i=0; i<nbrBins; i++)
884 correction[i] = (correction[i]*(n-1) + (waveTrace[i]-waveTraceAve[i]) * (intensity-intensityAveOld))/n;
CachedList::item_type result_t
define the results
double calcToftoMtC(double Timeoflight)
convert Time of Flight to mass to charge ratio
PreAverage(float alpha)
constructor.
check if there is some light in the chamber based upon the pulse energy
value_t getValue() const
return the value
size_t bintb1
tb1 converted to bin
double tb1
The lower limit for calculating baseline.
Event to store all LCLS Data.
float operator()(float currentValue, float Average_Nm1)
operator.
float _alpha
for the average calculation
virtual void createHistList(result_t::shared_pointer result)
create result list.
size_t bintb2
tb2 converted to bin
void ToftoMtC(const result_t &hist, result_t &MtC, double offset)
create m to q histogram from ToF histogram
const_iterator end() const
retrieve iterator to the end of storage
std::vector< value_t > storage_t
the storage of this container
double tb2
The upper limit for calculating baseline.
value_t pos(const int bin) const
calculate the position for a given bin
double e0
retardation voltage
virtual void loadSettings(size_t)
load the settings of the pp
virtual void loadSettings(size_t)
load the settings of the pp
const name_t name() const
retrieve the name of this processor
void calcCovariance(const result_t &waveTrace, const result_t &waveTraceAve, const float intensity, const float intensityAveOld, result_t &correction, float n)
calculate covariance
std::pair< float, float > _userTofRange
the user requested Tof-axis limits
size_t binTofLow
lower limit converted to bin
shared_pointer _pHist
pp containing input histogram
shared_pointer _pHist
pp containing input histogram
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
double e0
retardation voltage
double offset
the calculated level of baseline
size_t bintb1
tb1 converted to bin
size_t binTofLow
lower limit converted to bin
double calcEtoTof(double energy)
retrieve the time that corresponses to a given energy
shared_pointer _ave1D
pp containing input histogram 1D it should be averaged _hist1D
size_type size() const
return the raw size of the storage
shared_pointer _ave0D
pp containing input histogram 0D it should be averaged _hist0D
double t0
corrects the time of flight
double calcEtoTof(double energy)
retrieve the time that corresponses to a given energy
an axis of a more than 0 dimensional container
std::pair< float, float > _userTofRange
the user requested Tof-axis limits
double MtC1
mass to charge ratio of t1
double alpha
Coefficient to convert to energy.
virtual void process(const CASSEvent &, result_t &)
process event
virtual void process(const CASSEvent &, result_t &)
process event
double MtC0
mass to charge ratio of t0
size_t _nbrEventsAccumulated
the number of events the processor has accumulated
double tb2
The upper limit for calculating baseline.
std::pair< float, float > _userTofRange
the user requested Tof-axis limits
double ediff
difference from expected energy
shared_pointer _ave
pp containing input histogram
virtual void loadSettings(size_t)
load the settings
size_t bintb2
tb2 converted to bin
size_t bintb2
tb2 converted to bin
size_t bintb1
tb1 converted to bin
virtual void loadSettings(size_t)
load the settings of the pp
virtual void process(const CASSEvent &, result_t &)
process event
size_t binTofUp
Upper limit converted to bin.
double t0
corrects the time of flight
static void add(Level level, const std::string &line)
add a string to the log
void setValue(const_reference value)
assign the result container to a value
const_iterator begin() const
retrieve a iterator for read access to beginning
void ToftoEnergy(const result_t &TofHisto, result_t &Energy, double offset)
make the histgram in energy scale.
fromStdString(const std::string &str)
double tb1
The lower limit for calculating baseline.
shared_pointer _pHist
pp containing input histogram
size_t bintb2
tb2 converted to bin
shared_pointer _pHist
pp containing input histogram
double tb1
The lower limit for calculating baseline.
virtual void loadSettings(size_t)
load the settings
pp400(const name_t &)
constructor
virtual const result_t & result(const CASSEvent::id_t)
retrieve a result.
base class for processors.
size_t bint0
t0 converted to bin
double calcTofValue(const double tofPos, const size_t binlow, const double bin_size, const result_t &TofHisto)
retrieve the linear interpolation value
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
double calcEtoTof(double energy)
retrieve the time that corresponses to a given energy
const axis_t & axis() const
read access to the axis
size_t NbrBins
number of bins in converted histgram
devices_t & devices()
setters
double tb2
The upper limit for calculating baseline.
size_t bintb1
tb1 converted to bin
size_t binTofLow
lower limit converted to bin
double alpha
Coefficient to convert to energy.
double tb1
The lower limit for calculating baseline.
size_t NbrBins
number of bins in converted histgram
file contains declaration of classes and functions that help other processors to do their job...
double t0
corrects the time of flight
size_t binTofUp
Upper limit converted to bin.
void ToftoEnergy(const result_t &TofHisto, result_t &Energy, double offset)
make the histogram in energy scale.
virtual void process(const CASSEvent &, result_t &)
calc the pulse duration from the bld
double calcEtoTof(double energy)
retrieve the time that corresponses to a given energy
QReadWriteLock lock
lock for locking operations on the data of the container
virtual void loadSettings(size_t)
load the settings of the pp
pp412(const name_t &)
constructor
size_t NbrBins
number of bins in converted histgram
file contains global definitions for project cass
double ediff
corrects from photon energy value
shared_pointer _constHist
pp containing input OD histogram
double alpha
Coefficient to convert to energy.
std::string toString(const Type &t)
convert any type to a string
auxiliary data[Processor]
pp408(const name_t &)
constructor
double e0
retardation voltage
double t1
another time of flight of ion that we choosed
size_t binTofUp
Upper limit converted to bin.
set up the common mode correction
value(const QString &key, const QVariant &defaultValue=QVariant()
double tb2
The upper limit for calculating baseline.
virtual void createHistList(result_t::shared_pointer result)
create the list of results
size_t NbrBins
number of bins in converted histgram
double tb2
The upper limit for calculating baseline.
shared_pointer _pHist
pp containing histogram to work on
void ToftoEnergy(const result_t &TofHisto, result_t &Energy, double offset)
make the histgram in energy scale.
virtual void process(const CASSEvent &, result_t &)
process event
size_t bint0
t0 converted to bin
double e0
retardation voltage
void setupGeneral()
general setup of the processor
double calcTofValue(const double tofPos, const size_t binlow, const double bin_size, const result_t &TofHisto)
retrieve the linear interpolation value
definitions of a machine device
size_t bint0
t0 converted to bin
file contains specialized class that do the settings for cass
size_t binTofLow
lower limit converted to bin
void calcCovariance(const result_t &data, const result_t::storage_t &averageOld, const result_t &averageNew, result_t &variance, float n)
calculate the covariance map
Example of how to use the sacla online input
size_t bint0
t0 converted to bin
an accumulating processor
double t0
corrects the time of flight
pp407(const name_t &)
constructor
virtual void process(const CASSEvent &, result_t &)
process event
double calcMtCtoTof(double MasstoCharge)
calculate the tof from the mass to charge ratio
std::pair< float, float > _userTofRange
the user requested Tof-axis limits
shared_pointer _condition
pointer to the processor that will contain the condition
virtual void loadSettings(size_t)
load the settings of the pp
virtual void loadSettings(size_t)
load the settings from cass.ini
size_t bintb2
tb2 converted to bin
size_t binTofUp
Upper limit converted to bin.
pp405(const name_t &)
constructor
size_t bintb1
tb1 converted to bin
virtual void process(const CASSEvent &, result_t &)
process event
bool setupCondition(bool defaultConditionType=true)
setup the condition.
std::string name_t
define the name type
size_t NbrBins
number of bins in converted histgram
contains a logger for cass
std::pair< float, float > _userTofRange
the user requested Tof-axis limits
void ToftoEnergy(const result_t &TofHisto, result_t &Energy, double offset)
make the histogram in energy scale.
processors to calculate partical covariance
shared_pointer _hist1D
pp containing input histogram 1D
shared_pointer _pHist
pp containing input histogram
virtual void process(const CASSEvent &, result_t &)
process event
pp406(const name_t &)
constructor
size_t binTofLow
lower limit converted to bin
shared_pointer _constHist
pp containing input OD histogram
beginGroup(const QString &prefix)
pp404(const name_t &)
constructor
size_t binTofUp
Upper limit converted to bin.
pp410(const name_t &)
constructor
double alpha
Coefficient to convert to energy.
double t0
a time of flight of ion that we choosed
virtual const result_t & result(const CASSEvent::id_t eventid=0)
retrieve a result for a given id.
double tb1
The lower limit for calculating baseline.
shared_pointer _hist0D
pp containing input histogram 0D