WORK IN PROGRESS !!! For the moment have a look at the tutorial package highland2/tutorialAnalysis
Here we explain step by step the tutorialAnalysis package, which can be used to understand most elements of the framework.
This example contains two analyses algorithms, one, called tutorialAnalysis.
Each analysis algorithm inherits ultimately from the class AnalysisAlgorithm, which has many methods, somo of them mandatory.
Creating the analysis package
To create your own analysis the first thing you should do is to create a cmt package. After going into the folder where highland2 and psyche leave just type
This will create a folder tutorialAnalysis inside highland2 with a subfolder v0r0. Inside two folders will appear cmt and src. The file with instructions on how to compile and link your code is the requirements file, under the cmt folder. This file is basically empty. We should fill it with the appropriate instructions. You can have a look at the requirements file under tutorialAnalysis
package highland2/tutorialAnalysis
version v2r10
manager Anselmo Cervera <anselmo.cervera@cern.ch>
author nd280-software@mailman.t2k.org
branches cmt src doc app 
#indicate the packages that are use by this one
use nueCCAnalysis * highland2
# Build methods to include.
document doxygen doxygen -group=documentation src/*.cpp src/*.h src/*.hxx src/*.cxx ../doc/*.dox
# Build information used by packages that use this one.
macro tutorialAnalysis_cppflags " -DTUTORIALANALYSIS_USED"
macro tutorialAnalysis_linkopts " -L$(TUTORIALANALYSISROOT)/$(tutorialAnalysis_tag) -ltutorialAnalysis "
macro tutorialAnalysis_stamps " $(TUTORIALANALYSISROOT)/$(tutorialAnalysis_tag)/tutorialAnalysis.stamp"
# The paths to find this library.
path_remove PATH "$(TUTORIALANALYSISROOT)"
path_prepend PATH "$(TUTORIALANALYSISROOT)/$(tutorialAnalysis_tag)"
path_remove LD_LIBRARY_PATH "$(TUTORIALANALYSISROOT)"
path_prepend LD_LIBRARY_PATH "$(TUTORIALANALYSISROOT)/$(tutorialAnalysis_tag)"
path_remove DYLD_LIBRARY_PATH "" \
            Darwin            "$(TUTORIALANALYSISROOT)"
path_prepend DYLD_LIBRARY_PATH "" \
             Darwin            "$(TUTORIALANALYSISROOT)/$(tutorialAnalysis_tag)"
# The library to build
library tutorialAnalysis *.cxx  ../dict/*.cxx
# The executables to build (.exe files)
application RunTutorialAnalysis ../app/RunTutorialAnalysis*.cxx
application RunUseTutorialAnalysis ../app/RunUseTutorialAnalysis*.cxx
# tests
document doxygen doxygen -group=documentation ../scripts/* ../doc/*.dox
Once we have the proper requirements file to compile we go inside the cmt directory and do:
Notice that cmt config has to be used only the first time, to create the Makefile file. At this point nothing will be compiled because there are no source code files under the src folder.
Start filling the algorithm
The first files we should put there are tutorialAnalysis.hxx and tutorialAnalysis.cxx, which should contain the declaration and definition of the class tutorialAnalysis and its methods. This class should inherit from AnalysisAlgorithm or from another analysis algorithm (inheriting ultimately from AnalysisAlgorithm
AnalysisAlgorithm has some pure virtual methods (=0) that must be implemented in the derived analysis.
  virtual bool Initialize() = 0;
  virtual void DefineProductions() = 0;
  virtual void DefineInputConverters() = 0;
  virtual void DefineSelections() = 0;
  virtual void DefineCorrections() = 0;
  virtual void DefineSystematics() = 0;
  virtual void DefineConfigurations() = 0;
  virtual void DefineMicroTrees(bool addBase=true) = 0;
  virtual void DefineTruthTree() = 0;
  virtual void FillMicroTrees(bool addBase=true) = 0;
  virtual void FillToyVarsInMicroTrees(bool addBase=true) = 0;
  virtual void FillTruthTree() = 0;
 But don't worry, as we will see below, most of them are already implemented in the baseAnalysis class.
Other methods are optional and allow fintunning of the analysis or complicated cases
  virtual void Finalize(){}
  virtual bool InitializeSpill(){return true;}
  virtual void FinalizeSpill(){}
  virtual void InitializeBunch(){}
  virtual void FinalizeBunch(){}
  virtual void InitializeConfiguration(){}
  virtual bool FinalizeConfiguration(){return true;}
  virtual void InitializeToy(){}
  virtual void FinalizeToy(){}
  
  virtual void FillConfigTree(){}
From the list of
Including an event selection
baseAnalysis does not define any selection. Selections should be added to the selection manager in the method DefineSelections:
  
  
  
  
  
  if (!ND::params().GetParameterI("tutorialAnalysis.Selections.RunSelectionWithoutBranches"))
  if (!ND::params().GetParameterI("tutorialAnalysis.Selections.RunSelectionWithBranches"))
}
We can now compile and run the executable, provided input and output files:
../$TUTORIALANALYSISCONFIG/RunTutorialAnalysis.exe -o output.root input.root
The output file contains few root trees:
| tree  | description   | 
| default  | nominal selection  | 
| truth  | all true signal events  | 
| header  | POT information  | 
| config  | configuration of the analysis  | 
The default tree will not contain much information. Only the variables added automatically:
- categories for color code drawing
 
- cut information: accum_level, cut0, cut1, ...
 
Add variables to the micro-tree
The next step is to add variables to the micro-tree such that we can understand the selection. This is done in the DefineMicroTrees method.
  
  
  
  if (addBase) baseTrackerAnalysis::DefineMicroTrees(addBase);
  
  AddVarD(  output(), selmu_costheta,   "muon candidate reconstructed cos(theta) w.r.t. to neutrino direction");     
  AddVarF(  output(), selmu_truemom,    "muon candidate true momentum");           
  AddVarI(  output(), selmu_detectors,  "muon candidate detectors");               
  AddVarC(  output(), selmu_sense,      "muon candidate sense");                   
  AddVarF(  output(), selmu_deltaPhi,   "angle between muon candidate and the proton candidate (HMP track)");             
  AddVarF(  output(), selmu_pT,         "muon candidate reconstructed transverse momentum w.r.t to neutrino direction");  
  AddVarI(  output(), nLongTPCTracks,   "number of long TPC tracks");               
  
  
  AddVarVI(output(), selmu_tpc_det,         "muon candidate TPC number",                               selmu_ntpcs);
  AddVarVI(output(), selmu_tpc_nnodes,      "muon candidate #nodes in each TPC",                       selmu_ntpcs);  
  AddVarVF(output(), selmu_tpc_mom,         "muon candidate reconstructed momentum in each TPC",       selmu_ntpcs);  
  AddVarVD(output(), selmu_tpc_truemom,     "muon candidate true momentum in each TPC",                selmu_ntpcs);  
  
  AddVar4VF(output(), selmu_pos,    "muon candidate reconstructed position");     
  AddVar3VF(output(), selmu_dir,    "muon candidate reconstructed direction");    
  
  
  
  AddVar4MF(output(), selmu_tpc_pos,    "muon candidate true position in each tpc",  selmu_ntpcs);         
  AddVar3MF(output(), selmu_tpc_dir,    "muon candidate true direction in each tpc", selmu_ntpcs);         
  
  
  
  
  
  AddToyVarF(output(), selmu_mom,      "muon candidate reconstructed momentum");
  
  AddToyVarVF(output(), selmu_tpc_dedx,    "muon candidate dEdx (CT) in each TPC", NMAXTPCS);
}
  
Adding systematics
Adding configurations
  
  
  Int_t ntoys = ND::params().
GetParameterI(
"baseAnalysis.Systematics.NumberOfToys");
  Int_t randomSeed = ND::params().
GetParameterI(
"baseAnalysis.Systematics.RandomSeed");
  
  
  
  
  
  
  
  AddConfiguration(conf(), tutorial_syst, ntoys, randomSeed, 
new baseToyMaker(randomSeed));
  
  if (!ND::params().GetParameterI("tutorialAnalysis.Systematics.EnableTutorialSystematics"))
    conf().DisableConfiguration(tutorial_syst);
}
Computing efficiencies: the truth tree
The main trees in the output file are the "default" and "truth" trees. The "default" tree contains all selected events (the ones that passed a given cut, ussualy specified in the parameters file). This is the tree used to optimise the selection cuts, to make selection plots and to compute or plot the purity of the selection. The main reason for having a separate tree, call "truth", is to allow the efficiency computation. The "default" tree does not contain all true signal events, because it will be too big. The preselection for that tree is only based in reconstructed quantities (selection cuts). Instead, to compute true signal efficiencies we need all true signal events to be present in the output tree. The "truth" tree fullfils this condition. Since, in general, this tree will contain many events, only a reduced set of variables (the ones needed to compute the efficiency) is stored in that tree.SUMMARY: The "truth" tree also appears in the output file. It contains all interactions in which we are interested in regardless on whether the selection was passed or not. This is the tree that should be used to compute signal efficiencies  
  
hello
  
    The main trees in the output file are the "default" and "truth" trees. The "default" tree contains all selected events (the ones that passed a given cut, ussualy 
    specified in the parameters file). This is the tree used to optimise the selection cuts, to make selection plots and to compute or plot the purity of the selection. 
    The main reason for having a separate tree, call "truth", is to allow the efficiency computation. The "default" tree does not contain all true signal events, 
    because it will be too big. The preselection for that tree is only based in reconstructed quantities (selection cuts). Instead, to compute true signal efficiencies 
    we need all true signal events to be present in the output tree. The "truth" tree fullfils this condition. Since, in general, this tree will contain many events, only a 
    reduced set of variables (the ones needed to compute the efficiency) is stored in that tree. 
    
    SUMMARY: The "truth" tree also appears in the output file. It contains all interactions in which we are interested in regardless on whether 
    the selection was passed or not. This is the tree that should be used to compute signal efficiencies
  
  baseTrackerAnalysis::DefineTruthTree();
  
  AddVarI(  output(), truelepton_pdg,      "true lepton PDG");
  AddVar4VF(output(), truelepton_pos,      "true lepton position");
  
  
  
  
}
 WORK IN PROGRESS !!! For the moment have a look at the tutorial package highland2/tutorialAnalysis