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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron DebugTree //
21 register variables from the variable manager. The output will be written
24 NOTE: Please use with extream care! Only for debugging and test purposes!!!
28 ///////////////////////////////////////////////////////////////////////////
32 #include <TTreeStream.h>
33 #include <TObjString.h>
36 #include <AliAnalysisManager.h>
37 #include <AliESDInputHandler.h>
38 #include <AliESDEvent.h>
39 #include <AliVTrack.h>
41 #include "AliDielectron.h"
42 #include "AliDielectronMC.h"
43 #include "AliDielectronPair.h"
45 #include "AliDielectronDebugTree.h"
47 ClassImp(AliDielectronDebugTree)
49 AliDielectronDebugTree::AliDielectronDebugTree() :
51 fFileName("jpsi_debug.root"),
58 // Default Constructor
60 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
66 //______________________________________________
67 AliDielectronDebugTree::AliDielectronDebugTree(const char* name, const char* title) :
69 fFileName("jpsi_debug.root"),
78 for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i){
84 //______________________________________________
85 AliDielectronDebugTree::~AliDielectronDebugTree()
91 fStreamer->GetFile()->Write();
96 //______________________________________________
97 void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
100 // Fill configured variables to the tree
103 //is there anything to fill
104 if (fNVars==0&&fNVarsLeg==0) return;
106 //only in local mode!!!
107 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
109 if (man->GetAnalysisType()!=AliAnalysisManager::kLocalAnalysis) return;
111 //Get File and event information
113 Int_t eventInFile=-1;
116 TTree *t=man->GetTree();
118 TFile *file=t->GetCurrentFile();
119 if (file) fileName.SetString(file->GetName());
122 AliESDInputHandler *han=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler());
124 AliESDEvent *ev=dynamic_cast<AliESDEvent*>(han->GetEvent());
125 eventInFile=ev->GetEventNumberInFile();
126 runNumber=ev->GetRunNumber();
129 if (!fStreamer) fStreamer=new TTreeSRedirector(fFileName.Data());
130 Int_t id1=static_cast<AliVTrack*>(pair->GetFirstDaughter())->GetID();
131 Int_t id2=static_cast<AliVTrack*>(pair->GetSecondDaughter())->GetID();
132 //Fill Event information
133 (*fStreamer) << "Pair"
134 << "File.=" << &fileName
135 << "EventInFile=" << eventInFile
136 << "Run=" << runNumber
138 << "Leg2_ID=" << id2;
140 //Fill MC information
141 Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
144 if (fDielectron) pdg=fDielectron->GetMotherPdg();
145 Bool_t isMotherMC = AliDielectronMC::Instance()->IsMotherPdg(pair,pdg);
146 (*fStreamer) << "Pair"
147 << "mcTruth=" << isMotherMC;
151 Double_t values[AliDielectronVarManager::kNMaxValues];
152 Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues];
153 Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues];
156 AliDielectronVarManager::Fill(pair,values);
158 for (Int_t i=0; i<fNVars; ++i){
160 (*fStreamer) << "Pair"
161 << Form("%s=",AliDielectronVarManager::GetValueName(var))
168 AliDielectronVarManager::Fill(pair->GetFirstDaughter(),valuesLeg1);
170 AliDielectronVarManager::Fill(pair->GetSecondDaughter(),valuesLeg2);
172 for (Int_t i=0; i<fNVarsLeg; ++i){
173 var=fVariablesLeg[i];
174 (*fStreamer) << "Pair"
175 << Form("Leg1_%s=",AliDielectronVarManager::GetValueName(var))
177 << Form("Leg2_%s=",AliDielectronVarManager::GetValueName(var))
183 (*fStreamer) << "Pair" << "\n";
188 //______________________________________________
189 void AliDielectronDebugTree::DeleteStreamer()
192 // delete the streamer
194 if (!fStreamer) return;
200 //______________________________________________
201 void AliDielectronDebugTree::WriteTree()
206 if (!fStreamer) return;
207 fStreamer->GetFile()->Write();