PlotAmpVsMuScTDiff Class Reference
[Modules]

A one line description of what your module does. More...

#include <PlotAmpVsMuScTDiff.h>

Inheritance diagram for PlotAmpVsMuScTDiff:
BaseModule

List of all members.

Classes

struct  Plots

Public Member Functions

 PlotAmpVsMuScTDiff (modules::options *opts)
 Constructor description. If necessary, add a details tag like above.
 ~PlotAmpVsMuScTDiff ()
 Is anything done in the destructor?
int ProcessGenericEntry (TGlobalData *gData, const TSetupData *gSetup)
int Preprocess (TGlobalData *gData, const TSetupData *gSetup)
 Method called by the main pre-process loop.
int Postprocess (TGlobalData *gData, const TSetupData *gSetup)
 Method called by the main pre-process loop.
void SetAlias (const std::string &alias)
std::string GetAlias () const
const char * GetName () const
 Get the name of this module as given to the constructor of the base class.

Protected Member Functions

bool Debug () const
TDirectory * GetDirectory () const
 Get the TDirectory for this module.
TDirectory * GetDirectory (const std::string &name="")

Protected Attributes

TDirectory * dir

Private Types

typedef std::vector< IDs::sourceSourceVector

Private Member Functions

virtual int ProcessEntry (TGlobalData *gData, const TSetupData *gSetup)
 What's calculated for every entry? Don't hesitate to repeat what was said in the class description.
virtual int BeforeFirstEntry (TGlobalData *gData, const TSetupData *setup)
 What needes to be done before each run? Don't hesitate to repeat what was said in the class description.
virtual int AfterLastEntry (TGlobalData *gData, const TSetupData *setup)
 What needs to be done after each run? Don't hesitate to repeat what was said in the class description.
Plots GetHistogram (const IDs::source &detector, const IDs::source &muSc)

Private Attributes

std::map< std::string, PlotsfPlots
SourceVector fMuScSources
SourceVector fNotMuScSources

Detailed Description

A one line description of what your module does.

Author:
AuthorName

A longer, more descriptive block of text. Specifics like members and methods will be described later. You can add this to other groups instead of rootana_modules or in addition to rootana_modules by adding more of the ingroup tags.

Definition at line 24 of file PlotAmpVsMuScTDiff.h.


Member Typedef Documentation

typedef std::vector<IDs::source> PlotAmpVsMuScTDiff::SourceVector [private]

Definition at line 25 of file PlotAmpVsMuScTDiff.h.


Constructor & Destructor Documentation

PlotAmpVsMuScTDiff::PlotAmpVsMuScTDiff ( modules::options opts  ) 

Constructor description. If necessary, add a details tag like above.

Parameters:
[in] opts Describe the options this module takes.

Definition at line 21 of file PlotAmpVsMuScTDiff.cpp.

00021                                                           :
00022     BaseModule("PlotAmpVsMuScTDiff",opts){
00023 
00024     }

PlotAmpVsMuScTDiff::~PlotAmpVsMuScTDiff (  ) 

Is anything done in the destructor?

Definition at line 26 of file PlotAmpVsMuScTDiff.cpp.

00026                                        {
00027 }


Member Function Documentation

int PlotAmpVsMuScTDiff::AfterLastEntry ( TGlobalData gData,
const TSetupData setup 
) [private, virtual]

What needs to be done after each run? Don't hesitate to repeat what was said in the class description.

Parameters:
[in] gData See BaseModule::AfterLastEntry
[in] setup See BaseModule::AfterLastEntry
Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 92 of file PlotAmpVsMuScTDiff.cpp.

00092                                                                                 {
00093     return 0;
00094 }

int PlotAmpVsMuScTDiff::BeforeFirstEntry ( TGlobalData gData,
const TSetupData setup 
) [private, virtual]

What needes to be done before each run? Don't hesitate to repeat what was said in the class description.

Parameters:
[in] gData See BaseModule::BeforeFirstEntry
[in] setup See BaseModule::BeforeFirstEntry
Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 29 of file PlotAmpVsMuScTDiff.cpp.

References fMuScSources, fNotMuScSources, gAnalysedPulseMap, IDs::kAnyConfig, IDs::kAnySlowFast, and IDs::kMuSc.

00029                                                                                   {
00030     // Find the first muSc source ID
00031     IDs::source muSc(IDs::kMuSc,IDs::kAnySlowFast, "*", IDs::kAnyConfig);
00032     for (SourceAnalPulseMap::const_iterator i_source=gAnalysedPulseMap.begin();
00033             i_source!=gAnalysedPulseMap.end(); i_source++){
00034         if(i_source->first.matches(muSc)) fMuScSources.push_back(i_source->first);
00035         else fNotMuScSources.push_back(i_source->first);
00036     }
00037     // Check we have at least one muSc to compare to
00038     if(fMuScSources.empty()){
00039         cout<<"No muSc sources were found so we cannot make a TDiff plot to muSc"<<endl;
00040         return 1;
00041     }
00042     return 0;
00043 }

bool BaseModule::Debug (  )  const [inline, protected, inherited]
std::string BaseModule::GetAlias (  )  const [inline, inherited]

Returns a string for the alias of this module. May be empty if no alias was given in the modules file.

Definition at line 63 of file BaseModule.h.

References BaseModule::fAlias.

Referenced by BaseModule::BaseModule().

00063 {return fAlias;};

TDirectory * BaseModule::GetDirectory ( const std::string &  name = ""  )  [protected, inherited]

Definition at line 77 of file BaseModule.cpp.

References BaseModule::dir, and BaseModule::fDirectory.

00077                                                          {
00078   if(name.empty()) return fDirectory;
00079   TDirectory* dir=fDirectory->GetDirectory(name.c_str());
00080   if(dir) return dir;
00081   return fDirectory->mkdir(name.c_str());
00082 }

TDirectory* BaseModule::GetDirectory (  )  const [inline, protected, inherited]
PlotAmpVsMuScTDiff::Plots PlotAmpVsMuScTDiff::GetHistogram ( const IDs::source detector,
const IDs::source muSc 
) [private]

Definition at line 96 of file PlotAmpVsMuScTDiff.cpp.

References IDs::source::Channel(), PlotAmpVsMuScTDiff::Plots::coarse, PlotAmpVsMuScTDiff::Plots::fine, fPlots, TSetupData::GetNBits(), SetupNavigator::Instance(), TSetupData::Instance(), and IDs::source::str().

Referenced by ProcessEntry().

00096                                                                                                         {
00097     std::string keyname=detector.str()+ "-"+muSc.str();
00098     // check if we already have this plot and return it if so
00099     if(fPlots.find(keyname)!=fPlots.end()){
00100         return fPlots[keyname];
00101     }
00102 
00103     // names and axes labels
00104     std::string histname = "h" + keyname + "_AmpVsMuScTDiff_Coarse";
00105     std::string histtitle = "Amplitude vs time difference between " + detector.str() + " and " + muSc.str();
00106     std::string x_axis_title = "Time Difference (" + detector.str() + " - muSc) [ns]";
00107     std::string y_axis_title = "Amplitude from " + detector.str() + " [ADC Value]";
00108 
00109     // histogram ranges
00110     int n_bits = TSetupData::Instance()->GetNBits(SetupNavigator::Instance()->GetBank(detector.Channel()));
00111     double max_adc_value = std::pow(2, n_bits);
00112 
00113     // struct to hold return plots
00114     Plots plots;
00115 
00116     // coarse plot
00117     plots.coarse = new TH2F(histname.c_str(), histtitle.c_str(), 100,-50000,50000, 300,0,max_adc_value);
00118     plots.coarse->GetXaxis()->SetTitle(x_axis_title.c_str());
00119     plots.coarse->GetYaxis()->SetTitle(y_axis_title.c_str());
00120 
00121     // fine plot
00122     histname = "h" + keyname + "_AmpVsMuScTDiff_Fine";
00123     plots.fine = new TH2F(histname.c_str(), histtitle.c_str(), 5000,-5000,20000, 300,0,max_adc_value);
00124     plots.fine->GetXaxis()->SetTitle(x_axis_title.c_str());
00125     plots.fine->GetYaxis()->SetTitle(y_axis_title.c_str());
00126 
00127     // insert these plots into the list of plots
00128     fPlots[keyname]=plots;
00129     //DEBUG_VALUE(fPlots.size());
00130 
00131     return plots;
00132 
00133 }

const char* BaseModule::GetName (  )  const [inline, inherited]

Get the name of this module as given to the constructor of the base class.

Definition at line 66 of file BaseModule.h.

References BaseModule::fName.

Referenced by SavePulses::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), PlotTAP_Time::ProcessEntry(), PlotTAP_Energy::ProcessEntry(), PlotTAP_Amplitude::ProcessEntry(), and LoopSequence::Run().

00066 {return fName.c_str();};

int BaseModule::Postprocess ( TGlobalData gData,
const TSetupData gSetup 
) [inherited]

Method called by the main pre-process loop.

Does some simple work, then hooks into the derived class through AfterLastEntry.

Returns:
0 on sucess and non-zero if a problem occurred

Definition at line 66 of file BaseModule.cpp.

References BaseModule::AfterLastEntry(), and BaseModule::fDirectory.

Referenced by LoopSequence::Postprocess().

00066                                                                        {
00067   // This is called by our main routine and would allow later to split into different 
00068   // process routines if we have more than one Tree and hence different tpyes of data input.
00069 
00070   if(fDirectory) fDirectory->cd();
00071   int ret = AfterLastEntry(gData, gSetup);
00072   gDirectory->cd("/");
00073 
00074   return ret;
00075 }

int BaseModule::Preprocess ( TGlobalData gData,
const TSetupData gSetup 
) [inherited]

Method called by the main pre-process loop.

Does some simple work, then hooks into the derived class through BeforeFirstEntry.

Returns:
0 on sucess and non-zero if a problem occurred

Definition at line 55 of file BaseModule.cpp.

References BaseModule::BeforeFirstEntry(), and BaseModule::fDirectory.

Referenced by LoopSequence::Preprocess().

00055                                                                       {
00056   // This is called by our main routine and would allow later to split into different 
00057   // process routines if we have more than one Tree and hence different tpyes of data input.
00058 
00059   if(fDirectory) fDirectory->cd();
00060   int ret = BeforeFirstEntry(gData, gSetup);
00061   gDirectory->cd("/");
00062 
00063   return ret;
00064 }

int PlotAmpVsMuScTDiff::ProcessEntry ( TGlobalData gData,
const TSetupData gSetup 
) [private, virtual]

What's calculated for every entry? Don't hesitate to repeat what was said in the class description.

Parameters:
[in] gData See BaseModule::ProcessEntry
[in] gSetup See BaseModule::ProcessEntry
Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 45 of file PlotAmpVsMuScTDiff.cpp.

References PlotAmpVsMuScTDiff::Plots::coarse, DEBUG_PREFIX, PlotAmpVsMuScTDiff::Plots::fine, fMuScSources, fNotMuScSources, gAnalysedPulseMap, and GetHistogram().

00045                                                                               {
00046     Plots plots;
00047     AnalysedPulseList* not_muSc_pulses, *muSc_pulses;
00048 
00049     // for each source that's not a muSc source
00050     for(SourceVector::const_iterator i_not_muSc=fNotMuScSources.begin();
00051             i_not_muSc!=fNotMuScSources.end(); i_not_muSc++){
00052 
00053         // Get all pulses for i_not_muSc 
00054         not_muSc_pulses=&gAnalysedPulseMap[*i_not_muSc];
00055 
00056         // for each muSc source
00057         for(SourceVector::const_iterator i_muSc=fMuScSources.begin();
00058                 i_muSc!=fMuScSources.end(); i_muSc++){
00059 
00060             // get or make the histogram
00061             try{
00062             plots=GetHistogram(*i_not_muSc,*i_muSc);
00063             }catch(const std::bad_alloc& e){
00064                 DEBUG_PREFIX<<" Cannot allocate new histograms."<<endl;
00065                 throw e;
00066             }
00067 
00068             // Get all pulses for i_muSc
00069             muSc_pulses=&gAnalysedPulseMap[*i_muSc];
00070 
00071             for (AnalysedPulseList::const_iterator not_muSc = not_muSc_pulses->begin();
00072                     not_muSc != not_muSc_pulses->end(); ++not_muSc) {
00073                 for (AnalysedPulseList::const_iterator muSc = muSc_pulses->begin();
00074                         muSc != muSc_pulses->end(); ++muSc) {
00075 
00076                     // fill the histo
00077                     double arrival_time = (*not_muSc)->GetTime();
00078                     double muSc_time = (*muSc)->GetTime();
00079                     double t_diff = arrival_time - muSc_time;
00080                     double not_muSc_amp = (*not_muSc)->GetAmplitude();
00081 
00082                     plots.coarse->Fill(t_diff, not_muSc_amp);
00083                     plots.fine->Fill(t_diff, not_muSc_amp);
00084 
00085                 } // end loop over muSc pulses
00086             } // end loop over non-muSc pulses
00087         } // end loop over muSc sources
00088     } // end loop over non-muSc sources
00089     return 0;
00090 }

int BaseModule::ProcessGenericEntry ( TGlobalData gData,
const TSetupData gSetup 
) [inherited]

Method called by the main event loop for each entry in the input root tree. Does some simple work, then hooks into the derived class through ProcessEntry.

Returns:
0 on sucess and non-zero if a problem occurred

Definition at line 44 of file BaseModule.cpp.

References BaseModule::fDirectory, and BaseModule::ProcessEntry().

Referenced by LoopSequence::Process().

00044                                                                                {
00045   // This is called by our main routine and would allow later to split into different 
00046   // process routines if we have more than one Tree and hence different tpyes of data input.
00047 
00048   if(fDirectory) fDirectory->cd();
00049   int ret = ProcessEntry(gData, gSetup);
00050   gDirectory->cd("/");
00051 
00052   return ret;
00053 }

void BaseModule::SetAlias ( const std::string &  alias  )  [inline, inherited]

Sets the alias for this module, which should be provided in the modules file

Definition at line 59 of file BaseModule.h.

References BaseModule::fAlias.

Referenced by BaseModule::BaseModule().

00059 {fAlias=alias;};


Member Data Documentation

TDirectory* BaseModule::dir [protected, inherited]

Many modules use 'dir' still which was the old protected pointer to the modules directory. To prevent things being broken so soon, we keep this pointer available, but be warned that it will be removed shortly...

Definition at line 98 of file BaseModule.h.

Referenced by BaseModule::BaseModule(), FastSlowCompare::FastSlowCompare(), GeSpectrum::GeSpectrum(), BaseModule::GetDirectory(), MakeMuonEvents::MakeMuonEvents(), and PlotAmpVsTDiff::PlotAmpVsTDiff().

Definition at line 73 of file PlotAmpVsMuScTDiff.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

Definition at line 74 of file PlotAmpVsMuScTDiff.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

std::map<std::string, Plots> PlotAmpVsMuScTDiff::fPlots [private]

Definition at line 71 of file PlotAmpVsMuScTDiff.h.

Referenced by GetHistogram().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1