TemplateConvolveAPGenerator Class Reference

#include <TemplateConvolveAPGenerator.h>

Inheritance diagram for TemplateConvolveAPGenerator:
TVAnalysedPulseGenerator

List of all members.

Public Member Functions

 TemplateConvolveAPGenerator (TAPGeneratorOptions *opts)
virtual ~TemplateConvolveAPGenerator ()
virtual int ProcessPulses (const PulseIslandList &, AnalysedPulseList &)
 This method is called on each vector of pulses from a MIDAS event.
virtual bool MayDivideTPIs ()
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 Member Functions

bool PassesIntegralRatio (const TPulseIsland *pulse, double &integral, double &ratio) const
double CalibrateTime (double clockTime, const TPulseIsland *tpi) const
 Convert time from clock time within the TPI to real time.

Private Attributes

TTemplatefTemplate
TemplateConvolverfConvolver
double fIntegralMax
double fIntegralMin
double fIntegralRatioMax
double fIntegralRatioMin
double fTemplateAmp
double fTemplatePed
double fTemplateTime
double fPedestal
double fTicksPerNs
double fMuScTimeOffset
bool fExpectPileUp
Algorithm::IntegralRatiofIntegralRatio

Static Private Attributes

static TemplateArchivefTemplateArchive = NULL

Friends

class MakeAnalysedPulses

Detailed Description

Definition at line 15 of file TemplateConvolveAPGenerator.h.


Constructor & Destructor Documentation

TemplateConvolveAPGenerator::TemplateConvolveAPGenerator ( TAPGeneratorOptions opts  ) 

Definition at line 16 of file TemplateConvolveAPGenerator.cpp.

References TemplateConvolver::CharacteriseTemplate(), fConvolver, fIntegralMax, fIntegralMin, fIntegralRatio, fIntegralRatioMax, fIntegralRatioMin, fTemplate, fTemplateArchive, TVAnalysedPulseGenerator::GetChannel(), modules::options::GetDouble(), modules::options::GetFlag(), TTemplate::GetHisto(), modules::options::GetInt(), SetupRecord::GetPolarity(), EventNavigator::GetSetupRecord(), modules::options::GetString(), TemplateArchive::GetTemplate(), EventNavigator::Instance(), TTemplate::NormaliseToSumSquares(), and TTemplate::RebinToOriginalSampling().

00016                                                                                  :
00017    TVAnalysedPulseGenerator("TemplateConvolve",opts),
00018     fPedestal(EventNavigator::Instance().GetSetupRecord().GetPedestal(GetChannel())),
00019     fTicksPerNs(EventNavigator::Instance().GetSetupRecord().GetTickLength(GetChannel())),
00020     //fMuScTimeOffset(SetupNavigator::Instance()->GetCoarseTimeOffset(GetSource())),
00021     fMuScTimeOffset(0.),
00022     fExpectPileUp(false), fIntegralRatio(NULL)
00023 {
00024    // get the templates from the archive
00025    if(!fTemplateArchive){
00026      fTemplateArchive=new TemplateArchive(opts->GetString("template_archive").c_str(),"READ");
00027    }
00028    fTemplate=fTemplateArchive->GetTemplate(GetChannel());
00029    fTemplate->RebinToOriginalSampling();
00030    fTemplate->NormaliseToSumSquares();
00031 
00032    int fit_peak= opts->GetInt("n_quad_fit",5);
00033    int left= opts->GetInt("left",20);
00034    int right= opts->GetInt("right",120);
00035    fConvolver=new TemplateConvolver(GetChannel(), fTemplate, fit_peak, left, right);
00036    TH1* tpl=(TH1*)fTemplate->GetHisto()->Clone("Template");
00037    tpl->SetDirectory(gDirectory);
00038    fConvolver->CharacteriseTemplate();
00039 
00040    // prepare the integral ratio cuts
00041    if(opts->GetFlag("use_IR_cut")){
00042       fIntegralRatio=new Algorithm::IntegralRatio(
00043                       opts->GetInt("start_integral",10),
00044                       opts->GetInt("start_tail",60),
00045                       opts->GetInt("stop_integral",0),
00046                       EventNavigator::Instance().GetSetupRecord().GetPolarity(GetChannel()));
00047       fIntegralMax=opts->GetDouble("max_integral");
00048       fIntegralMin=opts->GetDouble("min_integral");
00049       fIntegralRatioMax=opts->GetDouble("max_ratio");
00050       fIntegralRatioMin=opts->GetDouble("min_ratio");
00051   }
00052 }

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

Definition at line 19 of file TemplateConvolveAPGenerator.h.

00019 {};


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 }

double TemplateConvolveAPGenerator::CalibrateTime ( double  clockTime,
const TPulseIsland tpi 
) const [private]

Convert time from clock time within the TPI to real time.

Definition at line 139 of file TemplateConvolveAPGenerator.cpp.

References fMuScTimeOffset, fTicksPerNs, and TPulseIsland::GetTimeStamp().

Referenced by ProcessPulses().

00139                                                                                                {
00140   return (clockTime + (double)tpi->GetTimeStamp()) * fTicksPerNs - fMuScTimeOffset;
00141 }

bool TVAnalysedPulseGenerator::Debug (  )  const [inline, inherited]
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 TemplateConvolveAPGenerator::MayDivideTPIs (  )  [inline, virtual]
Todo:
Document this

Implements TVAnalysedPulseGenerator.

Definition at line 24 of file TemplateConvolveAPGenerator.h.

00024 {return true;};

bool TemplateConvolveAPGenerator::PassesIntegralRatio ( const TPulseIsland pulse,
double &  integral,
double &  ratio 
) const [private]

Definition at line 122 of file TemplateConvolveAPGenerator.cpp.

References fIntegralRatio, Algorithm::IntegralRatio::GetRatio(), Algorithm::IntegralRatio::GetTotal(), and Algorithm::IntegralRatio::SetPedestalToMinimum().

Referenced by ProcessPulses().

00122                                                                                                                     {
00123    if(!fIntegralRatio) return true;
00124    try{
00125      fIntegralRatio->SetPedestalToMinimum(pulse);
00126      (*fIntegralRatio)(pulse);
00127    }catch(std::out_of_range& e){
00128      return false;
00129    }
00130    integral=fIntegralRatio->GetTotal();
00131    ratio=fIntegralRatio->GetRatio();
00132    if( fIntegralMax < integral || fIntegralMin > integral
00133        || fIntegralRatioMax < ratio || fIntegralRatioMin > ratio) {
00134        return false;
00135    }
00136    return true;
00137 }

int TemplateConvolveAPGenerator::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 54 of file TemplateConvolveAPGenerator.cpp.

References CalibrateTime(), TemplateConvolver::Convolve(), TVAnalysedPulseGenerator::Debug(), fConvolver, fExpectPileUp, TemplateConvolver::FindPeaks(), fIntegralRatio, fPedestal, fTemplate, TemplateConvolver::GetAmplitudeScale(), TemplateConvolver::GetEnergyConvolution(), TemplateConvolver::GetPeaks(), TemplateConvolver::GetTimeConvolution(), TemplateConvolver::GetTimeShift(), PassesIntegralRatio(), TAnalysedPulse::SetAmplitude(), TTemplateConvolveAnalysedPulse::SetAmplitudeScale(), TTemplateConvolveAnalysedPulse::SetEnergyConvolve(), TAnalysedPulse::SetIntegral(), TTemplateConvolveAnalysedPulse::SetIntegralRatio(), TTemplateConvolveAnalysedPulse::SetNPeaks(), TTemplateConvolveAnalysedPulse::SetPeakRank(), TAnalysedPulse::SetPedestal(), TTemplateConvolveAnalysedPulse::SetQuadraticFit(), TTemplateConvolveAnalysedPulse::SetTemplate(), TAnalysedPulse::SetTime(), TTemplateConvolveAnalysedPulse::SetTimeConvolve(), and TTemplateConvolveAnalysedPulse::SetTimeOffset().

00056                                     {
00057 
00058   // Loop over all the TPIs given to us
00059   double integral, ratio;
00060   TTemplateConvolveAnalysedPulse* tap;
00061   for (PulseIslandList::const_iterator tpi=pulseList.begin();
00062        tpi!=pulseList.end(); tpi++){
00063 
00064     // Check integral ratio if we're supposed to
00065     if(fIntegralRatio && !PassesIntegralRatio(*tpi, integral,ratio)){
00066        continue;
00067     }
00068     Algorithm::TpiMinusPedestal_iterator waveform((*tpi)->GetSamples().begin(),fPedestal);
00069     Algorithm::TpiMinusPedestal_iterator end((*tpi)->GetSamples().end());
00070 
00071     // convolve with the template
00072     int n_peaks=fConvolver->Convolve(waveform,end );
00073     if(n_peaks<0) {
00074       if(Debug())cout<<"Waveform too small to analyze"<<endl;
00075       continue;
00076     }
00077     n_peaks= fConvolver->FindPeaks(fExpectPileUp , waveform);
00078 
00079     const TemplateConvolver::PeaksVector& peaks=fConvolver->GetPeaks();
00080     int count=0;
00081     for(TemplateConvolver::PeaksVector::const_iterator i_tap=peaks.begin();
00082           i_tap!=peaks.end(); ++i_tap){
00083     //for(int i_peak=0; i_peak<3 || fConvolver->GetPeaks().size()==0 ; ++i_peak){
00084     //   // get the first pulse to be found
00085     //   const TemplateConvolver::FoundPeaks& i_tap=*fConvolver->GetPeaks().begin();
00086     
00087        // Make a new TAP to store the data.  This method makes a TAP and sets the parent TPI info.  It needs
00088        // the index of the parent TPI in the container as an argument
00089        tap = MakeNewTAP<TTemplateConvolveAnalysedPulse>(tpi-pulseList.begin());
00090        if(fIntegralRatio){
00091          tap->SetIntegral(integral);
00092          tap->SetIntegralRatio(ratio);
00093        }
00094        tap->SetNPeaks(n_peaks);
00095        tap->SetPeakRank(count);
00096        tap->SetEnergyConvolve(fConvolver->GetEnergyConvolution());
00097        tap->SetTimeConvolve(fConvolver->GetTimeConvolution());
00098        tap->SetTimeOffset(i_tap->time);
00099        tap->SetAmplitudeScale(i_tap->amplitude);
00100        tap->SetAmplitude(i_tap->amplitude*fConvolver->GetAmplitudeScale());
00101        tap->SetQuadraticFit(i_tap->quad,i_tap->linear, i_tap->constant);
00102        tap->SetTemplate(fTemplate);
00103        tap->SetPedestal(fPedestal);
00104        double time= CalibrateTime(i_tap->time + fConvolver->GetTimeShift() +0.5, *tpi);
00105        tap->SetTime(time);
00106        //DEBUG_VALUE(i_tap->amplitude, i_tap->time, i_tap->pedestal);
00107 
00108        // Finally add the new TAP to the output list
00109        analysedList.push_back(tap);
00110 
00112        //waveform.AddHistogram(fConvolver->GetTemplateACF(), i_tap.amplitude, -i_tap.time+fConvolver->GetLeftSafety());
00113        //n_peaks= fConvolver->Convolve(waveform,end );
00114        //if(n_peaks==0) break;
00115        count++;
00116     }
00117   }
00118 
00119   return 0;
00120 }

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;};

static const char* TemplateConvolveAPGenerator::TapType (  )  [inline, static]

Reimplemented from TVAnalysedPulseGenerator.

Definition at line 26 of file TemplateConvolveAPGenerator.h.

00026                                 {
00027        return TTemplateConvolveAnalysedPulse::Class()->GetName();
00028    }


Friends And Related Function Documentation

friend class MakeAnalysedPulses [friend, inherited]

Definition at line 101 of file TVAnalysedPulseGenerator.h.


Member Data Documentation

Definition at line 38 of file TemplateConvolveAPGenerator.h.

Referenced by ProcessPulses(), and TemplateConvolveAPGenerator().

Definition at line 45 of file TemplateConvolveAPGenerator.h.

Referenced by ProcessPulses().

Definition at line 40 of file TemplateConvolveAPGenerator.h.

Referenced by TemplateConvolveAPGenerator().

Definition at line 40 of file TemplateConvolveAPGenerator.h.

Referenced by TemplateConvolveAPGenerator().

Definition at line 41 of file TemplateConvolveAPGenerator.h.

Referenced by TemplateConvolveAPGenerator().

Definition at line 41 of file TemplateConvolveAPGenerator.h.

Referenced by TemplateConvolveAPGenerator().

Definition at line 44 of file TemplateConvolveAPGenerator.h.

Referenced by CalibrateTime().

Definition at line 43 of file TemplateConvolveAPGenerator.h.

Referenced by ProcessPulses().

Definition at line 37 of file TemplateConvolveAPGenerator.h.

Referenced by ProcessPulses(), and TemplateConvolveAPGenerator().

Definition at line 42 of file TemplateConvolveAPGenerator.h.

Definition at line 36 of file TemplateConvolveAPGenerator.h.

Referenced by TemplateConvolveAPGenerator().

Definition at line 42 of file TemplateConvolveAPGenerator.h.

Definition at line 42 of file TemplateConvolveAPGenerator.h.

Definition at line 44 of file TemplateConvolveAPGenerator.h.

Referenced by CalibrateTime().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1