GaussFitAPGenerator Class Reference

#include <GaussFitAPGenerator.h>

Inheritance diagram for GaussFitAPGenerator:
TVAnalysedPulseGenerator

List of all members.

Classes

struct  FittedVals

Public Member Functions

 GaussFitAPGenerator (TAPGeneratorOptions *opts)
virtual ~GaussFitAPGenerator ()
virtual int ProcessPulses (const PulseIslandList &, AnalysedPulseList &)
 This method is called on each vector of pulses from a MIDAS event.
virtual bool MayDivideTPIs ()
void FitPulse (const TPulseIsland *tpi, const int &id, FittedVals &tap)
void SetPulseList (PulseIslandList *list)
template<typename TypeOfTAP >
TypeOfTAP * MakeNewTAP (int parent_index) const
 The suggested method for constructing a new TAP.
TAnalysedPulseMakeNewTAP (int parent_index) const
bool Debug () const
IDs::channel GetChannel () const
std::string GetBank () const
const IDs::sourceGetSource () const
 Get the source id for this generator being used on the current channel.
virtual void CalibratePulses (AnalysedPulseList &theAnalysedPulses) const

Static Public Member Functions

static const char * TapType ()

Protected Member Functions

virtual void SetChannel (const std::string &det)
 Set the channel for this generator. Should NOT be called by user code.

Private Types

enum  FitParams {
  kAmplitude = 0, kTime, kPedestal, kGradient,
  kWidth, kNumParams
}
 

an enum to help keep the parameters being fitted in order

More...

Private Attributes

double fMean
double fWidth
double fAmplitude
double fPedestal
double fGradient
TF1 * fFitFunc

Static Private Attributes

static const char * fFitName = "GausLinear"

Friends

class MakeAnalysedPulses

Detailed Description

Definition at line 9 of file GaussFitAPGenerator.h.


Member Enumeration Documentation

an enum to help keep the parameters being fitted in order

Enumerator:
kAmplitude 
kTime 
kPedestal 
kGradient 
kWidth 
kNumParams 

Definition at line 12 of file GaussFitAPGenerator.h.


Constructor & Destructor Documentation

GaussFitAPGenerator::GaussFitAPGenerator ( TAPGeneratorOptions opts  ) 

Definition at line 17 of file GaussFitAPGenerator.cpp.

References fAmplitude, fFitFunc, fFitName, fGradient, fMean, fPedestal, fWidth, functions::gauss_lin(), modules::options::GetDouble(), kAmplitude, kGradient, kPedestal, kTime, and kWidth.

00017                                                                  :
00018     TVAnalysedPulseGenerator("GaussFit",opts){
00019         // Do things to set up the generator here. 
00020         fMean=opts->GetDouble("time",200);
00021         fWidth=opts->GetDouble("width",60);
00022         fAmplitude=opts->GetDouble("amplitude",200);
00023         fPedestal=opts->GetDouble("pedestal",0);
00024         fGradient=opts->GetDouble("gradient",0);
00025 
00026         fFitFunc=new TF1(fFitName,functions::gauss_lin,0,1000,5);
00027         fFitFunc->SetParName(kPedestal,"pedestal");
00028         fFitFunc->SetParName(kAmplitude,"amplitude");
00029         fFitFunc->SetParName(kWidth,"width");
00030         fFitFunc->SetParName(kGradient,"gradient");
00031         fFitFunc->SetParName(kTime,"time");
00032     }

virtual GaussFitAPGenerator::~GaussFitAPGenerator (  )  [inline, virtual]

Definition at line 24 of file GaussFitAPGenerator.h.

00024 {};


Member Function Documentation

void TVAnalysedPulseGenerator::CalibratePulses ( AnalysedPulseList theAnalysedPulses  )  const [virtual, inherited]

Definition at line 23 of file TVAnalysedPulseGenerator.cpp.

References TVAnalysedPulseGenerator::fAdcToEnergyGain, TVAnalysedPulseGenerator::fAdcToEnergyOffset, and TVAnalysedPulseGenerator::fCanCalibrate.

00023                                                                                        {
00024    if(fCanCalibrate){
00025       for(AnalysedPulseList::iterator i_tap=theAnalysedPulses.begin(); i_tap != theAnalysedPulses.end(); ++i_tap){
00026          const double amplitude=(*i_tap)->GetAmplitude();
00027          (*i_tap)->SetEnergy(fAdcToEnergyGain * amplitude + fAdcToEnergyOffset);
00028       }
00029    }
00030 }

bool TVAnalysedPulseGenerator::Debug (  )  const [inline, inherited]
void GaussFitAPGenerator::FitPulse ( const TPulseIsland tpi,
const int &  id,
FittedVals tap 
)

Definition at line 74 of file GaussFitAPGenerator.cpp.

References GaussFitAPGenerator::FittedVals::chi2, TVAnalysedPulseGenerator::Debug(), GaussFitAPGenerator::FittedVals::error, fAmplitude, fFitFunc, fGradient, fMean, fPedestal, fWidth, TPulseIsland::GetPulseLength(), TPulseIsland::GetPulseWaveform(), kAmplitude, kGradient, kPedestal, kTime, kWidth, GaussFitAPGenerator::FittedVals::status, and GaussFitAPGenerator::FittedVals::value.

Referenced by ProcessPulses().

00074                                                                                        {
00075 
00076     // Fill a TH1 with the TPI samples
00077     std::stringstream histname("tpi_");
00078     histname<<id;
00079     TH1I* hPulse = tpi->GetPulseWaveform(histname.str(), histname.str());
00080 
00081     // Set the parameters for the fit 
00082     fFitFunc->SetParameters(fPedestal,fGradient,fAmplitude,fMean,fWidth);
00083     fFitFunc->SetRange(0,tpi->GetPulseLength());
00084 
00085     // Perform the fit
00086     std::string options ="S R";
00087     if(!Debug()) options+=" Q";
00088     TFitResultPtr result=hPulse->Fit(fFitFunc,options.c_str());
00089 
00090     // Get the values from the fit 
00091     tap.value[kAmplitude] = fFitFunc->GetParameter(kAmplitude);
00092     tap.value[kTime     ] = fFitFunc->GetParameter(kTime);
00093     tap.value[kPedestal ] = fFitFunc->GetParameter(kPedestal);
00094     tap.value[kGradient ] = fFitFunc->GetParameter(kGradient);
00095     tap.value[kWidth    ] = fFitFunc->GetParameter(kWidth);
00096 
00097     // Get errors from the fit
00098     tap.error[kAmplitude] = fFitFunc->GetParError(kAmplitude);
00099     tap.error[kTime     ] = fFitFunc->GetParError(kTime);
00100     tap.error[kPedestal ] = fFitFunc->GetParError(kPedestal);
00101     tap.error[kGradient ] = fFitFunc->GetParError(kGradient);
00102     tap.error[kWidth    ] = fFitFunc->GetParError(kWidth);
00103 
00104     // Set other fit properties
00105     tap.chi2          = result->Chi2();
00106     tap.status        = result;
00107 
00108     delete hPulse;
00109 
00110 }

std::string TVAnalysedPulseGenerator::GetBank (  )  const [inline, inherited]

A convenience method for analysis to get the channel ID of the channel being analysed

Definition at line 85 of file TVAnalysedPulseGenerator.h.

References TVAnalysedPulseGenerator::fBankName.

00085 {return fBankName;};

IDs::channel TVAnalysedPulseGenerator::GetChannel (  )  const [inline, inherited]
const IDs::source& TVAnalysedPulseGenerator::GetSource (  )  const [inline, inherited]

Get the source id for this generator being used on the current channel.

Useful for a generator to know the full source much like in the above GetChannel method, but this could also be useful for checking that this generator is the one that made a given TAP in later analysis by comparing this value to that stored in the TAP itself.

Definition at line 94 of file TVAnalysedPulseGenerator.h.

References TVAnalysedPulseGenerator::fSource.

Referenced by TVAnalysedPulseGenerator::MakeNewTAP(), and IntegralRatioAPGenerator::ProcessPulses().

00094 {return fSource;};

TAnalysedPulse* TVAnalysedPulseGenerator::MakeNewTAP ( int  parent_index  )  const [inline, inherited]

Definition at line 73 of file TVAnalysedPulseGenerator.h.

00073                                                          {
00074             return MakeNewTAP<TAnalysedPulse>(parent_index);
00075         }

template<typename TypeOfTAP >
TypeOfTAP * TVAnalysedPulseGenerator::MakeNewTAP ( int  parent_index  )  const [inline, inherited]

The suggested method for constructing a new TAP.

In the process of constructing TAP, information that isn't immediately obvious how to get needs to be passed to TAP. This method returns a pointer to a TAP construced for you, and all you need to pass it is the TPulseIslandID.

In the case where a generator wants to add extra information to the standard TAP information, we expect people to derive from TAnalysedPulse. If your generator is one of these, then use the template argument to produce the type of TAP you desire. Note that this forces the constructor of the specialised TAP to be the same as for TAnalysedPulse itself.

For example, for to make a specialied analysed pulse called TSpecialAnalysedPulse (original, huh?) you would do:

 TSpecialAnalysedPulse* tsap=MakeNewTAP<TSpecialAnalysedPulse>(parent_index);
Parameters:
[in] parent_index The TPulseIslandID of the TPI being used to make the new TAP.
Template Parameters:
in] TypeOfTAP The type of specialisation of TAnalysedPulse that you want to create.

Definition at line 137 of file TVAnalysedPulseGenerator.h.

References TVAnalysedPulseGenerator::fPulseList, and TVAnalysedPulseGenerator::GetSource().

Referenced by FirstCompleteAPGenerator::AnalyseOneTpi(), SimpIntAPGenerator::ProcessPulses(), MaxBinAPGenerator::ProcessPulses(), CFTimeMBAmpAPGenerator::ProcessPulses(), and CFTimeAPGenerator::ProcessPulses().

00137                                                                            {
00138     TypeOfTAP* pulse=NULL;
00139     TPulseIsland* parent = fPulseList->at(parent_index);
00140     pulse=new TypeOfTAP(GetSource(),parent_index,parent);
00141     return pulse;
00142 }

virtual bool GaussFitAPGenerator::MayDivideTPIs (  )  [inline, virtual]
Todo:
Document this

Implements TVAnalysedPulseGenerator.

Definition at line 31 of file GaussFitAPGenerator.h.

00031 {return false;};

int GaussFitAPGenerator::ProcessPulses ( const PulseIslandList pil,
AnalysedPulseList apl 
) [virtual]

This method is called on each vector of pulses from a MIDAS event.

Parameters:
[in] pil The vector of TPIs to produce TAPs from.
[out] apl The vector of TAPs to append the new TAPs to.

Implements TVAnalysedPulseGenerator.

Definition at line 34 of file GaussFitAPGenerator.cpp.

References ExportPulse::AddToExportList(), GaussFitAPGenerator::FittedVals::chi2, GaussFitAPGenerator::FittedVals::error, FitPulse(), ExportPulse::Instance(), kAmplitude, kGradient, kPedestal, kWidth, TGaussFitAnalysedPulse::SetAmplitude(), TGaussFitAnalysedPulse::SetChi2(), TGaussFitAnalysedPulse::SetFitStatus(), TGaussFitAnalysedPulse::SetGradient(), TGaussFitAnalysedPulse::SetPedestal(), TGaussFitAnalysedPulse::SetWidth(), GaussFitAPGenerator::FittedVals::status, and GaussFitAPGenerator::FittedVals::value.

00036                                         {
00037     // Do something here that takes the TPIs in the PulseIslandList and
00038     // fills the list of TAPS
00039 
00040     // Loop over all the TPIs given to us
00041     TGaussFitAnalysedPulse* tap;
00042     FittedVals tap_data;
00043     int index;
00044     for (PulseIslandList::const_iterator tpi=pulseList.begin();
00045             tpi!=pulseList.end(); tpi++){
00046 
00047         // Analyse each TPI
00048         index=tpi-pulseList.begin();
00049         FitPulse(*tpi,index,tap_data);
00050 
00051         // Make a TGaussFitAnalysedPulse 
00052         tap = MakeNewTAP<TGaussFitAnalysedPulse>(index);
00053 
00054         // Now assign all the measure values
00055         tap->SetAmplitude ( tap_data.value[kAmplitude] , tap_data.error[kAmplitude] );
00056         tap->SetPedestal  ( tap_data.value[kPedestal]  , tap_data.error[kPedestal]  );
00057         tap->SetGradient  ( tap_data.value[kGradient]  , tap_data.error[kGradient]  );
00058         tap->SetWidth     ( tap_data.value[kWidth]     , tap_data.error[kWidth]     );
00059         tap->SetChi2      ( tap_data.chi2   );
00060         tap->SetFitStatus ( tap_data.status );
00061 
00062         if(ExportPulse::Instance() && tap_data.status!=0){
00063             ExportPulse::Instance()->AddToExportList(tap);
00064         }
00065 
00066         // Finally add the new TAP to the output list
00067         analysedList.push_back(tap);
00068     }
00069 
00070     // returning 0 tells the caller that we were successful, return non-zero if not
00071     return 0;
00072 }

virtual void TVAnalysedPulseGenerator::SetChannel ( const std::string &  det  )  [inline, protected, virtual, inherited]

Set the channel for this generator. Should NOT be called by user code.

Called by MakeAnalysedPulses to tell this generator what channel it is looking at.

Definition at line 108 of file TVAnalysedPulseGenerator.h.

References IDs::source::Channel(), TVAnalysedPulseGenerator::fBankName, TVAnalysedPulseGenerator::fSource, SetupNavigator::GetBank(), and SetupNavigator::Instance().

Referenced by TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().

00108                                                      {
00109            fSource.Channel()=det;
00110            fBankName= SetupNavigator::Instance()->GetBank(det);
00111          };

void TVAnalysedPulseGenerator::SetPulseList ( PulseIslandList list  )  [inline, inherited]

Definition at line 44 of file TVAnalysedPulseGenerator.h.

References TVAnalysedPulseGenerator::fPulseList.

00044 {fPulseList=list;};

const char * GaussFitAPGenerator::TapType (  )  [static]

Reimplemented from TVAnalysedPulseGenerator.

Definition at line 112 of file GaussFitAPGenerator.cpp.

00112                                         {
00113     return TGaussFitAnalysedPulse::Class()->GetName();
00114 }


Friends And Related Function Documentation

friend class MakeAnalysedPulses [friend, inherited]

Definition at line 101 of file TVAnalysedPulseGenerator.h.


Member Data Documentation

Definition at line 37 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().

Definition at line 38 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().

const char * GaussFitAPGenerator::fFitName = "GausLinear" [static, private]

Definition at line 39 of file GaussFitAPGenerator.h.

Referenced by GaussFitAPGenerator().

Definition at line 37 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().

double GaussFitAPGenerator::fMean [private]

Definition at line 37 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().

Definition at line 37 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().

double GaussFitAPGenerator::fWidth [private]

Definition at line 37 of file GaussFitAPGenerator.h.

Referenced by FitPulse(), and GaussFitAPGenerator().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1