Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AnalysisModule.cxx

Go to the documentation of this file.
00001 
00002 //$Id: AnalysisModule.cxx,v 1.2 2006/02/25 00:47:10 gmieg Exp $
00003 //
00004 //AnalysisModule.cxx
00005 //
00006 // A template module used for doing analysis with the AnalysisNtuples package
00007 //
00008 //B. Rebel 2/2005
00010 
00011 #include "AnalysisNtuples/Module/AnalysisModule.h"
00012 
00013 #include "MessageService/MsgService.h"
00014 #include "MinosObjectMap/MomNavigator.h"
00015 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00016 #include "JobControl/JobCommand.h"
00017 
00018 #include "TFolder.h"
00019 #include "TDirectory.h"
00020 #include "TObjArray.h"
00021 #include "TCanvas.h"
00022 #include "TPad.h"
00023 #include "TArc.h"
00024 
00025 #include <cassert>
00026 #include <algorithm>
00027 
00028 ClassImp(AnalysisModule)
00029 
00030 CVSID("$Id: AnalysisModule.cxx,v 1.2 2006/02/25 00:47:10 gmieg Exp $");
00031 
00032 // Declare this module to JobControll. Arguments are:
00033 //  (1) The class name 
00034 //  (2) The human-readable name 
00035 //  (3) A short, human-readable description of what the module does
00036 JOBMODULE(AnalysisModule, 
00037           "AnalysisModule",
00038           "A template module used for analyzing data");
00039 
00040 //......................................................................
00041 AnalysisModule::AnalysisModule() :
00042     fFileName("beamTestResults.root"),
00043     fTreeName("ANtp"),
00044     fDataPath("data/*.root")
00045 {
00046     MSG("JobC", Msg::kDebug) << "AnalysisModule::Constructor" << endl;
00047         
00048     //make histograms for raw distributions
00049 
00050         
00051     //histograms for cut distributions
00052         
00053     //the info objects
00054     fHeaderInfo = new ANtpHeaderInfo();
00055     fEventInfo = new ANtpEventInfo();
00056     fShowerInfo = new ANtpShowerInfo();
00057     fTrackInfo = new ANtpTrackInfo();
00058     
00059 }
00060 
00061 //----------------------------------------------------------------------
00062 AnalysisModule::~AnalysisModule()
00063 {
00064 
00065   MSG("JobC", Msg::kDebug) << "AnalysisModule::Destructor" << endl;
00066 
00067 }
00068 
00069 //......................................................................
00070 void AnalysisModule::BeginJob()
00071 {
00072     MSG("AnalysisModule", Msg::kDebug) << "start BeginJob" << endl;
00073 
00074     
00075     return;
00076 }
00077 
00078 //......................................................................
00079 //here is where you would loop over the events in the snarl to fill the 
00080 //analysis tree
00081 JobCResult AnalysisModule::Ana(const MomNavigator *mom)
00082 {
00083     MSG("AnalysisModule", Msg::kDebug) << "start ana" << endl;
00084     
00085     JobCResult result(JobCResult::kPassed);
00086     
00087     //get the records from MOM
00088     assert(mom);
00089         
00090     return result;
00091 }
00092 
00093 //......................................................................
00094 void AnalysisModule::Help() 
00095 {
00096   MSG("JobC", Msg::kInfo) 
00097     << "AnalysisModule::Help\n"
00098     <<"AnalysisModule is a module which analyzes beam data."
00099     << endl;
00100 }
00101 
00102 //----------------------------------------------------------------------
00103 void AnalysisModule::EndJob() 
00104 {
00105 
00106     MSG("AnalysisModule", Msg::kInfo) << "start end job method" << endl;        
00107     
00108     //create a chain for the analysis ntuples with name in fTreeName
00109     fChain = new TChain(fTreeName.c_str());
00110     
00111     MSG("AnalysisModule", Msg::kInfo) << "path = " << fDataPath << endl;
00112     
00113     //add the files to the chain
00114     fChain->Add(fDataPath.c_str());
00115     
00116     //attach the info objects to the chains
00117     fChain->SetBranchAddress("header.", &fHeaderInfo);
00118     fChain->SetBranchAddress("event.", &fEventInfo);
00119     fChain->SetBranchAddress("shower.", &fShowerInfo);
00120     fChain->SetBranchAddress("track.", &fTrackInfo);
00121     fChain->SetBranchAddress("truth.", &fTruthInfo);
00122 
00123     //do your analysis here.  probably best to write methods to do individual bits 
00124     //of analysis like declaring and filling histograms, drawing histograms, 
00125     //checking if the event vertex is in the fiducial volume, etc
00126     
00127     return;
00128 }
00129 
00130 //......................................................................
00131 const Registry& AnalysisModule::DefaultConfig() const
00132 {
00133     
00134     int itrue = 1;  // work around for lack of bool in registry
00135     int ifalse = 0; // work around for lack of bool in registry
00136     
00137     static Registry r;
00138     
00139     r.UnLockValues();
00140     
00141     r.Set("FileName",               "analysisResults.root");
00142     r.Set("TreeName",               "ANtp");
00143     r.Set("DataPath",               "data/*.root");
00144     
00145     r.LockValues();
00146 
00147     itrue = ifalse;
00148 
00149     return r;
00150 }
00151 
00152 //......................................................................
00153 void AnalysisModule::Config(const Registry& r)
00154 {
00155     int         tmpb;  // a temp bool. See comment under DefaultConfig...
00156     int         tmpi;  // a temp int.
00157     double      tmpd;  // a temp double.
00158     const char* tmps;  // a temp string
00159 
00160     if (r.Get("FileName",               tmps)) fFileName               = tmps;
00161     if (r.Get("TreeName",               tmps)) fTreeName               = tmps;
00162     if (r.Get("DataPath",               tmps)) fDataPath               = tmps;
00163 
00164     tmpb = 0;
00165     tmpi = 0;
00166     tmpd = 0.;
00167 
00168     return;
00169 }

Generated on Mon Feb 15 11:06:21 2010 for loon by  doxygen 1.3.9.1