]>
Commit | Line | Data |
---|---|---|
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 <TTree.h> | |
32 | #include <TTreeStream.h> | |
33 | #include <TObjString.h> | |
34 | #include <TString.h> | |
35 | ||
36 | #include <AliAnalysisManager.h> | |
37 | #include <AliESDInputHandler.h> | |
38 | #include <AliESDEvent.h> | |
39 | #include <AliVTrack.h> | |
40 | ||
41 | #include "AliDielectron.h" | |
42 | #include "AliDielectronMC.h" | |
43 | #include "AliDielectronPair.h" | |
44 | ||
45 | #include "AliDielectronDebugTree.h" | |
46 | ||
47 | ClassImp(AliDielectronDebugTree) | |
48 | ||
49 | AliDielectronDebugTree::AliDielectronDebugTree() : | |
50 | TNamed(), | |
51 | fFileName("jpsi_debug.root"), | |
52 | fNVars(0), | |
53 | fNVarsLeg(0), | |
54 | fStreamer(0x0), | |
55 | fDielectron(0x0) | |
56 | { | |
57 | // | |
58 | // Default Constructor | |
59 | // | |
60 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){ | |
61 | fVariables[i]=0; | |
62 | fVariablesLeg[i]=0; | |
63 | } | |
64 | } | |
65 | ||
66 | //______________________________________________ | |
67 | AliDielectronDebugTree::AliDielectronDebugTree(const char* name, const char* title) : | |
68 | TNamed(name, title), | |
69 | fFileName("jpsi_debug.root"), | |
70 | fNVars(0), | |
71 | fNVarsLeg(0), | |
72 | fStreamer(0x0), | |
73 | fDielectron(0x0) | |
74 | { | |
75 | // | |
76 | // Named Constructor | |
77 | // | |
78 | for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){ | |
79 | fVariables[i]=0; | |
80 | fVariablesLeg[i]=0; | |
81 | } | |
82 | } | |
83 | ||
84 | //______________________________________________ | |
85 | AliDielectronDebugTree::~AliDielectronDebugTree() | |
86 | { | |
87 | // | |
88 | // Default Destructor | |
89 | // | |
90 | if (fStreamer){ | |
91 | fStreamer->GetFile()->Write(); | |
92 | delete fStreamer; | |
93 | } | |
94 | } | |
95 | ||
96 | //______________________________________________ | |
97 | void AliDielectronDebugTree::Fill(AliDielectronPair *pair) | |
98 | { | |
99 | // | |
100 | // Fill configured variables to the tree | |
101 | // | |
102 | ||
103 | //is there anything to fill | |
104 | if (fNVars==0&&fNVarsLeg==0) return; | |
105 | ||
106 | //only in local mode!!! | |
107 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
108 | if (!man) return; | |
109 | // if (man->GetAnalysisType()!=AliAnalysisManager::kLocalAnalysis) return; | |
110 | ||
111 | //Get File and event information | |
112 | TObjString fileName; | |
113 | Int_t eventInFile=-1; | |
114 | Int_t runNumber=-1; | |
115 | UInt_t eventTime=0; | |
116 | ||
117 | TTree *t=man->GetTree(); | |
118 | if (t) { | |
119 | TFile *file=t->GetCurrentFile(); | |
120 | if (file) fileName.SetString(file->GetName()); | |
121 | } | |
122 | ||
123 | AliESDInputHandler *han=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler()); | |
124 | if (han){ | |
125 | AliESDEvent *ev=dynamic_cast<AliESDEvent*>(han->GetEvent()); | |
126 | eventInFile=ev->GetEventNumberInFile(); | |
127 | runNumber=ev->GetRunNumber(); | |
128 | eventTime=ev->GetTimeStamp(); | |
129 | } | |
130 | ||
131 | if (!fStreamer) fStreamer=new TTreeSRedirector(fFileName.Data()); | |
132 | Int_t id1=static_cast<AliVTrack*>(pair->GetFirstDaughterP())->GetID(); | |
133 | Int_t id2=static_cast<AliVTrack*>(pair->GetSecondDaughterP())->GetID(); | |
134 | //Fill Event information | |
135 | (*fStreamer) << "Pair" | |
136 | << "File.=" << &fileName | |
137 | << "EventInFile=" << eventInFile | |
138 | << "Run=" << runNumber | |
139 | << "Leg1_ID=" << id1 | |
140 | << "Leg2_ID=" << id2 | |
141 | << "EventTime=" << eventTime; | |
142 | ||
143 | //Fill MC information | |
144 | Bool_t hasMC=AliDielectronMC::Instance()->HasMC(); | |
145 | if (hasMC){ | |
146 | Int_t pdg=443; | |
147 | if (fDielectron) pdg=fDielectron->GetMotherPdg(); | |
148 | Bool_t isMotherMC = AliDielectronMC::Instance()->IsMotherPdg(pair,pdg); | |
149 | (*fStreamer) << "Pair" | |
150 | << "mcTruth=" << isMotherMC; | |
151 | } | |
152 | ||
153 | Int_t var=0; | |
154 | Double_t values[AliDielectronVarManager::kNMaxValues]; | |
155 | Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues]; | |
156 | Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues]; | |
157 | // fill pair values | |
158 | if (fNVars>0){ | |
159 | AliDielectronVarManager::Fill(pair,values); | |
160 | ||
161 | for (Int_t i=0; i<fNVars; ++i){ | |
162 | var=fVariables[i]; | |
163 | (*fStreamer) << "Pair" | |
164 | << Form("%s=",AliDielectronVarManager::GetValueName(var)) | |
165 | << values[var]; | |
166 | } | |
167 | } | |
168 | ||
169 | if (fNVarsLeg>0){ | |
170 | //leg1 | |
171 | AliDielectronVarManager::Fill(pair->GetFirstDaughterP(),valuesLeg1); | |
172 | //leg2 | |
173 | AliDielectronVarManager::Fill(pair->GetSecondDaughterP(),valuesLeg2); | |
174 | ||
175 | for (Int_t i=0; i<fNVarsLeg; ++i){ | |
176 | var=fVariablesLeg[i]; | |
177 | (*fStreamer) << "Pair" | |
178 | << Form("Leg1_%s=",AliDielectronVarManager::GetValueName(var)) | |
179 | << valuesLeg1[var] | |
180 | << Form("Leg2_%s=",AliDielectronVarManager::GetValueName(var)) | |
181 | << valuesLeg2[var]; | |
182 | } | |
183 | ||
184 | } | |
185 | ||
186 | (*fStreamer) << "Pair" << "\n"; | |
187 | ||
188 | ||
189 | } | |
190 | ||
191 | //______________________________________________ | |
192 | void AliDielectronDebugTree::DeleteStreamer() | |
193 | { | |
194 | // | |
195 | // delete the streamer | |
196 | // | |
197 | if (!fStreamer) return; | |
198 | delete fStreamer; | |
199 | fStreamer=0x0; | |
200 | ||
201 | } | |
202 | ||
203 | //______________________________________________ | |
204 | void AliDielectronDebugTree::WriteTree() | |
205 | { | |
206 | // | |
207 | // Write file | |
208 | // | |
209 | if (!fStreamer) return; | |
210 | fStreamer->GetFile()->Write(); | |
211 | } |