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;
117 TTree *t=man->GetTree();
119 TFile *file=t->GetCurrentFile();
120 if (file) fileName.SetString(file->GetName());
123 AliESDInputHandler *han=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler());
125 AliESDEvent *ev=dynamic_cast<AliESDEvent*>(han->GetEvent());
126 eventInFile=ev->GetEventNumberInFile();
127 runNumber=ev->GetRunNumber();
128 eventTime=ev->GetTimeStamp();
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
141 << "EventTime=" << eventTime;
143 //Fill MC information
144 Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
147 if (fDielectron) pdg=fDielectron->GetMotherPdg();
148 Bool_t isMotherMC = AliDielectronMC::Instance()->IsMotherPdg(pair,pdg);
149 (*fStreamer) << "Pair"
150 << "mcTruth=" << isMotherMC;
154 Double_t values[AliDielectronVarManager::kNMaxValues];
155 Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues];
156 Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues];
159 AliDielectronVarManager::Fill(pair,values);
161 for (Int_t i=0; i<fNVars; ++i){
163 (*fStreamer) << "Pair"
164 << Form("%s=",AliDielectronVarManager::GetValueName(var))
171 AliDielectronVarManager::Fill(pair->GetFirstDaughter(),valuesLeg1);
173 AliDielectronVarManager::Fill(pair->GetSecondDaughter(),valuesLeg2);
175 for (Int_t i=0; i<fNVarsLeg; ++i){
176 var=fVariablesLeg[i];
177 (*fStreamer) << "Pair"
178 << Form("Leg1_%s=",AliDielectronVarManager::GetValueName(var))
180 << Form("Leg2_%s=",AliDielectronVarManager::GetValueName(var))
186 (*fStreamer) << "Pair" << "\n";
191 //______________________________________________
192 void AliDielectronDebugTree::DeleteStreamer()
195 // delete the streamer
197 if (!fStreamer) return;
203 //______________________________________________
204 void AliDielectronDebugTree::WriteTree()
209 if (!fStreamer) return;
210 fStreamer->GetFile()->Write();