Mixed Data Coincidence Analysis Software 1.0
A program to analyze files produced by the EventMixer software.
GammaLine.cc
Go to the documentation of this file.
00001 #include "GammaLine.hh"
00002 
00003 GammaLine::GammaLine(float tol, float bgTol)
00004   :tolerance(tol), bgTolerance(bgTol)
00005 {
00006   for(float i = tol-bgTol; i<=tol+bgTol; i+=2*tol)
00007     {
00008       background.push_back(0);
00009     }
00010 }
00011 
00012 void GammaLine::addBackground(float bg)
00013 {
00014   for(unsigned int i = 0; i<background.size(); i++)
00015     {
00016       if((tolerance-bgTolerance+i*tolerance)>bg)
00017         {
00018           ++background[i];
00019           return;
00020         }
00021     }
00022 }
00023 
00024 void GammaLine::addCoincidenceIfValid(pair<EventHit*, EventHit*> toAdd)
00025 {
00026   if(AbsVal(toAdd.second->Ge-gamma)<tolerance)
00027     {
00028       coincidences.push_back(toAdd);
00029     }
00030   if(AbsVal(toAdd.second->Ge-gamma)<bgTolerance)
00031     {
00032       addBackground(toAdd.second->Ge);
00033     }
00034 }
00035 
00036 float GammaLine::AbsVal(float toAbs)
00037 {
00038   if(toAbs<0)
00039     return -toAbs;
00040   return toAbs;
00041 }
00042 
00043 
00044 float GammaLine::standardDeviation(vector<float> toDeviate)
00045 {
00046   if(toDeviate.size()<2)
00047     return 0;
00048   float mean = meanValue(toDeviate);
00049   float stdev = 0;
00050   for(vector<float>::iterator it = toDeviate.begin(); it!=toDeviate.end(); it++)
00051     {
00052       stdev+=pow(*it-mean,2);
00053     }
00054   stdev/=(toDeviate.size()-1);
00055   return sqrt(stdev);
00056 }
00057 
00058 float GammaLine::meanValue(vector<float> toMean)
00059 {
00060   return sum(toMean)/toMean.size();
00061 }
00062 
00063 
00064 float GammaLine::sum(vector<float> toSum)
00065 {
00066   float sum = 0;
00067   for(vector<float>::iterator it = toSum.begin(); it!=toSum.end(); it++)
00068     {
00069       sum+=*it;
00070     }
00071   return sum;
00072 }
00073 
00074 float GammaLine::getBackgroundSTD()
00075 {
00076   return standardDeviation(background);
00077 }
00078 
00079 float GammaLine::getBackgroundMean()
00080 {
00081   return meanValue(background);
00082 }
 All Classes Files Functions Variables Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark