laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauMergeDataFiles.hh
Go to the documentation of this file.
1 
2 /*
3 Copyright 2008 University of Warwick
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 /*
19 Laura++ package authors:
20 John Back
21 Paul Harrison
22 Thomas Latham
23 */
24 
25 #include <map>
26 #include <cstdlib>
27 
28 #include "TFile.h"
29 #include "TString.h"
30 #include "TTree.h"
31 
44 {
45  public:
47 
52  LauMergeDataFiles(const TString& fileName1, const TString& fileName2, const TString& treeName);
53 
55  virtual ~LauMergeDataFiles();
56 
58 
61  void process(const TString& fileName);
62 
63  protected:
65  typedef std::map<TString,Double_t> LeafDoubleMap;
67  typedef std::map<TString,Int_t> LeafIntegerMap;
69  typedef std::map< Int_t,std::pair<Int_t,Int_t> > ExptsMap;
70 
72  void openInputFiles();
74  void setupInputTrees();
76  void setupOutputTree();
78  void findExperiments(TTree* tree, ExptsMap& exptsMap);
80  Bool_t checkExperimentMaps() const;
82  void readExperiment(TTree* tree, const ExptsMap::const_iterator& exptsMap, Int_t offset);
84  void writeFile();
85 
86  private:
88  TString fileName1_;
90  TString fileName2_;
92  TString treeName_;
93 
95  TFile * inputFile1_;
97  TFile * inputFile2_;
98 
100  TTree * inputTree1_;
102  TTree * inputTree2_;
103 
105  TFile * outputFile_;
107  TTree * outputTree_;
108 
109  // Tree variables
111  Int_t iExpt_;
114 
119 
124 
125  ClassDef(LauMergeDataFiles,0)
126 };
127 
TFile * inputFile2_
Input file 2.
Int_t iExpt_
Storage for the experiment index variable.
TString treeName_
Name of the tree.
Bool_t checkExperimentMaps() const
Check that the experiments in each tree match.
ExptsMap tree1Expts_
Experiment -&gt; first and last tree entry for tree 1.
std::map< Int_t, std::pair< Int_t, Int_t > > ExptsMap
Type to hold for each experiment the first and last entry numbers in a tree.
TTree * outputTree_
Output tree.
Int_t iEvtWithinExpt_
Storage for the event-within-experiment index variable.
void readExperiment(TTree *tree, const ExptsMap::const_iterator &exptsMap, Int_t offset)
Read the entries for a given experiment from the given tree and store in the output tree...
void findExperiments(TTree *tree, ExptsMap &exptsMap)
Determine the experiments stored a given tree.
std::map< TString, Int_t > LeafIntegerMap
Type to relate leaf names with their integer value.
TString fileName2_
Name of file 2.
TString fileName1_
Name of file 1.
void setupOutputTree()
Create the structure of the output tree.
LeafDoubleMap doubleVars_
Storage for double-precision leaves.
TFile * outputFile_
Output file.
TTree * inputTree1_
Input tree 1.
std::map< TString, Double_t > LeafDoubleMap
Type to relate leaf names with their double-precision value.
ExptsMap tree2Expts_
Experiment -&gt; first and last tree entry for tree 2.
void openInputFiles()
Open the specified input files and check that the trees can be read.
void setupInputTrees()
Read the structure of the input trees, create appropriate storage and set the branch addresses...
void writeFile()
Write the output file.
LauMergeDataFiles(const TString &fileName1, const TString &fileName2, const TString &treeName)
Constructor.
TTree * inputTree2_
Input tree 2.
TFile * inputFile1_
Input file 1.
virtual ~LauMergeDataFiles()
Destructor.
LeafIntegerMap integerVars_
Storage for integer leaves.
void process(const TString &fileName)
Do the merge.