LoadPulses Class Reference
[Modules]

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

#include <LoadPulses.h>

Inheritance diagram for LoadPulses:
BaseModule

List of all members.

Public Member Functions

 LoadPulses (modules::options *opts)
 Constructor description. If necessary, add a details tag like above.
 ~LoadPulses ()
 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::map< IDs::source,
TClonesArray * > 
SourceToClonesArrayMap
typedef std::vector< std::pair
< IDs::source, TBranch * > > 
BranchList

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.

Private Attributes

std::string fFileName
std::string fTreeName
TTree * fInTree
Long64_t fCurrentEntry
Long64_t fNumEntries
SourceToClonesArrayMap fArrays
BranchList fBranches

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 LoadPulses.h.


Member Typedef Documentation

typedef std::vector<std::pair<IDs::source, TBranch*> > LoadPulses::BranchList [private]

Definition at line 64 of file LoadPulses.h.

typedef std::map<IDs::source,TClonesArray*> LoadPulses::SourceToClonesArrayMap [private]

Definition at line 62 of file LoadPulses.h.


Constructor & Destructor Documentation

LoadPulses::LoadPulses ( 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 23 of file LoadPulses.cpp.

References fFileName, fTreeName, and modules::options::GetString().

00023                                           :
00024    BaseModule("LoadPulses",opts){
00025        fFileName=opts->GetString("file_name");
00026        fTreeName=opts->GetString("tree_name","TAP_tree");
00027 }

LoadPulses::~LoadPulses (  ) 

Is anything done in the destructor?

Definition at line 29 of file LoadPulses.cpp.

00029                        {
00030 }


Member Function Documentation

int LoadPulses::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.

Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 117 of file LoadPulses.cpp.

00117                                                                         {
00118   return 0;
00119 }

int LoadPulses::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.

Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 32 of file LoadPulses.cpp.

References fArrays, fBranches, fCurrentEntry, fFileName, fInTree, fNumEntries, fTreeName, gAnalysedPulseMap, EventNavigator::GetStartEntry(), and EventNavigator::Instance().

00032                                                                           {
00033     // open the file
00034     if(fFileName.empty()){
00035         cout<<"LoadPulses: Error: no input file specified "<<endl;
00036         return 1;
00037     }
00038     TFile* inFile=TFile::Open(fFileName.c_str(), "READ");
00039     if(!inFile){
00040         cout<<"LoadPulses: Error: Unable to open input file, "<<fFileName<<endl;
00041         return 2;
00042     }
00043     // open the tree
00044     inFile->GetObject(fTreeName.c_str(),fInTree);
00045     if(!fInTree){
00046         cout<<"LoadPulses: Error: Unable to find input tree, "<<fTreeName<<" in file "<<fFileName<<endl;
00047         return 3;
00048     }
00049     // Prepare the TAP flyweights
00050     FlyWeight<IDs::source,TAnalysedPulse::Tag>::LoadProxyList(gDirectory,"TAP_sources");
00051 
00052     // Loop over each branch
00053     TObjArray* listOfArraysOfTAPs=fInTree->GetListOfBranches();
00054     TBranchClones* branch;
00055     IDs::source tmp_source;
00056     for(int i_array=0;i_array<listOfArraysOfTAPs->GetSize();i_array++){
00057         // Get the branch
00058         branch=(TBranchClones*)listOfArraysOfTAPs->At(i_array);
00059         if(!branch) continue;
00060         // Create the corrsponding source ID
00061         tmp_source=branch->GetName();
00062         // Add to the list of branches
00063         fBranches.push_back(std::make_pair(tmp_source,branch));
00064         // Prepare gAnalysedPulseMap
00065         gAnalysedPulseMap[tmp_source];
00066     }
00067     for(BranchList::iterator i_branch=fBranches.begin();
00068             i_branch!=fBranches.end(); ++i_branch){
00069         // Set the TClonesArray address
00070         i_branch->second->SetAddress(&fArrays[i_branch->first]);
00071     }
00072     //fInTree->SetDebug();
00073 
00074     // Get the first entry to read from
00075     fCurrentEntry=EventNavigator::Instance().GetStartEntry();
00076     fNumEntries=fInTree->GetEntries();
00077   return 0;
00078 }

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 LoadPulses::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.

Returns:
Non-zero to indicate a problem.

Implements BaseModule.

Definition at line 80 of file LoadPulses.cpp.

References fArrays, fCurrentEntry, fInTree, fNumEntries, and gAnalysedPulseMap.

00080                                                                       {
00081     if(fCurrentEntry>fNumEntries){
00082         cout<<"LoadPulses: Error: input file contains no more entries so I'm stopping the run"<<endl;
00083         return 1;
00084     }
00085 
00086     fInTree->GetEntry(fCurrentEntry);
00087     int n_entries=0;
00088     SourceAnalPulseMap::iterator i_output;
00089     AnalysedPulseList* pulseList;
00090     for(SourceToClonesArrayMap::iterator i_array=fArrays.begin();
00091             i_array!=fArrays.end(); ++i_array){
00092         // Get the pulse list to put the TAPs into
00093         i_output=gAnalysedPulseMap.find(i_array->first);
00094         if(i_output==gAnalysedPulseMap.end()){
00095             cout<<"LoadPulses: Error: gAnalysedPulseMap doesn't contain a pulse list for "<<i_array->first<<endl;
00096             return 1;
00097         }
00098         pulseList=&i_output->second;
00099 
00100         // Loop over each TAP on file and put it into gAnalysedPulseMap;
00101         n_entries=i_array->second->GetEntries();
00102         TAnalysedPulse* pulse;
00103         for(int i_pulse=0;i_pulse<n_entries;++i_pulse){
00104             pulse=(TAnalysedPulse*)(i_array->second->At(i_pulse));
00105             pulseList->push_back(pulse);
00106         }
00107     }
00108 
00109     //for (SourceAnalPulseMap::const_iterator i_source = gAnalysedPulseMap.begin();
00110     //        i_source != gAnalysedPulseMap.end(); ++i_source) {
00111     //    cout<<i_source->second.size()<<" pulses for source: "<<i_source->first<<"  "<<endl;
00112     //}
00113     ++fCurrentEntry;
00114   return 0;
00115 }

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 63 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

Definition at line 65 of file LoadPulses.h.

Referenced by BeforeFirstEntry().

Long64_t LoadPulses::fCurrentEntry [private]

Definition at line 60 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

std::string LoadPulses::fFileName [private]

Definition at line 57 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and LoadPulses().

TTree* LoadPulses::fInTree [private]

Definition at line 59 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

Long64_t LoadPulses::fNumEntries [private]

Definition at line 61 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and ProcessEntry().

std::string LoadPulses::fTreeName [private]

Definition at line 58 of file LoadPulses.h.

Referenced by BeforeFirstEntry(), and LoadPulses().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1