HighLAND
Public Types | Public Member Functions | List of all members
tutorialAnalysis Class Reference

Inherit from baseTrackerAnalysis, which inherit from basAnslysis, which inherits from AnalysisAlgorithm (in highlandCore) More...

#include <tutorialAnalysis.hxx>

Inheritance diagram for tutorialAnalysis:
baseTrackerAnalysis baseAnalysis AnalysisAlgorithm

Public Types

enum  enumStandardMicroTrees_tutorialAnalysis {
  nLongTPCTracks = nueCCAnalysis::enumStandardMicroTreesLast_nueCCAnalysis+1, selmu_truemom, selmu_detectors, selmu_sense,
  selmu_costheta, selmu_deltaPhi, selmu_pT, selmu_dir,
  selmu_pos, selmu_ntpcs, selmu_tpc_det, selmu_tpc_nnodes,
  selmu_tpc_mom, selmu_tpc_pos, selmu_tpc_dir, selmu_tpc_truemom,
  selmu_mom, selmu_tpc_dedx, truelepton_pdg, truelepton_mom,
  truelepton_pos, truelepton_dir, truelepton_costheta, enumStandardMicroTreesLast_tutorialAnalysis
}
 
enum  enumSyst_tutorialAnalysis { kTutorialWeight = SystId::SystEnumLast_SystId+1, kTutorialVariation, enumSystLast_tutorialAnalysis }
 
enum  enumConf_tutorialAnalysis { tutorial_syst =enumConfLast_baseTrackerAnalysis+1, enumConfLast_btutorialAnalysis }
 
enum  enumConfigTree_tutorialAnalysis { nNucleonsFGD1 = enumConfigTreeLast_AnalysisAlgorithm+1, nNucleonsFGD2scint, nNucleonsFGD2water, enumConfigTreeLast_tutorialAnalysis }
 
- Public Types inherited from baseTrackerAnalysis
enum  enumStandardMicroTrees_baseTrackerAnalysis {
  ntpctracks = enumStandardMicroTreesLast_baseAnalysis+1, ntpcposQualityFV, ntpcnegQualityFV, nfgdtracks,
  nfgdonlytracks, chargeid_ncorrect, chargeid_nwrong, tpcfgdmatch_ncorrect,
  tpcfgdmatch_nwrong, tpctr_ncorrect, tpctr_nwrong, fgdtr_ncorrect,
  fgdtr_nwrong, fgdhybtr_ncorrect, fgdhybtr_nwrong, meeff_ncorrect,
  meeff_nwrong, mepur_ncorrect, mepur_nwrong, tpc_ecal_match_ncorrect,
  tpc_ecal_match_nwrong, tpc_p0d_match_ncorrect, tpc_p0d_match_nwrong, fgd_ecal_match_ncorrect,
  fgd_ecal_match_nwrong, fgd_ecal_smrd_match_ncorrect, fgd_ecal_smrd_match_nwrong, ecal_pid_ncorrect,
  ecal_pid_nwrong, ecal_tr_ncorrect, ecal_tr_nwrong, ecal_emhippid_ncorrect,
  ecal_emhippid_nwrong, fgd2shower_ncorrect, fgd2shower_nwrong, enumStandardMicroTreesLast_baseTrackerAnalysis
}
 
enum  enumConf_baseTrackerAnalysis {
  bfield_syst =baseAnalysis::enumConfLast_baseAnalysis+1, momscale_syst, momresol_syst, momrange_resol_syst,
  tpcpid_syst, fgdpid_syst, chargeideff_syst, tpctrackeff_syst,
  fgdtrackeff_syst, fgdhybridtrackeff_syst, tpcfgdmatcheff_syst, tpcclustereff_syst,
  michel_syst, oofv_syst, pileup_syst, fgdmass_syst,
  sandmu_syst, ecal_emresol_syst, ecal_emscale_syst, tpc_ecal_matcheff_syst,
  tpc_p0d_matcheff_syst, fgd_ecal_matcheff_syst, fgd_ecal_smrd_matcheff_syst, ecal_trackeff_syst,
  ecal_pid_syst, tof_resol_syst, ecal_emhippid_syst, fgd2shower_syst,
  nuetpcpileup_syst, nuep0dpileup_syst, nueecalpileup_syst, nueoofv_syst,
  p0d_elossscale_syst, p0d_elossresol_syst, p0d_veto_syst, enumConfLast_baseTrackerAnalysis
}
 
- Public Types inherited from baseAnalysis
enum  enumStandardMicroTrees_baseAnalysis {
  run = enumStandardMicroTreesLast_AnalysisAlgorithm+1, subrun, evt, evt_time,
  bunch, NWEIGHTS, weight, TruthVertexID,
  TruthVertexNB, RooVtxIndex, RooVtxEntry, RooVtxEntry2,
  RooVtxFile, nu_pdg, nu_trueE, nu_truereac,
  nu_truedir, truelepton_mom, truelepton_costheta, truelepton_dir,
  truevtx_pos, selvtx_det, selvtx_pos, selvtx_truepos,
  true_signal, weight_syst_total_noflux, enumStandardMicroTreesLast_baseAnalysis
}
 
enum  enumConf_baseAnalysis {
  sipion_syst =ConfigurationManager::enumConfLast_ConfigurationManager+1, siproton_syst, nuflux_syst, antinuflux_syst,
  all_syst, zero_var, enumConfLast_baseAnalysis
}
 
- Public Types inherited from AnalysisAlgorithm
enum  enumAnalysisPoint {
  kInitialize =0, kDefineProductions, kDefineInputConverters, kDefineSelections,
  kDefineCorrections, kDefineSystematics, kDefineConfigurations, kDefineMicroTrees,
  kDefineTruthTree, kFillConfigTree, kInitializeSpill, kInitializeBunch,
  kInitializeConfiguration, kInitializeToy, kInitializeSelection, kFinalizeSelection,
  kFinalizeToy, kFillToyVarsInMicroTrees, kFinalizeConfiguration, kFillCategories,
  kFillMicroTrees, kFinalizeBunch, kFillTruthTree, kFinalizeSpill,
  kFinalize
}
 
enum  enumStandardMicroTrees_AnalysisAlgorithm {
  firstCategory = OutputManager::enumStandardMicroTreesLast_OutputManager+1, firstCategoryCounter = firstCategory+NMAXCATEG, entry = firstCategoryCounter + NMAXCATEGCOUNTERS, toy_ref,
  toy_index, toy_par_weight, toy_par_var, NWEIGHTSYST,
  weight_syst, weight_syst_total, weight_corr, weight_corr_total,
  redo, accum_level, first_cut, last_cut =first_cut+NMAXSTEPS,
  enumStandardMicroTreesLast_AnalysisAlgorithm
}
 
enum  enumConfigTree_AnalysisAlgorithm {
  SoftwareVersion =0, HOSTNAME, CMTPATH, INPUTFILE,
  OriginalFile, MinAccumLevelToSave, enumConfigTreeLast_AnalysisAlgorithm
}
 

Public Member Functions

 tutorialAnalysis (AnalysisAlgorithm *ana=NULL)
 
bool Initialize ()
 [AnalysisAlgorithm_mandatory]
 
void DefineSelections ()
 Add to the selection manager the selections for this analysis. More...
 
void DefineCorrections ()
 [tutorialAnalysis_DefineSelections] More...
 
void DefineSystematics ()
 [tutorialAnalysis_DefineCorrections] More...
 
void DefineConfigurations ()
 [tutorialAnalysis_DefineSystematics] More...
 
void DefineMicroTrees (bool addBase=true)
 [tutorialAnalysis_DefineConfigurations] More...
 
void DefineTruthTree ()
 [tutorialAnalysis_DefineMicroTrees] More...
 
void FillMicroTrees (bool addBase=true)
 [tutorialAnalysis_DefineTruthTree] More...
 
void FillToyVarsInMicroTrees (bool addBase=true)
 [tutorialAnalysis_FillMicroTrees] More...
 
bool CheckFillTruthTree (const AnaTrueVertex &vtx)
 [tutorialAnalysis_FillToyVarsInMicroTrees]
 
void FillTruthTree (const AnaTrueVertex &vtx)
 
void FillConfigTree ()
 
void FillCategories ()
 
- Public Member Functions inherited from baseTrackerAnalysis
 baseTrackerAnalysis (AnalysisAlgorithm *ana=NULL)
 
virtual void FillTruthTreeBase (const AnaTrueVertex &vtx, const SubDetId::SubDetEnum det=SubDetId::kFGD1, bool IsAntinu=false)
 
virtual const ToyBoxTrackerbox (Int_t isel=-1) const
 Returns the ToyBoxTracker.
 
virtual AnaVertexBGetVertex () const
 Returns the vertex for the ToyBoxTracker.
 
virtual AnaTrueVertexBGetTrueVertex () const
 Returns the true vertex for the ToyBoxTracker.
 
- Public Member Functions inherited from baseAnalysis
 baseAnalysis (AnalysisAlgorithm *ana=NULL)
 
virtual bool InitializeSpill ()
 
virtual bool FinalizeConfiguration ()
 
virtual void DefineProductions ()
 
virtual void DefineInputConverters ()
 
void FillMicroTreesBase (bool addBase=true)
 
void FillToyVarsInMicroTreesBase (bool addBase=true)
 
void FillTruthTree ()
 
void FillTruthTreeBase (const AnaTrueVertex &vtx, const SubDetId::SubDetEnum det=SubDetId::kFGD1, bool IsAntinu=false)
 
AnaSpillGetSpill ()
 Get a casted AnaSpillC to AnaSpill from the InputManager.
 
AnaBunchGetBunch ()
 Get a casted AnaBunchBB to AnaBunch from the InputManager (TODO the protection)
 
AnaEventGetEvent ()
 Get a casted AnaEventC to AnaEvent.
 
virtual AnaEventCMakeEvent ()
 Create the appropriate event time from an Spill and a Bunch in that spill.
 
void SetSaveRooTracker (bool save)
 Set whether to save the RooTrackerVtx tree or not.
 
void SetRooVtxManager (RooTrackerVtxManager *man)
 Set the RooTrackerVtxManager.
 
- Public Member Functions inherited from AnalysisAlgorithm
 AnalysisAlgorithm (AnalysisAlgorithm *ana=NULL)
 
virtual void Finalize ()
 [AnalysisAlgorithm_optional]
 
virtual void FinalizeSpill ()
 
virtual void InitializeBunch ()
 
virtual void FinalizeBunch ()
 
virtual void InitializeConfiguration ()
 
virtual void InitializeToy ()
 
virtual void FinalizeToy ()
 
virtual void InitializeSelection (const SelectionBase &)
 
virtual void FinalizeSelection (const SelectionBase &)
 
void FinalizeToyBase ()
 [AnalysisAlgorithm_mandatory] More...
 
void SetFillSuccessOnly (bool fill)
 Fill trees and process weight systematics only when any of the branches is successful.
 
bool GetFillSuccessOnly ()
 
void SetInitializeTrees (bool ini)
 Initialize trees at the beginning of each configuration.
 
bool GetInitializeTrees ()
 
void SetMinAccumCutLevelToSave (Int_t level)
 Set the minimum accumulated cut level to save an event into the micro-tree.
 
Int_t GetMinAccumCutLevelToSave ()
 Get the minimum accumulated cut level to save an event into the micro-tree.
 
bool CheckAccumLevelToSave ()
 Check if the condition is fulfilled for at least one branch.
 
void SetEvent (AnaEventC *event)
 Set the current event into the algorithm and all used algorithms.
 
void SetToyBox (const ToyBoxB *box, Int_t isel=0)
 Set the current box into the algorithm and all used algorithms. This is useful when one Analysis uses another.
 
void UseAnalysis (AnalysisAlgorithm *ana)
 Used a given analysis.
 
void SetSelectedSelection (Int_t sel)
 Select one of the selections.
 
void SetVersionCheck (bool check)
 Set version checking.
 
void SetAnalysisPoint (enumAnalysisPoint point)
 Set the point of the analysis at which AnalysisLoop is.
 
HighlandInputManagerinput ()
 
SelectionManagersel ()
 
CorrectionManagercorr ()
 
SystematicManagersyst ()
 
EventWeightManagereweight ()
 
EventVariationManagerevar ()
 
OutputManageroutput ()
 
ConfigurationManagerconf ()
 
CategoryManagercat ()
 
DocStringManagerdoc ()
 
virtual const ToyBoxBboxB (Int_t isel=-1) const
 

Additional Inherited Members

- Protected Member Functions inherited from baseAnalysis
void AddZeroVarConfiguration ()
 
- Protected Attributes inherited from baseTrackerAnalysis
bool _computeEfficiency
 Compute analysis sample efficiency.
 
ChargeIDEffSystematics_chargeid
 
TPCFGDMatchEffSystematics_tpcfgdmatch
 
TPCTrackEffSystematics_tpctr
 
FGDTrackEffSystematics_fgdtr
 
FGDHybridTrackEffSystematics_fgdhybtr
 
MichelElectronEffSystematics_me
 
TPCECalMatchEffSystematics_tpc_ecal_matcheff
 
TPCP0DMatchEffSystematics_tpc_p0d_matcheff
 
FGDECalMatchEffSystematics_fgd_ecal_matcheff
 
FGDECalSMRDMatchEffSystematics_fgd_ecal_smrd_matcheff
 
ECalTrackEffSystematics_ecal_trackeff
 
ECalPIDSystematics_ecal_pid
 
ECalEmHipPIDSystematics_ecal_emhippid
 
FGD2ShowerSystematics_fgd2shower
 
- Protected Attributes inherited from baseAnalysis
RooTrackerVtxManager_rooVtxManager
 the manager of the RooTrackerVtx
 
bool _saveRooTrackerVtxTree
 Save RooTracker tree in output file.
 
FluxWeighting_flux
 Access to the flux weighting.
 
bool _applyFluxWeight
 Flag to enable/disable flux weight.
 
std::string _fluxFile
 Flux file and option.
 
std::string _fluxTuning
 
bool _enableSingleVariationSystConf
 
bool _enableSingleWeightSystConf
 
bool _enableAllSystConfig
 
bool _enableZeroVarConfig
 
Int_t _ntoys
 
Int_t _randomSeed
 
- Protected Attributes inherited from AnalysisAlgorithm
HighlandInputManager_inputManager
 Input Manager: access to the current Event.
 
CorrectionManager_corrManager
 Correction Manager.
 
SystematicManager_systManager
 Systematics Manager.
 
EventWeightManager_weightManager
 EventWeight Manager.
 
EventVariationManager_variationManager
 EventVariation Manager.
 
OutputManager_outputManager
 Output Manager.
 
ConfigurationManager_confManager
 Configuration Manager.
 
SelectionManager_selManager
 
CategoryManager_categManager
 
DocStringManager_docManager
 
const ToyBoxB_box [NMAXSELECTIONS]
 The analysis box.
 
Int_t _min_accum_cut_level
 the minimum accumulated cut level to save an event into the micro-tree
 
bool _fillSuccessOnly
 Fill trees and process weight systematics only when any of the branches is succesful.
 
bool _initializeTrees
 Initialize trees at the beginning of each configuration.
 
AnaEventC_event
 The current event.
 
std::vector< AnalysisAlgorithm * > _usedAnalyses
 The Vector of used analysis.
 
Int_t _selectedSelection
 The selected selection.
 
bool _setMethodCalled
 Boolean parameter to know whether nny of the methods that sets things into used analysis has been called.
 
bool _versionCheck
 
enumAnalysisPoint _analysisPoint
 

Detailed Description

Inherit from baseTrackerAnalysis, which inherit from basAnslysis, which inherits from AnalysisAlgorithm (in highlandCore)

Definition at line 9 of file tutorialAnalysis.hxx.

Member Function Documentation

§ DefineConfigurations()

void tutorialAnalysis::DefineConfigurations ( )
virtual

[tutorialAnalysis_DefineSystematics]

[tutorialAnalysis_DefineConfigurations]

Reimplemented from baseTrackerAnalysis.

Definition at line 230 of file tutorialAnalysis.cxx.

230  {
231 //********************************************************************
232 
233  /*
234  The user can run several analyses in parallel minimising the acces to disk.
235  Those parallel analyses are call configurations. Although this might be extended in the future, currenly
236  configurations only allow you to specify which systematics errors will be propagated, the number of toy experiments
237  and the random seed.
238 
239  A tree for each configuration is produced in the output file, with the same name as the configuration.
240  By default a single configuration (called "default") is run, producing
241  a single tree (with name default). This tree does not have any systematics enabled and hence it represents the nominal selection.
242  */
243 
244  // Some configurations are defined in baseTrackerAnalysis (have a look at baseTrackerAnalysis/vXrY/src/baseTrackerAnalysis.cxx)
246 
247  Int_t ntoys = ND::params().GetParameterI("baseAnalysis.Systematics.NumberOfToys");
248  Int_t randomSeed = ND::params().GetParameterI("baseAnalysis.Systematics.RandomSeed");
249 
250  // Add a new configuration called "tutorial_syst" with the following properties:
251  // - the number of toys defined in the baseAnalysis parameters file
252  // - the random seed for toy experiments defined in the baseAnalysis parameters file
253  // - The ToyMaker used to CreateTheToyExperiments (random throws for each systematic parameter).
254  // Have a look at baseToyMaker in baseAnalysis/vXrY/src
255  // - This configuration has two systematics kTutorialWeight and kTutorialVariation, defined above
256 
257  AddConfiguration(conf(), tutorial_syst, ntoys, randomSeed, new baseToyMaker(randomSeed));
258  conf().EnableSystematic(kTutorialWeight, tutorial_syst); // Enable the kTutorialWeight in the tutorial_syst configuration
259  conf().EnableSystematic(kTutorialVariation, tutorial_syst); // Enable the kTutorialVariation in the tutorial_syst configuration
260 
261  // Disable the configuration when requested
262  if (!ND::params().GetParameterI("tutorialAnalysis.Systematics.EnableTutorialSystematics"))
263  conf().DisableConfiguration(tutorial_syst);
264 }
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
Creates ToyExperiments.
void EnableSystematic(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
virtual void DefineConfigurations()

§ DefineCorrections()

void tutorialAnalysis::DefineCorrections ( )
virtual

[tutorialAnalysis_DefineSelections]

[tutorialAnalysis_DefineCorrections]

Reimplemented from baseTrackerAnalysis.

Definition at line 164 of file tutorialAnalysis.cxx.

164  {
165 //********************************************************************
166 
167  /* Corrections change the input data to rectify a problem in the MC or in the real data. Imagine for example that the energy deposited by a particle
168  in a given sub-detector is overestimated in the MC by about 5%, and that this effect depends on the particle type (6% for muons and 4% for electrons).
169  We could introduce a correction for the MC, which would scale the deposited energy by 0.94 for true muons and by 0.96 for true electrons. In this way
170  we make sure that any cut using the deposited energy will have the same effect in data and MC, avoiding the corresponding systematic.
171 
172  The entire analysis will proceed on the modified data
173  Corrections are only applied once per spill.
174  */
175 
176  // Some corrections are defined in baseTrackerAnalysis (have a look at baseTrackerAnalysis/vXrY/src/baseTrackerAnalysis.cxx)
177  baseTrackerAnalysis::DefineCorrections();
178 
179  // ----- We can add here extra corrections ----------
180 
181  // A dummy correction which moves forward the position of all global tracks by some mm, as specified in
182  // an external data file (data/tutorialCorrection.dat)
183  corr().AddCorrection("tutorialCorrection", new tutorialCorrection());
184 }
void AddCorrection(Int_t index, const std::string &name, CorrectionBase *corr)

§ DefineMicroTrees()

void tutorialAnalysis::DefineMicroTrees ( bool  addBase = true)
virtual

[tutorialAnalysis_DefineConfigurations]

[tutorialAnalysis_DefineMicroTrees]

Reimplemented from baseTrackerAnalysis.

Definition at line 269 of file tutorialAnalysis.cxx.

269  {
270 //********************************************************************
271 
272  /* We call Micro-trees to the standard analysis trees appearing in the output file.
273  There is always a Micro-Tree call "default" which should contain the basic info to understand our selection.
274  The user can add extra Micro-Trees by adding configurations to the analysis (see DefineConfigurations method above).
275 
276  Here we give an example of different variables that can be added. Have a look at OutputManager.hxx under highlandCore
277  to see all available methods.
278  */
279 
280  // -------- Add variables to the analysis tree ----------------------
281 
282  // Variables from baseTrackerAnalysis (run, event, ..., tracker related stuff, ...)
283  if (addBase) baseTrackerAnalysis::DefineMicroTrees(addBase);
284 
285  // --- Single variables -------
286  AddVarD( output(), selmu_costheta, "muon candidate reconstructed cos(theta) w.r.t. to neutrino direction"); // Double
287  AddVarF( output(), selmu_truemom, "muon candidate true momentum"); // Float
288  AddVarI( output(), selmu_detectors, "muon candidate detectors"); // Integer
289  AddVarC( output(), selmu_sense, "muon candidate sense"); // Char
290 
291  AddVarF( output(), selmu_deltaPhi, "angle between muon candidate and the proton candidate (HMP track)"); // Float
292  AddVarF( output(), selmu_pT, "muon candidate reconstructed transverse momentum w.r.t to neutrino direction"); // Float
293 
294  AddVarI( output(), nLongTPCTracks, "number of long TPC tracks"); // Integer
295 
296  // --- Vector variables -------
297  // selmu_ntpcs is the counter, which is added automatically as integer variable
298  AddVarVI(output(), selmu_tpc_det, "muon candidate TPC number", selmu_ntpcs);
299  AddVarVI(output(), selmu_tpc_nnodes, "muon candidate #nodes in each TPC", selmu_ntpcs); // Vector of integers
300  AddVarVF(output(), selmu_tpc_mom, "muon candidate reconstructed momentum in each TPC", selmu_ntpcs); // Vector of floats
301  AddVarVD(output(), selmu_tpc_truemom, "muon candidate true momentum in each TPC", selmu_ntpcs); // Vector of doubles
302 
303  // --- 3D and 4D vector variables (i.e. directions and positions) -------
304  AddVar4VF(output(), selmu_pos, "muon candidate reconstructed position"); // 4-Vector of floats
305  AddVar3VF(output(), selmu_dir, "muon candidate reconstructed direction"); // 3-Vector of floats
306 
307  // --- Matrix variables -------
308  // AddVarMF(output(), selmu_tpc, "",selmu_necals,-30,4);
309 
310  // --- 3D and 4D matrix variables (i.e. directions and positions for constituents) -------
311  AddVar4MF(output(), selmu_tpc_pos, "muon candidate true position in each tpc", selmu_ntpcs);
312  AddVar3MF(output(), selmu_tpc_dir, "muon candidate true direction in each tpc", selmu_ntpcs);
313 
314 
315  // Now we had toy-dependent variables
316  // There could be many variables that are toy-dependent. We don't need to save all of them as toy variables,
317  // but only the ones we are interested in plotting for different toys.
318  // TOY VARIABLES ARE VERY SPACE CONSUMING SO WE SHOULD MINIMISE ITS NUMBER !!!!
319 
320  // --- single toy variables -------
321  AddToyVarF(output(), selmu_mom, "muon candidate reconstructed momentum");
322 
323  // --- vector toy variables -------
324  AddToyVarVF(output(), selmu_tpc_dedx, "muon candidate dEdx (CT) in each TPC", NMAXTPCS);
325 }

§ DefineSelections()

void tutorialAnalysis::DefineSelections ( )
virtual

Add to the selection manager the selections for this analysis.

[tutorialAnalysis_DefineSelections]

Implements AnalysisAlgorithm.

Definition at line 126 of file tutorialAnalysis.cxx.

126  {
127 //********************************************************************
128 
129  /* In this method the user will add to the SelectionManager (accessed by sel() ) the selections to be run,
130  defined in other files. In general an analysis has a single selection, which could have multiple branches.
131  Each of the branches is in fact a different selection (different cuts and actions), but defining them as branches
132  we ussualy gain in speed and simplicity since the steps that are common are applied only once.
133  Sometimes the user does not want to expend time merging two selections in a single one (as branches), but preffers to run
134  both independently. This is in general done for quick checks (are the selections mutually exclusive ?, etc).
135  This is possible in highland2. An example on how to do that is shown below.
136 
137  In this case we add two selections to the SelectionManager provided:
138  - Name of the selection (kTrackerTutorial, kTrackerTutorialBranches)
139  - Title, the one dumped by the DrawingTools::DumpSelections() method. It is an explaination of the selection
140  - Pointer to the selection. The argument in the constructor (false) indicates that the
141  step sequence is not broken when a cut is not passed. In this way we can save intermediate information for events
142  not passing the entire selection
143  */
144 
145 
146  // Add a simple selection with no branches
147  sel().AddSelection("kTrackerTutorial", "tutorial selection", new tutorialSelection(false));
148 
149  // Add a more complicated selection with branches
150  sel().AddSelection("kTrackerTutorialBranches", "tutorial selection with branches", new tutorialBranchesSelection(false));
151 
152  // Disable the ones not enabled in parameters file
153  if (!ND::params().GetParameterI("tutorialAnalysis.Selections.RunSelectionWithoutBranches"))
154  sel().DisableSelection("kTrackerTutorial");
155 
156  if (!ND::params().GetParameterI("tutorialAnalysis.Selections.RunSelectionWithBranches"))
157  sel().DisableSelection("kTrackerTutorialBranches");
158 
159 }
void AddSelection(const std::string &name, const std::string &title, SelectionBase *sel, Int_t presel=-1)
Add a user selection to the selection manager.
void DisableSelection(const std::string &sel)
Disable a selection.

§ DefineSystematics()

void tutorialAnalysis::DefineSystematics ( )
virtual

[tutorialAnalysis_DefineCorrections]

[tutorialAnalysis_DefineSystematics]

Reimplemented from baseTrackerAnalysis.

Definition at line 189 of file tutorialAnalysis.cxx.

189  {
190 //********************************************************************
191 
192  /* Systematics will modify the effective number of events passing the selection and the distribution of the observables.
193 
194  After corrections have been applied it is possible to
195  "manipulate" again the information using Systematics. In this case the purpose is different: we want to test several values of
196  a given detector property and check the impact on the number of selected events. This allows propagating systematic errors numerically.
197 
198  There are two kind of systematics:
199  - Variations: modify the input data (momentum, PID variables, etc). The selection is run on the modified data such that
200  the result of the selection can be different
201  - Weights: do not modify the input data. The selection is not affected. Simply a weight is added to the event.
202  Since events with different values of a given observable (i.e. momentum ) can have different weights,
203  distributions of that observable may change.
204 
205  In the above example about the deposited energy (in DefineCorrections(), the correction introduced cannot be perfectly known.
206  The 4% and 6% mentioned have an error (i.e. 0.5%).
207  This error should be propagated as a systematic. A given number of toy experiments will be run with different values of the scaling parameter
208  for the deposited energy (i.e. for muons 0.93, 0.935, 0.95, ..., following
209  a gaussian distribution with mean 0.94 and sigma 0.005). If a cut on the deposited energy (or a variable using it)
210  is applied the number of selected events could differ depending on the scaling applied.
211  The RMS of the number of selected events for all toy experiments represents the systematic error induced by the deposited energy scaling.
212  */
213 
214 
215  // Some systematics are defined in baseTrackerAnalysis (have a look at baseTrackerAnalysis/vXrY/src/baseTrackerAnalysis.cxx)
217 
218  // ----- We can add here extra systematics ----------
219 
220  // An example of variation systematic, which is added to the EventVariationManager
221  evar().AddEventVariation(kTutorialVariation, "TutorialVarSyst", new tutorialVariationSystematics());
222 
223  // A example of weight systematic, which is added to the EventWeightManager
224  eweight().AddEventWeight( kTutorialWeight, "TutorialWeightSyst", new tutorialWeightSystematics());
225 }
virtual void DefineSystematics()
void AddEventVariation(Int_t index, EventVariationBase *sys)
Add a new Event Variation provided its index in the manager and a pointer to it.
void AddEventWeight(Int_t index, EventWeightBase *sys)
Add a new Event Weight provided its index in the manager and a pointer to it.
This is a normalization systematic. It takes into account the uncertainty on the FGD mass introduced ...

§ DefineTruthTree()

void tutorialAnalysis::DefineTruthTree ( )
virtual

[tutorialAnalysis_DefineMicroTrees]

[tutorialAnalysis_DefineTruthTree]

[tutorialAnalysis_DefineTruthTree_info]

[tutorialAnalysis_DefineTruthTree_info]

Reimplemented from baseTrackerAnalysis.

Definition at line 334 of file tutorialAnalysis.cxx.

334  {
335 //********************************************************************
336 
337 
338 //! \if INTERNAL
339 
340 hello
341 //! \endif
342 
343 //! [tutorialAnalysis_DefineTruthTree_info]
344  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
345  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.
346  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,
347  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
348  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
349  reduced set of variables (the ones needed to compute the efficiency) is stored in that tree.
350 
351  SUMMARY: The "truth" tree also appears in the output file. It contains all interactions in which we are interested in regardless on whether
352  the selection was passed or not. This is the tree that should be used to compute signal efficiencies
353 //! [tutorialAnalysis_DefineTruthTree_info]
354 
355 
356 
357  // Variables from baseTrackerAnalysis (run, event, ...)
358  baseTrackerAnalysis::DefineTruthTree();
359 
360  //--- muon variables -------
361  AddVarI( output(), truelepton_pdg, "true lepton PDG");
362  AddVar4VF(output(), truelepton_pos, "true lepton position");
363  // Moved to baseAnalysis !!!!!!!
364  // AddVarF( output(), truelepton_mom, "true lepton momentum");
365  // AddVarF( output(), truelepton_costheta, "true lepton cos(theta) w.r.t. neutrino direction");
366  // AddVar3VF(output(), truelepton_dir, "true lepton direction");
367 }

§ FillMicroTrees()

void tutorialAnalysis::FillMicroTrees ( bool  addBase = true)
virtual

[tutorialAnalysis_DefineTruthTree]

[tutorialAnalysis_FillMicroTrees]

Reimplemented from baseTrackerAnalysis.

Definition at line 372 of file tutorialAnalysis.cxx.

372  {
373 //********************************************************************
374 
375  /* In this method we fill all toy-independent variables (all except the ones added with AddToy...) defined in the method DefineMicroTrees.
376  This method is called once all toys has been run, what means that the value of all variables for the last toy will be saved. This is not a problem
377  for variables that are not expected to change from a toy to another.
378  */
379 
380  // Variables from baseTrackerAnalysis (run, event, ...)
381  if (addBase) baseTrackerAnalysis::FillMicroTreesBase(addBase);
382 
383  // Add a variable that is only in the derived box AnaBoxTutorial. We need to cast the base box to have access
384  output().FillVar(nLongTPCTracks, static_cast<const ToyBoxTutorial*>(&box())->nLongTPCTracks);
385 
386  // Muon candidate variables. The MainTrack (The muon candidate) should exist in the box
387  if (box().MainTrack){
388 
389  // Since Detectors is not in BaseDataClasses (in psycheEventModel) but in DataClasses in (highlandEventModel) we need to cast
390  // the AnaTrackB pointer in box().MainTrack to the derived class AnaTrack.
391  output().FillVar(selmu_detectors, static_cast<AnaTrack*>(box().MainTrack)->Detectors);
392 
393  // Compute the cosine of the angle between the muon and the neutrino
394  // vertex defined as start of muon track, neutrino direction calculated from this
395  TVector3 nuDirVec = anaUtils::GetNuDirRec(box().MainTrack->PositionStart); // Method in NuDirUtils (in psycheND280Utils)
396  TVector3 muDirVec = anaUtils::ArrayToTVector3(box().MainTrack->DirectionStart);
397  double costheta_mu_nu = nuDirVec.Dot(muDirVec);
398 
399  // Cast it to a double because we have defined this variable as double in DefineMicroTrees
400  // (no need to be a double, it is just to have an example of double variable)
401  output().FillVar(selmu_costheta, costheta_mu_nu);
402 
403  // Transverse component of muon momentum calculated relative to reconstructed neutrino direction
404  Float_t nuDirArr[3];
405  nuDirVec.GetXYZ(nuDirArr);
406  Float_t pT = anaUtils::GetTransverseMom(nuDirArr,box().MainTrack->DirectionStart,box().MainTrack->Momentum); // Method in NuDirUtils (in psycheND280Utils)
407  output().FillVar(selmu_pT, pT);
408 
409  // Coplanarity angle requires a proton... for now just assume use highest momentum +ve track
410  Float_t deltaPhi=0;
411  if(box().HMPtrack)
412  deltaPhi = anaUtils::GetDPhi(nuDirArr,box().MainTrack->DirectionStart,box().HMPtrack->DirectionStart); // Method in NuDirUtils (in psycheND280Utils)
413  output().FillVar(selmu_deltaPhi, deltaPhi);
414 
415  // This is unnecessary here (we could use 1 and -1 which are smaller types), but serves as an example
416  if (box().MainTrack->DirectionStart[2]>0)
417  output().FillVar(selmu_sense, "forward");
418  else
419  output().FillVar(selmu_sense, "backward");
420 
421  // This is the way we fill 3 and 4-vectors. Must specify the array size when using FillVectorVarFromArray
422  output().FillVectorVarFromArray(selmu_pos, box().MainTrack->PositionStart, 4);
423  output().FillVectorVarFromArray(selmu_dir, box().MainTrack->DirectionStart, 3);
424 
425  // Properties of the true particle associated to the muon candidate.
426  // We can also acces the truth with box().MainTrack->TrueObject, but this is of the more basic type AnaTrueObjectC, which does not have Momentum. The GetTrueParticle() method
427  // just do the casting
428  if( box().MainTrack->GetTrueParticle() ) {
429  output().FillVar(selmu_truemom, box().MainTrack->GetTrueParticle()->Momentum);
430  }
431 
432  // Info in all TPCs
433  for (Int_t subdet = 0; subdet<3; subdet++) {
434  if (!SubDetId::GetDetectorUsed(box().MainTrack->Detector, static_cast<SubDetId::SubDetEnum >(subdet+2))) continue;
435  AnaTPCParticle* TPCSegment = static_cast<AnaTPCParticle*>(anaUtils::GetSegmentInDet( *box().MainTrack,static_cast<SubDetId::SubDetEnum >(subdet+2)));
436  if (!TPCSegment) continue;
437  output().FillVectorVar(selmu_tpc_det, subdet);
438  output().FillVectorVar(selmu_tpc_mom, TPCSegment->Momentum);
439  output().FillVectorVar(selmu_tpc_nnodes, TPCSegment->NNodes);
440 
441  // Must specify the array size when using FillMatrixVarFromArray
442  output().FillMatrixVarFromArray(selmu_tpc_pos, TPCSegment->PositionStart, 4);
443  output().FillMatrixVarFromArray(selmu_tpc_dir, TPCSegment->DirectionStart, 3);
444 
445  if (TPCSegment->GetTrueParticle()){
446  // Cast it to a double because we have defined this variable as double in DefineMicroTrees
447  // (no need to be a double, it is just to have an example of double variable)
448  output().FillVectorVar(selmu_tpc_truemom, (Double_t)TPCSegment->GetTrueParticle()->Momentum);
449  }
450 
451  // increment the value of the counter for all TPC variables (selmu_ntpcs)
452  // The same effect will have output().IncrementCounter(selmu_ntpcs);
453  output().IncrementCounterForVar(selmu_tpc_det);
454  }
455  }
456 
457 }
Float_t PositionStart[4]
The reconstructed start position of the particle.
void FillVectorVar(Int_t index, Float_t var, Int_t indx=-1)
Fill a vector variable.
Int_t NNodes
The number of nodes in the reconstructed object.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
Float_t Momentum
The initial momentum of the true particle.
AnaParticleB * GetSegmentInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
void FillMatrixVarFromArray(Int_t index, const Double_t var[], Int_t indx1, UInt_t size)
Fill a matrix variable from array.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
Float_t GetTransverseMom(const Float_t *nudir, const Float_t *thisdir, Float_t thismom)
Get the transverse momentum.
void FillVar(Int_t index, Float_t var)
Fill a single variable.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Representation of a TPC segment of a global track.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Float_t GetDPhi(const Float_t *nudir, const Float_t *mudir, const Float_t *pdir)
Returns pi-(the angle between muon and proton). Should be delta-fn in ideal back2back.
void FillVectorVarFromArray(Int_t index, const Double_t var[], UInt_t size)
Fill a vector variable from array.

§ FillToyVarsInMicroTrees()

void tutorialAnalysis::FillToyVarsInMicroTrees ( bool  addBase = true)
virtual

[tutorialAnalysis_FillMicroTrees]

[tutorialAnalysis_FillToyVarsInMicroTrees]

Reimplemented from baseTrackerAnalysis.

Definition at line 462 of file tutorialAnalysis.cxx.

462  {
463 //********************************************************************
464 
465  /* In this method we fill all toy-dependent variables (the ones added with AddToy...) defined in the method DefineMicroTrees.
466  This method is called at the end of each toy.
467 
468  There could be many variables that are toy-dependent. We don't need to save all of them as toy variables, but only the ones we are interested in plotting
469  for different toys.
470 
471  TOY VARIABLES ARE VERY SPACE CONSUMING SO WE SHOULD MINIMISE ITS NUMBER !!!!
472  */
473 
474  // Fill the common variables
475  if (addBase) baseTrackerAnalysis::FillToyVarsInMicroTreesBase(addBase);
476 
477  //---- variables specific for this analysis -----
478  if (box().MainTrack){
479  // Since we are applying a systematic that varies the momentum we need to save the momentum for each toy
480  output().FillToyVar(selmu_mom, box().MainTrack->Momentum);
481 
482  // Info in all TPCs
483  for (Int_t subdet = 0; subdet<3; subdet++) {
484  if (!SubDetId::GetDetectorUsed(box().MainTrack->Detector, static_cast<SubDetId::SubDetEnum >(subdet+2))) continue;
485  AnaTPCParticle* TPCSegment = static_cast<AnaTPCParticle*>(anaUtils::GetSegmentInDet( *box().MainTrack, static_cast<SubDetId::SubDetEnum >(subdet+2)));
486  if (!TPCSegment) continue;
487  // In principle we need this variable here when PID systematics are run
488  output().FillToyVectorVar(selmu_tpc_dedx, TPCSegment->dEdxMeas, subdet);
489  }
490  }
491 }
void FillToyVectorVar(Int_t index, Int_t var, Int_t comp)
Fill a vector analysis variable.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
AnaParticleB * GetSegmentInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
Float_t dEdxMeas
dE/dx as measured by the TPC.
void FillToyVar(Int_t index, Int_t var)
Fill a single analysis variable.
Representation of a TPC segment of a global track.

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