CalcCoarseTimeOffset Class Reference
[Modules]

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

#include <CalcCoarseTimeOffset.h>

Inheritance diagram for CalcCoarseTimeOffset:
BaseModule

List of all members.

Public Member Functions

 CalcCoarseTimeOffset (modules::options *opts)
 Constructor description. If necessary, add a details tag like above.
 ~CalcCoarseTimeOffset ()
 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.
void CreateHistogramsIfDontExist (const std::string &source, const std::string &generator)

Private Attributes

std::string fDetNameA
 Don't forget to forget descirptions for each field...
std::string fDetNameB
std::map< std::string, TH1F * > oned_plots
SourceVector fDetASources
SourceVector fDetBSources

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 25 of file CalcCoarseTimeOffset.h.


Member Typedef Documentation

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

Definition at line 26 of file CalcCoarseTimeOffset.h.


Constructor & Destructor Documentation

CalcCoarseTimeOffset::CalcCoarseTimeOffset ( 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 28 of file CalcCoarseTimeOffset.cpp.

References fDetNameA, fDetNameB, and modules::options::GetString().

00028                                                               :
00029   BaseModule("CalcCoarseTimeOffset",opts){    
00030   fDetNameA = opts->GetString("det1");
00031   fDetNameB = opts->GetString("det2");
00032 }

CalcCoarseTimeOffset::~CalcCoarseTimeOffset (  ) 

Is anything done in the destructor?

Definition at line 36 of file CalcCoarseTimeOffset.cpp.

00036                                            {
00037 }


Member Function Documentation

int CalcCoarseTimeOffset::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 103 of file CalcCoarseTimeOffset.cpp.

References fDetASources, SetupNavigator::Instance(), oned_plots, and SetupNavigator::SetCoarseTimeOffset().

00103                                                                                    {
00104   for (unsigned int i = 0; i < fDetASources.size(); ++i) {
00105     const std::string keyname = fDetASources[i].str();
00106     const double dt = oned_plots[keyname]->GetBinCenter(oned_plots[keyname]->GetMaximumBin());
00107     SetupNavigator::Instance()->SetCoarseTimeOffset(fDetASources[i], dt);
00108   }
00109   return 0;
00110 }

int CalcCoarseTimeOffset::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 41 of file CalcCoarseTimeOffset.cpp.

References fDetASources, fDetBSources, fDetNameA, fDetNameB, and gAnalysedPulseMap.

00041                                                                                     {
00042 
00043   //call my source finders and build histogram for each source with
00044   //a time component.
00045   
00046   //should I continue to work on just two? or should I have this loop 
00047   //through all pairs
00048   
00049   for(SourceAnalPulseMap::const_iterator sourceIt = gAnalysedPulseMap.begin();
00050       sourceIt != gAnalysedPulseMap.end(); sourceIt++) {
00051     if( sourceIt->first.Channel() != fDetNameA) {
00052       continue;   //check for detector A
00053     }
00054     
00055     //I need to check that this source generates a time
00056     AnalysedPulseList pulses = sourceIt->second;
00057     
00058     for(SourceAnalPulseMap::const_iterator sourceIt2 = gAnalysedPulseMap.begin(); sourceIt2 != gAnalysedPulseMap.end(); sourceIt2++) {
00059       if(sourceIt2->first.Channel() != fDetNameB)
00060         continue;  //check for detector B
00061       if(sourceIt2->first.Generator() != sourceIt->first.Generator())
00062         continue;  //make sure they have the same generator
00063       
00064       //I should make a vector of the sources for detA and detB
00065       fDetASources.push_back(sourceIt->first);
00066       fDetBSources.push_back(sourceIt2->first);
00067     }
00068   }
00069   return 0;
00070 }

void CalcCoarseTimeOffset::CreateHistogramsIfDontExist ( const std::string &  source,
const std::string &  generator 
) [private]

Definition at line 112 of file CalcCoarseTimeOffset.cpp.

References fDetNameA, fDetNameB, and oned_plots.

Referenced by ProcessEntry().

00112                                                                                                  {
00113   if( oned_plots.find(src) == oned_plots.end() ) {
00114     std::string histname = "h" + fDetNameB + "_" + src + "TDiff_1D";
00115     std::string histtitle = "Time difference between  " + fDetNameA + " and " + fDetNameB + " detectors with the " + gen + " generator";
00116     TH1F* dplots = new TH1F(histname.c_str(), histtitle.c_str(), 500, -10000, 10000);
00117     dplots->GetXaxis()->SetTitle("Time Difference (ns)");
00118     dplots->GetYaxis()->SetTitle("Count");
00119     oned_plots[src] = dplots;
00120   }      
00121 }

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]
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 CalcCoarseTimeOffset::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 74 of file CalcCoarseTimeOffset.cpp.

References CreateHistogramsIfDontExist(), fDetASources, fDetBSources, gAnalysedPulseMap, and oned_plots.

00074                                                                                  {
00075   for(SourceVector::const_iterator sourceIt = fDetASources.begin(); sourceIt != fDetASources.end(); sourceIt++) {
00076     const AnalysedPulseList& detAPulses = gAnalysedPulseMap[*sourceIt];
00077     const AnalysedPulseList& detBPulses = gAnalysedPulseMap[fDetBSources.at(sourceIt - fDetASources.begin())];
00078 
00079     const std::string keyname = sourceIt->str();
00080     CreateHistogramsIfDontExist(keyname, (*sourceIt).Generator().str());
00081 
00082     for(AnalysedPulseList::const_iterator pulseIt = detAPulses.begin();
00083         pulseIt != detAPulses.end(); ++pulseIt) {
00084       double timeA = (*pulseIt)->GetTime();
00085       for(AnalysedPulseList::const_iterator pulseIt2 = detBPulses.begin();
00086           pulseIt2 != detBPulses.end(); ++pulseIt2) {
00087 
00088         double timeB = (*pulseIt2)->GetTime();
00089         double tDiff = timeA - timeB;
00090 
00091         oned_plots[keyname]->Fill(tDiff);
00092 
00093       }//end detBPulse loop
00094     }//end detAPulse loop
00095   }//end sourceIt loop
00096 
00097   return 0;
00098 }

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 74 of file CalcCoarseTimeOffset.h.

Referenced by AfterLastEntry(), BeforeFirstEntry(), and ProcessEntry().

Definition at line 74 of file CalcCoarseTimeOffset.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

std::string CalcCoarseTimeOffset::fDetNameA [private]

Don't forget to forget descirptions for each field...

...and don't hesitate to include details.

Definition at line 71 of file CalcCoarseTimeOffset.h.

Referenced by BeforeFirstEntry(), CalcCoarseTimeOffset(), and CreateHistogramsIfDontExist().

std::string CalcCoarseTimeOffset::fDetNameB [private]
std::map<std::string, TH1F*> CalcCoarseTimeOffset::oned_plots [private]

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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1