]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/dielectron/AliDielectronDebugTree.cxx
Updates and additions: Classes for signal and spectrum extraction; saving of
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronDebugTree.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////////
17 //                Dielectron DebugTree                                  //
18 //                                                                       //
19 //                                                                       //
20 /*
21 register variables from the variable manager. The output will be written
22 to a tree
23
24 NOTE: Please use with extream care! Only for debugging and test purposes!!!
25
26 */
27 //                                                                       //
28 ///////////////////////////////////////////////////////////////////////////
29
30 #include <TFile.h>
31 #include <TTreeStream.h>
32 #include <TString.h>
33
34 #include <AliAnalysisManager.h>
35
36 #include "AliDielectronPair.h"
37
38 #include "AliDielectronDebugTree.h"
39
40 ClassImp(AliDielectronDebugTree)
41
42 AliDielectronDebugTree::AliDielectronDebugTree() :
43   TNamed(),
44   fFileName("jpsi_debug.root"),
45   fNVars(0),
46   fNVarsLeg(0),
47   fStreamer(0x0)
48 {
49   //
50   // Default Constructor
51   //
52   for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
53     fVariables[i]=0;
54     fVariablesLeg[i]=0;
55   }
56 }
57
58 //______________________________________________
59 AliDielectronDebugTree::AliDielectronDebugTree(const char* name, const char* title) :
60   TNamed(name, title),
61   fFileName("jpsi_debug.root"),
62   fNVars(0),
63   fNVarsLeg(0),
64   fStreamer(0x0)
65 {
66   //
67   // Named Constructor
68   //
69   for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
70     fVariables[i]=0;
71     fVariablesLeg[i]=0;
72   }
73 }
74
75 //______________________________________________
76 AliDielectronDebugTree::~AliDielectronDebugTree()
77 {
78   //
79   // Default Destructor
80   //
81   if (fStreamer){
82     fStreamer->GetFile()->Write();
83     delete fStreamer;
84   }
85 }
86
87 //______________________________________________
88 void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
89 {
90   //
91   // Fill configured variables to the tree
92   //
93
94   //is there anything to fill
95   if (fNVars==0&&fNVarsLeg==0) return;
96   
97   //only in local mode!!!
98   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
99   if (man && man->GetAnalysisType()!=AliAnalysisManager::kLocalAnalysis) return;
100   
101   if (!fStreamer) fStreamer=new TTreeSRedirector(fFileName.Data());
102
103   Int_t var=0;
104   Double_t values[AliDielectronVarManager::kNMaxValues];
105   Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues];
106   Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues];
107 // fill pair values
108   if (fNVars>0){
109     AliDielectronVarManager::Fill(pair,values);
110
111     for (Int_t i=0; i<fNVars; ++i){
112       var=fVariables[i];
113       (*fStreamer) << "Pair"
114                    << Form("%s=",AliDielectronVarManager::GetValueName(var))
115                    << values[var];
116     }
117   }
118
119   if (fNVarsLeg>0){
120     //leg1
121     AliDielectronVarManager::Fill(pair->GetFirstDaughter(),valuesLeg1);
122     //leg2
123     AliDielectronVarManager::Fill(pair->GetSecondDaughter(),valuesLeg2);
124     
125     for (Int_t i=0; i<fNVarsLeg; ++i){
126       var=fVariablesLeg[i];
127       (*fStreamer) << "Pair"
128                    << Form("Leg1_%s=",AliDielectronVarManager::GetValueName(var))
129                    << valuesLeg1[var]
130                    << Form("Leg2_%s=",AliDielectronVarManager::GetValueName(var))
131                    << valuesLeg2[var];
132     }
133     
134   }
135   
136   (*fStreamer) << "Pair" << "\n";
137     
138   
139 }
140
141 //______________________________________________
142 void AliDielectronDebugTree::DeleteStreamer()
143 {
144   //
145   // delete the streamer
146   //
147   if (!fStreamer) return;
148   delete fStreamer;
149   fStreamer=0x0;
150
151 }
152
153 //______________________________________________
154 void AliDielectronDebugTree::WriteTree()
155 {
156   //
157   // Write file
158   //
159   if (!fStreamer) return;
160   fStreamer->GetFile()->Write();
161 }