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