1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
19 // Dielectron DebugTree //
23 register variables from the variable manager. The output will be written
26 NOTE: Please use with extream care! Only for debugging and test purposes!!!
30 ///////////////////////////////////////////////////////////////////////////
34 #include <TTreeStream.h>
35 #include <TObjString.h>
38 #include <AliAnalysisManager.h>
39 #include <AliESDInputHandler.h>
40 #include <AliESDEvent.h>
41 #include <AliVTrack.h>
43 #include "AliDielectron.h"
44 #include "AliDielectronMC.h"
45 #include "AliDielectronPair.h"
47 #include "AliDielectronDebugTree.h"
49 ClassImp(AliDielectronDebugTree)
51 AliDielectronDebugTree::AliDielectronDebugTree() :
53 fFileName("jpsi_debug.root"),
60 // Default Constructor
62 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
68 //______________________________________________
69 AliDielectronDebugTree::AliDielectronDebugTree(const char* name, const char* title) :
71 fFileName("jpsi_debug.root"),
80 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
86 //______________________________________________
87 AliDielectronDebugTree::~AliDielectronDebugTree()
93 fStreamer->GetFile()->Write();
98 //______________________________________________
99 void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
102 // Fill configured variables to the tree
105 //is there anything to fill
106 if (fNVars==0&&fNVarsLeg==0) return;
108 //only in local mode!!!
109 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
111 if (man->GetAnalysisType()!=AliAnalysisManager::kLocalAnalysis) return;
113 //Get File and event information
115 Int_t eventInFile=-1;
118 TTree *t=man->GetTree();
120 TFile *file=t->GetCurrentFile();
121 if (file) fileName.SetString(file->GetName());
124 AliESDInputHandler *han=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler());
126 AliESDEvent *ev=dynamic_cast<AliESDEvent*>(han->GetEvent());
127 eventInFile=ev->GetEventNumberInFile();
128 runNumber=ev->GetRunNumber();
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"
136 << "File.=" << &fileName
137 << "EventInFile=" << eventInFile
138 << "Run=" << runNumber
140 << "Leg2_ID=" << id2;
142 //Fill MC information
143 Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
146 if (fDielectron) pdg=fDielectron->GetMotherPdg();
147 Bool_t isMotherMC = AliDielectronMC::Instance()->IsMotherPdg(pair,pdg);
148 (*fStreamer) << "Pair"
149 << "mcTruth=" << isMotherMC;
153 Double_t values[AliDielectronVarManager::kNMaxValues];
154 Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues];
155 Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues];
158 AliDielectronVarManager::Fill(pair,values);
160 for (Int_t i=0; i<fNVars; ++i){
162 (*fStreamer) << "Pair"
163 << Form("%s=",AliDielectronVarManager::GetValueName(var))
170 AliDielectronVarManager::Fill(pair->GetFirstDaughter(),valuesLeg1);
172 AliDielectronVarManager::Fill(pair->GetSecondDaughter(),valuesLeg2);
174 for (Int_t i=0; i<fNVarsLeg; ++i){
175 var=fVariablesLeg[i];
176 (*fStreamer) << "Pair"
177 << Form("Leg1_%s=",AliDielectronVarManager::GetValueName(var))
179 << Form("Leg2_%s=",AliDielectronVarManager::GetValueName(var))
185 (*fStreamer) << "Pair" << "\n";
190 //______________________________________________
191 void AliDielectronDebugTree::DeleteStreamer()
194 // delete the streamer
196 if (!fStreamer) return;
202 //______________________________________________
203 void AliDielectronDebugTree::WriteTree()
208 if (!fStreamer) return;
209 fStreamer->GetFile()->Write();